/* Design tokens mirror mypa.today */
:root {
  --bg: #ffffff;
  --bg-tint: #f7f9fc;
  --bg-cool: #eef2fb;
  --blue: #1e90ff;
  --blue-deep: #1577e0;
  --blue-light: #4ba6ff;
  --blue-mid: #cee7ff;
  --blue-pale: #ebf5ff;
  --blue-text: #006dd6;
  --blue-glow: rgba(30, 144, 255, 0.22);
  --ink: #0a0f1c;
  --ink-2: #374060;
  --muted: #627298;
  --line: #e4e8f2;
  --line-soft: #f0f2f8;
  --green: #22c55e;
  --green-soft: #f0fdf4;
  --green-border: #bdebc8;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --r-xs: 6px;
  --r: 8px;
  --r-btn: 10px;
  --r-hero: 16px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 4px rgba(10, 15, 28, 0.07), 0 1px 2px rgba(10, 15, 28, 0.04);
  --shadow-md: 0 4px 20px rgba(10, 15, 28, 0.09), 0 2px 8px rgba(10, 15, 28, 0.05);
  --shadow-blue: 0 4px 24px rgba(30, 144, 255, 0.28);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg-tint);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.brand img { width: 28px; height: 28px; }
.brand span.sub { color: var(--blue-text); }
.balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--blue-pale);
  color: var(--blue-text);
  font-weight: 600;
  font-size: 14px;
  border: 0;
}
.balance-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }

.screen { padding: 16px; display: grid; gap: 16px; animation: fade-in 0.25s var(--ease-out); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.link-btn { background: none; border: 0; color: var(--blue-text); font-weight: 500; font-size: 14px; padding: 0; }

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.card.flush { padding: 0; overflow: hidden; }

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-hero);
  padding: 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-deep) 100%);
  box-shadow: var(--shadow-blue);
}
.hero::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 180px;
  height: 180px;
  background: url("./assets/logo.png") center / contain no-repeat;
  opacity: 0.14;
  filter: brightness(0) invert(1);
}
.hero .label { font-size: 13px; opacity: 0.85; font-weight: 500; }
.hero .points { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin: 4px 0; }
.hero .points small { font-size: 16px; font-weight: 500; opacity: 0.9; margin-left: 4px; }
.hero .sub { font-size: 14px; opacity: 0.92; }
.hero .actions { display: flex; gap: 8px; margin-top: 16px; position: relative; z-index: 1; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--r-btn);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 15px;
  transition: transform 0.12s var(--ease-out), background 0.15s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 2px 10px var(--blue-glow); }
.btn-primary:hover:not(:disabled) { background: var(--blue-deep); }
.btn-white { background: #fff; color: var(--ink); }
.btn-ghost-white { background: rgba(255, 255, 255, 0.14); color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.btn-secondary { background: var(--bg); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-tint); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }

/* List rows */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--line-soft);
}
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 13px; color: var(--muted); }
.amount-pos { color: #15803d; font-weight: 600; white-space: nowrap; }
.amount-neg { color: var(--ink-2); font-weight: 600; white-space: nowrap; }

.icon-tile {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  display: grid;
  place-items: center;
  background: var(--blue-pale);
  color: var(--blue);
}
.icon-tile svg { width: 20px; height: 20px; }
.icon-tile.green { background: var(--green-soft); color: #15803d; }
.icon-tile.amber { background: var(--amber-soft); color: var(--amber); }

/* Offers */
.offer {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: var(--r);
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.offer:hover { border-color: var(--blue-mid); box-shadow: var(--shadow-md); }
.offer img, .offer .ph {
  width: 56px;
  height: 56px;
  border-radius: var(--r);
  object-fit: cover;
  flex: none;
  background: var(--bg-cool);
}
.offer .ph { display: grid; place-items: center; color: var(--blue); }
.offer .body { flex: 1; min-width: 0; }
.offer .t { font-weight: 600; }
.offer .d { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reward-chip {
  flex: none;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-cool);
  color: var(--ink-2);
  text-transform: capitalize;
}
.badge.green { background: var(--green-soft); color: #15803d; }
.badge.blue { background: var(--blue-pale); color: var(--blue-text); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }

/* Segmented control */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  background: var(--bg-cool);
  border-radius: var(--r-btn);
  gap: 4px;
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 8px;
  min-height: 40px;
  font-weight: 600;
  color: var(--muted);
}
.segmented button.active { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Forms */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--r-btn);
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
.input-wrap { position: relative; }
.input-wrap .suffix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
}
.chip:hover { border-color: var(--blue-mid); color: var(--blue-text); }

.preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--blue-pale);
  color: var(--blue-text);
  font-weight: 600;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--bg);
  text-align: left;
  width: 100%;
}
.radio-card.selected { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
.radio-card .ring { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.radio-card.selected .ring { border: 5px solid var(--blue); }

.notice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r);
  font-size: 14px;
  background: var(--bg-cool);
  color: var(--ink-2);
}
.notice.warn { background: var(--amber-soft); color: var(--amber); }
.notice.ok { background: var(--green-soft); color: #15803d; }

.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px dashed var(--blue-light);
  border-radius: var(--r);
  background: var(--blue-pale);
}
.code-box .code { font-size: 24px; font-weight: 700; letter-spacing: 0.12em; color: var(--blue-text); }

.steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { display: flex; gap: 12px; align-items: flex-start; counter-increment: step; }
.steps li::before {
  content: counter(step);
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue-pale);
  color: var(--blue-text);
  font-weight: 700;
  font-size: 13px;
}

.progress { height: 6px; border-radius: var(--r-pill); background: var(--bg-cool); overflow: hidden; margin-top: 6px; }
.progress > span { display: block; height: 100%; background: var(--blue); border-radius: inherit; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; padding: 12px 8px; border-radius: var(--r); background: var(--bg-tint); }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }

/* Bottom tab bar */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; max-width: 560px; height: var(--tabbar-h); }
.tab {
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--blue); }

/* Sheet (modal) */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 15, 28, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.2s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%;
  max-width: 560px;
  background: var(--bg);
  border-radius: var(--r-hero) var(--r-hero) 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  display: grid;
  gap: 14px;
  animation: slide-up 0.35s var(--ease-drawer);
}
@keyframes slide-up { from { transform: translateY(100%); } }
.sheet .grabber { width: 40px; height: 4px; border-radius: 2px; background: var(--line); justify-self: center; }
.summary { display: grid; gap: 8px; padding: 14px; border-radius: var(--r); background: var(--bg-tint); }
.summary div { display: flex; justify-content: space-between; font-size: 14px; }
.summary div b { font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: var(--r-btn);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: fade-in 0.2s var(--ease-out);
}
.toast.error { background: var(--red); }

/* States */
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .icon-tile { margin: 0 auto 10px; }
.skeleton {
  border-radius: var(--r);
  background: linear-gradient(90deg, var(--bg-cool) 25%, var(--line-soft) 50%, var(--bg-cool) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.center-state { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.center-state img { width: 64px; height: 64px; margin: 0 auto 16px; }
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--blue-mid);
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.games-card { display: flex; align-items: center; gap: 14px; }
.games-card .art {
  width: 56px;
  height: 56px;
  border-radius: var(--r);
  flex: none;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #7c3aed, var(--blue));
  color: #fff;
}
.games-card .art svg { width: 28px; height: 28px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
