/* ===========================================================================
   play as gpt-2 — "language-model lab" theme
   OKLCH tinted neutrals (never pure black/white), monospace-forward so BPE
   tokens read crisply, strong type hierarchy, explicit interactive states.
   =========================================================================== */

/* ---- dark theme (default) ---- */
:root {
  color-scheme: dark;
  --bg:        oklch(0.16 0.018 275);
  --surface:   oklch(0.21 0.022 275);
  --surface-2: oklch(0.255 0.026 275);
  --surface-3: oklch(0.30 0.030 275);
  --border:    oklch(0.33 0.030 275);
  --border-2:  oklch(0.42 0.035 275);

  --ink:  oklch(0.96 0.008 275);
  --ash:  oklch(0.74 0.018 275);
  --dim:  oklch(0.58 0.018 275);

  --accent:        oklch(0.74 0.155 280);
  --accent-strong: oklch(0.66 0.175 280);
  --accent-glow:   oklch(0.74 0.155 280 / 0.30);
  --accent-soft:   oklch(0.26 0.05 280);   /* soft accent fill for active states */
  --on-accent:     oklch(0.16 0.02 275);   /* text sitting on an accent fill */

  --good:    oklch(0.82 0.165 152);
  --good-bg: oklch(0.34 0.070 152);
  --bad:     oklch(0.72 0.185 23);
  --bad-bg:  oklch(0.34 0.090 23);
  --near:    oklch(0.85 0.150 92);
  --near-bg: oklch(0.36 0.075 92);
  --robot:   oklch(0.83 0.130 80);

  --card-top: var(--surface);
  --card-bottom: oklch(0.19 0.02 275);
  --card-shadow: 0 24px 60px -20px oklch(0 0 0 / 0.65);
  --grain-dot: oklch(0.7 0.02 275 / 0.05);
  --glow-1: oklch(0.27 0.05 285 / 0.55);
  --glow-2: oklch(0.24 0.05 200 / 0.30);
  --readout-bg: oklch(0.14 0.015 275);

  --mono: "JetBrains Mono", "Berkeley Mono", ui-monospace, SFMono-Regular,
          "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
}

/* ---- light theme (ARENA-style: clean, minimal, white) ---- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg:        oklch(0.985 0.003 270);
  --surface:   oklch(1 0 0);
  --surface-2: oklch(0.975 0.003 270);
  --surface-3: oklch(0.945 0.006 270);
  --border:    oklch(0.905 0.006 270);
  --border-2:  oklch(0.82 0.010 270);

  --ink:  oklch(0.25 0.012 275);
  --ash:  oklch(0.46 0.012 275);
  --dim:  oklch(0.605 0.012 275);

  --accent:        oklch(0.52 0.18 280);
  --accent-strong: oklch(0.46 0.19 280);
  --accent-glow:   oklch(0.52 0.18 280 / 0.16);
  --accent-soft:   oklch(0.955 0.035 280);
  --on-accent:     oklch(0.99 0 0);

  --good:    oklch(0.50 0.15 150);
  --good-bg: oklch(0.935 0.055 150);
  --bad:     oklch(0.53 0.20 25);
  --bad-bg:  oklch(0.945 0.050 25);
  --near:    oklch(0.55 0.13 85);
  --near-bg: oklch(0.93 0.075 85);
  --robot:   oklch(0.52 0.13 80);

  --card-top: oklch(1 0 0);
  --card-bottom: oklch(0.995 0.002 270);
  --card-shadow: 0 12px 32px -16px oklch(0.30 0.02 275 / 0.16);
  --grain-dot: oklch(0.40 0.02 275 / 0.05);
  --glow-1: oklch(0.85 0.06 285 / 0.45);
  --glow-2: oklch(0.88 0.05 200 / 0.35);
  --readout-bg: oklch(0.975 0.004 270);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 560px at 50% -8%, var(--glow-1), transparent 70%),
    radial-gradient(900px 600px at 90% 110%, var(--glow-2), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}

/* faint dot-grid texture, very low contrast */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(var(--grain-dot) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(circle at 50% 30%, #000 30%, transparent 85%);
}

#app {
  position: relative; z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 56px 20px 72px;
}

/* ---------- theme toggle ---------- */
.theme-toggle {
  position: absolute; top: 0; right: 0;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface-2); color: var(--ash);
  border: 1px solid var(--border); font-size: 1rem; line-height: 1;
  transition: color .12s, border-color .12s, background .12s, transform .1s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--border-2); transform: translateY(-1px); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- masthead ---------- */
.masthead { text-align: center; margin-bottom: 30px; }
.title {
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  font-weight: 800; letter-spacing: -0.03em; margin: 0;
  display: inline-flex; align-items: baseline; gap: 0.1em;
}
.title-accent {
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-glow);
}
.caret {
  color: var(--accent); font-weight: 400;
  animation: blink 1.1s steps(2, start) infinite;
}
@keyframes blink { to { opacity: 0; } }
.tagline {
  color: var(--ash); margin: 12px auto 0; max-width: 46ch; font-size: 0.92rem;
}
.tagline em { color: var(--ink); font-style: normal; border-bottom: 1px dashed var(--border-2); }

/* ---------- cards ---------- */
.card {
  position: relative;
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow:
    0 1px 0 oklch(1 0 0 / 0.04) inset,
    var(--card-shadow);
  overflow: hidden;
}
.card-rule {
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.8;
}

.kicker {
  text-transform: uppercase; letter-spacing: 0.22em;
  font-size: 0.66rem; font-weight: 700; color: var(--dim);
  margin: 0 0 10px;
}
h2 {
  font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em;
  margin: 0 0 8px; color: var(--ink);
}
.muted { color: var(--ash); }
kbd {
  font-family: var(--mono); font-size: 0.82em;
  background: var(--surface-3); border: 1px solid var(--border-2);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--ink);
}

/* ---------- start: difficulty modes ---------- */
.modes {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-top: 20px;
}
.mode {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  padding: 16px 16px; border-radius: var(--r-md); cursor: pointer;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--border); text-align: left;
  font-family: var(--mono);
  transition: transform .12s ease, border-color .15s, background .15s, box-shadow .15s;
}
.mode:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow: 0 12px 28px -16px var(--accent-glow);
}
.mode:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode:active { transform: translateY(-1px); }
.mode-name { font-weight: 700; font-size: 1.05rem; }
.mode-detail { font-size: 0.82rem; color: var(--ash); }
.mode-base { font-size: 0.7rem; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.mode-recommended { border-color: var(--accent); position: relative; overflow: visible; }
.mode-rec {
  position: absolute; top: -8px; right: 10px;
  font-size: 0.56rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  background: var(--accent); color: var(--on-accent);
  padding: 2px 7px; border-radius: 999px;
}
.mode-insane { border-color: var(--bad); background: var(--bad-bg); }
.mode-insane .mode-name { color: var(--bad); }
.mode-insane:hover { border-color: var(--bad); box-shadow: 0 12px 28px -16px var(--bad); }

/* opponent model picker */
.models-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 4px; }
.modelbtn {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 14px 15px; border-radius: var(--r-md); cursor: pointer; text-align: left;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
  font-family: var(--mono);
  transition: transform .12s ease, border-color .15s, background .15s, box-shadow .15s;
}
.modelbtn:hover { transform: translateY(-2px); border-color: var(--border-2); background: var(--surface-3); }
.modelbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modelbtn.active {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset, 0 12px 28px -16px var(--accent-glow);
}
.modelbtn-name { font-weight: 700; font-size: 1.02rem; }
.modelbtn.active .modelbtn-name { color: var(--accent); }
.modelbtn-params { font-size: 0.7rem; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.modelbtn-blurb { font-size: 0.76rem; color: var(--ash); line-height: 1.4; }
.section-gap { margin-top: 26px; }
.bot { color: var(--robot); font-weight: 700; }

.datanote {
  margin: 22px 0 0; font-size: 0.8rem;
  padding-left: 16px; position: relative;
}
.datanote::before {
  content: ""; position: absolute; left: 0; top: 0.55em;
  width: 8px; height: 8px; border-radius: 50%;
}
.datanote.sample { color: var(--robot); }
.datanote.sample::before { background: var(--robot); box-shadow: 0 0 8px var(--robot); }
.datanote.real { color: var(--good); }
.datanote.real::before { background: var(--good); box-shadow: 0 0 8px var(--good); }

/* text-style segmented control (clean / mixed / rough) */
.rough-pick { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.rough-label {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--dim);
}
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.seg-btn {
  font-family: var(--mono); font-size: 0.8rem; color: var(--ash);
  background: transparent; border: none; border-radius: 999px;
  padding: 5px 13px; cursor: pointer; transition: color .12s, background .12s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--accent-strong); color: var(--on-accent); font-weight: 700; }
.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rough-hint { flex-basis: 100%; font-size: 0.74rem; color: var(--dim); }

/* advanced: pick a specific passage */
.advanced { margin-top: 18px; }
.advanced > summary {
  cursor: pointer; width: max-content; list-style: none;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--dim);
  padding: 4px 0; transition: color .12s;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::before { content: "▸ "; color: var(--accent); }
.advanced[open] > summary::before { content: "▾ "; }
.advanced > summary:hover { color: var(--ash); }
.advanced-body { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.adv-label {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--dim);
}
.passage-pick {
  flex: 1 1 16em; min-width: 0; max-width: 100%;
  font-family: var(--mono); font-size: 0.82rem; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 10px; cursor: pointer;
}
.passage-pick:hover { border-color: var(--border-2); }
.passage-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.adv-hint { flex-basis: 100%; font-size: 0.74rem; color: var(--dim); }

/* ---------- game: hud + progress ---------- */
.hud {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; font-size: 0.82rem; color: var(--ash); margin-bottom: 12px;
}
.hud-menu {
  font-family: var(--mono); font-size: 0.74rem; color: var(--ash);
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 12px; cursor: pointer; white-space: nowrap;
  transition: color .12s, border-color .12s, background .12s;
}
.hud-menu:hover { color: var(--ink); border-color: var(--border-2); background: var(--surface-2); }
.hud-menu:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hud-progress { color: var(--dim); letter-spacing: 0.04em; margin-right: auto; padding-left: 10px; }
.hud-score b { color: var(--ink); }
.hud-score { font-variant-numeric: tabular-nums; }
.pill {
  background: var(--surface-3); border: 1px solid var(--border-2);
  border-radius: 999px; padding: 3px 14px; color: var(--accent);
  font-weight: 700; font-size: 0.78rem; letter-spacing: 0.02em;
}
.bar-track {
  height: 4px; border-radius: 999px; background: var(--surface-3);
  overflow: hidden; margin-bottom: 20px;
}
.bar-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width .35s cubic-bezier(.2,.8,.2,1);
}

/* ---------- the readout (growing passage) ---------- */
.readout-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.readout-head .kicker { margin: 0; }
.readout-actions { display: flex; gap: 8px; }
.skip-btn {
  font-family: var(--mono); font-size: 0.74rem; color: var(--ash);
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 12px; cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.skip-btn:hover { color: var(--ink); border-color: var(--border-2); background: var(--surface-2); }
.skip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* personal leaderboard */
.board:empty { display: none; }
#board-start { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 18px; }
#board { margin-top: 22px; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.board-head .kicker { margin: 0; }
.board-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; font-variant-numeric: tabular-nums; }
.board-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.board-table tr:last-child td { border-bottom: none; }
.board-table .rk { color: var(--dim); width: 1.6em; }
.board-table .pc { color: var(--ink); font-weight: 700; }
.board-table .tx { color: var(--ash); max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-table .op { color: var(--ash); }
.board-table .dt { color: var(--dim); text-align: right; }
.board-table tr.me { background: var(--accent-soft); }
.board-table tr.me td:first-child { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.board-table tr.me td:last-child { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
.board-table tr.me .pc { color: var(--accent); }
.board-note { margin: 10px 2px 0; font-size: 0.8rem; color: var(--ash); }

.readout {
  background: var(--readout-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 18px 20px;
}
#context, #end-passage {
  font-size: 1.12rem; line-height: 1.85; margin: 0;
  word-spacing: 0.04em;
  overflow-wrap: break-word;   /* safety net for a single very long token */
}
#context::after {
  content: "▌"; color: var(--accent); margin-left: 1px;
  animation: blink 1.1s steps(2, start) infinite;
}

/* tokens render as a visible stream. FILL = your result, UNDERLINE = GPT-2's
   result; the opening "given" prefix tokens get a neutral grey underline. */
.tok {
  /* no horizontal padding/margin: a token with no leading space glues onto the
     previous one with zero gap and reads as one word; boundaries still show via
     each token's fill / underline colour */
  padding: 1px 0; margin: 0; border-radius: 0;
  text-decoration-line: underline;
  text-decoration-thickness: 2px; text-underline-offset: 4px;
  text-decoration-skip-ink: none;
}
.tok.given { color: var(--ash); text-decoration-color: var(--border-2); }
.tok.you-right { background: var(--good-bg); }
.tok.you-near  { background: var(--near-bg); }
.tok.you-wrong { background: var(--bad-bg); }
.tok.gpt-right { text-decoration-color: var(--good); }
.tok.gpt-wrong { text-decoration-color: var(--bad); }
.tok.just { animation: pop .65s cubic-bezier(.2,.8,.2,1); }

/* the leading space a token owns, shown explicitly but kept subtle */
.sp { color: var(--dim); opacity: 0.4; font-size: 0.9em; }
.choice .sp { opacity: 0.6; }
/* control chars inside a token (newline / tab / empty) — small and quiet */
.ctrl { color: var(--dim); font-size: 0.78em; opacity: 0.75; vertical-align: 0.06em; }
@keyframes pop {
  0%   { filter: brightness(2.4); }
  100% { filter: none; }
}

/* ---------- legend ---------- */
.legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 2px;
  margin: 12px 2px 22px; font-size: 0.76rem; color: var(--ash);
}
.legend .tok { font-size: 0.76rem; }
.legend-sep { color: var(--ash); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; vertical-align: -1px; }
.swatch.good { background: var(--good); }
.swatch.bad { background: var(--bad); }

/* ---------- choices ---------- */
.prompt-kicker { margin-top: 4px; }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.choice {
  position: relative; display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 1.05rem;
  padding: 13px 14px; border-radius: var(--r-sm); cursor: pointer; text-align: left;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
  transition: transform .1s ease, border-color .12s, background .12s, box-shadow .12s;
}
.choice:hover:not(:disabled) {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 10px 22px -14px var(--accent-glow);
}
.choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice:disabled { cursor: default; }
/* number badge styled as a keycap */
.choice .num {
  flex: none; display: grid; place-items: center;
  width: 1.7em; height: 1.7em; border-radius: 6px;
  background: var(--surface-3); color: var(--ash);
  border: 1px solid var(--border-2); border-bottom-width: 2px;
  font-size: 0.78rem; font-weight: 700;
}
.choice .prob {
  margin-left: auto; color: var(--dim); font-size: 0.82rem;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.choice.correct {
  background: var(--good-bg); border-color: var(--good);
  box-shadow: 0 0 0 1px var(--good) inset;
}
.choice.correct .num { border-color: var(--good); color: var(--good); }
.choice.wrong {
  background: var(--bad-bg); border-color: var(--bad);
}
.choice.wrong .num { border-color: var(--bad); color: var(--bad); }

/* ---------- type (Insane) mode ---------- */
.type-row { display: flex; gap: 10px; }
#type-input {
  flex: 1; font-family: var(--mono); font-size: 1.05rem;
  padding: 13px 15px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
  transition: border-color .12s, box-shadow .12s;
}
#type-input::placeholder { color: var(--dim); }
#type-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
#type-input:disabled { opacity: 0.7; }
.type-go {
  padding: 0 22px; border: none; border-radius: var(--r-sm); cursor: pointer;
  background: var(--accent-strong); color: var(--on-accent);
  font-family: var(--mono); font-weight: 700; font-size: 0.95rem;
  transition: background .12s, transform .1s;
}
.type-go:hover:not(:disabled) { background: var(--accent); }
.type-go:active:not(:disabled) { transform: translateY(1px); }
.type-go:disabled { opacity: 0.5; cursor: default; }
.type-hint { margin: 10px 2px 0; font-size: 0.76rem; color: var(--dim); }
.type-hint .mono { color: var(--ash); background: var(--surface-3); padding: 0 4px; border-radius: 4px; }
.near-word { color: var(--near); font-weight: 700; }

/* ---------- result readout: real · you · model + per-size strip ---------- */
.result {
  margin-top: 16px; padding: 10px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  display: flex; flex-direction: column; gap: 9px;
}
.res-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 16px; }
.res-sizes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sz {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
}
.sz-ok { background: var(--good-bg); color: var(--good); }
.sz-no { background: var(--bad-bg); color: var(--bad); }
.res-status { font-size: 1.2rem; font-weight: 800; line-height: 1; }
.result.correct .res-status { color: var(--good); }
.result.near    .res-status { color: var(--near); }
.result.wrong   .res-status { color: var(--bad); }
.res-item { display: inline-flex; align-items: center; gap: 7px; }
.res-lab {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--dim);
}
.rtok {
  font-family: var(--mono); font-size: 0.95rem;
  padding: 2px 8px; border-radius: 6px;
  background: var(--surface-3); color: var(--ink);
}
.rtok.real     { background: var(--good-bg); color: var(--good); }
.rtok.r-right  { background: var(--good-bg); color: var(--good); }
.rtok.r-near   { background: var(--near-bg); color: var(--near); }
.rtok.r-wrong  { background: var(--bad-bg);  color: var(--bad); }
.res-rank { font-size: 0.7rem; color: var(--dim); margin-left: 2px; }

/* ---------- primary button ---------- */
button.primary {
  margin-top: 20px; width: 100%; padding: 14px;
  border: none; border-radius: var(--r-sm); cursor: pointer;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: var(--on-accent);
  font-family: var(--mono); font-size: 1rem; font-weight: 700; letter-spacing: 0.02em;
  box-shadow: 0 10px 24px -12px var(--accent-glow);
  transition: filter .12s, transform .1s;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:active { transform: translateY(1px); }
button.primary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- end screen ---------- */
.final {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em;
  text-align: center; margin: 6px 0 4px;
}
.final b { font-variant-numeric: tabular-nums; }
.verdict { text-align: center; color: var(--ash); margin: 0 0 4px; }
.end-wrap { margin-top: 18px; }

/* model-size ladder on the end screen */
.ladder:empty { display: none; }
.ladder { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.ladder-verdict { margin: 0 0 12px; font-size: 0.92rem; color: var(--ink); }
.ladder-verdict b { color: var(--accent); }
.ladder-caveat { color: var(--dim); font-size: 0.8rem; }
.rung { display: grid; grid-template-columns: 7.5em 1fr 3em; align-items: center; gap: 10px; margin: 5px 0; font-size: 0.82rem; }
.rung-name { color: var(--ash); display: flex; flex-direction: column; line-height: 1.2; }
.rung-params { color: var(--dim); font-size: 0.68rem; }
.rung-bar { position: relative; height: 9px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.rung-fill { height: 100%; border-radius: 999px; }
.rung-fill.model { background: var(--robot); }
.rung-fill.me { background: linear-gradient(90deg, var(--accent-strong), var(--accent)); }
/* in-game size bars: faint = corpus average, solid = this passage so far */
.rung-fill.avg { position: absolute; left: 0; top: 0; background: var(--robot); opacity: 0.26; }
.rung-fill.live { position: absolute; left: 0; top: 0; background: var(--robot); transition: width 0.25s ease; }
.rung-tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ash); opacity: 0.7; }
.rung-pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--ash); }
.rung-pct-dim { color: var(--dim); }
.rung.you .rung-name, .rung.you .rung-pct { color: var(--accent); font-weight: 700; }

/* ---------- footer ---------- */
footer { text-align: center; margin-top: 26px; font-size: 0.76rem; color: var(--dim); }
footer .muted { color: var(--dim); }
footer em { color: var(--ash); font-style: normal; }
/* ---------- top-left nav ---------- */
.topnav {
  position: absolute; top: 0; left: 0;
  display: flex; align-items: center; gap: 4px;
  height: 38px;   /* match the theme toggle so they sit on one line */
}
.topnav a {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--ash); text-decoration: none;
  font-size: 0.82rem; line-height: 1;
  padding: 6px 9px; border-radius: 999px;
  border: 1px solid transparent;
  transition: color .12s, background .12s, border-color .12s;
}
.topnav a:hover { color: var(--ink); background: var(--surface-2); border-color: var(--border); }
.topnav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topnav .ico { width: 16px; height: 16px; flex: none; }
.cont { font-family: var(--mono); color: var(--accent); }

.hidden { display: none !important; }

@media (max-width: 520px) {
  #app { padding: 36px 14px 56px; }
  .card { padding: 22px 18px; }
  .modes { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr; }
}

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