:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --accent: #2976d3; /* white text on it: 4.5:1 (charts keep #2a78d6) */
  --accent-hover: #256abf;
  --accent-text: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --on-accent: #fff; /* text on accent-filled buttons */
  --series-1: #2a78d6;
  --good: #006300;
  --bad: #d03b3b;
  --bad-wash: rgba(208, 59, 59, 0.10);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
  --radius: 12px;
  --font: system-ui, "Segoe UI Variable Text", "Segoe UI", -apple-system, sans-serif;
}

/* Dark: follows the OS, unless the web build forces a theme with data-theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-text: #86b6ef;
    --accent-wash: rgba(57, 135, 229, 0.16);
    --on-accent: #071526; /* white on #3987e5 is only 3.6:1 */
    --series-1: #3987e5;
    --good: #0ca30c;
    --bad: #e66767;
    --bad-wash: rgba(230, 103, 103, 0.14);
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --accent: #3987e5;
  --accent-hover: #5598e7;
  --accent-text: #86b6ef;
  --accent-wash: rgba(57, 135, 229, 0.16);
  --on-accent: #071526;
  --series-1: #3987e5;
  --good: #0ca30c;
  --bad: #e66767;
  --bad-wash: rgba(230, 103, 103, 0.14);
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-y: auto;
}
h1 { font-size: 24px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
p { margin: 0; }
.muted { color: var(--muted); }
.lede { color: var(--ink-2); max-width: 62ch; }
kbd {
  font: 600 11px var(--font);
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid currentColor;
  opacity: 0.65;
  margin-left: 6px;
}
button { font: inherit; color: inherit; }

/* ---- top bar ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 56px; padding: 0 20px;
  background: var(--page);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand .logo { flex: none; display: block; }
.logo-bg { fill: var(--accent); }
.logo-fg { fill: var(--on-accent); }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: none; cursor: pointer;
  padding: 8px 16px; border-radius: 8px; color: var(--ink-2); font-weight: 500;
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.active { background: var(--accent-wash); color: var(--accent-text); }
.top-right { justify-self: end; display: flex; align-items: center; gap: 10px; }
body[data-view="game"] .topbar, body[data-view="game"] main,
body[data-view="e80game"] .topbar, body[data-view="e80game"] main,
body[data-view="oagame"] .topbar, body[data-view="oagame"] main,
body[data-view="zapgame"] .topbar, body[data-view="zapgame"] main { display: none; }

/* ---- segmented control -------------------------------------------------- */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: 9px;
}
.seg button {
  border: 0; background: none; cursor: pointer;
  padding: 5px 12px; border-radius: 7px; color: var(--ink-2); font-size: 13px;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--border); font-weight: 500; }

/* ---- layout ------------------------------------------------------------- */
main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 56px; }
.view { display: none; }
.view.active { display: block; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  margin-bottom: 20px;
}
.filters { display: flex; align-items: center; gap: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.sub { color: var(--muted); font-size: 13px; }

/* ---- controls ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 36px; padding: 0 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled:hover { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled:hover { background: var(--accent); }
.btn.big { height: 46px; padding: 0 26px; font-size: 16px; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.ghost { background: none; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.link { background: none; border: 0; color: var(--accent-text); padding: 0 6px; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.danger:hover { color: var(--bad); }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="number"] {
  width: 64px; height: 32px; padding: 0 6px; text-align: center;
  font: inherit; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 7px;
}
input[type="number"]::-webkit-inner-spin-button { display: none; }
input[type="number"]:disabled { opacity: 0.4; }
select {
  height: 34px; padding: 0 10px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px;
}
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.check.small { font-size: 13px; color: var(--ink-2); gap: 7px; }
.inline-field { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-2); white-space: nowrap; }

/* ---- play --------------------------------------------------------------- */
.play-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.side .card + .card { margin-top: 16px; }
.setup { padding: 26px 28px; }
.setup .lede { margin-bottom: 22px; }
.op-row { display: grid; grid-template-columns: 136px 1fr; align-items: center; gap: 12px; min-height: 58px; padding: 10px 0; border-top: 1px solid var(--border); }
.op-row .check span { font-weight: 500; }
.range { display: flex; align-items: center; gap: 5px; color: var(--ink-2); white-space: nowrap; }
.range input[type="number"] { width: 52px; }
.rg { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.field-row { display: grid; grid-template-columns: 136px auto; align-items: center; gap: 12px; padding: 16px 0 22px; border-top: 1px solid var(--border); }
.field-row label { font-weight: 500; }
.field-row select { justify-self: start; min-width: 160px; }

.record { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 12px; }
.mini-label { font-size: 12px; color: var(--muted); }
.mini-value { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.spark { color: var(--series-1); }
.spark svg { display: block; }
.focus-list { list-style: none; padding: 0; margin: 4px 0 14px; }
.focus-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.focus-list li:first-child { border-top: 0; }
.focus-list .name { flex: 1; min-width: 0; }
.focus-list .num { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.empty-note { color: var(--ink-2); }

/* ---- op badge ----------------------------------------------------------- */
.op {
  display: inline-grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink-2); font-weight: 600; font-size: 13px;
}

/* ---- game --------------------------------------------------------------- */
.game { height: 100vh; height: 100dvh; display: none; flex-direction: column; background: var(--page); }
.game.active { display: flex; }
.banner {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px; font-size: 18px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; background: var(--surface); border-bottom: 1px solid var(--border);
}
.game-label { font-size: 14px; color: var(--accent-text); }
.timebar { height: 3px; background: var(--grid); }
.timebar span { display: block; height: 100%; background: var(--accent); transform-origin: left; }
.arena { flex: 1; display: grid; place-items: center; padding-bottom: 6vh; }
.problem { display: flex; align-items: center; gap: 22px; font-size: 64px; font-weight: 500; letter-spacing: -0.01em; }
.problem .eq { color: var(--muted); }
#answer {
  width: 4.4ch; height: 1.5em; padding: 0 16px;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 2px solid var(--axis); border-radius: 14px; outline: none;
  font-variant-numeric: tabular-nums;
}
#answer:focus { border-color: var(--accent); }
#answer.wrong { border-color: var(--bad); background: var(--bad-wash); }
.game-hint { text-align: center; color: var(--muted); padding-bottom: 26px; }

/* ---- results ------------------------------------------------------------ */
.hero-card { padding: 26px 28px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 22px; }
.hero-label { color: var(--ink-2); font-weight: 500; }
.hero-row { display: flex; align-items: center; gap: 14px; }
.hero { font-size: 84px; font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; }
.hero-sub { color: var(--ink-2); margin-top: 4px; }
.hero-sub:empty { display: none; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--accent-wash); color: var(--accent-text);
}
.res-cols { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.res-cols .card + .card { margin-top: 0; }

.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.plist li:first-child { border-top: 0; padding-top: 0; }
.plist .q { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plist .detail { color: var(--ink-2); font-size: 13px; flex: 1; min-width: 0; }
.plist .t { font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; margin-left: auto; }
.typed { color: var(--bad); font-variant-numeric: tabular-nums; }

/* ---- stat tiles --------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 12.5px; color: var(--ink-2); }
.tile .value { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; }
.tile .note { font-size: 12px; color: var(--muted); }
.tiles.compact { grid-template-columns: repeat(2, minmax(130px, 1fr)); margin: 0; }
.tiles.compact .tile { box-shadow: none; background: var(--page); padding: 10px 14px; }
.tiles.compact .value { font-size: 20px; }

/* ---- charts ------------------------------------------------------------- */
.chart { position: relative; min-height: 220px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--ink); font-size: 13px; font-weight: 600; }
.chart .note-label { fill: var(--ink-2); font-size: 12px; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .hover-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }

.tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 280px;
  padding: 8px 11px; border-radius: 8px; font-size: 12.5px; line-height: 1.45;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
}
.tip b { font-weight: 600; }
.tip .tmuted { color: var(--ink-2); }

/* ---- category table ----------------------------------------------------- */
table.cats { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cats th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 0 8px 8px; }
.cats th.num, .cats td.num { text-align: right; }
.cats td { padding: 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.cats td:first-child, .cats th:first-child { padding-left: 0; }
.cats td:last-child, .cats th:last-child { padding-right: 0; text-align: right; }
.cats .who { display: flex; align-items: center; gap: 10px; }
.cats .ex { color: var(--muted); font-size: 12.5px; }
.cats tr.thin td { color: var(--muted); }
.cats tr.thin .op { opacity: 0.6; }
.costcell { width: 34%; }
.cost { display: flex; align-items: center; gap: 10px; }
.track { position: relative; flex: 1; height: 10px; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series-1); border-radius: 0 4px 4px 0; }
.track .avg { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--ink-2); }
.cats tr.thin .fill { opacity: 0.35; }
.cost .v { width: 44px; text-align: right; font-weight: 600; }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 999px; padding: 0 6px; margin-left: 6px; }
.more-row { margin-top: 10px; }

/* ---- heat map ----------------------------------------------------------- */
.stats-cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.stats-cols .card + .card { margin-top: 0; }
.stats-cols + .card { margin-top: 16px; }
.hm { display: grid; grid-template-columns: 44px repeat(4, 1fr); gap: 2px; font-variant-numeric: tabular-nums; }
.hm .colh { font-size: 12px; color: var(--ink-2); text-align: center; padding-bottom: 6px; line-height: 1.25; }
.hm .colh small { display: block; color: var(--muted); font-size: 11px; }
.hm .rowh {
  border: 0; background: none; cursor: pointer; text-align: right; padding: 0 10px 0 0;
  color: var(--ink-2); font-weight: 600; font-size: 13px; border-radius: 6px;
}
.hm .rowh:hover { color: var(--accent-text); }
.hm-cell {
  display: grid; place-items: center;
  height: 30px; border: 0; border-radius: 4px; cursor: pointer;
  font-size: 12.5px; font-weight: 600;
}
.hm-cell:hover { outline: 2px solid var(--ink); outline-offset: -2px; }
.hm-cell.thin { opacity: 0.5; }
.hm-cell.hm-none { background: var(--surface-2); color: var(--muted); cursor: default; font-weight: 400; }
.hm-cell.hm-none:hover { outline: 0; }
.legend { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.legend .ramp { flex: 0 0 160px; height: 10px; border-radius: 3px; }

/* ---- mistake bars ------------------------------------------------------- */
.mk { list-style: none; margin: 0; padding: 0; }
.mk li { padding: 9px 0; border-top: 1px solid var(--border); }
.mk li:first-child { border-top: 0; padding-top: 0; }
.mk .row1 { display: flex; align-items: center; gap: 10px; }
.mk .label { width: 46%; font-weight: 500; }
.mk .track { height: 8px; }
.mk .n { width: 34px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.mk .eg { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }

/* ---- trouble ------------------------------------------------------------ */
.trouble { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 24px; }
.trouble .plist li:first-child { border-top: 1px solid var(--border); padding-top: 8px; }

/* ---- drill -------------------------------------------------------------- */
.drill-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.drill-grid .card + .card { margin-top: 0; }
.drill-card { display: flex; flex-direction: column; }
.drill-card .lede { margin-bottom: 14px; }
.drill-card .grow { flex: 1; }
.drill-card .actions { margin-top: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.chip .c { color: var(--ink-2); font-size: 12px; }
button.chip { cursor: pointer; }
button.chip:hover { background: var(--surface-2); }
button.chip.on { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-text); }
button.chip.on .c { color: var(--accent-text); }
.pick-group { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.pick-group:first-of-type { border-top: 0; }
.pick-group .g { font-weight: 500; padding-top: 5px; }

/* ---- misc --------------------------------------------------------------- */
.empty { text-align: center; padding: 56px 24px; color: var(--ink-2); }
.empty h2 { font-size: 18px; color: var(--ink); }
.stats-foot { display: flex; gap: 6px; justify-content: flex-end; margin-top: 20px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--page);
  font-size: 13px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

/* ---- 80 in 8 ------------------------------------------------------------ */
.rules { list-style: none; padding: 0; margin: 6px 0 22px; }
.rules li { padding: 11px 0; border-top: 1px solid var(--border); color: var(--ink-2); }
.rules li:first-child { border-top: 0; }
.rules li b { color: var(--ink); font-weight: 600; }
.rules select { height: 30px; margin: 0 4px; }
.fine { font-size: 12.5px; color: var(--muted); margin-top: 18px; max-width: 64ch; }

.e80-stage { display: flex; flex-direction: column; align-items: center; gap: 48px; width: min(940px, 92vw); }
.e80-q { font-size: 58px; font-weight: 500; letter-spacing: -0.01em; text-align: center; }
.e80-opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; width: 100%; }
.e80-opt {
  position: relative; height: 88px; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--axis); background: var(--surface); color: var(--ink);
  font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.e80-opt:hover { border-color: var(--accent); background: var(--accent-wash); }
.e80-opt .key { position: absolute; top: 7px; left: 11px; font-size: 12px; font-weight: 600; color: var(--muted); }
.e80-opt.good { border-color: var(--good); background: rgba(12, 163, 12, 0.12); }
.e80-opt.bad { border-color: var(--bad); background: var(--bad-wash); }
.chart .ref { stroke: var(--ink-2); stroke-width: 1; opacity: 0.55; }
.chart .ref-label { fill: var(--ink-2); font-size: 11.5px; }

.rules kbd, .game-hint kbd { margin: 0 2px; }

/* ---- sync --------------------------------------------------------------- */
.sync-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.sync-btn:hover { color: var(--ink); background: var(--surface-2); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.sync-btn[data-state="ok"] .sync-dot, .sync-btn[data-state="idle"] .sync-dot { background: var(--good); }
.sync-btn[data-state="syncing"] .sync-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.sync-btn[data-state="error"] .sync-dot { background: var(--bad); }
.sync-btn[data-state="error"] { color: var(--bad); }
@keyframes pulse { 50% { opacity: 0.3; } }

.modal {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.42);
}
.modal-card {
  width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px 24px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
}
.steps { margin: 14px 0 18px; padding-left: 20px; color: var(--ink-2); }
.steps li { margin-bottom: 8px; }
.steps a, .modal-card a { color: var(--accent-text); }
code { font: 13px ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.field { display: grid; gap: 5px; margin-bottom: 12px; font-weight: 500; font-size: 13px; color: var(--ink-2); }
.field input {
  height: 40px; padding: 0 12px; font: 15px var(--font); color: var(--ink);
  background: var(--page); border: 1px solid var(--border-strong); border-radius: 8px;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.sync-msg { margin-top: 12px; min-height: 1.4em; color: var(--ink-2); }
.sync-msg.bad { color: var(--bad); }

/* ---- game chrome for touch ---------------------------------------------- */
.banner-right { display: inline-flex; align-items: center; gap: 14px; }
.quit {
  height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
  border: 1px solid var(--border-strong); background: none; color: var(--ink-2);
}
.quit:hover { color: var(--ink); background: var(--surface-2); }
.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) {
  kbd, .game-hint { display: none; }
  .kbd-only { display: none; }
  .touch-only { display: inline; }
}

/* ---- phone -------------------------------------------------------------- */
@media (max-width: 700px) {
  body { font-size: 15px; }
  .topbar {
    grid-template-columns: auto 1fr auto; gap: 6px; padding: env(safe-area-inset-top) 10px 0;
    height: calc(54px + env(safe-area-inset-top));
  }
  .brand span, .theme-seg, .range-label { display: none; }
  .tabs { justify-content: center; gap: 0; }
  .tab { padding: 8px 7px; white-space: nowrap; font-size: 14px; }
  .sync-btn { padding: 0 9px; height: 32px; font-size: 12px; gap: 5px; }
  main { padding: 18px 14px calc(40px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
  .card { padding: 16px; }
  .setup { padding: 18px 16px; }
  .play-grid, .drill-grid, .stats-cols, .res-cols { grid-template-columns: minmax(0, 1fr); }
  .op-row { grid-template-columns: 1fr; gap: 8px; }
  .range { flex-wrap: wrap; white-space: normal; gap: 6px 8px; }
  .range input[type="number"] { width: 50px; height: 36px; }
  .field-row { grid-template-columns: 1fr auto; }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .filters { flex-wrap: wrap; gap: 10px; }
  .seg { max-width: 100%; overflow-x: auto; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles > .tile:last-child:nth-child(odd) { grid-column: span 2; }
  .tile .value { font-size: 22px; }
  .hero-top { flex-direction: column; }
  .hero { font-size: 68px; }
  .tiles.compact { width: 100%; }
  .trouble { grid-template-columns: minmax(0, 1fr); }
  .card-head { flex-wrap: wrap; }
  table.cats th:nth-child(2), table.cats td:nth-child(2), .cost .track { display: none; }
  .costcell { width: auto; }
  .cost .v { width: auto; }
  .cats td, .cats th { padding-left: 4px; padding-right: 4px; }
  .pick-group { grid-template-columns: 1fr; gap: 6px; }
  .hm { grid-template-columns: 30px repeat(4, minmax(0, 1fr)); }
  .hm .colh { font-size: 11px; }
  .hm .colh small { display: none; }
  .mk .label { width: 52%; }
  .stats-foot { flex-wrap: wrap; justify-content: center; }
  .plist li { flex-wrap: wrap; }

  .banner { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; font-size: 15px; }
  .game-label { display: none; }
  .arena { place-items: start center; padding: 8vh 14px 0; }
  .problem { flex-direction: column; gap: 16px; font-size: 46px; }
  .problem .eq { display: none; }
  #answer { width: 5ch; text-align: center; }
  .e80-stage { gap: 30px; }
  .e80-q { font-size: 40px; }
  .e80-opts { grid-template-columns: 1fr 1fr; gap: 10px; }
  .e80-opt { height: 78px; font-size: 25px; }
  .modal-card { padding: 18px 16px; }
}

/* ---- goals -------------------------------------------------------------- */
.goal { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.goal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.goal-edit { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.goal-edit input[type="number"] { width: 56px; height: 28px; }
.goal-track { height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.goal-track span { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.chart .ref.goal { stroke: var(--good); opacity: 0.9; }

/* ---- manage data -------------------------------------------------------- */
.modal-card.wide { width: min(720px, 100%); }
.game-list.history { overflow-y: auto; }
.game-list li { align-items: center; }
.game-list .q { font-weight: 500; font-size: 13px; min-width: 120px; }
.btn.danger-outline { border-color: var(--bad); color: var(--bad); }
.btn.danger-outline:hover { background: var(--bad-wash); }

/* ---- smart drill stats ---------------------------------------------------- */
.tiles.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles.four .tile { box-shadow: none; background: var(--page); }
.mini-h { font-size: 14px; font-weight: 600; margin: 18px 0 8px; }
.better { color: var(--good); font-weight: 600; }
.worse { color: var(--bad); font-weight: 600; }
.tag.live { color: var(--accent-text); border-color: var(--accent); margin-left: 0; }
.tag.done { color: var(--good); border-color: var(--good); margin-left: 0; }
@media (max-width: 700px) { .tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- undo / history ----------------------------------------------------- */
.undo-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; margin-bottom: 14px; border-radius: 10px;
  background: var(--accent-wash); color: var(--ink); font-weight: 500;
}
.game-list.history { max-height: 30vh; }

/* ---- notices, footer, what's new ---------------------------------------- */
.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px; padding: 10px 14px; border-radius: 10px;
  background: var(--accent-wash); border: 1px solid var(--accent); color: var(--ink);
}
.notice a { color: var(--accent-text); font-weight: 600; }
.app-foot { margin-top: 36px; text-align: center; font-size: 12.5px; color: var(--muted); }
.app-foot .btn.link { font-size: 12.5px; height: auto; }
.changes { margin: 0 0 14px; padding-left: 20px; color: var(--ink-2); }
.changes li { margin-bottom: 4px; }

/* ---- round options, countdown, hurry, keypad ------------------------------ */
.field-row.tight { padding: 8px 0; }
.field-row.tight + .field-row.tight { border-top: 0; }
.field-row.tight:last-of-type { padding-bottom: 22px; }
.countdown {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: color-mix(in srgb, var(--page) 82%, transparent); pointer-events: none;
}
.countdown span { font-size: 120px; font-weight: 700; color: var(--accent); animation: pop 0.7s ease-out infinite; }
@keyframes pop { from { transform: scale(1.25); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .countdown span { animation: none; } }
.hurry #secondsLeft, .hurry #e80Time { color: var(--bad); font-weight: 600; }
.hurry .timebar span { background: var(--bad); }
.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  width: min(420px, 100%); margin: 0 auto; padding: 0 14px calc(14px + env(safe-area-inset-bottom));
}
.keypad button {
  height: 62px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font: 600 26px var(--font);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
}
.keypad button:active { background: var(--accent-wash); border-color: var(--accent); }
.keypad button.fn { background: var(--surface-2); color: var(--ink-2); font-size: 22px; }
#answer[readonly] { caret-color: transparent; }
@media (max-width: 700px) { .keypad button { height: 58px; } }

/* ---- results delta ------------------------------------------------------ */
.hero-delta { margin-top: 4px; color: var(--ink-2); }
.hero-delta:empty { display: none; }

/* ---- phone: tabs move to a bottom bar ------------------------------------ */
@media (max-width: 700px) {
  .topbar { grid-template-columns: 1fr auto; }
  .brand span { display: inline; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .tab { padding: 10px 4px; font-size: 13.5px; text-align: center; border-radius: 10px; }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (max-width: 700px) {
  .field-row, .field-row.tight { grid-template-columns: 104px minmax(0, 1fr); }
  .field-row select { width: 100%; min-width: 0; }
  /* Start goes right under the intro so it's on the first screen; the
     settings follow it. */
  .setup { display: flex; flex-direction: column; }
  .setup h1 { order: -3; }
  .setup .lede { order: -2; margin-bottom: 16px; }
  .setup .actions { display: contents; }
  #startBtn { order: -1; width: 100%; margin-bottom: 18px; }
  #defaultsBtn { align-self: flex-start; margin-top: 14px; }
}

/* ---- account ------------------------------------------------------------ */
.btn.google { width: 100%; height: 46px; gap: 10px; font-size: 15px; margin-top: 4px; }
.or { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: var(--muted); font-size: 12.5px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ---- daily challenge ---------------------------------------------------- */
.daily p.sub { margin: 4px 0 14px; }
.daily .record { grid-template-columns: repeat(2, 1fr); }
.daily .mini-value small { font-size: 13px; font-weight: 400; color: var(--muted); }
@media (max-width: 700px) {
  /* On a phone the daily card leads, above the game settings. */
  .play-grid { display: flex; flex-direction: column; align-items: stretch; }
  .play-grid .side { display: contents; }
  #dailyCard { order: -1; }
  .side .card + .card { margin-top: 0; }
}
.cal { display: grid; grid-template-rows: repeat(7, 11px); grid-auto-flow: column; grid-auto-columns: 11px; gap: 3px; }
.cal i { border-radius: 2px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.cal i.l1 { background: color-mix(in srgb, var(--accent) 42%, var(--surface-2)); }
.cal i.l2 { background: color-mix(in srgb, var(--accent) 62%, var(--surface-2)); }
.cal i.l3 { background: color-mix(in srgb, var(--accent) 82%, var(--surface-2)); }
.cal i.l4 { background: var(--accent); }
.cal i.today { outline: 1.5px solid var(--ink-2); outline-offset: 1px; }
.cal i.future { visibility: hidden; }
.modal-card p.sub + .field { margin-top: 14px; }

/* ---- online assessment ---------------------------------------------------- */
.back-link { padding: 0; margin-bottom: 6px; font-size: 13px; }
.oa-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.oa-grid .card + .card { margin-top: 0; }
.oa-card { display: flex; flex-direction: column; }
.oa-card.soon { opacity: 0.6; }
.oa-head { display: flex; align-items: center; gap: 12px; }
.oa-head h2 { margin: 0; }
.oa-num {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-wash); color: var(--accent-text); font-weight: 600; font-size: 14px;
}
.oa-about { color: var(--ink-2); margin: 12px 0 6px; }
.oa-format { font-size: 13px; color: var(--muted); margin: 0 0 10px; font-variant-numeric: tabular-nums; }
.oa-rec { margin: auto 0 12px; font-size: 14px; }
.oa-card .actions { margin-top: 0; }

.oa-stage { flex: 1; overflow-y: auto; display: grid; place-items: start center; padding: 7vh 20px 40px; }
.oa-stage button { touch-action: manipulation; } /* quick taps (Pump, Buy, codes) mustn't zoom the page */
.oa-q { width: min(820px, 100%); }
.oa-prompt { font-size: 22px; line-height: 1.45; margin: 0 0 26px; }
.oa-prompt:focus { outline: none; } /* focus follows each new question; it isn't a control */
.oa-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.oa-choices { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.oa-choice {
  position: relative; min-height: 72px; padding: 18px 8px 10px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--axis); background: var(--surface); color: var(--ink);
  font-size: 21px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.oa-choice:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-wash); }
.oa-choice .k { position: absolute; top: 5px; left: 9px; font-size: 11px; font-weight: 600; color: var(--muted); }
.oa-choice.right { border-color: var(--good); background: rgba(12, 163, 12, 0.12); }
.oa-choice.wrong { border-color: var(--bad); background: var(--bad-wash); }
.oa-choice:disabled { cursor: default; }
.oa-foot { display: flex; gap: 8px; margin-top: 18px; color: var(--muted); }
.oa-explain { margin-top: 18px; padding: 16px 18px; border-radius: 12px; background: var(--surface-2); line-height: 1.5; }
.oa-explain p { margin: 0 0 8px; }
.oa-explain .actions { margin-top: 10px; }

.res-cols.oa-res { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.oa-review { border-top: 1px solid var(--border); padding: 10px 0; }
.oa-review summary { display: flex; gap: 10px; align-items: baseline; cursor: pointer; list-style: none; }
.oa-review summary::-webkit-details-marker { display: none; }
.oa-review .n { color: var(--muted); font-size: 12px; min-width: 18px; font-variant-numeric: tabular-nums; }
.oa-review .q { flex: 1; }
.oa-review .mark { font-size: 13px; }
.oa-review p { margin: 8px 0 0 28px; }

@media (max-width: 700px) {
  .oa-grid { grid-template-columns: minmax(0, 1fr); }
  .oa-stage { padding: 4vh 14px 30px; }
  .oa-prompt { font-size: 18px; }
  .oa-choices { grid-template-columns: 1fr 1fr; }
  .oa-choice { min-height: 60px; font-size: 19px; }
  .res-cols.oa-res { grid-template-columns: minmax(0, 1fr); }
}
.oa-prompt.big { font-size: 40px; font-weight: 500; letter-spacing: 0.01em; text-align: center; margin: 4vh 0 40px; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .oa-prompt.big { font-size: 28px; } }
.oa-hint { color: var(--ink-2); margin: 18px 0 10px; }
.oa-rank { display: grid; gap: 10px; }
.oa-rank-item {
  display: grid; grid-template-columns: 34px 22px 1fr auto; align-items: center; gap: 10px; text-align: left;
  padding: 14px 16px; border-radius: 12px; cursor: pointer; font-size: 17px;
  border: 2px solid var(--axis); background: var(--surface); color: var(--ink);
}
.oa-rank-item:hover:not(:disabled) { border-color: var(--accent); }
.oa-rank-item .slot {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600;
  border: 1.5px dashed var(--axis); color: var(--accent-text);
}
.oa-rank-item.picked { border-color: var(--accent); background: var(--accent-wash); }
.oa-rank-item.picked .slot, .oa-rank-item.done .slot { border: 0; background: var(--accent); color: var(--on-accent); }
.oa-rank-item .letter { font-weight: 600; color: var(--muted); }
.oa-rank-item .p { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }
.oa-rank-item:disabled { cursor: default; }
.oa-rank-actions { margin-top: 14px; }
.oa-table { border-collapse: collapse; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.oa-table th, .oa-table td { padding: 6px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.oa-table th { font-size: 13px; color: var(--muted); font-weight: 500; }
.oa-table.scores td, .oa-table.scores th { padding: 3px 10px; }
.oa-table .n { color: var(--muted); font-size: 12px; }
@media (max-width: 700px) {
  .oa-rank-item { font-size: 15px; padding: 12px; gap: 8px; grid-template-columns: 30px 16px 1fr auto; }
  .oa-table th, .oa-table td { padding: 5px 8px; }
  .oa-table.scores td, .oa-table.scores th { padding: 2px 5px; font-size: 13px; }
}
.oa-iv { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 22px; }
.oa-iv label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.oa-iv input {
  width: 130px; height: 46px; padding: 0 12px; border-radius: 10px; font-size: 20px; font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--ink);
}
.oa-iv input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.oa-iv .to, .oa-iv .unit { color: var(--ink-2); padding-bottom: 12px; }
.oa-iv .btn { height: 46px; }
.oa-visual { display: block; width: min(420px, 100%); height: auto; margin: 6px 0 4px; }
.oa-visual.path { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.oa-visual.path polyline { fill: none; stroke: var(--accent); stroke-width: 0.8; stroke-linejoin: round; }
.oa-visual.path circle { fill: var(--accent); }
.oa-visual.path .bar line { stroke: var(--ink); stroke-width: 0.5; }
.oa-visual.density, .oa-visual.graph, .oa-visual.trend { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.oa-visual.trend { width: min(560px, 100%); }
.oa-visual.trend .pt { fill: var(--series-1); }
.oa-visual.trend .mark.q { stroke: var(--muted); }
.oa-visual.trend .qmark { fill: var(--ink); font-size: 15px; font-weight: 700; }
.oa-numbers.dense { grid-template-columns: repeat(20, minmax(0, 36px)); gap: 3px; font-size: 15px; }
.oa-numbers.dense span { padding: 3px 0; border-radius: 4px; }
.oa-coins {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 24px)); gap: 2px 3px; margin: 6px 0;
  font: 600 16px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; text-align: center;
}
.oa-coins b { color: var(--ink); }
.oa-coins i { font-style: normal; color: var(--muted); font-weight: 400; }
.oa-visual.density { width: min(560px, 100%); }
.oa-visual.graph { width: min(400px, 100%); }
.oa-visual .gl { stroke: var(--grid); stroke-width: 1; }
.oa-visual .axis { stroke: var(--axis); stroke-width: 1; }
.oa-visual .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.oa-visual .tick.key { fill: var(--ink-2); font-size: 12px; }
.oa-visual .curve { fill: none; stroke-width: 2; stroke-linejoin: round; }
.oa-visual .curve.c0 { stroke: var(--series-1); }
.oa-visual .curve.c1 { stroke: var(--ink); stroke-dasharray: 8 4; }
.oa-visual .curve.c2 { stroke: var(--ink-2); stroke-dasharray: 2 3; stroke-width: 2.2; }
.oa-visual .mark { stroke: var(--bad); stroke-width: 1.5; stroke-dasharray: 5 4; }
.oa-visual.graph .edge { fill: none; stroke: var(--ink-2); stroke-width: 1.5; }
.oa-visual.graph marker path { fill: var(--ink-2); }
.oa-visual.graph .node circle { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.oa-visual.graph .node.start circle { fill: var(--accent-wash); stroke: var(--accent); stroke-width: 2; }
.oa-visual.graph .node text { fill: var(--ink); font-size: 17px; font-weight: 600; text-anchor: middle; dominant-baseline: central; }
.oa-visual.graph .w {
  fill: var(--ink); font-size: 14px; font-weight: 500; text-anchor: middle; dominant-baseline: central;
  font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round;
}
@media (max-width: 700px) {
  .oa-visual .tick { font-size: 16px; }
  .oa-visual .tick.key { font-size: 17px; }
  .oa-visual .tick.odd { display: none; }
}
.oa-visual.path .bar text { font-size: 3.2px; fill: var(--ink-2); }
.oa-visual .sh-red { fill: #d03b3b; }
.oa-visual .sh-blue { fill: #2a78d6; }
.oa-visual .sh-green { fill: #1f9d55; }
.oa-visual .die { fill: var(--surface); stroke: var(--axis); stroke-width: 1.2; }
.oa-visual .pip { fill: var(--ink); }
.oa-numbers { display: grid; grid-template-columns: repeat(10, minmax(0, 46px)); gap: 6px; margin: 6px 0; font-size: 18px; font-variant-numeric: tabular-nums; }
.oa-numbers span { text-align: center; padding: 6px 0; border-radius: 6px; background: var(--surface-2); }
.oa-cal { margin-bottom: 16px; }
.oa-cal .tiles { margin: 6px 0 10px; }
@media (max-width: 700px) {
  .oa-iv input { width: 110px; }
  .oa-numbers { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .oa-numbers.dense { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 2px; font-size: 13px; }
  .oa-numbers.dense span { padding: 2px 0; }
  .oa-coins { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 1px 0; font-size: 12px; }
}
.ob-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ob-grid.wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ob-card { border: 2px solid var(--axis); border-radius: 12px; background: var(--surface); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.ob-card.long { border-color: var(--good); }
.ob-card.short { border-color: var(--bad); }
.ob-card.in-answer { border-color: var(--accent); background: var(--accent-wash); }
.ob-top { display: flex; justify-content: space-between; align-items: center; min-height: 20px; }
.ob-letter { font-weight: 600; color: var(--muted); }
.ob-pos { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.ob-legs { font-size: 18px; line-height: 1.35; min-height: 50px; }
.ob-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ob-btns button {
  height: 40px; border-radius: 8px; cursor: pointer; font-size: 14px; font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--border-strong); background: var(--surface-2); color: var(--ink);
}
.ob-btns .ob-sell:hover:not(:disabled) { border-color: var(--bad); }
.ob-btns .ob-buy:hover:not(:disabled) { border-color: var(--good); }
.ob-btns button:disabled { cursor: default; opacity: 0.6; }
.ob-status { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 16px 0 4px; font-variant-numeric: tabular-nums; }
.ob-status span { padding: 4px 10px; border-radius: 8px; background: var(--surface-2); }
.ob-status .off b { color: var(--bad); }
.ob-status .ok b { color: var(--good); }
.ob-msg { min-height: 22px; color: var(--bad); margin: 8px 0 0; }
@media (max-width: 700px) {
  .ob-grid, .ob-grid.wide { grid-template-columns: 1fr 1fr; gap: 8px; }
  .ob-legs { font-size: 16px; }
}
.zap-games { display: grid; gap: 10px; margin-top: 4px; }
.zap-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.zap-row .oa-rec { margin: 4px 0 0; font-size: 13px; }
.oa-q.zap { text-align: center; }
.nb-target { font-size: 22px; color: var(--ink-2); margin: 2vh 0 26px; }
.nb-target b { font-size: 56px; color: var(--ink); display: block; font-variant-numeric: tabular-nums; }
.nb-tiles { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.nb-tile {
  position: relative; min-width: 92px; height: 92px; padding: 0 12px; border-radius: 16px; cursor: pointer; font-size: 34px; font-weight: 500;
  border: 2px solid var(--axis); background: var(--surface); color: var(--ink); font-variant-numeric: tabular-nums;
}
.nb-tile .k { position: absolute; top: 6px; left: 9px; font-size: 11px; color: var(--muted); }
.nb-tile.sel { border-color: var(--accent); background: var(--accent-wash); }
.nb-tile.win { border-color: var(--good); background: rgba(12, 163, 12, 0.12); }
.nb-ops { display: flex; justify-content: center; gap: 12px; margin-top: 22px; }
.nb-op { width: 64px; height: 56px; border-radius: 12px; cursor: pointer; font-size: 26px; border: 1.5px solid var(--border-strong); background: var(--surface-2); color: var(--ink); }
.nb-op.sel { border-color: var(--accent); background: var(--accent-wash); color: var(--accent-text); }
.nb-msg { min-height: 24px; margin: 18px 0 0; color: var(--ink-2); }
.oa-q.zap .oa-foot { justify-content: center; }
.cc-code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 54px; letter-spacing: 0.12em; margin: 4vh 0 34px; }
.cc-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 640px; margin: 0 auto; }
.cc-opt {
  position: relative; height: 72px; border-radius: 12px; cursor: pointer; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 28px; letter-spacing: 0.1em; border: 2px solid var(--axis); background: var(--surface); color: var(--ink);
}
.cc-opt .k { position: absolute; top: 5px; left: 9px; font-size: 11px; color: var(--muted); font-family: inherit; letter-spacing: 0; }
.cc-opt:hover { border-color: var(--accent); }
.bl-svg { width: min(320px, 70vw); height: auto; }
.bl-balloon { fill: #d03b3b; }
.bl-string { stroke: var(--axis); stroke-width: 2; }
.bl-pop { font-size: 64px; font-weight: 700; fill: var(--bad); }
.bl-bank { font-size: 18px; margin: 4px 0 0; }
.bl-actions { justify-content: center; margin-top: 12px; }
@media (max-width: 700px) {
  .nb-tile { min-width: 70px; height: 74px; font-size: 28px; }
  .nb-target b { font-size: 44px; }
  .cc-code { font-size: 36px; }
  .cc-opt { font-size: 20px; height: 60px; }
}

/* ---- Stats: Classic / OA ---------------------------------------------------- */
.stats-title { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.stats-title h1 { margin: 0; }
.oas td { vertical-align: middle; }
.oas .ex { font-size: 12.5px; color: var(--muted); }
.oas .spk { width: 150px; }
.oas-spark { width: 140px; height: 32px; }
.oas-head { margin-bottom: 14px; }
.oas-head h2 { margin: 4px 0 0; font-size: 22px; }
.oas-head h2 .sub { font-size: 14px; font-weight: 400; margin-left: 6px; }
.oas-rounds li { align-items: center; }
.oas-rounds .q { min-width: 140px; font-size: 13px; }
@media (max-width: 700px) {
  .oas .avg, .oas .spk { display: none; }
  .oas td, .oas th { padding-left: 4px; padding-right: 4px; }
  .oas-rounds .q { min-width: 0; }
}
/* Trend hover: a strip per value; dots appear while hovering the line. */
.spark-pt { position: absolute; top: 0; height: 100%; cursor: default; }
.spark-pt i {
  position: absolute; left: calc(50% - 3px); width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 0 1.5px var(--surface); opacity: 0; transition: opacity 0.12s, transform 0.12s;
}
.spark.has-points:hover .spark-pt i { opacity: 0.6; }
.spark.has-points .spark-pt:hover i { opacity: 1; transform: scale(1.6); }
.spark.has-points .spark-pt:hover::before {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1px dashed var(--axis);
}
.spark-pt.single i { opacity: 1; }

/* Full OA practice: hub card, stage screen and report (oa-ui.js) */
.oa-mock-card { margin-bottom: 16px; border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.oa-mock-card .actions { margin-top: 0; }
.mk-cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.mk-cols .card + .card { margin-top: 0; }
.mk-cols.report { margin-top: 16px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.mk-title { margin: 6px 0 4px; font-size: 26px; }
.mk-break { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mk-abandon { margin-top: 14px; }
.mk-stages { list-style: none; margin: 0; padding: 0; }
.mk-stage { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); }
.mk-stage:first-child { border-top: 0; padding-top: 0; }
.mk-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.mk-stage.done .mk-dot { background: var(--good); color: #fff; }
.mk-stage.next .mk-dot { background: var(--accent); color: var(--on-accent); }
.mk-stage.done .mk-name b { color: var(--ink-2); font-weight: 500; }
.mk-state { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mk-stage.next .mk-state { color: var(--accent-text); font-weight: 600; }
.mk-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.mk-badge.r2 { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.mk-badge.r1 { background: var(--accent-wash); color: var(--accent-text); }
.mk-badge.r0 { background: var(--bad-wash); color: var(--bad); }
.mk-badge.none { background: var(--surface-2); color: var(--muted); }
.mk-badge.small { padding: 1px 8px; font-size: 11.5px; }
.mk-badge.big { padding: 6px 14px; font-size: 16px; }
.mk-hero .actions { margin-top: 14px; }
.mk-tally { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.mk-lede { margin: -4px 0 14px; }
.mk-focus { margin: 0; padding-left: 22px; display: grid; gap: 16px; }
.mk-focus li::marker { color: var(--muted); font-weight: 600; }
.mk-f-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.mk-tag { font-size: 12.5px; color: var(--muted); }
.mk-focus .sub { margin: 2px 0 4px; }
.mk-action { margin: 0 0 8px; }
.mk-mods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.mk-mods .card + .card { margin-top: 0; }
.mk-mod { display: flex; flex-direction: column; }
.mk-mod .actions { margin-top: auto; padding-top: 12px; flex-wrap: wrap; }
.mk-mod-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.mk-mod-head h2 { margin: 0; }
.mk-line { margin: 0; font-size: 22px; font-variant-numeric: tabular-nums; }
.mk-sub { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.mk-game + .mk-game { margin-top: 10px; }
.mk-game-head { display: flex; align-items: center; gap: 8px; }
@media (max-width: 700px) {
  .mk-cols, .mk-cols.report, .mk-mods { grid-template-columns: minmax(0, 1fr); }
  .mk-title { font-size: 22px; }
}

/* ---- leaderboard (lb-ui.js) ------------------------------------------------ */
.tab .short { display: none; }
.lb-kinds { margin: -6px 0 16px; }
.lb-cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.lb-cols .card + .card { margin-top: 0; }
.lb-rule { margin: -6px 0 10px; }
.lb-day { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.lb-day span { min-width: 104px; text-align: center; }
.lb-day .btn { width: 32px; height: 32px; padding: 0; font-size: 18px; }
.lb-rows { list-style: none; margin: 0; padding: 0; }
.lb-row {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto 56px; align-items: center; gap: 12px;
  padding: 9px 8px; border-top: 1px solid var(--border);
}
.lb-rows .lb-row:first-child { border-top: 0; }
.lb-rank { font-weight: 600; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.lb-row.top1 .lb-rank, .lb-row.top2 .lb-rank, .lb-row.top3 .lb-rank { color: var(--accent-text); }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.lb-when { color: var(--muted); font-size: 12.5px; text-align: right; }
.lb-row.you { background: var(--accent-wash); border-radius: 8px; border-top-color: transparent; }
.lb-row.you + .lb-row { border-top-color: transparent; }
.lb-you { margin-left: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-text); }
.lb-sep { margin: 14px 0 4px; }
.lb-empty { margin: 8px 0 12px; color: var(--ink-2); }
.lb-me p { margin: 0 0 12px; }
.lb-me .field { margin-bottom: 12px; }
.lb-fine { margin-top: 16px; }
@media (max-width: 700px) {
  .lb-cols { grid-template-columns: minmax(0, 1fr); }
  .lb-row { grid-template-columns: 28px minmax(0, 1fr) auto 48px; gap: 10px; }
  .tab .long { display: none; }
  .tab .short { display: inline; }
}

/* ---- skill levels (Stats) and level-ups (results) ------------------------- */
.lv-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 32px; }
.lv-row { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.lv-row .op { margin-top: 1px; }
.lv-row .btn { margin-top: 2px; }
.lv-main { flex: 1; min-width: 0; }
.lv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.lv-name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lv-level { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lv-bar { height: 6px; margin: 6px 0 4px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.lv-bar span { display: block; height: 100%; background: var(--accent); border-radius: 0 3px 3px 0; }
.lv-sub { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lv-sub .better { font-weight: 600; }
.hero-levels { margin-top: 4px; color: var(--ink-2); }
.hero-levels:empty { display: none; }
@media (max-width: 700px) {
  .lv-list { grid-template-columns: minmax(0, 1fr); }
}

/* ---- practice card: calendar, weekly goal, last week ---------------------- */
.cal-note { margin: 8px 0 0; }
.week-goal .goal-head { margin-bottom: 4px; }
.week-goal select { height: 28px; padding: 0 8px; font-size: 13px; font-weight: 500; }
.week-goal .sub { margin: 0 0 8px; }
.recap { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.recap .mini-h { margin: 0 0 4px; }
.recap .sub { margin-top: 2px; }

/* ---- next up (Play) ------------------------------------------------------ */
.next-lead { margin: 2px 0 4px; }
.next-why { margin: 0 0 14px; }
.focus-list + .next-why { margin-top: -6px; }
#focusCard .lv-bar { margin: 8px 0 10px; }

/* ---- Quick play and game effects (oa-ui.js) -------------------------------- */
.qp-rec { color: var(--accent-text); font-size: 13px; }
.qp-hud {
  display: flex; align-items: center; justify-content: center; gap: 22px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.qp-hud[hidden] { display: none; }
.qp-lives { display: inline-flex; gap: 4px; font-size: 20px; line-height: 1; }
.qp-lives i { font-style: normal; color: var(--grid); transition: color 0.2s; }
.qp-lives i.on { color: var(--bad); }
.qp-lives i.lost { animation: qp-heart 0.6s ease-out; }
.qp-level { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 3px 10px; border-radius: 99px; background: var(--surface-2); }
.qp-level.up { animation: qp-pop 0.5s ease-out; color: var(--accent-text); background: var(--accent-wash); }
.qp-combo { min-width: 92px; font-size: 14px; font-weight: 600; color: var(--muted); text-align: center; }
.qp-combo.on { color: #c2410c; }
.qp-combo.up { animation: qp-pop 0.45s ease-out; }
.qp-score { min-width: 72px; font-size: 22px; font-weight: 700; color: var(--ink); text-align: right; }
.qp-score.bump { animation: qp-pop 0.35s ease-out; }
.qp-lost { color: var(--bad); font-weight: 600; margin-left: 6px; }
.qp-title { margin: 2px 0 6px; font-size: 18px; font-weight: 600; color: var(--accent-text); }
.sound-btn {
  height: 30px; padding: 0 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px;
  border: 1px solid var(--border); background: none; color: var(--ink-2);
}
.sound-btn[aria-pressed="true"] { color: var(--accent-text); border-color: var(--accent); }
.cc-streak { min-height: 1.3em; margin: 0 0 4px; text-align: center; font-weight: 600; color: #c2410c; }
.bl-pop { animation: qp-pop 0.4s ease-out; transform-origin: center; transform-box: fill-box; }

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.fx-float {
  position: absolute; left: 50%; top: 34%; transform: translateX(-50%);
  font-size: 30px; font-weight: 800; color: var(--accent-text);
  animation: fx-rise 1.05s ease-out forwards;
}
.fx-float.good { color: var(--good); }
.fx-float.bad { color: var(--bad); }
.fx-float.level { top: 24%; font-size: 40px; color: var(--accent-text); }
.fx-jolt { animation: fx-jolt 0.35s ease-in-out; }
.fx-confetti {
  position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px;
  animation: fx-fall 1.8s ease-in forwards;
}
@keyframes fx-rise { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 100% { opacity: 0; transform: translate(-50%, -70px) scale(1); } }
@keyframes fx-jolt { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes fx-fall { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--drift), 105vh) rotate(540deg); opacity: 0.6; } }
@keyframes qp-pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes qp-heart { 0% { transform: scale(1.4); color: var(--bad); } 100% { transform: scale(1); } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .qp-combo.on, :root:not([data-theme="light"]) .cc-streak { color: #fb923c; }
}
:root[data-theme="dark"] .qp-combo.on, :root[data-theme="dark"] .cc-streak { color: #fb923c; }
@media (prefers-reduced-motion: reduce) {
  .fx-float, .fx-jolt, .qp-level.up, .qp-combo.up, .qp-score.bump, .qp-lives i.lost, .bl-pop { animation: none; }
  .fx-float { opacity: 0; }
  .fx-confetti { display: none; }
}
@media (max-width: 700px) {
  .qp-hud { gap: 12px; padding: 8px 12px; justify-content: space-between; }
  .qp-combo { min-width: 0; font-size: 13px; }
  .qp-score { min-width: 0; font-size: 19px; }
  .qp-hud .sound-btn { padding: 0 8px; }
}
.btn.qp-btn { color: var(--accent-text); }
.fx-float { text-shadow: 0 0 10px var(--page), 0 0 4px var(--page); }

/* ---- the app's own title bar (Windows desktop, see main.js) ---------------- */
/* The top bar (and a game's banner) drags the window; the native window buttons
   sit over its right end, so content stops short of them. The env() values only
   exist when the window has that overlay; elsewhere the extra padding is zero. */
.topbar, .banner { -webkit-app-region: drag; }
.topbar button, .topbar a, .topbar input, .topbar select, .topbar .tabs, .banner button { -webkit-app-region: no-drag; }
.topbar { padding-right: calc(20px + 100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw)); }
.banner { padding-right: calc(28px + 100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw)); }
@media (max-width: 700px) {
  .banner { padding-right: calc(14px + 100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw)); }
}
/* Slim scrollbars in the app's colors. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border: 2px solid transparent; border-radius: 10px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-corner { background: transparent; }
/* ---- short and mid windows: main pages ---- */
/* Mid widths sit between the phone layout and full width (a half-screen
   snap, a narrow browser). Columns that get squeezed there make room. */
@media (min-width: 701px) and (max-width: 1060px) {
  /* The brackets already say it's a range (phones drop the label too), and
     without it both ranges stay on one line inside the card. */
  #setupForm .range-label { display: none; }
  /* Keep the tabs off the sign-in and theme controls. */
  .topbar { column-gap: 16px; }
  /* Results: misses and slowest stack on the left, by operation runs beside them. */
  #view-results .res-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-results .res-cols > :nth-child(3) { grid-column: 2; grid-row: 1 / span 2; }
  /* Trouble lists keep their three columns; each detail gets its own line
     instead of wrapping word by word beside the problem. */
  .trouble .plist li { flex-wrap: wrap; row-gap: 2px; }
  .trouble .plist .detail { order: 1; flex-basis: 100%; }
}
@media (min-width: 701px) and (max-width: 940px) {
  .tab { padding: 8px 12px; }
  /* Play: the setup card takes the full width and the side cards pair up below. */
  #view-play .play-grid { grid-template-columns: minmax(0, 1fr); }
  #view-play .side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
  #view-play .side .card + .card { margin-top: 0; }
  /* Leaderboard: a narrower join card leaves the board more room. */
  .lb-cols { grid-template-columns: minmax(0, 1fr) 260px; }
}
@media (min-width: 701px) and (max-width: 800px) {
  .topbar { column-gap: 12px; }
  .tab { padding: 8px 10px; }
  .theme-seg button { padding: 5px 9px; }
}
@media (min-width: 701px) and (max-width: 740px) {
  .tab .long { display: none; }
  .tab .short { display: inline; }
}
/* Short windows (a quarter-screen snap, a landscape tablet): the Classic
   setup tightens so Start is on the first screen, and Start stays pinned to
   the bottom of the window if the card still runs past it. */
@media (min-width: 701px) and (max-height: 700px) {
  main { padding-top: 12px; }
  #setupForm { padding: 16px 24px 6px; }
  #setupForm h1 { line-height: 1.2; }
  #setupForm .lede { margin-bottom: 10px; }
  #setupForm .op-row { min-height: 0; padding: 5px 0; }
  #setupForm .field-row, #setupForm .field-row.tight { padding: 5px 0; }
  #setupForm .actions {
    position: sticky; bottom: 0; z-index: 1;
    margin: 0 -24px; padding: 6px 24px 12px;
    background: var(--surface);
    container-type: scroll-state;
  }
  #startBtn { height: 42px; }
  /* A rule above Start only while it's pinned over the settings. */
  @container scroll-state(stuck: bottom) {
    #startBtn::before { content: ''; position: absolute; inset: 0 0 auto; border-top: 1px solid var(--border); pointer-events: none; }
  }
}

/* ---- short windows: OA game screens ---- */
/* A window snapped to a quarter of the screen (about 960×518 or 640×518), or a
   narrow one that isn't phone-shaped (640×763), keeps each game's main button
   above the fold: whitespace goes first, then cards and pictures shrink to the
   height that's left. Full-size windows (1280×763 and up) match none of this. */
@media (max-height: 700px), (max-width: 700px) and (min-aspect-ratio: 3/4) {
  #view-oagame .banner, #view-zapgame .banner { padding-top: 10px; padding-bottom: 10px; }
  .qp-hud { padding-top: 6px; padding-bottom: 6px; }
  .oa-stage { padding-top: 14px; padding-bottom: 24px; }
  .oa-prompt { line-height: 1.4; margin-bottom: 12px; }
  .oa-prompt.big { margin: 2vh 0 28px; }
  .oa-foot { margin-top: 12px; }
  .oa-explain { margin-top: 12px; padding: 12px 16px; }

  .oa-hint { margin: 10px 0 8px; }
  .oa-rank { gap: 8px; }
  .oa-rank-item { padding-top: 9px; padding-bottom: 9px; }
  .oa-rank-actions { margin-top: 10px; }
  .oa-table th, .oa-table td { padding-top: 4px; padding-bottom: 4px; }
  .oa-table.scores td, .oa-table.scores th { padding-top: 2px; padding-bottom: 2px; }

  .oa-iv { margin-top: 12px; }
  .oa-iv input, .oa-iv .btn { height: 40px; }
  .oa-iv .to, .oa-iv .unit { padding-bottom: 9px; }
  .oa-numbers { gap: 4px; }
  .oa-numbers span { padding: 3px 0; }
  .oa-numbers.dense { gap: 2px 3px; line-height: 1.3; }
  .oa-numbers.dense span { padding: 2px 0; }
  .oa-coins { row-gap: 1px; line-height: 1.25; }

  .ob-grid { gap: 8px; }
  .ob-card { padding: 8px 10px; gap: 5px; }
  .ob-top { min-height: 0; line-height: 1.25; }
  .ob-legs { font-size: 16px; line-height: 1.3; min-height: 42px; }
  .ob-btns { gap: 6px; }
  .ob-btns button { height: 34px; }
  .ob-status { margin: 10px 0 8px; }
  .ob-status span { padding: 2px 10px; }
  .ob-msg { margin-top: 4px; }

  .nb-target { margin: 1vh 0 16px; }
  .nb-ops { margin-top: 14px; }
  .nb-msg { margin-top: 10px; }
  .cc-code { margin: 2vh 0 22px; }
  .bl-actions { margin-top: 8px; }
}
@media (min-width: 701px) and (max-height: 700px) {
  .oa-prompt { font-size: 20px; }
  .oa-coins { font-size: 15px; line-height: 1.2; }
}
/* Pictures sized to the height that's left, with a floor so they stay readable;
   Quick play's score bar takes another 44px. */
@media (max-height: 700px) {
  .oa-visual.shapes, .oa-visual.dice { width: min(420px, 100%, max(220px, 100dvh - 240px)); }
  .oa-visual.path { width: min(560px, 100%, max(300px, (100dvh - 240px) * 1.39)); }
  .oa-visual.trend { width: min(560px, 100%, max(400px, (100dvh - 240px) * 2.13)); }
  .quick .oa-visual.shapes, .quick .oa-visual.dice { width: min(420px, 100%, max(220px, 100dvh - 284px)); }
  .quick .oa-visual.path { width: min(560px, 100%, max(300px, (100dvh - 284px) * 1.39)); }
  .quick .oa-visual.trend { width: min(560px, 100%, max(400px, (100dvh - 284px) * 2.13)); }
  .bl-svg { width: min(320px, 70vw, max(170px, (100dvh - 215px) * 0.94)); }
}
/* Between phone and desktop widths, order cards three to a row (four when short)
   and the number grid twenty to a row, as on the desktop. */
@media (min-width: 560px) and (max-width: 700px) and (min-aspect-ratio: 3/4) {
  .ob-grid, .ob-grid.wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .oa-numbers.dense { grid-template-columns: repeat(20, minmax(0, 1fr)); }
  .oa-q:has(> .oa-rank) > .oa-visual.graph { width: min(360px, 100%); }
}
@media (min-width: 560px) and (max-width: 700px) and (max-height: 640px) {
  .ob-grid.wide { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .ob-grid.wide .ob-card { padding: 7px 6px; }
  .ob-grid.wide .ob-btns { gap: 4px; }
  .ob-grid.wide .ob-btns button { padding: 0 2px; font-size: 13px; white-space: nowrap; }
}
/* Likelihood-list with a table or chart: the chart on the left, the ranking and
   Submit on the right, under a full-width prompt. */
@media (min-width: 600px) and (max-height: 700px) {
  .oa-q:has(> .oa-rank):has(> .oa-table, > .oa-visual) {
    display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: repeat(5, auto) 1fr;
    column-gap: 24px; align-items: start;
  }
  .oa-q:has(> .oa-rank):has(> .oa-table, > .oa-visual) > * { grid-column: 2; }
  .oa-q:has(> .oa-rank):has(> .oa-table, > .oa-visual) > .oa-prompt { grid-column: 1 / -1; }
  .oa-q:has(> .oa-rank):has(> .oa-table, > .oa-visual) > :is(.oa-table, .oa-visual) { grid-column: 1; grid-row: 2 / -1; margin-top: 0; }
  .oa-q:has(> .oa-rank):has(> .oa-table, > .oa-visual) > .oa-hint { margin-top: 0; }
  .oa-q:has(> .oa-rank) > .oa-visual.graph { width: min(400px, 100%, (100dvh - 180px) * 1.35); }
  .oa-q:has(> .oa-rank) > .oa-visual.density { width: min(560px, 100%, (100dvh - 180px) * 2.47); }
  .quick .oa-q:has(> .oa-rank) > .oa-visual.graph { width: min(400px, 100%, (100dvh - 224px) * 1.35); }
  .quick .oa-q:has(> .oa-rank) > .oa-visual.density { width: min(560px, 100%, (100dvh - 224px) * 2.47); }
  /* The chart is drawn smaller than usual, so its labels are set larger to read the same. */
  .oa-q:has(> .oa-rank) > .oa-visual .tick { font-size: 13px; }
  .oa-q:has(> .oa-rank) > .oa-visual .tick.key { font-size: 14px; }
}
@media (min-width: 600px) and (max-width: 700px) and (max-height: 700px) {
  .oa-q:has(> .oa-rank) > .oa-visual .tick { font-size: 18px; }
  .oa-q:has(> .oa-rank) > .oa-visual .tick.key { font-size: 19px; }
  .oa-q:has(> .oa-rank) > .oa-visual.graph .w { font-size: 16px; }
  .oa-q:has(> .oa-rank) > .oa-visual.graph .node text { font-size: 19px; }
}
/* Narrower desktop windows: the brand keeps only its icon, leaving room for the
   window buttons at the right end of the top bar. */
@media (min-width: 701px) and (max-width: 900px) {
  .brand span { display: none; }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .topbar .tabs { justify-self: center; }
}
@media (min-width: 701px) and (max-width: 820px) {
  /* The theme switch shows A / L / D (full names in the tooltip and to screen readers). */
  .theme-seg button { font-size: 0; padding: 5px 9px; }
  .theme-seg button::first-letter { font-size: 13px; }
}

/* ---- declutter: OA hub, Leaderboard ---- */
/* OA hub: Full OA practice as a hero, then a tile per module. A tile is its
   title (which opens the module's "about"), one format line, big bests over
   small labels, and its buttons: Test first, Learn and Quick play quiet. */
.oa-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.oa-info > summary {
  display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%;
  cursor: pointer; list-style: none; border-radius: 6px;
}
.oa-info > summary::-webkit-details-marker { display: none; }
.oa-info > summary h2 { margin: 0; font-size: 16px; min-width: 0; }
.oa-info .oa-num { width: 22px; height: 22px; font-size: 12px; }
.oa-i {
  flex: none; display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid currentColor; color: var(--muted); font: italic 600 10px/1 Georgia, serif; opacity: 0.75;
}
.oa-info > summary:hover .oa-i, .oa-info[open] .oa-i { color: var(--accent-text); opacity: 1; }
.oa-info .oa-about { margin: 8px 0 2px; font-size: 13px; color: var(--ink-2); max-width: 72ch; }
.oa-info .oa-about p + p, .oa-info .oa-about ul { margin-top: 6px; }
.oa-info .oa-about ul { margin-bottom: 0; padding-left: 18px; }
.oa-info .oa-about li + li { margin-top: 3px; }
.oa-card .oa-format { margin: 4px 0 0; }
.oa-stats { display: flex; flex-wrap: wrap; gap: 6px 28px; }
.oa-card .oa-stats { margin: 16px 0 0; font-size: inherit; }
.oa-stat { display: flex; flex-direction: column; min-width: 0; }
.oa-stat b { font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.oa-stat.none b { color: var(--muted); opacity: 0.6; }
.oa-stat span { margin-top: 2px; font-size: 12px; color: var(--muted); }
.oa-card .actions { margin-top: auto; padding-top: 16px; gap: 4px; }
.oa-card .actions .btn.ghost { padding: 0 12px; }
.btn.oa-go { background: var(--accent-wash); border-color: transparent; color: var(--accent-text); }
.btn.oa-go:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
/* Zap-N: one tile across the grid, a column per game (a row each on phones). */
.oa-zap { grid-column: 1 / -1; }
.oa-zap-games { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 24px; margin-top: 16px; }
.oa-zap-game { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-width: 0; }
.oa-card .oa-zap-game .oa-stats { margin: 0; }
/* Full OA practice: text left, Start or Resume right. */
.oa-hero {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px 24px;
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.oa-hero-main { flex: 1 1 320px; min-width: 0; }
.oa-hero .oa-info > summary h2 { font-size: 19px; letter-spacing: -0.01em; }
.oa-hero .oa-format { margin: 4px 0 0; font-size: 13.5px; color: var(--ink-2); }
.oa-hero .oa-format b { color: var(--ink); font-weight: 600; }
.oa-hero .actions { flex: none; }
.oa-fine, .lb-fine { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .oa-zap-games { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .oa-zap-game { flex-direction: row; align-items: center; justify-content: space-between; }
  .oa-zap-game .oa-stat { align-items: flex-end; }
}
/* Leaderboard: rows set apart by spacing, not rules; a compact join card. */
.lb-row { border-top: 0; padding: 8px; }
.lb-me h2 { margin-bottom: 6px; }
.lb-me .card-head { margin-bottom: 6px; }
.lb-join { display: flex; gap: 8px; }
.lb-join input {
  flex: 1 1 auto; min-width: 0; height: 36px; padding: 0 12px; font: 15px var(--font); color: var(--ink);
  background: var(--page); border: 1px solid var(--border-strong); border-radius: 8px;
}
.lb-join input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.lb-me .sync-msg { margin-top: 8px; min-height: 0; }
.lb-me .sync-msg:empty { display: none; }
/* ---- declutter: Stats ---- */
/* Big numbers, small labels; quieter row actions; spacing, not rules, inside cards;
   the sections below the headline cards fold into named one-line summaries. */
#statsBody .tile .label { font-size: 12px; color: var(--muted); }
#statsBody .tile .value { font-size: 30px; line-height: 1.15; margin-top: 4px; }
#statsBody .tile .note { margin-top: 2px; }
#statsBody .tile[title], #statsBody .hint { cursor: help; }
#statsBody .hint { text-decoration: underline dotted var(--border-strong); text-underline-offset: 3px; }
#statsBody .card-head .sub { text-align: right; }
/* Rows: no rules between them, a little more air instead, and a hover wash to follow one across. */
#statsBody .cats td { border-top: 0; padding-top: 7px; padding-bottom: 7px; }
#statsBody .cats tbody tr:hover td { background: var(--surface-2); }
#statsBody .cats tbody tr:hover td:first-child { border-radius: 6px 0 0 6px; }
#statsBody .cats tbody tr:hover td:last-child { border-radius: 0 6px 6px 0; }
#statsBody .mk li, #statsBody .plist li, #statsBody .trouble .plist li { border-top: 0; padding: 6px 0; }
#statsBody .mk li { padding: 8px 0; }
/* Per-row Drill / Details / Review read as links; each card keeps one real button. */
#statsBody .cats .btn.small, #statsBody .lv-row .btn.small, #statsBody .oas-rounds .btn.small {
  border-color: transparent; background: none; box-shadow: none; color: var(--accent-text);
}
#statsBody .cats .btn.small:hover, #statsBody .lv-row .btn.small:hover, #statsBody .oas-rounds .btn.small:hover { background: var(--accent-wash); }
#statsBody .oas .ex { display: inline; margin-left: 4px; }
/* Folding sections */
#statsBody .folds { margin-top: 16px; display: grid; gap: 10px; }
#statsBody .folds:empty { display: none; }
#statsBody .folds > .card + .card { margin-top: 0; }
#statsBody .fold { padding: 0; }
#statsBody .fold > summary {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px;
  padding: 16px 48px 16px 22px; position: relative; cursor: pointer; list-style: none; border-radius: var(--radius);
}
#statsBody .fold > summary::-webkit-details-marker { display: none; }
#statsBody .fold > summary::after {
  content: ""; position: absolute; right: 24px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s;
}
#statsBody .fold[open] > summary::after { transform: rotate(45deg); margin-top: -7px; }
#statsBody .fold > summary:hover { background: var(--surface-2); }
#statsBody .fold > summary:hover::after { border-color: var(--ink-2); }
#statsBody .fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#statsBody .fold > summary h2 { margin: 0; font-size: 16px; }
#statsBody .fold-sum { color: var(--muted); font-size: 13px; min-width: 0; font-variant-numeric: tabular-nums; }
#statsBody .fold-body { padding: 4px 22px 20px; }
#statsBody .fold-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 12px; }
#statsBody .fold-tools .seg { margin-left: auto; }
#statsBody [data-fold="factors"] .fold-body > * { max-width: 640px; }
#statsBody .legend { flex-wrap: wrap; }
#statsBody .legend-hint { color: var(--muted); margin-left: auto; }
#statsBody .tiles.compact .tile { border: 0; background: none; padding: 0; }
#statsBody .tiles.compact { gap: 24px; }
#statsBody .tiles.compact .tile .value { font-size: 22px; }
#statsBody .oa-cal.fold { margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { #statsBody .fold > summary::after { transition: none; } }
@media (max-width: 700px) {
  #statsBody .tile .value { font-size: 24px; }
  #statsBody .fold > summary { padding: 14px 40px 14px 16px; }
  #statsBody .fold > summary::after { right: 18px; }
  #statsBody .fold-body { padding: 2px 16px 16px; }
  #statsBody .legend-hint { margin-left: 0; flex-basis: 100%; }
}

/* ---- declutter: shell, Play, Drill ---- */
/* Top bar: one account button (initial or "Sign in", with a sync dot) opening a
   small menu with Account & sync, the theme switch and Manage data. */
.acct { position: relative; }
.acct-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 500;
}
.acct-btn:hover, .acct-btn[aria-expanded="true"] { color: var(--ink); background: var(--surface-2); }
.acct-btn.signed-in {
  width: 32px; padding: 0; border-color: transparent;
  background: var(--accent-wash); color: var(--accent-text); font-size: 14px; font-weight: 600;
}
.acct-btn.signed-in:hover, .acct-btn.signed-in[aria-expanded="true"] { background: var(--accent-wash); box-shadow: 0 0 0 2px var(--accent); color: var(--accent-text); }
.acct-dot {
  position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 2px var(--page);
}
.acct-btn[data-state="off"] .acct-dot { display: none; }
.acct-btn[data-state="ok"] .acct-dot, .acct-btn[data-state="idle"] .acct-dot,
.menu-item[data-state="ok"] .sync-dot, .menu-item[data-state="idle"] .sync-dot { background: var(--good); }
.acct-btn[data-state="syncing"] .acct-dot, .menu-item[data-state="syncing"] .sync-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.acct-btn[data-state="error"] .acct-dot, .menu-item[data-state="error"] .sync-dot { background: var(--bad); }
.acct-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20;
  width: 260px; max-width: calc(100vw - 20px); padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.16); -webkit-app-region: no-drag;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 0; border-radius: 8px; background: none; color: var(--ink); text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item .sync-dot { margin-left: 2px; }
.mi-text { display: flex; flex-direction: column; min-width: 0; }
.mi-main { font-weight: 500; }
.mi-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item[data-state="error"] .mi-sub { color: var(--bad); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; }
.menu-row + .menu-item, .menu-item + .menu-row { margin-top: 2px; }
.acct-menu .theme-seg { display: inline-flex; }
.acct-menu .theme-seg button { font-size: 13px; padding: 4px 10px; }

/* Play: Classic (summary, Start, Customize) and Record on the left; Today and
   This week on the right. Spacing, not rules, separates things inside a card. */
#setupForm { padding: 24px 26px; }
#setupForm h1 { margin: 0 0 2px; }
.setup-sum { color: var(--ink-2); font-size: 15px; font-variant-numeric: tabular-nums; margin-bottom: 18px; }
.start-row { display: flex; }
#startBtn { min-width: 200px; }
details.customize, details.cal-details { margin-top: 16px; }
details.customize > summary, details.cal-details > summary {
  display: inline-flex; align-items: center; gap: 6px; list-style: none; cursor: pointer;
  color: var(--ink-2); font-weight: 500; font-size: 13.5px; border-radius: 6px;
}
details.customize > summary::-webkit-details-marker, details.cal-details > summary::-webkit-details-marker { display: none; }
details.customize > summary::after, details.cal-details > summary::after {
  content: ''; width: 6px; height: 6px; margin: -3px 2px 0;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg);
}
details.customize[open] > summary::after, details.cal-details[open] > summary::after { margin-top: 3px; transform: rotate(-135deg); }
details.customize > summary:hover, details.cal-details > summary:hover { color: var(--ink); }
.cust-body { padding-top: 10px; }
#setupForm .op-row { border-top: 0; min-height: 0; padding: 5px 0; }
#setupForm .field-row { border-top: 0; padding: 5px 0; }
#setupForm .op-row + .field-row { margin-top: 10px; }
.cust-foot { margin-top: 10px; }
#defaultsBtn { height: 28px; padding: 0; font-size: 13.5px; }

.today h2 { margin-bottom: 4px; }
.today-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 0; }
.today-row + .today-row { padding-top: 10px; }
.tr-label { font-size: 12px; color: var(--muted); }
.tr-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-line b { font-weight: 600; }
.tr-big { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; font-variant-numeric: tabular-nums; }

.rec-val { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.rec-val small { font-size: 15px; font-weight: 500; color: var(--muted); }
.rec-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 28px; align-items: center; margin: 0 0 12px; }
.record-card .spark { min-width: 80px; }
.rec-goal { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rec-goal .goal-edit, .wk-goal { font-weight: 500; color: var(--ink-2); }
.wk-goal select { height: 28px; padding: 0 8px; font-size: 13px; }
.wk-stats { display: flex; gap: 32px; margin: 0 0 12px; }
.wk-status { margin-top: 8px; }
.cal-details .cal { margin-top: 12px; }
.cal-details[open] .when-closed, .cal-details:not([open]) .when-open { display: none; }
.cal-details .recap { margin-top: 14px; padding-top: 0; border-top: 0; }

/* Drill: a short head, one line per drill, quieter chips and stats. */
#view-drill .drill-head { flex-direction: row; align-items: center; margin-bottom: 16px; }
.drill-head h1 { margin: 0; }
.drill-desc { margin: -6px 0 14px; }
#customCard .pick-group { border-top: 0; padding: 6px 0; }
.pick-actions { margin-top: 14px; }
#smartStatsCard .tiles.four { margin-bottom: 4px; }
#smartStatsCard .tiles.four .tile { border: 0; background: none; box-shadow: none; padding: 0; }
#smartStatsCard .tile .value { margin: 0; line-height: 1.15; }
#smartStatsCard .tile .value small { font-size: 15px; font-weight: 500; color: var(--muted); }
#smartStatsCard .tile .label { font-size: 12px; color: var(--muted); }
#smartStatsCard .cats td { border-top: 0; padding-top: 5px; padding-bottom: 5px; }
.st { font-size: 13px; }
.st.live { color: var(--accent-text); }
.st.done { color: var(--good); }

/* Short windows: the Classic card is short now, so it needs no pinned Start. */
@media (min-width: 701px) and (max-height: 700px) {
  #setupForm { padding: 18px 24px; }
  .setup-sum { margin-bottom: 14px; }
}
/* Phones: one column in the order Classic, Today, This week, Record. */
@media (max-width: 700px) {
  .play-grid .play-main { display: contents; }
  #todayCard { order: 1; }
  #weekCard { order: 2; }
  #recordCard { order: 3; }
  #view-play .card + .card { margin-top: 0; }
  #setupForm { padding: 18px 16px; }
  #startBtn { width: 100%; margin-bottom: 0; }
  #defaultsBtn { margin-top: 0; }
  .rec-row { gap: 20px; }
  /* Pinned to the window's right edge: the button can sit well left of it
     (the desktop title bar's window buttons), and the menu must stay on screen. */
  .acct-menu { position: fixed; top: calc(58px + env(safe-area-inset-top)); right: 10px; }
  .acct-menu .theme-seg button { padding: 4px 9px; }
}

/* The tabs center on the window, not on the space left beside the window buttons:
   equal side columns, then a shift right by half the buttons' width (zero outside
   the desktop app, where nothing is reserved). */
@media (min-width: 701px) {
  .topbar { grid-template-columns: 1fr auto 1fr; }
  .topbar .tabs {
    justify-self: center;
    transform: translateX(calc((100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw)) / 2));
  }
}

/* ---- color themes (themes.js) --------------------------------------------- */
/* Every theme beyond Light and Dark is data in themes.js: app.js sets its colors
   on <html> as custom properties (and color-scheme), so it looks the same whatever
   the OS mode. A test checks every theme's contrast. */

/* The account menu: Auto, the eight main themes as swatches (the theme's page, a
   card and its accent), then "More themes…", which names a theme from there in use. */
.theme-swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px 4px 6px; }
.theme-swatches button {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 6px 1px;
  border: 1px solid transparent; border-radius: 10px; background: none; color: var(--ink-2); cursor: pointer; font-size: 12px;
}
.theme-swatches button:hover { background: var(--surface-2); color: var(--ink); }
.theme-swatches button.on { border-color: var(--accent); color: var(--ink); }
.theme-swatches .sw-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-swatches .sw {
  width: 38px; height: 26px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: linear-gradient(135deg, var(--sw-page) 0 50%, var(--sw-surface) 50% 100%);
  position: relative;
}
.theme-swatches .sw::after { content: ''; position: absolute; right: 5px; bottom: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--sw-accent); }
.menu-item.theme-more { justify-content: space-between; }
.menu-item.theme-more.on { box-shadow: inset 0 0 0 1px var(--accent); }
.theme-more-now { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-more-now:empty { display: none; }
.theme-more-now::before { content: ''; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--sw-accent); }

/* The one-time "New: color themes" note. */
.announce {
  position: fixed; right: 20px; bottom: 20px; z-index: 40; max-width: min(460px, calc(100vw - 40px));
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  animation: announce-in 0.35s ease-out;
}
.announce-swatches { display: grid; grid-template-columns: repeat(4, 10px); gap: 3px; flex: none; }
.announce-swatches i { width: 10px; height: 10px; border-radius: 50%; }
.announce-text { display: flex; flex-direction: column; font-size: 13px; color: var(--ink-2); line-height: 1.35; flex: 1; min-width: 0; }
.announce-text b { color: var(--ink); font-size: 14px; }
.announce .btn { flex: none; }
@keyframes announce-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .announce { animation: none; } }
@media (max-width: 700px) {
  .announce { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: none; flex-wrap: wrap; }
}

/* ---- score chart zoom ---- */
/* The Fit / Full switch sits beside the settings note. */
.score-head-tools { display: flex; align-items: center; gap: 12px; margin-left: auto; min-width: 0; }
.score-head-tools .seg { flex: none; }
.score-head-tools .seg button { padding: 3px 10px; font-size: 12px; }
.chart .ref-label.off { fill: var(--muted); }
.chart .ref-label.off.goal { fill: var(--good); opacity: 0.85; }
@media (max-width: 700px) {
  .score-head-tools { width: 100%; justify-content: space-between; }
}

/* Play: the two columns end on the same line. The last card in each (Record,
   This week) stretches to fill its column; in mid-width windows the paired side
   cards match heights. */
@media (min-width: 941px) {
  #view-play .play-grid { align-items: stretch; }
  #view-play .play-main, #view-play .play-grid > .side { display: flex; flex-direction: column; }
  #view-play #recordCard, #view-play #weekCard { flex: 1 1 auto; }
}
@media (min-width: 701px) and (max-width: 940px) {
  #view-play .side { align-items: stretch; }
}
/* ---- welcome and tour ---- */
/* First run: a centered welcome card. The tour dims the page around one element
   at a time (a cut-out drawn by a huge shadow) with a small popover beside it.
   Both sit above everything and keep the title bar from swallowing clicks. */
.welcome {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--page) 78%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  -webkit-app-region: no-drag;
}
.welcome-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  width: min(380px, 100%); padding: 36px 32px 20px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.16);
  animation: tour-in 0.3s ease-out;
}
.welcome-card:focus { outline: none; }
.welcome-logo { display: block; margin-bottom: 18px; }
.welcome-card h1 { margin: 0 0 6px; }
.welcome-card p { color: var(--ink-2); margin-bottom: 26px; max-width: 30ch; }
.welcome-actions { display: grid; gap: 10px; width: 100%; }
.welcome-actions .btn { width: 100%; }
.welcome-skip { margin-top: 12px; }
.tour-block { position: fixed; inset: 0; z-index: 70; -webkit-app-region: no-drag; }
.tour-block.dim { background: rgba(0, 0, 0, 0.55); }
.tour-spot {
  position: fixed; z-index: 71; pointer-events: none; border-radius: 12px;
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 200vmax rgba(0, 0, 0, 0.55);
}
.tour-spot.glide { transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease; }
.tour-pop {
  position: fixed; z-index: 72; width: min(300px, calc(100vw - 24px)); padding: 14px 16px 12px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); -webkit-app-region: no-drag;
}
.tour-pop:focus { outline: none; }
.tour-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tour-pop h2 { font-size: 15px; margin: 2px 0 4px; }
.tour-pop p { color: var(--ink-2); font-size: 13.5px; text-wrap: pretty; }
.tour-foot { display: flex; align-items: center; gap: 6px; margin-top: 14px; }
.tour-foot .tour-skip { margin: 0 auto 0 -10px; }
.tour-arrow {
  position: absolute; left: calc(var(--arrow-x, 50%) - 6px); width: 12px; height: 12px;
  background: var(--surface); border: 1px solid var(--border-strong); transform: rotate(45deg);
}
.tour-pop[data-side="below"] .tour-arrow { top: -7px; border-right: 0; border-bottom: 0; }
.tour-pop[data-side="above"] .tour-arrow { bottom: -7px; border-left: 0; border-top: 0; }
.tour-pop[data-side="over"] .tour-arrow { display: none; }
@keyframes tour-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .welcome-card { animation: none; }
  .tour-spot.glide { transition: none; }
}
@media (max-width: 700px) {
  .welcome-card { padding: 30px 20px 16px; }
}
/* ---- Play ambient card ---- */
/* A short, wide decorative card under Record and This week (ambient.js draws the
   drifting math glyphs). Only where those two sit side by side; it sits below them, so it never pushes
   Start or the other cards down. */
.ambient-card { display: none; }
@media (min-width: 941px) {
  #view-play .ambient-card {
    display: block; grid-column: 1 / -1; height: 140px; padding: 0; overflow: hidden;
    pointer-events: none; user-select: none; -webkit-user-select: none;
  }
  #view-play .ambient-card canvas { display: block; width: 100%; height: 100%; }
}

/* ---- More themes picker ---- */
/* A modal <dialog>: a search box, then a scrolling grid per tone (light, mid-tone,
   dark). Each button shows its theme's name in that theme's own text and page
   colors, with a card chip and accent dot; the theme in use is ringed. On the
   desktop it sits below the title bar's window buttons. */
dialog.tp {
  top: env(titlebar-area-height, 0px); bottom: 0;
  width: min(680px, calc(100vw - 24px)); max-width: none;
  max-height: calc(100dvh - 32px - env(titlebar-area-height, 0px));
  padding: 0; overflow: hidden;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
  -webkit-app-region: no-drag;
}
dialog.tp[open] { display: flex; flex-direction: column; }
dialog.tp::backdrop { background: rgba(0, 0, 0, 0.42); }
.tp-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 18px 20px 0; }
.tp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.tp-head h2 { margin: 0; }
.tp-search {
  flex: none; width: 100%; height: 36px; padding: 0 12px; font: inherit; color: var(--ink);
  background: var(--page); border: 1px solid var(--border-strong); border-radius: 8px;
}
.tp-search::placeholder { color: var(--muted); opacity: 1; }
.tp-search:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.tp-hint { flex: none; margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.tp-list {
  flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  margin: 6px -20px 0; padding: 2px 20px 18px;
}
.tp-list:focus { outline: none; }
.tp-group[hidden], .tp-item[hidden] { display: none; }
.tp-group-h { margin: 14px 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.tp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tp-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; min-height: 46px; padding: 6px 10px 6px 12px;
  border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer;
  background: var(--tp-page); color: var(--tp-ink); font: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.25; text-align: left;
}
.tp-item:hover { border-color: var(--tp-accent); }
.tp-item.on { border-color: transparent; box-shadow: 0 0 0 2px var(--accent); }
.tp-name { min-width: 0; overflow-wrap: anywhere; }
.tp-chip {
  flex: none; position: relative; width: 28px; height: 20px; border-radius: 6px;
  background: var(--tp-surface); box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.4);
}
.tp-chip::after {
  content: ''; position: absolute; right: 5px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--tp-accent);
}
/* The theme in use: its chip carries a tick in the theme's accent. */
.tp-item.on .tp-chip::after {
  right: 9px; top: 3px; width: 5px; height: 10px; border-radius: 0; background: none;
  border: solid var(--tp-accent); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.tp-empty { flex: none; margin: 4px 0 20px; color: var(--muted); }
@media (pointer: coarse) { .tp-hint { display: none; } }
@media (max-width: 480px) {
  dialog.tp { width: calc(100vw - 16px); max-height: calc(100dvh - 16px - env(titlebar-area-height, 0px)); }
  .tp-card { padding: 14px 14px 0; }
  .tp-list { margin: 6px -14px 0; padding: 2px 14px 14px; }
  .tp-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
  .tp-item { font-size: 13px; padding: 6px 8px 6px 10px; }
}

/* ---- smart drill slips ---- */
#smartCard .slip-line { margin: 10px 0 0; overflow-wrap: anywhere; }

/* ---- signed-out account dialog ---- */
/* One even rhythm: intro, Google button, its note, then the old-password option set apart. */
#syncBody .acct-lede { margin: 0 0 16px; max-width: none; }
#syncBody .acct-fine { margin: 10px 0 0; max-width: none; }
#syncBody .acct-msg:empty { display: none; }
#syncBody .legacy-signin { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
#syncBody .legacy-signin > summary { cursor: pointer; }

/* ---- Auto and Random ---- */
/* Auto is a setting (it stays selected); Random is a one-off action, so it's its own
   button a little apart, styled like the segmented control so the row stays calm. */
.theme-actions { display: inline-flex; align-items: center; gap: 8px; }
.theme-random {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; font: inherit; font-size: 13px; line-height: 1.4;
  color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.theme-random:hover { color: var(--ink); border-color: var(--border-strong); }
.theme-random:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-random svg { flex: none; }

/* ---- Zap-N ---- */
/* Balloon: grown in place (oa-ui.js sets the body's scale and --fill, 0…1), so each
   pump eases it bigger with a little spring. The skin thins and the wobble grows with
   the pumps alone; nothing here depends on the hidden limit. */
.bl-svg { overflow: visible; --fill: 0; }
.bl-body { transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); }
.bl-skin { fill: hsl(0 62% calc(50% + var(--fill) * 9%)); }
.bl-knot { fill: hsl(0 55% 40%); }
.bl-shine { fill: #fff; opacity: calc(0.18 + var(--fill) * 0.32); }
.bl-string { fill: none; stroke: var(--axis); stroke-width: 2; }
.bl-wob { transform-origin: 0px 116px; }
.bl-wob.go { animation: bl-wob 0.32s ease-out; }
.bl-svg.popped .bl-body { opacity: 0; }
.bl-svg.popped .bl-string { animation: bl-drop 0.6s ease-in forwards; }
.bl-shard { fill: hsl(0 62% calc(50% + var(--fill) * 9%)); transform-box: fill-box; transform-origin: center; animation: bl-shard 0.6s cubic-bezier(0.2, 0.7, 0.4, 1) forwards; }
.bl-ring { fill: none; stroke: hsl(0 62% 60%); stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: bl-ring 0.45s ease-out forwards; }
.bl-fly.away { animation: bl-away 0.85s cubic-bezier(0.45, 0, 0.75, 0.3) forwards; }
.bl-bank b { display: inline-block; min-width: 2.2ch; font-variant-numeric: tabular-nums; color: color-mix(in srgb, var(--bad) calc(var(--risk, 0) * 75%), var(--ink)); }
.bl-bank b.go { animation: zap-tick 0.18s ease-out; }
.bl-bank.banked b { color: var(--good); animation: zap-tick 0.3s ease-out; }
.bl-bank.lost b { color: var(--muted); text-decoration: line-through; }
.bl-strip { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 16px auto 0; max-width: 340px; }
.bl-strip i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--border-strong); box-sizing: border-box; }
.bl-strip i.c { background: var(--good); border-color: var(--good); }
.bl-strip i.p { background: var(--bad); border-color: var(--bad); }
.bl-strip i.now { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }
#zapScore.zap-bump { display: inline-block; animation: zap-bump 0.45s ease-out; }
@keyframes bl-wob {
  0% { transform: scale(1, 1); }
  30% { transform: scale(calc(1 + 0.03 + var(--fill) * 0.05), calc(1 - 0.025 - var(--fill) * 0.04)); }
  65% { transform: scale(calc(1 - 0.01 - var(--fill) * 0.02), calc(1 + 0.01 + var(--fill) * 0.02)); }
  100% { transform: scale(1, 1); }
}
@keyframes bl-shard { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); } }
@keyframes bl-ring { 0% { opacity: 0.8; transform: scale(0.9); } 100% { opacity: 0; transform: scale(1.5); } }
@keyframes bl-drop { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(40px); } }
@keyframes bl-away { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 100% { opacity: 0; transform: translate(14px, -280px) rotate(6deg); } }
@keyframes zap-tick { 0% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes zap-bump { 0% { transform: scale(1); } 35% { transform: scale(1.2); color: var(--good); } 100% { transform: scale(1); } }

/* Number Box: built tiles show how they were made and pop in as two combine. */
.nb-tile { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; }
.nb-tile .nb-v { line-height: 1.1; }
.nb-tile .nb-how { margin-top: 3px; font-size: 12px; font-weight: 400; line-height: 1; color: var(--ink-2); white-space: nowrap; }
.nb-tile.merged { animation: nb-merge 0.32s cubic-bezier(0.34, 1.56, 0.64, 1); }
.nb-tile.win { animation: nb-win 0.5s ease-out; }
.nb-tile.off { border-color: var(--bad); }
.nb-target.hit b { color: var(--good); animation: zap-tick 0.3s ease-out; }
@keyframes nb-merge { 0% { transform: scale(0.55); opacity: 0.4; } 100% { transform: scale(1); opacity: 1; } }
@keyframes nb-win { 0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.5); } 100% { box-shadow: 0 0 0 18px rgba(12, 163, 12, 0); } }

/* Code Compare: the streak warms up; a miss shows the code over what was picked,
   with the characters that differ marked. */
.cc-streak .cc-pace { margin-left: 8px; font-size: 13px; font-weight: 400; color: var(--ink-2); }
.cc-streak.hot { text-shadow: 0 0 12px rgba(234, 88, 12, 0.45); }
.cc-code.ok { animation: cc-in 0.12s ease-out; }
.cc-last { display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center; gap: 4px 10px; margin: 12px auto 0; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 20px; }
.cc-last .cc-lbl { font-family: system-ui, sans-serif; font-size: 12px; color: var(--muted); text-align: right; }
.cc-row { display: inline-flex; gap: 1px; }
.cc-row i { display: inline-block; width: 1em; font-style: normal; text-align: center; border-radius: 4px; }
.cc-row i.x { color: var(--bad); background: var(--bad-wash); box-shadow: inset 0 -2px 0 var(--bad); }
.cc-row i.y { background: color-mix(in srgb, var(--good) 14%, transparent); box-shadow: inset 0 -2px 0 var(--good); }
.cc-row.cc-none { font-family: system-ui, sans-serif; font-size: 14px; color: var(--muted); }
.cc-last.now { animation: cc-reveal 2.4s ease-out forwards; }
@keyframes cc-in { 0% { opacity: 0.35; } 100% { opacity: 1; } }
@keyframes cc-reveal { 0% { opacity: 0; transform: translateY(-4px); } 8%, 70% { opacity: 1; transform: none; } 100% { opacity: 0.55; } }

/* Results: a review card per game */
.zr-card { margin-top: 16px; }
.zr-chart { display: block; width: 100%; max-width: 720px; height: auto; margin-top: 8px; }
.zr-hit { fill: transparent; }
.zr-bar.c path { fill: var(--good); }
.zr-bar.p path { fill: var(--bad); }
.zr-bar:hover path { opacity: 0.75; }
.zr-room { fill: var(--good); opacity: 0.16; }
.zr-tick { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.zr-best { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.zr-axis { stroke: var(--axis); stroke-width: 1; }
.zr-lbl { fill: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.zr-best-lbl { fill: var(--ink-2); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.zr-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; font-size: 13px; color: var(--ink-2); }
.zr-legend .sw { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
.zr-legend .sw.c { background: var(--good); }
.zr-legend .sw.p { background: var(--bad); }
.zr-legend .sw.tick { width: 14px; height: 2px; border-radius: 1px; background: var(--ink); vertical-align: 3px; }
.zr-legend .sw.best { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed var(--ink-2); vertical-align: 3px; }
.zr-misses li { align-items: center; }
.zr-misses .cc-last { margin: 0; font-size: 17px; justify-content: start; }
.zr-mark { flex: none; width: 1.2em; text-align: center; font-weight: 700; }
.zr-mark.ok { color: var(--good); }
.zr-mark.skip { color: var(--muted); }
@media (max-width: 700px) {
  .cc-last { font-size: 16px; }
  .nb-tile .nb-how { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .bl-body { transition: none; }
  .bl-wob.go, .bl-bank b.go, .bl-bank.banked b, .nb-tile.merged, .nb-tile.win, .nb-target.hit b, .cc-code.ok, .cc-last.now, #zapScore.zap-bump { animation: none; }
  .bl-shard, .bl-ring { display: none; }
  .bl-svg.popped .bl-string { animation: none; opacity: 0; }
  .bl-fly.away { animation: none; opacity: 0.25; }
}

/* ---- Intervals and Orderbooks ---- */
/* Intervals: a number line under the bounds shows the range and its live score; on
   reveal the answer drops onto it, green inside the range and red outside. */
#oaStage[data-module="iv"] .iv-line { width: min(560px, 100%); margin-top: 14px; }
#oaStage[data-module="iv"] .iv-line-svg { display: block; width: 100%; height: auto; overflow: visible; }
#oaStage[data-module="iv"] .iv-axis { stroke: var(--axis); stroke-width: 1.5; }
#oaStage[data-module="iv"] .iv-tick { stroke: var(--axis); stroke-width: 1; }
#oaStage[data-module="iv"] .iv-tl { fill: var(--muted); font-size: 11px; text-anchor: middle; font-variant-numeric: tabular-nums; }
#oaStage[data-module="iv"] .iv-band { fill: var(--accent-wash); stroke: var(--accent); stroke-width: 1.5; }
#oaStage[data-module="iv"] .iv-band.hit { fill: rgba(12, 163, 12, 0.14); stroke: var(--good); }
#oaStage[data-module="iv"] .iv-band.miss { fill: var(--bad-wash); stroke: var(--bad); }
#oaStage[data-module="iv"] .iv-bl { fill: var(--ink); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
#oaStage[data-module="iv"] .iv-truth line { stroke: var(--ink); stroke-width: 2; }
#oaStage[data-module="iv"] .iv-truth circle { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
#oaStage[data-module="iv"] .iv-truth text { fill: var(--ink); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
#oaStage[data-module="iv"] .iv-truth.hit line { stroke: var(--good); }
#oaStage[data-module="iv"] .iv-truth.hit circle { fill: var(--good); }
#oaStage[data-module="iv"] .iv-truth.hit text { fill: var(--good); }
#oaStage[data-module="iv"] .iv-truth.miss line { stroke: var(--bad); }
#oaStage[data-module="iv"] .iv-truth.miss circle { fill: var(--bad); }
#oaStage[data-module="iv"] .iv-truth.miss text { fill: var(--bad); }
#oaStage[data-module="iv"] .iv-read { margin: 6px 0 0; min-height: 22px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
#oaStage[data-module="iv"] .iv-read b { color: var(--ink); font-size: 18px; }
#oaStage[data-module="iv"] .iv-read.warn, #oaStage[data-module="iv"] .iv-read.warn b { color: var(--bad); }
#oaStage[data-module="iv"] .iv-read.hit { color: var(--good); font-weight: 600; }
#oaStage[data-module="iv"] .iv-read.miss { color: var(--bad); font-weight: 600; }

/* Orderbooks: a bought card turns green with its Buy button pressed, a sold card red with
   Sell pressed; each card shows what its trades cost or bring in. */
#oaStage[data-module="ob"] .ob-card { transition: border-color 0.12s, background-color 0.12s; }
#oaStage[data-module="ob"] .ob-top { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
#oaStage[data-module="ob"] .ob-letter {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink-2); font-size: 13px;
}
#oaStage[data-module="ob"] .ob-cash { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); }
#oaStage[data-module="ob"] .ob-card.long { background: rgba(12, 163, 12, 0.07); }
#oaStage[data-module="ob"] .ob-card.short { background: var(--bad-wash); }
#oaStage[data-module="ob"] .ob-card.long .ob-pos, #oaStage[data-module="ob"] .ob-card.long .ob-letter { color: var(--good); }
#oaStage[data-module="ob"] .ob-card.short .ob-pos, #oaStage[data-module="ob"] .ob-card.short .ob-letter { color: var(--bad); }
#oaStage[data-module="ob"] .ob-card.long .ob-cash { color: var(--bad); }
#oaStage[data-module="ob"] .ob-card.short .ob-cash { color: var(--good); }
#oaStage[data-module="ob"] .ob-card.long .ob-buy { background: var(--good); border-color: var(--good); color: #fff; }
#oaStage[data-module="ob"] .ob-card.short .ob-sell { background: var(--bad); border-color: var(--bad); color: #fff; }
#oaStage[data-module="ob"] .ob-keys { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
#oaStage[data-module="ob"] .ob-status .cash { font-size: 16px; }
#oaStage[data-module="ob"] .ob-status.ready .cash { background: rgba(12, 163, 12, 0.14); }
#oaStage[data-module="ob"] .ob-status .ob-ready { color: var(--good); font-weight: 600; background: none; padding-left: 0; }
/* Reveal: the answer's cards light up, the rest fade, and the path reads out step by step. */
#oaStage[data-module="ob"] .ob-card.dim { opacity: 0.45; }
#oaStage[data-module="ob"] .ob-card.ans-buy .ob-pos { color: var(--good); }
#oaStage[data-module="ob"] .ob-card.ans-sell .ob-pos { color: var(--bad); }
#oaStage[data-module="ob"] .ob-card.ans-buy .ob-cash { color: var(--bad); }
#oaStage[data-module="ob"] .ob-card.ans-sell .ob-cash { color: var(--good); }
#oaStage[data-module="ob"] .ob-card.ans-buy .ob-buy { border-color: var(--good); border-width: 2px; opacity: 1; }
#oaStage[data-module="ob"] .ob-card.ans-sell .ob-sell { border-color: var(--bad); border-width: 2px; opacity: 1; }
#oaStage[data-module="ob"] .ob-status.revealed { align-items: center; }
#oaStage[data-module="ob"] .ob-status .ob-path-h { background: none; padding-left: 0; color: var(--muted); font-size: 13px; }
#oaStage[data-module="ob"] .ob-step i { font-style: normal; font-weight: 600; margin-left: 4px; }
#oaStage[data-module="ob"] .ob-step.buy i { color: var(--bad); }
#oaStage[data-module="ob"] .ob-step.sell i { color: var(--good); }
#oaStage[data-module="ob"] .ob-step.cash b { color: var(--good); }
@media (prefers-reduced-motion: no-preference) {
  #oaStage[data-module="iv"] .iv-line.shown .iv-truth { animation: iv-drop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
  #oaStage[data-module="ob"] .ob-card.bump { animation: ob-press 0.18s ease-out; }
  #oaStage[data-module="ob"] .ob-btns button:active:not(:disabled) { transform: translateY(1px); }
  #oaStage[data-module="ob"] .ob-status.revealed .ob-step { animation: ob-step-in 0.3s ease-out both; animation-delay: calc(var(--k, 0) * 0.12s); }
}
@media (prefers-reduced-motion: reduce) {
  #oaStage[data-module="ob"] .ob-card { transition: none; }
}
@keyframes iv-drop { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes ob-press { 0% { transform: scale(1); } 40% { transform: scale(0.97); } 100% { transform: scale(1); } }
@keyframes ob-step-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
@media (max-width: 700px) {
  /* The line scales down to the screen, so its text is drawn larger to stay readable. */
  #oaStage[data-module="iv"] .iv-tl { font-size: 17px; }
  #oaStage[data-module="iv"] .iv-bl, #oaStage[data-module="iv"] .iv-truth text { font-size: 20px; }
  #oaStage[data-module="ob"] .ob-keys { display: none; }
}

/* ---- Beat the Odds ---- */
/* A small picture of the setup sits beside the question on wide screens, under it on narrow ones. */
[data-module="bto"] .oa-q:has(> .bto-scene) { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 28px; align-items: center; }
[data-module="bto"] .oa-q:has(> .bto-scene) > * { grid-column: 1 / -1; }
[data-module="bto"] .oa-q:has(> .bto-scene) > .oa-prompt { grid-column: 1; grid-row: 1; }
[data-module="bto"] .oa-q:has(> .bto-scene) > .bto-scene { grid-column: 2; grid-row: 1; justify-self: end; margin-bottom: 26px; }
[data-module="bto"] .bto-scene { display: block; max-width: 100%; height: auto; overflow: visible; }
[data-module="bto"] .bto-scene text { font-family: inherit; }
[data-module="bto"] .bto-die { fill: var(--surface); stroke: var(--ink-2); stroke-width: 2; }
[data-module="bto"] .bto-pip { fill: var(--ink); }
[data-module="bto"] .bto-q { fill: var(--muted); font-size: 20px; font-weight: 700; }
[data-module="bto"] .bto-dlabel { fill: var(--ink-2); font-size: 13px; font-weight: 700; }
[data-module="bto"] .bto-vs { fill: var(--muted); font-size: 13px; font-style: italic; }
[data-module="bto"] .bto-coin { fill: #ecc967; stroke: #b98a28; stroke-width: 2; }
[data-module="bto"] .bto-coin.t { fill: #d9b65a; }
[data-module="bto"] .bto-cl { fill: #5e4510; font-size: 15px; font-weight: 700; }
[data-module="bto"] .bto-more { fill: var(--muted); font-size: 14px; font-weight: 600; }
[data-module="bto"] .bto-card { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.5; }
[data-module="bto"] .bto-back { fill: var(--accent-wash); stroke: var(--accent); stroke-width: 1; }
[data-module="bto"] .bto-cardn { fill: var(--accent-text); font-size: 13px; font-weight: 700; }
[data-module="bto"] .bto-urn { fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-module="bto"] .bto-ball.red { fill: #e5484d; }
[data-module="bto"] .bto-ball.blue { fill: #3e63dd; }
[data-module="bto"] .bto-line, [data-module="bto"] .bto-tick { stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; }
[data-module="bto"] .bto-end { fill: var(--muted); font-size: 12px; font-weight: 600; }
[data-module="bto"] .bto-you { fill: var(--accent); }
[data-module="bto"] .bto-youl { fill: var(--accent-text); font-size: 12px; font-weight: 700; }
/* The reveal: a tick or a cross, a pop for a right pick, a shake for a wrong one, the rest faded. */
[data-module="bto"] .oa-choice { transition: opacity 0.2s ease; }
[data-module="bto"] .oa-choice.right::after, [data-module="bto"] .oa-choice.wrong::after { position: absolute; top: 4px; right: 9px; font-size: 14px; font-weight: 800; }
[data-module="bto"] .oa-choice.right::after { content: "\2713"; color: var(--good); }
[data-module="bto"] .oa-choice.wrong::after { content: "\2717"; color: var(--bad); }
[data-module="bto"] .oa-choice.bto-hit { animation: bto-pop 0.38s ease-out; }
[data-module="bto"] .oa-choice.bto-miss { animation: bto-shake 0.4s ease-in-out; }
[data-module="bto"] .oa-choice.bto-dim { opacity: 0.45; }
[data-module="bto"] .bto-exact { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--good); }
/* Learn mode's worked solution: one step per line. */
[data-module="bto"] .oa-explain p + p { white-space: pre-line; }
@keyframes bto-pop { 0% { transform: scale(1); } 45% { transform: scale(1.07); } 100% { transform: scale(1); } }
@keyframes bto-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
@media (max-width: 700px) {
  [data-module="bto"] .oa-q:has(> .bto-scene) { grid-template-columns: minmax(0, 1fr); }
  [data-module="bto"] .oa-q:has(> .bto-scene) > .bto-scene { grid-column: 1; grid-row: auto; justify-self: start; margin: -8px 0 18px; }
}
@media (prefers-reduced-motion: reduce) {
  [data-module="bto"] .oa-choice.bto-hit, [data-module="bto"] .oa-choice.bto-miss { animation: none; }
  [data-module="bto"] .oa-choice { transition: none; }
}

/* ---- NumberLogic and Likelihood-list ---- */
/* NumberLogic: the sequence as tiles. The reveal fills the ? and writes the rule
   underneath, layer by layer: steps between terms (or labels under them), then
   the steps' own steps, the one that gives the answer lit. */
.nl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.oa-prompt.big.nl-seq { font-size: 16px; letter-spacing: 0; margin: 3vh 0 40px; }
.nl-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; row-gap: 16px; }
.nl-col, .nl-gap { display: flex; flex-direction: column; align-items: center; }
.nl-gap { width: 16px; padding-top: 56px; }
.nl-t {
  display: grid; place-items: center; box-sizing: border-box; min-width: 50px; height: 56px; padding: 0 10px;
  border: 2px solid var(--axis); border-radius: 12px; background: var(--surface); color: var(--ink);
  font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.nl-col.q .nl-t { border-style: dashed; border-color: var(--accent); color: var(--accent-text); background: var(--accent-wash); }
.nl-col.q.right .nl-t { border-style: solid; border-color: var(--good); color: var(--good); background: rgba(12, 163, 12, 0.12); animation: nl-pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; }
.nl-col.q.solved .nl-t { border-style: solid; color: var(--ink); animation: nl-pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; }
.nl-u, .nl-l1, .nl-l2, .nl-l3 {
  display: flex; justify-content: center; width: 100%; height: 0; overflow: visible; white-space: nowrap;
  font-style: normal; font-size: 13px; line-height: 24px; font-weight: 600; color: var(--accent-text); font-variant-numeric: tabular-nums;
}
.nl-seq.revealed .nl-u, .nl-seq.revealed .nl-l1 { height: 26px; }
.nl-seq.revealed.has-l2 .nl-l2 { height: 26px; }
.nl-seq.revealed.has-l3 .nl-l3 { height: 26px; margin-top: 26px; }
.nl-l2, .nl-l3 { font-size: 12px; color: var(--ink-2); }
.nl-seq i > span { padding: 0 6px; border-radius: 6px; animation: nl-in 0.32s ease-out both; animation-delay: calc(var(--i, 0) * 55ms); }
.nl-seq i.hot > span { background: var(--accent); color: var(--on-accent); }
.nl-col.g0 .nl-t { border-color: var(--series-1); }
.nl-col.g1 .nl-t { border-color: #d9822b; }
.nl-col.g2 .nl-t { border-color: #8e4ec6; }
.nl-col.g0 .nl-u { color: var(--series-1); }
.nl-col.g1 .nl-u { color: #c06f1d; }
.nl-col.g2 .nl-u { color: #8e4ec6; }
@keyframes nl-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes nl-pop { 0% { transform: scale(0.85); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@media (max-width: 700px) {
  .nl-t { min-width: 36px; height: 44px; padding: 0 7px; font-size: 21px; border-radius: 10px; }
  .nl-gap { width: 10px; padding-top: 44px; }
  .nl-u, .nl-l1, .nl-l2, .nl-l3 { font-size: 11px; }
}

/* Likelihood-list: a ladder of three places fills as outcomes are picked; the
   reveal slides the outcomes into the true order and fills each with its chance. */
/* contain: its slots' long one-line texts mustn't widen the question past the screen. */
.ll-ladder { display: flex; align-items: center; gap: 8px; margin: 20px 0 2px; contain: inline-size; }
.ll-end { flex: none; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ll-sep { flex: none; font-style: normal; font-size: 18px; color: var(--muted); }
.ll-slot {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 10px;
  border: 1.5px dashed var(--axis); border-radius: 10px; background: transparent; color: var(--ink);
  font: inherit; text-align: left; cursor: pointer;
}
.ll-slot:disabled { cursor: default; color: var(--ink); }
.ll-slot .ll-n {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--axis); font-size: 12px; font-weight: 600; color: var(--muted);
}
.ll-chip { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.ll-chip b { font-size: 17px; }
.ll-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.ll-slot.filled { border-style: solid; border-color: var(--accent); background: var(--accent-wash); }
.ll-slot.filled .ll-n { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.ll-slot.filled:not(:disabled):hover { border-color: var(--bad); }
.ll-slot.pop .ll-chip { animation: ll-pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; }
.ll-slot.done.hit { border-color: var(--good); background: rgba(12, 163, 12, 0.10); }
.ll-slot.done.hit .ll-n { border-color: var(--good); background: var(--good); color: #fff; }
.ll-slot.done.miss { border-color: var(--bad); background: var(--bad-wash); }
.ll-slot.done.miss .ll-n { border-color: var(--bad); background: var(--bad); color: #fff; }
.oa-rank-item { position: relative; overflow: hidden; }
.oa-rank-item > span:not(.bar) { position: relative; z-index: 1; }
.oa-rank-item .bar {
  position: absolute; inset: 0; z-index: 0; pointer-events: none; transform-origin: left center; transform: scaleX(0);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.oa-rank.grown .oa-rank-item .bar { transform: scaleX(var(--w, 0)); transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
.oa-rank-item.picked .slot { animation: ll-pop 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; }
.oa-rank-item.done.hit .slot { background: var(--good); color: #fff; }
.oa-rank-item.done.miss .slot { background: var(--bad); color: #fff; }
.oa-rank-item.done.miss { border-color: var(--bad); }
.oa-rank-item.done.hit { border-color: var(--good); }
.ll-you { font-size: 12px; font-weight: 600; color: var(--bad); white-space: nowrap; }
@keyframes ll-pop { from { opacity: 0; transform: translateY(6px) scale(0.9); } to { opacity: 1; transform: none; } }
@media (max-width: 700px) {
  .ll-ladder { gap: 5px; }
  .ll-end { display: none; }
  .ll-slot { height: 40px; padding: 0 8px; gap: 6px; }
  .ll-chip span { display: none; }
}

/* Charts: names at the curves' peaks, the bar labeled, tails that shade in on the reveal, and bar charts. */
.oa-visual .name { font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.oa-visual .name.c0 { fill: var(--series-1); }
.oa-visual .name.c1 { fill: var(--ink); }
.oa-visual .name.c2 { fill: var(--ink-2); }
.oa-visual .mark-label { fill: var(--bad); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.oa-visual .tail { opacity: 0; transition: opacity 0.6s ease; }
.oa-visual.shown .tail { opacity: 0.2; }
.oa-visual .tail.c0 { fill: var(--series-1); }
.oa-visual .tail.c1 { fill: var(--ink); }
.oa-visual .tail.c2 { fill: var(--ink-2); }
.oa-visual.bars { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.oa-visual.bars .bar { fill: var(--series-1); }
.oa-visual.bars .val { fill: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .nl-seq i > span, .nl-col.q .nl-t, .ll-slot.pop .ll-chip, .oa-rank-item.picked .slot { animation: none; }
  .oa-rank.grown .oa-rank-item .bar, .oa-visual .tail { transition: none; }
}
