/* Wealth5 — token system. Light on :root; dark via media query + data-theme override. */
:root {
  --bg: #FBF8F8;
  --surface: #FFFFFF;
  --surface2: #F5EDEF;
  --ink: #23151A;
  --muted: #75616A;
  --line: #E9DCE0;
  --brand: #E31837;
  --brand-deep: #B00E24;
  --on-brand: #FFFFFF;
  --gold: #A67C1B;
  --gain: #0B8A5C;
  --loss: #C2410C;
  --neutral-bar: #C9B8BD;
  --shadow: 0 10px 30px rgba(35, 21, 26, 0.10);
  --radius: 18px;
  --font-display: 'Unbounded', 'Arial Black', sans-serif;
  --font-body: 'Figtree', 'Segoe UI', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #150A0E;
    --surface: #211318;
    --surface2: #2C1B21;
    --ink: #F7EDF0;
    --muted: #AD939C;
    --line: #3B262E;
    --brand: #F2314F;
    --brand-deep: #E31837;
    --gold: #E3B84F;
    --gain: #35D69C;
    --loss: #FC9A4B;
    --neutral-bar: #63474F;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  --bg: #150A0E;
  --surface: #211318;
  --surface2: #2C1B21;
  --ink: #F7EDF0;
  --muted: #AD939C;
  --line: #3B262E;
  --brand: #F2314F;
  --brand-deep: #E31837;
  --gold: #E3B84F;
  --gain: #35D69C;
  --loss: #FC9A4B;
  --neutral-bar: #63474F;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100dvh;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 20px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 0 18px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-bbk {
  font-family: var(--font-display);
  font-weight: 700; font-size: 15px; letter-spacing: 0.06em;
  color: var(--on-brand); background: var(--brand);
  padding: 3px 9px; border-radius: 8px;
}
.brand-sep { width: 1px; height: 18px; background: var(--line); }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.brand-name em { font-style: normal; color: var(--brand); }
.icon-btn {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  width: 38px; height: 38px; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center; transition: border-color 0.2s;
}
.icon-btn:hover { border-color: var(--brand); }
:root[data-theme="dark"] .ic-moon { display: none; }
:root:not([data-theme="dark"]) .ic-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ic-moon { display: none; }
  :root:not([data-theme="light"]) .ic-sun { display: block; }
}

/* ---------- screens ---------- */
.screen { display: none; animation: rise 0.45s ease both; }
.screen.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}

/* ---------- landing ---------- */
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 10px;
}
.hero { padding: 26px 0 8px; }
.hero-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(27px, 7.6vw, 36px); line-height: 1.18; letter-spacing: -0.01em;
  text-wrap: balance;
}
.hero-title .accent { color: var(--brand); }
.hero-sub { margin-top: 16px; color: var(--muted); font-size: 15.5px; }
.how { list-style: none; margin: 26px 0; display: grid; gap: 12px; }
.how li {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: grid; gap: 2px;
  counter-increment: step;
}
.how li strong { font-weight: 700; font-size: 15px; }
.how li span { color: var(--muted); font-size: 14px; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body); font-weight: 700; font-size: 16px;
  border: none; border-radius: 14px; cursor: pointer;
  padding: 14px 22px; transition: transform 0.12s ease, background 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .chip:focus-visible, .icon-btn:focus-visible, .input:focus-visible {
  outline: 3px solid var(--brand); outline-offset: 2px;
}
.btn-primary { background: var(--brand); color: var(--on-brand); box-shadow: 0 6px 18px rgba(227, 24, 55, 0.30); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-big { width: 100%; padding: 16px 22px; font-size: 17px; margin-top: 8px; }
.btn-ghost { background: var(--surface2); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--brand); }

.tiny { font-size: 12.5px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--loss); font-weight: 600; font-size: 14px; margin: 10px 0; }

/* ---------- setup ---------- */
.screen-title { font-family: var(--font-display); font-weight: 700; font-size: 24px; margin-bottom: 8px; }
.screen-sub { color: var(--muted); font-size: 15px; margin-bottom: 20px; }
.field-label { font-weight: 700; font-size: 14px; margin: 18px 0 8px; display: block; }
.input {
  width: 100%; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 14px; font-size: 16px;
  font-family: var(--font-body);
}
.input:focus { border-color: var(--brand); outline: none; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.chip {
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink);
  border-radius: 12px; padding: 10px 12px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: left; transition: border-color 0.15s, background 0.15s;
  font-family: var(--font-body);
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.chip .cost { color: var(--muted); font-weight: 500; font-size: 12.5px; white-space: nowrap; }
.chip[aria-pressed="true"], .chip[aria-checked="true"] {
  border-color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, var(--surface));
}
.chip[aria-pressed="true"] .cost, .chip[aria-checked="true"] .cost { color: var(--brand); font-weight: 700; }

.card-surface {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.setup-summary { margin-top: 20px; padding: 14px 16px; box-shadow: none; }
.sum-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14.5px; }
.sum-row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-size: 15.5px; }
.sum-row strong { font-variant-numeric: tabular-nums; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }

.consent { display: flex; gap: 10px; margin: 18px 0 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.consent input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); cursor: pointer; flex: none; }

/* ---------- payday statement (signature moment) ---------- */
.statement { margin: 6px 0 18px; padding: 6px 18px; }
.st-line {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
  opacity: 0; transform: translateY(8px);
}
.st-line.stamped { animation: stamp 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
@keyframes stamp { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.st-line:last-child { border-bottom: none; }
.st-label { font-size: 14.5px; }
.st-sub { display: block; color: var(--muted); font-size: 12px; }
.st-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 15.5px; }
.st-line.total { border-top: 2px solid var(--ink); border-bottom: none; margin-top: 2px; }
.st-line.total .st-label { font-weight: 700; }
.st-line.total .st-amount { font-family: var(--font-display); font-size: 19px; }
.st-pct { font-size: 12px; font-weight: 700; margin-left: 6px; }

/* ---------- round / HUD ---------- */
.hud { display: flex; justify-content: space-between; padding: 12px 18px; margin-bottom: 14px; box-shadow: none; }
.hud-item { display: grid; gap: 1px; text-align: center; }
.hud-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.hud-value { font-family: var(--font-display); font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; }
.hud-of { color: var(--muted); font-size: 12px; }
.hud-cash .hud-value { color: var(--brand); }
.hud-value.overdraft { color: var(--loss); }
.deck-count { text-align: center; color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 10px; }

/* ---------- playing card ---------- */
.play-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow); padding: 20px; position: relative; overflow: hidden;
  animation: deal 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
@keyframes deal { from { opacity: 0; transform: translateX(40px) rotate(3deg); } to { opacity: 1; transform: none; } }
.pc-ribbon {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 4px 10px; border-radius: 99px; margin-bottom: 12px;
}
.pc-ribbon.invest { background: color-mix(in srgb, var(--gain) 14%, var(--surface)); color: var(--gain); }
.pc-ribbon.tempt { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); color: var(--brand); }
.pc-name { font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.25; }
.pc-blurb { color: var(--muted); font-size: 14px; margin: 8px 0 14px; }
.pc-meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.pc-meta-item { font-size: 13px; font-weight: 600; }
.pc-meta-item .lbl { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.risk-dots { display: inline-flex; gap: 3px; }
.risk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.risk-dot.on { background: var(--brand); }
.pc-cost { font-family: var(--font-display); font-size: 18px; }

.amount-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.amt-chip {
  background: var(--surface2); border: 1.5px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 8px 13px; font-weight: 700; font-size: 14px; cursor: pointer;
  font-family: var(--font-body); font-variant-numeric: tabular-nums;
}
.amt-chip[aria-pressed="true"] { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); color: var(--brand); }
.amt-chip:disabled { opacity: 0.4; cursor: not-allowed; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card-actions .solo { grid-column: 1 / -1; }

/* ---------- results ---------- */
.networth {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(38px, 12vw, 54px); color: var(--brand);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em; margin: 2px 0 6px;
}
.rank-line { font-weight: 600; font-size: 15px; margin-bottom: 24px; }
.block-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; margin: 26px 0 10px; }

.breakdown { padding: 16px 18px; display: grid; gap: 13px; box-shadow: none; }
.bk-row { display: grid; gap: 4px; }
.bk-head { display: flex; justify-content: space-between; font-size: 13.5px; }
.bk-head .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.bk-track { height: 10px; background: var(--surface2); border-radius: 6px; overflow: hidden; }
.bk-fill { height: 100%; border-radius: 6px 4px 4px 6px; min-width: 2px; transition: width 0.8s cubic-bezier(0.2, 0.8, 0.3, 1); }
.bk-fill.c-salary { background: var(--neutral-bar); }
.bk-fill.c-returns { background: var(--gold); }
.bk-fill.c-expenses { background: var(--muted); }
.bk-fill.c-tempt { background: var(--brand); }

.perf { padding: 6px 18px; box-shadow: none; }
.perf-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 11px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.perf-row:last-child { border-bottom: none; }
.perf-row .sub { color: var(--muted); font-size: 12px; display: block; }
.perf-row .ret { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.perf-empty { padding: 14px 0; color: var(--muted); font-size: 14px; }

.lesson {
  border-left: 4px solid var(--gold); background: var(--surface);
  border-radius: 12px; padding: 12px 16px; margin: 10px 0;
  border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.lesson h4 { font-size: 14.5px; margin-bottom: 3px; }
.lesson p { font-size: 13.5px; color: var(--muted); }

.board { padding: 8px 18px; list-style: none; box-shadow: none; }
.board li { display: flex; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.board li:last-child { border-bottom: none; }
.board .pos { font-family: var(--font-display); font-weight: 600; font-size: 13px; color: var(--muted); width: 26px; flex: none; }
.board li.top .pos { color: var(--gold); }
.board .who { flex: 1; font-weight: 600; }
.board .worth { font-weight: 700; font-variant-numeric: tabular-nums; }
.board li.me { background: color-mix(in srgb, var(--brand) 7%, transparent); margin: 0 -18px; padding-left: 18px; padding-right: 18px; border-radius: 10px; }

.share { margin-top: 26px; padding: 20px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.share-title { margin: 0; }
#qr-canvas { background: #FFFFFF; border-radius: 12px; padding: 8px; width: 180px; height: 180px; }

@media (min-width: 640px) {
  #app { padding-top: 28px; }
  .chip-grid { grid-template-columns: 1fr 1fr 1fr; }
}
