/* Layout: full-screen 3D race behind; scoreboard-style panels float over it.
   One deliberate look in every theme: race-day scoreboard (deep navy, cream text, gold). */
:root {
  --ink: #0f1530;
  --panel: rgba(15, 21, 48, 0.9);
  --panel-solid: #141b3a;
  --line: #2c3766;
  --text: #f6f1e4;
  --muted: #aab3d4;
  --gold: #ffc53d;
  --gold-ink: #3a2600;
  --points: #3d8bff;
  --mult: #ff4d4f;
  --good: #4fd18b;
  --bad: #ff6b6b;
  --sky: #7fb3f2;
  --display: 'Bungee', 'Arial Black', Impact, system-ui, sans-serif;
  --body: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}

html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body { touch-action: manipulation; overscroll-behavior: none; }
.nogl { position: fixed; inset: auto 16px 40% 16px; z-index: 70; background: var(--panel-solid); border: 2px solid var(--line); border-radius: 14px; padding: 16px; line-height: 1.5; }
body {
  margin: 0;
  background: var(--sky);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2 { text-wrap: balance; margin: 0; }
.eyebrow {
  margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold);
}
.t-points { color: var(--points); }
.t-mult { color: var(--mult); }

/* ---------- buttons ---------- */
.btn {
  font: 800 15px/1 var(--body); letter-spacing: 0.02em;
  border: 0; border-radius: 10px; padding: 13px 18px; cursor: pointer;
  color: var(--text); background: transparent;
  transition: transform 0.08s ease, filter 0.15s ease;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: translateY(2px); }
.btn:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn-gold { background: var(--gold); color: var(--gold-ink); box-shadow: 0 4px 0 #b9861a; }
.btn-gold:hover { filter: brightness(1.06); }
.btn-gold:active { box-shadow: 0 2px 0 #b9861a; }
.btn-ghost { border: 2px solid var(--line); background: rgba(255,255,255,0.03); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-big { font-size: 18px; padding: 16px 26px; }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}
.screen.modal { background: rgba(6, 10, 26, 0.55); z-index: 40; }
.card {
  width: 100%; max-width: 520px; margin: auto;
  background: var(--panel); border: 2px solid var(--line); border-radius: 18px;
  padding: 22px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
}
.card > * { flex-shrink: 0; } /* scrollable cards must scroll, not squash their contents */
.card h2 { font-family: var(--display); font-weight: 400; font-size: 26px; line-height: 1.1; }
.card-head { display: flex; flex-direction: column; gap: 6px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* splash */
.splash { background: linear-gradient(180deg, rgba(15,21,48,0.15), rgba(15,21,48,0.75)); }
.splash-inner { max-width: 520px; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.logo {
  font-family: var(--display); font-weight: 400; font-size: clamp(64px, 18vw, 120px); line-height: 0.88;
  color: var(--gold); text-shadow: 0 5px 0 #b9861a, 0 10px 30px rgba(0,0,0,0.35);
}
.lede { margin: 0; font-size: 18px; line-height: 1.45; max-width: 34ch; text-shadow: 0 1px 8px rgba(0,0,0,0.4); }
.splash-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.splash-actions .btn-ghost { background: rgba(15,21,48,0.55); }
.hint { margin: 0; color: var(--muted); font-size: 13px; }

/* sheets: the 3D scene stays visible above (phone) or to the right (desktop) */
.sheet-screen { align-items: flex-end; }
.sheet { max-height: 58vh; overflow-y: auto; margin: 0 auto; }
@media (min-width: 900px) {
  .sheet-screen { align-items: center; justify-content: flex-start; }
  .sheet { max-height: 88vh; max-width: 460px; margin: 0; }
}

/* stable */
.tabs { display: flex; gap: 6px; background: #0a0f24; border-radius: 12px; padding: 4px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--muted); font: 800 14px var(--body); padding: 10px; border-radius: 9px; cursor: pointer; }
.tab.on { background: var(--gold); color: var(--gold-ink); }
.slots { display: flex; flex-direction: column; gap: 14px; }
.slot-label { margin: 0 0 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  position: relative; min-width: 44px; height: 44px; padding: 0 12px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--line); background: #0a0f24; color: var(--text); font: 700 13px var(--body);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.opt.swatch { width: 44px; padding: 0; }
.opt.swatch i { width: 26px; height: 26px; border-radius: 6px; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.2); }
.opt.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.opt.locked { opacity: 0.55; }
.opt .cost { position: absolute; bottom: -7px; right: -6px; font-size: 10px; font-weight: 800; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 6px; padding: 1px 4px; color: var(--gold); }

/* results: headline + curve stay fixed, the rest scrolls beneath */
.final-card.sheet { overflow: hidden; display: flex; flex-direction: column; gap: 0; padding: 0; }
.final-top { padding: 20px 22px 12px; display: flex; flex-direction: column; gap: 8px; border-bottom: 2px solid var(--line); background: var(--panel-solid); flex-shrink: 0; }
.final-scroll { overflow-y: auto; min-height: 0; flex: 1 1 auto; padding: 14px 22px 22px; display: flex; flex-direction: column; gap: 16px; }
.final-scroll > * { flex-shrink: 0; }
@media (max-width: 899px) {
  .final-card.sheet { max-height: 70vh; }
  .final-top .curve svg { max-height: 70px; }
  .final-total { font-size: 40px; }
}

/* percentile curve */
.curve { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.curve svg { width: 100%; height: auto; display: block; }
.curve figcaption { font-size: 15px; }
.curve figcaption b { color: var(--gold); font-family: var(--display); font-weight: 400; font-size: 22px; }
.curve small { color: var(--muted); font-size: 11px; }
.feedback .report { border-color: var(--muted); color: var(--text); text-transform: none; }
.curve .pf { color: var(--text); font-weight: 800; }
.vault-list .s { display: flex; flex-direction: column; align-items: flex-end; }
.vault-list .s small { color: var(--muted); font-size: 11px; }

/* lobby tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  border: 0; border-radius: 14px; padding: 12px; color: #fff; font: inherit; min-width: 0;
  background: var(--tile); box-shadow: 0 4px 0 var(--tile-dark), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.tile:hover { filter: brightness(1.08); }
.tile:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--tile-dark); }
.tile:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.tile svg { flex: none; width: 30px; height: 30px; padding: 6px; border-radius: 10px; background: rgba(255,255,255,0.18); fill: currentColor; }
.tile span { display: flex; flex-direction: column; min-width: 0; }
.tile b { font-size: 14px; line-height: 1.2; }
.tile small { font-size: 11px; opacity: 0.85; }
/* brand tiles: the game's own colours (trophy gold, starting-gate green, silks red, race-card cream) */
.t-stable { --tile: linear-gradient(180deg, #ffd25e, #ffc53d); --tile-dark: #b9861a; color: #2a1c00; }
.t-past { --tile: linear-gradient(180deg, #3a915c, #2f7d4f); --tile-dark: #1c4f31; }
.t-score { --tile: linear-gradient(180deg, #ef5a5f, #e5484d); --tile-dark: #8a1c1f; }
.t-about { --tile: linear-gradient(180deg, #fbf7ec, #efe7d4); --tile-dark: #c7b98f; color: #0f1530; }
.tile { border: 2px solid rgba(15,21,48,0.35); }
.tile-icon { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: rgba(15,21,48,0.16); }
.px svg { display: block; shape-rendering: crispEdges; }

/* starter pistol */
.logo-row { display: flex; align-items: flex-end; gap: 6px; }
.pistol { position: relative; border: 0; background: none; padding: 0 0 18px; cursor: pointer; transform-origin: 30% 70%; }
.pistol:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; border-radius: 8px; }
.pistol .flash, .pistol .smoke { position: absolute; pointer-events: none; opacity: 0; }
.pistol .flash { left: 100%; top: -14px; margin-left: -6px; }
.pistol .smoke { left: 100%; top: -40px; margin-left: -4px; }
.pistol.fire { animation: recoil 0.45s cubic-bezier(.2,.9,.3,1.3); }
.pistol.fire .flash { animation: flash 0.16s steps(2) forwards; }
.pistol.fire .smoke { animation: smoke 1.1s ease-out forwards; }
@keyframes recoil { 0% { transform: none; } 12% { transform: translate(-10px, -4px) rotate(-24deg); } 100% { transform: none; } }
@keyframes flash { 0% { opacity: 1; transform: scale(1.2); } 100% { opacity: 0; transform: scale(0.6); } }
@keyframes smoke { 0% { opacity: 0.9; transform: translate(0, 10px) scale(0.6); } 100% { opacity: 0; transform: translate(18px, -30px) scale(1.4); } }
@media (prefers-reduced-motion: reduce) { .pistol.fire, .pistol.fire .smoke { animation: none; } }

/* scoring popup */
.scoring-card { max-width: 520px; max-height: 90vh; overflow-y: auto; }
.horse-preview { width: 100%; height: 210px; display: block; border-radius: 14px; background: radial-gradient(ellipse at 50% 85%, #6fae47 0 30%, transparent 31%), linear-gradient(180deg, #4b86d6, #cfe6ff); }

/* wallet + level */
.wallet { display: inline-flex; align-items: baseline; gap: 4px; margin-right: 10px; }
.wallet .coin::before { content: ""; display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; background: var(--gold); box-shadow: inset 0 -2px 0 #b9861a; margin-right: 4px; vertical-align: -0.05em; }
.wallet em { font-style: normal; color: var(--good); font-weight: 800; }
.lvl-bar { display: block; height: 8px; border-radius: 4px; background: #0a0f24; overflow: hidden; margin: 8px 0 4px; }
.lvl-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--good), var(--gold)); }
.excl { margin-left: 6px; font-size: 10px; color: var(--gold); letter-spacing: 0.06em; }
.opt.earned .cost { color: var(--good); border-color: var(--good); }

/* stable: trying on locked gear */
.opt.trying { opacity: 1; border-style: dashed; }

/* about */
.link-btn { background: none; border: 0; padding: 0; color: var(--text); font: 700 14px var(--body); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.about-card { max-width: 600px; max-height: 88vh; overflow-y: auto; }
.story p { margin: 0 0 12px; line-height: 1.6; color: var(--text); max-width: 62ch; }
.story b { color: var(--gold); }
.board-wrap { overflow-x: auto; border-radius: 14px; background: #10301f; border: 3px solid #6b4f2a; box-shadow: inset 0 0 0 3px #0b2416; }
.board { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; min-width: 420px; color: #f6f1e4; }
.board caption { caption-side: top; text-align: left; padding: 12px 14px 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: #cfe8d0; }
.board th { text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #a9c9ad; font-weight: 700; padding: 6px 14px; }
.board td { padding: 9px 14px; border-top: 1px dashed rgba(246,241,228,0.18); }
.board-odds { font-family: var(--display); color: var(--gold); font-size: 18px; }
.board-ex { font-style: italic; color: var(--tier); }
.house-rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); line-height: 1.5; }
.house-rules b { color: var(--text); }

/* answers board */
.answers-card { max-width: 640px; max-height: 88vh; overflow-y: auto; }
.ans-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.ans-tab { flex: none; border: 2px solid var(--line); background: #0a0f24; color: var(--muted); font: 800 13px var(--body); padding: 8px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.ans-tab.on { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.ans-tier { display: flex; flex-direction: column; gap: 8px; }
.ans-tier h3 { margin: 0; display: flex; align-items: baseline; gap: 8px; font-size: 15px; color: var(--tier); }
.ans-tier h3 span { font-family: var(--display); font-weight: 400; }
.ans-tier h3 small { color: var(--muted); font-weight: 500; font-size: 12px; }
.ans-body { display: flex; flex-direction: column; gap: 16px; }
.ans-list { display: flex; flex-wrap: wrap; gap: 5px; }
.ans-list span { padding: 4px 8px; border-radius: 7px; font-size: 13px; text-transform: capitalize; border: 1px solid var(--line); color: var(--muted); }
.ans-list span.got { background: var(--tier); border-color: var(--tier); color: #0f1530; font-weight: 800; }

/* codes */
.code-btn {
  position: fixed; z-index: 45; right: max(12px, env(safe-area-inset-right, 0px)); bottom: max(12px, env(safe-area-inset-bottom, 0px));
  width: 36px; height: 36px; border-radius: 10px; border: 2px solid rgba(255,255,255,0.35); background: rgba(15,21,48,0.55); cursor: pointer; font-size: 15px; opacity: 0.7;
}
.code-btn:hover { opacity: 1; }
.code-box {
  position: fixed; z-index: 46; right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(max(12px, env(safe-area-inset-bottom, 0px)) + 46px);
  width: min(300px, calc(100vw - 24px)); background: var(--panel-solid); border: 2px solid var(--line); border-radius: 14px; padding: 12px; box-sizing: border-box;
}
.code-box label { font-size: 13px; font-weight: 800; }
.code-row { display: flex; gap: 8px; margin-top: 8px; }
.code-row input { flex: 1; min-width: 0; font-size: 15px; padding: 8px 10px; }
.code-msg { margin: 8px 0 0; font-size: 12px; color: var(--muted); min-height: 1em; }

/* bug report */
.bug-btn { right: auto; left: max(12px, env(safe-area-inset-left, 0px)); }
.bug-card { max-width: 480px; }
.bug-form { display: flex; flex-direction: column; gap: 10px; }
.bug-form label { font-size: 13px; font-weight: 800; }
.bug-form textarea { font: 500 16px var(--body); color: var(--text); background: #0a0f24; border: 2px solid var(--line); border-radius: 10px; padding: 12px 14px; resize: vertical; }

/* tally best answers */
.tally-best { display: flex; flex-wrap: wrap; gap: 6px; }
.tally-best:empty { display: none; }
.best-chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 10px; border-radius: 10px; border: 2px solid var(--tier); background: #0a0f24; font-weight: 800; text-transform: capitalize; }
.best-chip em { font-style: normal; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--tier); }
.feedback .suggest { margin-left: 6px; padding: 3px 10px; border-radius: 8px; border: 2px solid var(--gold); background: transparent; color: var(--gold); font: 800 13px var(--body); cursor: pointer; text-transform: capitalize; }

/* lobby */
.cat-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.cat-list li {
  aspect-ratio: 3 / 4; border-radius: 10px; border: 2px solid var(--line);
  display: grid; place-items: center; font-family: var(--display); font-size: 22px; color: var(--muted);
  background: repeating-linear-gradient(135deg, rgba(255,255,255,0.03) 0 6px, transparent 6px 12px);
}
.start-btn { margin-top: 10px; }
.lobby-meta { margin: 0; color: var(--muted); line-height: 1.5; }
.lobby-meta b { color: var(--text); }
.rules { border-top: 1px solid var(--line); padding-top: 12px; }
.rules summary { cursor: pointer; font-weight: 700; }
.rules p { color: var(--muted); line-height: 1.5; font-size: 14px; }
.tier-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tier-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; padding: 4px 0; }
.tier-table td { padding: 5px 0; border-top: 1px solid var(--line); }
.odds { color: var(--muted); font-size: 12px; margin-left: 4px; }
.hint-key { color: var(--muted); font-size: 12px; }
.tier-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: 0; }

.played { display: flex; flex-direction: column; gap: 10px; }
.played-score { font-family: var(--display); font-size: 40px; margin: 0; }
.played-score small { font-family: var(--body); font-size: 14px; color: var(--muted); margin-left: 8px; }

/* newsletter form */
.extra { border: 2px dashed var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.extra h3 { margin: 0; font-size: 16px; }
.extra p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.extra form { display: flex; gap: 8px; flex-wrap: wrap; }
.extra input[type=email] { flex: 1 1 200px; min-width: 0; }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); }
input[type=text], input[type=email] {
  font: 500 17px var(--body); color: var(--text);
  background: #0a0f24; border: 2px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
input::placeholder { color: #6c769c; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 15;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  padding-left: var(--gutter-l); padding-right: calc(var(--gutter-r) + 44px);
  pointer-events: none;
}
.hud-row { display: flex; align-items: center; gap: 12px; max-width: 760px; margin: 0 auto; }
.pips { list-style: none; display: flex; gap: 5px; margin: 0; padding: 0; }
.pips li { width: 12px; height: 12px; border-radius: 3px; background: rgba(15,21,48,0.55); border: 2px solid rgba(255,255,255,0.5); }
.pips li.done { background: var(--gold); border-color: var(--gold); }
.pips li.now { background: #fff; border-color: #fff; }
.journey { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.journey-labels { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; text-shadow: 0 1px 4px rgba(0,0,0,0.6); white-space: nowrap; overflow: hidden; }
.journey-bar { height: 8px; border-radius: 4px; background: rgba(15,21,48,0.55); overflow: hidden; border: 1px solid rgba(255,255,255,0.35); }
.journey-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--good), var(--gold)); }
.total { display: flex; flex-direction: column; align-items: flex-end; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }
.total small { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.total b { font-family: var(--display); font-weight: 400; font-size: 20px; font-variant-numeric: tabular-nums; }
.mute {
  position: fixed; z-index: 50; top: max(8px, env(safe-area-inset-top, 0px)); right: var(--gutter-r);
  width: 38px; height: 38px; border-radius: 10px; border: 2px solid rgba(255,255,255,0.5);
  background: rgba(15,21,48,0.6); color: var(--text); font-size: 18px; cursor: pointer;
}
.mute.off { opacity: 0.55; text-decoration: line-through; }

/* ---------- play panel ---------- */
.play {
  position: fixed; z-index: 20; left: 0; right: 0; top: 0;
  padding-top: calc(max(10px, env(safe-area-inset-top, 0px)) + 44px);
  padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  display: flex; justify-content: center; pointer-events: none;
}
.play-card {
  pointer-events: auto; width: 100%; max-width: 560px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 16px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.3);
}
.play-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cat-name { font-family: var(--display); font-weight: 400; font-size: clamp(20px, 5.4vw, 28px); line-height: 1.05; margin-top: 4px; }
.timer {
  flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  border: 3px solid var(--text); font-family: var(--display); font-size: 20px; font-variant-numeric: tabular-nums;
}
.timer.low { border-color: var(--mult); color: var(--mult); animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.timer-bar { height: 6px; background: #0a0f24; border-radius: 3px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--gold); transform-origin: left; }

.scoreline { display: flex; align-items: stretch; gap: 8px; }
.chip-box {
  flex: 1; border-radius: 10px; padding: 6px 10px; display: flex; flex-direction: column; align-items: center;
  font-variant-numeric: tabular-nums; min-width: 0;
}
.chip-box small { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.85; }
.chip-box b { font-family: var(--display); font-weight: 400; font-size: 26px; line-height: 1.1; }
.chip-box.points { background: var(--points); box-shadow: 0 3px 0 #1f5fc4; }
.chip-box.mult { background: var(--mult); box-shadow: 0 3px 0 #b8282a; }
.chip-box.score { background: var(--gold); color: var(--gold-ink); box-shadow: 0 3px 0 #b9861a; }
.chip-box.bump b { animation: bump 0.25s ease; }
@keyframes bump { 40% { transform: scale(1.3) rotate(-4deg); } }
.times { align-self: center; font-family: var(--display); font-size: 22px; color: var(--muted); }
.count { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 4px; font-variant-numeric: tabular-nums; }
.count b { font-family: var(--display); font-weight: 400; font-size: 20px; }
.count small { color: var(--muted); font-size: 11px; }

.answer-form { display: flex; gap: 8px; }
.answer-form input { flex: 1; min-width: 0; }
.answer-form input.shake { animation: shake 0.3s; border-color: var(--bad); }
.answer-form input.okflash { border-color: var(--good); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.feedback-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.feedback { margin: 0; min-height: 18px; font-size: 13px; color: var(--muted); min-width: 0; }
.btn-small { font-size: 12px; padding: 6px 10px; border-radius: 8px; flex: none; }
.feedback.bad { color: var(--bad); }

.answers { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; max-height: 22vh; overflow-y: auto; }
.answers li {
  text-transform: capitalize;
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 8px;
  font-size: 14px; font-weight: 700; background: #0a0f24; border: 2px solid var(--tier);
  animation: pop 0.25s ease;
}
.answers li em { font-style: normal; font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--tier); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }

@media (min-width: 900px) {
  .play { justify-content: flex-start; }
  .play-card { max-width: 470px; }
}

/* ---------- tally ---------- */
.tally-card { align-items: stretch; }
.tally-sum { display: flex; align-items: stretch; gap: 6px; }
.tally-sum .chip-box b { font-size: clamp(18px, 6vw, 28px); }
.tier-bars { display: flex; flex-direction: column; gap: 6px; }
.tier-bar { display: grid; grid-template-columns: 92px 1fr 64px; align-items: center; gap: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.tier-bar .track { height: 10px; background: #0a0f24; border-radius: 5px; overflow: hidden; }
.tier-bar .fill { height: 100%; border-radius: 5px; }
.tier-bar span:last-child { text-align: right; color: var(--muted); }
.tally-note { margin: 0; color: var(--muted); line-height: 1.45; }

/* ---------- final ---------- */
.final-total { margin: 0; font-family: var(--display); font-size: 52px; line-height: 1; color: var(--gold); font-variant-numeric: tabular-nums; }
.final-total small { font-family: var(--body); font-size: 15px; color: var(--muted); margin-left: 8px; }
.final-rounds { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.final-rounds li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.final-rounds .emo { letter-spacing: 1px; font-size: 12px; max-width: 150px; overflow: hidden; white-space: nowrap; text-overflow: clip; }
.final-rounds b { font-family: var(--display); font-weight: 400; }
.share-text { width: 100%; min-height: 120px; box-sizing: border-box; font: 13px/1.4 ui-monospace, monospace; background: #0a0f24; color: var(--text); border: 2px solid var(--line); border-radius: 10px; padding: 10px; }
.next-race { margin: 0; color: var(--muted); font-size: 14px; }
.next-race b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- vault ---------- */
.vault-card { max-height: 86vh; }
.vault-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 46vh; }
.vault-list button {
  width: 100%; text-align: left; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  background: #0a0f24; border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); font: inherit; cursor: pointer;
}
.vault-list button:hover { border-color: var(--gold); }
.vault-list .d { font-family: var(--display); font-size: 14px; color: var(--gold); }
.vault-list .c { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.vault-list .s { font-variant-numeric: tabular-nums; font-size: 13px; }
.paywall { display: flex; flex-direction: column; gap: 12px; }
.paywall p { margin: 0; color: var(--muted); line-height: 1.5; }
.price { font-family: var(--display); font-size: 40px; color: var(--gold); margin: 0; }
.devnote { font-size: 12px; color: var(--muted); }

/* ---------- overlays ---------- */
.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 60; transition: opacity 0.35s ease; }
.flash.on { opacity: 1; }
.big-text {
  position: fixed; left: 0; right: 0; top: 46%; z-index: 30; text-align: center; pointer-events: none;
  font-family: var(--display); font-size: clamp(40px, 12vw, 96px); line-height: 1; color: var(--gold);
  text-shadow: 0 5px 0 #b9861a, 0 12px 30px rgba(0,0,0,0.45);
  padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  opacity: 0;
}
.big-text small { display: block; font-family: var(--body); font-weight: 800; font-size: 16px; letter-spacing: 0.2em; text-transform: uppercase; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.6); margin-bottom: 8px; }
.big-text.show { animation: bigIn 1.4s ease forwards; }
.big-text.quick { animation: bigIn 0.8s ease forwards; }
@keyframes bigIn {
  0% { opacity: 0; transform: scale(2.2); }
  15% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; transform: scale(1.03); }
  100% { opacity: 0; transform: scale(0.9); }
}

@media (max-width: 420px) {
  .card { padding: 16px; }
  .chip-box b { font-size: 22px; }
  .tier-bar { grid-template-columns: 78px 1fr 54px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .big-text.show, .big-text.quick { opacity: 1; animation: none; }
}

/* phones held sideways: short screens get a compact layout, panels on the left */
@media (max-height: 520px) and (orientation: landscape) {
  .logo { font-size: 21vh; }
  .splash-inner { gap: 8px; max-width: 560px; }
  .lede { font-size: 14px; }
  .btn-big { font-size: 15px; padding: 11px 18px; }
  .card { padding: 14px; gap: 10px; }
  .card h2 { font-size: 20px; }
  .sheet-screen { align-items: center; justify-content: flex-start; }
  .sheet { max-width: 420px; max-height: 92vh; margin: 0; }
  .cat-list { display: none; }
  .tiles { gap: 8px; }
  .tile { padding: 8px; }
  .tile-icon { width: 32px; height: 32px; }
  .play { justify-content: flex-start; padding-top: calc(max(6px, env(safe-area-inset-top, 0px)) + 34px); }
  .play-card { max-width: 430px; padding: 10px; gap: 6px; }
  .cat-name { font-size: 16px; }
  .timer { width: 40px; height: 40px; font-size: 15px; }
  .chip-box { padding: 3px 8px; }
  .chip-box b { font-size: 18px; }
  .answer-form input { padding: 8px 10px; font-size: 16px; }
  .answers { max-height: 16vh; }
  .final-card.sheet { max-height: 94vh; }
  .final-top .curve svg { max-height: 56px; }
}
