/* ============================================================
   J! Testing App — design tokens + global styles
   ============================================================ */

:root {
  /* type */
  --font-ui: "Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: "Newsreader", "Source Serif 4", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  /* density (overridden by .density-compact / .density-comfy) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --row-pad-y: 14px;
  --row-pad-x: 18px;
  --card-pad: 22px;
  --header-h: 64px;
}

.density-compact {
  --row-pad-y: 9px;
  --row-pad-x: 14px;
  --card-pad: 16px;
  --header-h: 56px;
}

.density-comfy {
  --row-pad-y: 18px;
  --row-pad-x: 22px;
  --card-pad: 28px;
  --header-h: 72px;
}

/* ---------- DARK (default, preserved) ---------- */
.theme-dark {
  --bg: #161616;
  --bg-elev: #1f1f1f;
  --bg-elev-2: #262626;
  --bg-input: #1a1a1a;
  --border: #2e2e2e;
  --border-strong: #3a3a3a;
  --text: #e8e8e8;
  --text-dim: #a0a0a0;
  --text-faint: #6d6d6d;
  --accent: var(--accent-dark, #4b86ff);
  --accent-soft: color-mix(in oklab, var(--accent) 18%, transparent);
  --accent-text: #ffffff;
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --shadow-card: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.4);
  --shadow-pop: 0 12px 36px rgba(0,0,0,.55);
}

/* ---------- LIGHT (Jeopardy! blue + white) ---------- */
.theme-light {
  --bg: #f5f6fa;
  --bg-elev: #ffffff;
  --bg-elev-2: #ffffff;
  --bg-input: #ffffff;
  --border: #e3e5ee;
  --border-strong: #c9ccd8;
  --text: #0b1330;
  --text-dim: #525c78;
  --text-faint: #8a93ac;
  --accent: var(--accent-light, #060CE9); /* authentic Jeopardy! blue */
  --accent-soft: color-mix(in oklab, var(--accent) 12%, transparent);
  --accent-text: #ffffff;
  --good: #15803d;
  --bad: #b91c1c;
  --warn: #b45309;
  --shadow-card: 0 1px 2px rgba(11,19,48,.04), 0 8px 24px rgba(11,19,48,.06);
  --shadow-pop: 0 12px 36px rgba(11,19,48,.18);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  min-height: 100vh;
}

/* selection + focus */
::selection { background: var(--accent-soft); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font-family: inherit; }

/* shell */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: var(--space-7) var(--space-5) var(--space-7);
}
.page.narrow { max-width: 720px; }

/* ============== HEADER ============== */
.hdr {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--space-5);
}
.hdr-left { display: flex; align-items: center; gap: var(--space-3); }
.hdr-right { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); }

.hdr-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -.01em;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  white-space: nowrap;
}
.hdr-title .j {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--accent);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -.02em;
}

/* header layout variants */
.hdr-layout-logo-left { grid-template-columns: auto 1fr auto; }
.hdr-layout-logo-left .hdr-title { justify-self: start; }
.hdr-layout-logo-left .hdr-center { justify-self: center; font-weight: 500; color: var(--text-dim); }

.hdr-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; color: var(--text-dim);
  font: inherit; cursor: pointer; padding: 6px 10px; border-radius: 8px;
}
.hdr-back:hover { color: var(--text); background: var(--bg-elev); }

/* profile menu */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer;
  letter-spacing: .02em;
  box-shadow: 0 0 0 0 var(--accent-soft);
  transition: box-shadow .15s ease;
}
.avatar:hover { box-shadow: 0 0 0 4px var(--accent-soft); }
.avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.pmenu-wrap { position: relative; }
.pmenu {
  position: absolute;
  top: calc(100% + 10px); right: 0;
  width: 260px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 8px;
  z-index: 100;
  animation: pmenu-in .14s ease-out;
}
@keyframes pmenu-in {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.pmenu-id {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.pmenu-name { font-weight: 600; color: var(--text); font-size: 14px; }
.pmenu-email { color: var(--text-faint); font-size: 12px; margin-top: 2px; }
.pmenu-item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  background: none; border: 0;
  color: var(--text); font: inherit; text-align: left;
  border-radius: 8px; cursor: pointer;
  gap: 12px;
}
.pmenu-item:hover { background: var(--bg-elev-2); }
.pmenu-item.danger { color: var(--bad); }
.pmenu-section {
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px 12px 4px;
}
.pmenu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* segmented control inside pmenu (theme toggle) */
.seg {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}
.seg button {
  appearance: none; border: 0; background: none;
  color: var(--text-dim);
  font: inherit; font-size: 12px; font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.seg button.on {
  background: var(--accent);
  color: var(--accent-text);
}

/* ============== HOME PAGE ============== */
.hero {
  text-align: center;
  margin: var(--space-7) 0 var(--space-6);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(36px, 5vw, 52px);
  letter-spacing: -.02em;
  margin: 0 0 12px;
  line-height: 1.05;
}
.hero p { color: var(--text-dim); margin: 0; font-size: 16px; }

.hero h1 .j {
  font-style: italic;
  color: var(--accent);
  font-weight: 600;
}

/* ============== CARDS (accordion) ============== */
.card-stack { display: flex; flex-direction: column; gap: var(--space-4); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color .15s ease;
}
.card.open { border-color: color-mix(in oklab, var(--accent) 50%, var(--border)); }

.card-head {
  display: flex; align-items: center; gap: var(--space-4);
  width: 100%;
  padding: var(--row-pad-y) var(--row-pad-x);
  background: none; border: 0;
  color: var(--text);
  font: inherit; text-align: left;
  cursor: pointer;
}
.card-head:hover { background: var(--bg-elev-2); }
.card-icon {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 22px;
  font-style: italic;
}
.card-head-text { flex: 1; min-width: 0; }
.card-head-title {
  font-weight: 600; font-size: 17px; letter-spacing: -.01em;
  color: var(--text);
}
.card-head-sub {
  color: var(--text-dim); font-size: 13.5px; margin-top: 2px;
}
.chev {
  color: var(--text-faint);
  transition: transform .2s ease;
}
.card.open .chev { transform: rotate(180deg); color: var(--text-dim); }

.card-body {
  padding: 4px var(--card-pad) var(--card-pad);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: var(--space-4);
  animation: cbody-in .18s ease-out;
}
/* Same pattern as .loading-screen[hidden]: explicit display:flex would
   otherwise win over the user-agent [hidden] { display: none } rule. All
   three card bodies are now rendered server-side at all times (bodies
   for non-open cards carry the [hidden] attribute); home.js toggles the
   attribute on chevron click. Without this rule the Test/Play bodies
   would render visible alongside Search. */
.card-body[hidden] { display: none; }
/* A <form> inside .card-body becomes a flex item of the column layout,
   but its OWN children are block-level by default — so .check labels
   (display:inline-flex) inside the form would flow inline next to each
   other instead of stacking. Push the form layout into a column too. */
.card-body form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
@keyframes cbody-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}

/* ============== FORMS ============== */
.input, .select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit; font-size: 15px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-faint); }

.search-row {
  display: flex; gap: var(--space-2);
}
.search-len-hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.search-row .input { flex: 1; }

.check {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--text-dim); cursor: pointer; font-size: 14px;
  user-select: none;
  padding: 4px 0;
}
.check input { display: none; }
.check .box {
  width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-input);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s ease;
}
.check input:checked + .box,
.check .box[data-on="true"] {
  background: var(--accent);
  border-color: var(--accent);
}
.check input:checked + .box::after,
.check .box[data-on="true"]::after {
  content: "";
  width: 5px; height: 9px;
  border: solid var(--accent-text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
}
.check input:disabled + .box {
  opacity: .35;
}
.check.disabled { color: var(--text-faint); cursor: not-allowed; }

.help-text {
  font-size: 12.5px; color: var(--text-faint);
  margin-top: -2px;
}

/* buttons */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14.5px;
  padding: 11px 22px;
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .06s ease, box-shadow .15s ease, background .15s ease;
  letter-spacing: .005em;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover {
  background: color-mix(in oklab, var(--accent) 88%, white);
}
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-elev-2); border-color: var(--border-strong); }
.btn-danger {
  background: transparent;
  color: var(--bad);
  border: 1px solid color-mix(in oklab, var(--bad) 40%, var(--border));
}
.btn-danger:hover { background: color-mix(in oklab, var(--bad) 8%, transparent); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Access tab (admin-only, item 3) ─────────────────────────────────────── */
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  font-size: 11px; font-weight: 700; line-height: 1;
  color: var(--accent-text); background: var(--accent);
  border-radius: 999px;
}
.access-intro { font-size: 13.5px; margin-bottom: 14px; max-width: 60ch; }
.access-h {
  font-size: 14px; font-weight: 600; margin: 20px 0 8px; color: var(--text-dim);
}
.access-list { display: flex; flex-direction: column; }
.access-row { align-items: center; }
.access-actions { display: inline-flex; gap: 8px; flex-shrink: 0; }

/* mode picker (test card checkboxes with smart disable) */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}
.mode-opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  cursor: pointer;
  transition: all .12s ease;
}
.mode-opt:hover:not(.disabled) {
  border-color: var(--border-strong);
}
.mode-opt.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.mode-opt.disabled {
  opacity: .35; cursor: not-allowed;
}
.mode-opt .mtext { display: flex; flex-direction: column; gap: 1px; }
.mode-opt .mname { font-weight: 600; font-size: 14px; color: var(--text); }
.mode-opt .mdesc { font-size: 12px; color: var(--text-dim); line-height: 1.35; }

.adaptive-note { margin: 14px 0 6px; line-height: 1.45; }

/* ============== BADGES & CHIPS ============== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge.dd {
  background: color-mix(in oklab, var(--warn) 18%, transparent);
  color: var(--warn);
  border-color: color-mix(in oklab, var(--warn) 30%, var(--border));
}
.badge.ts {
  background: color-mix(in oklab, var(--bad) 14%, transparent);
  color: var(--bad);
  border-color: color-mix(in oklab, var(--bad) 30%, var(--border));
}
.badge.round {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in oklab, var(--accent) 30%, var(--border));
}

.value-pill {
  font-family: var(--font-display);
  font-weight: 700;
  font-style: italic;
  font-size: 18px;
  color: var(--accent);
}

/* ============== SEARCH RESULTS ============== */
.results-summary {
  display: flex; justify-content: space-between; align-items: center;
  margin: var(--space-5) 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.results-summary .count {
  color: var(--text-dim); font-size: 13px;
}
.results-summary .count b { color: var(--text); font-weight: 600; }

.group {
  margin-bottom: var(--space-6);
}
.group-head {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.group-bar {
  flex: 0 0 4px; height: 28px;
  border-radius: 2px;
  background: var(--accent);
}
.group-bar.medium { background: color-mix(in oklab, var(--accent) 80%, var(--warn) 20%); opacity: .85; }
.group-bar.hard { background: var(--warn); }
.group-bar.final { background: var(--accent); height: 32px; }
.group-title {
  font-family: var(--font-display);
  font-weight: 500; font-size: 22px;
  letter-spacing: -.01em;
  color: var(--text);
}
.group-meta { color: var(--text-faint); font-size: 13px; margin-left: auto; }

.clue-list { display: flex; flex-direction: column; gap: var(--space-2); }
.clue-row {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--row-pad-y) var(--row-pad-x);
  transition: border-color .12s ease;
}
.clue-row:hover { border-color: var(--border-strong); }
.clue-row-head {
  display: flex; align-items: center; gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.clue-row-text {
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}
.clue-row-resp {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 4px;
}
.clue-row-resp b {
  color: var(--accent);
  font-weight: 600;
}
.clue-row-meta {
  color: var(--text-faint); font-size: 12px;
  margin-top: 8px;
  display: flex; gap: 12px; flex-wrap: wrap;
}
.cluster-note {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text-faint);
  font-size: 12px;
  margin-left: auto;
}

/* Cross-reference chips: "this answer also appears in → [other card]" */
.clue-row-xref {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.clue-row-xref .xref-lbl {
  color: var(--text-faint); font-size: 12px; margin-right: 2px;
}
.xref-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  font-size: 12px; line-height: 1.4;
  color: var(--accent); text-decoration: none;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 999px;
}
.xref-chip:hover { border-color: var(--accent); text-decoration: none; }
.xref-chip .xref-n {
  font-size: 11px; font-weight: 600;
  color: var(--text-faint);
  background: var(--bg); border-radius: 999px;
  padding: 0 5px;
}

/* Heading + meta for search results page */
.sr-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(28px, 4vw, 36px);
  letter-spacing: -.02em;
  margin: var(--space-5) 0 4px;
}
.sr-meta { font-size: 13.5px; }

/* 'harder' bucket bar (template emits class name from bucket key) */
.group-bar.harder { background: var(--warn); }

/* Multi-topic chips inside clue row header */
.cat-topics { display: inline-flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.cat-topic-plus { color: var(--text-faint); font-size: 11px; }

/* Utility */
.muted { color: var(--text-dim); }
.tiny  { font-size: 12px; }

/* ============================================================
   PER-CARD ACTIONS (cluster expander + Anki suggestion button)
   ============================================================ */
.clue-row-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.row-action-btn {
  appearance: none; background: transparent; border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 500; letter-spacing: .01em;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.row-action-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev-2);
  color: var(--text);
}
.row-action-btn.on {
  background: color-mix(in oklab, var(--accent) 14%, var(--bg-elev-2));
  border-color: color-mix(in oklab, var(--accent) 35%, var(--border-strong));
  color: var(--text);
}
.row-action-btn b { color: var(--text); font-weight: 600; }
.ra-icon { display: inline-flex; color: var(--text-faint); }
.row-action-btn.on .ra-icon { color: var(--accent); }
.ra-chev {
  width: 14px; height: 14px;
  color: var(--text-faint);
  transition: transform .18s ease;
}
.row-action-btn.on .ra-chev { transform: rotate(180deg); color: var(--text-dim); }
.row-action-btn.anki-action .anki-glyph {
  width: 18px; height: 18px; border-radius: 4px;
  background: color-mix(in oklab, var(--accent) 18%, var(--bg-elev-2));
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-style: italic;
  font-size: 11px;
}

/* Similar clues expander panel */
.similar-panel {
  margin-top: 10px;
  padding: 10px 12px 4px;
  background: color-mix(in oklab, var(--accent) 4%, var(--bg-elev));
  border: 1px solid color-mix(in oklab, var(--accent) 18%, var(--border));
  border-radius: var(--radius-md);
}
.similar-head { color: var(--text-dim); font-size: 12px; margin-bottom: 8px; }
.similar-head b { color: var(--text); font-weight: 600; }
.similar-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 6px; }
.similar-mini {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.similar-mini .sm-head {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; font-size: 12px; margin-bottom: 4px;
}
.similar-mini .sm-value { font-size: 11px; padding: 1px 6px; }
.similar-mini .sm-air { margin-left: auto; color: var(--text-faint); font-size: 11px; }
.similar-mini .sm-archive {
  color: var(--accent); font-size: 11px; text-decoration: none; white-space: nowrap;
}
.similar-mini .sm-archive:hover { text-decoration: underline; }
.similar-mini .sm-text { color: var(--text); font-size: 13px; line-height: 1.5; }
.similar-mini .sm-anki { margin-top: 6px; }
.similar-mini .sm-anki-btn { font-size: 12px; padding: 3px 8px; }

/* Anki glyph (global — shared by action button and inline label) */
.anki-glyph {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #2e86d4;
  color: white;
  font-family: var(--font-display);
  font-style: italic; font-weight: 700; font-size: 13px;
  border-radius: 5px; flex-shrink: 0;
}

/* Anki inline block (inside a single clue row) */
.anki-inline {
  margin-top: 10px;
  padding: 10px 12px;
  background: color-mix(in oklab, var(--accent) 6%, var(--bg-elev));
  border: 1px solid color-mix(in oklab, var(--accent) 22%, var(--border));
  border-radius: var(--radius-md);
}
.anki-inline-lbl {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-dim); font-size: 12px; margin-bottom: 6px;
}
.anki-inline-lbl .anki-glyph {
  width: 18px; height: 18px; border-radius: 4px; font-size: 11px;
  background: color-mix(in oklab, var(--accent) 22%, var(--bg-elev-2));
  color: var(--accent);
}
.anki-inline-row { display: flex; gap: 8px; align-items: stretch; }
.anki-inline-row .anki-text {
  flex: 1;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px; color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.anki-inline-row .anki-copy {
  appearance: none; border: 0;
  background: var(--accent); color: white;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background .12s ease;
  flex-shrink: 0;
}
.anki-inline-row .anki-copy:hover { background: color-mix(in oklab, var(--accent) 88%, white); }
.anki-inline-row .anki-copy.copied { background: var(--good); }
.anki-inline-row .anki-copy.fail { background: var(--bad); }

/* ============== TEST PAGE (one clue at a time) ============== */
.test-shell { max-width: 760px; margin: 0 auto; }

.test-progress {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-4);
  font-size: 13px;
  color: var(--text-dim);
}
.test-progress .scores {
  display: flex; gap: 14px;
  font-variant-numeric: tabular-nums;
}
.test-progress .scores span b { color: var(--text); }
.test-progress .good b { color: var(--good); }
.test-progress .bad b { color: var(--bad); }
.test-progress .skip b { color: var(--text-faint); }

.pbar {
  height: 4px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: var(--space-6);
}
.pbar-fill {
  height: 100%;
  background: var(--accent);
  transition: width .3s ease;
}

.clue-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-7) var(--space-6);
  box-shadow: var(--shadow-card);
  min-height: 360px;
  display: flex; flex-direction: column;
}
.clue-card .meta-row {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.clue-card .category {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.clue-card .clue {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(24px, 3.4vw, 32px);
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -.01em;
  margin: var(--space-4) 0 var(--space-6);
  text-wrap: pretty;
}
.clue-card .response-block {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: var(--space-5);
  animation: cbody-in .18s ease-out;
}
.clue-card .response-block .label {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.clue-card .response-block .response {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -.005em;
}

.test-actions {
  margin-top: auto;
  display: flex; gap: 10px;
  padding-top: var(--space-5);
}
.test-actions .btn { flex: 1; padding: 14px 18px; }
.test-actions .mark-good { background: var(--good); color: white; }
.test-actions .mark-good:hover { background: color-mix(in oklab, var(--good) 88%, black); }
.test-actions .mark-bad { background: var(--bad); color: white; }
.test-actions .mark-bad:hover { background: color-mix(in oklab, var(--bad) 88%, black); }
.test-actions .mark-skip {
  background: var(--bg-elev);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.test-actions .mark-skip:hover { background: var(--bg-elev-2); }

.test-bottom {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-6);
  color: var(--text-dim); font-size: 13px;
  flex-wrap: wrap;
}
.test-bottom .meta { color: var(--text-dim); }
.test-bottom .actions { display: flex; gap: 10px; align-items: center; }

/* J-Archive link styled as a visible accent chip */
.archive-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--border));
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background .12s ease, transform .06s ease;
}
.archive-chip:hover {
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  text-decoration: none;
}
.archive-chip:active { transform: translateY(1px); }

/* Visible End-session button */
.end-btn {
  appearance: none;
  background: transparent;
  color: var(--bad);
  border: 1.5px solid color-mix(in oklab, var(--bad) 55%, var(--border));
  font: inherit; font-weight: 600; font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.end-btn:hover {
  background: var(--bad);
  color: white;
  border-color: var(--bad);
}

/* ============== SUMMARY ============== */
.score-hero {
  text-align: center;
  margin: var(--space-6) 0 var(--space-7);
}
.score-hero .big {
  font-family: var(--font-display);
  font-size: 84px; font-weight: 500;
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.score-hero .big .of {
  color: var(--text-faint); font-weight: 400;
}
.score-hero .lbl {
  color: var(--text-dim); font-size: 14px;
  margin-top: 6px;
  letter-spacing: .04em; text-transform: uppercase;
}

.score-breakdown {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-7);
}
.sb-cell {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  text-align: center;
}
.sb-cell .v {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.sb-cell.good .v { color: var(--good); }
.sb-cell.bad .v { color: var(--bad); }
.sb-cell.skip .v { color: var(--text-dim); }
.sb-cell .l {
  color: var(--text-dim); font-size: 12px;
  letter-spacing: .04em; text-transform: uppercase;
  margin-top: 4px;
}

.study-section {
  margin-top: var(--space-6);
}
.study-section h2 {
  font-family: var(--font-display);
  font-weight: 500; font-size: 26px;
  letter-spacing: -.01em;
  margin: 0 0 var(--space-2);
}
.study-section .sub {
  color: var(--text-dim); margin: 0 0 var(--space-5);
}
/* Per-deck "Other times this came up …" label — match .sub's font + color,
   centered, with breathing room before the cards below it. */
.deck-section-label {
  color: var(--text-dim);
  text-align: center;
  margin: var(--space-4) 0 var(--space-5);
}

.brush-up {
  background: linear-gradient(180deg, var(--accent-soft), transparent);
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border));
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}
.brush-up h3 {
  font-family: var(--font-display);
  font-weight: 500; font-size: 20px;
  margin: 0 0 4px;
}
.brush-up h3 b {
  color: var(--accent);
  font-style: italic;
  font-weight: 700;
}
.brush-up p {
  color: var(--text-dim); margin: 0 0 var(--space-3);
  font-size: 14px; line-height: 1.55;
}
.brush-up .topic-tags {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.brush-up .topic-tag {
  font-size: 12px; padding: 4px 9px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-dim);
}
.brush-up .topic-tag b { color: var(--text); font-weight: 600; }
.brush-up .cta-row { display: flex; gap: 8px; flex-wrap: wrap; }
.brush-up .cta-row .btn { padding: 9px 16px; font-size: 13.5px; }

.missed-clue {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--row-pad-y) var(--row-pad-x);
  margin-bottom: var(--space-3);
}
.missed-clue .clue-text {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--text);
  margin: 6px 0 6px;
  line-height: 1.4;
}
.missed-clue .answer { color: var(--text-dim); font-size: 14px; }
.missed-clue .answer b { color: var(--accent); font-weight: 600; }
.missed-clue .study-tip {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.6;
}
.missed-clue .study-tip .tip-label {
  color: var(--accent);
  font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  margin-bottom: 4px;
}

/* ============== PROFILE PAGE ============== */
.profile-head {
  display: flex; align-items: center; gap: var(--space-4);
  margin: var(--space-4) 0 var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.profile-head .avatar-lg {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  font-weight: 600; font-size: 28px;
  display: inline-flex; align-items: center; justify-content: center;
}
.profile-head h1 {
  font-family: var(--font-display);
  font-weight: 500; font-size: 32px;
  margin: 0 0 4px;
}
.profile-head .email { color: var(--text-dim); font-size: 14px; }

.name-display {
  display: inline-flex; align-items: center; gap: 12px;
}
.name-edit-btn {
  appearance: none; background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-dim); font: inherit; font-size: 12.5px; font-weight: 500;
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: all .12s ease;
}
.name-edit-btn:hover { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); }
.name-edit {
  display: flex; gap: 8px; align-items: center;
  max-width: 480px;
  margin-bottom: 6px;
}
.name-edit .input { font-family: var(--font-display); font-size: 22px; font-weight: 500; padding: 8px 12px; }
.name-edit .btn { padding: 9px 16px; font-size: 13.5px; }
.name-reset {
  background: none; border: 0; color: var(--text-faint); font: inherit;
  font-size: 12px; cursor: pointer; padding: 4px 0; margin-top: 4px;
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px;
}
.name-reset:hover { color: var(--accent); }

.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.tab {
  background: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 500; font-size: 14px;
  color: var(--text-dim);
  padding: 12px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }

.history-row {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--row-pad-y) 0;
  border-bottom: 1px solid var(--border);
}
.history-row:last-child { border-bottom: 0; }
.history-row .h-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 36px;
}
.history-row .h-main { flex: 1; min-width: 0; }
.history-row .h-title {
  font-weight: 500; color: var(--text); font-size: 14.5px;
  margin-bottom: 2px;
}
.history-row .h-meta {
  color: var(--text-faint); font-size: 12.5px;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.history-row .h-meta .sep { opacity: .5; }
.history-row .h-score {
  font-family: var(--font-display);
  font-weight: 500; font-size: 18px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.history-row .h-score .of { color: var(--text-faint); font-weight: 400; }

/* Both <button> (sessions/games — JS resume) and <a> (past searches — nav)
   use .history-row-btn; rules must apply to both, and the row must NOT pick
   up the global a:hover underline — hover highlights the chevron instead. */
.history-row-btn {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 0;
  text-decoration: none;
  transition: background .12s ease, padding .12s ease;
}
.history-row-btn:hover {
  background: var(--bg-elev);
  padding-left: 10px;
  padding-right: 10px;
  text-decoration: none;
}
.history-row-btn:hover .h-cta { color: var(--accent); transform: translateX(2px); }
.history-row-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--bg-elev);
}
.history-row .h-cta {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  color: var(--text-faint);
  transition: color .12s ease, transform .12s ease;
}

.empty-state {
  text-align: center;
  padding: var(--space-7) 0;
  color: var(--text-faint);
}
.empty-state svg { margin-bottom: 8px; opacity: .6; }

/* ============== TOPIC / CATEGORY combined label ============== */
.cat-line {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.cat-topic {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--accent);
  letter-spacing: 0;
  text-transform: none;
}
.cat-sep {
  color: var(--text-faint);
  font-weight: 400;
}
.cat-cat {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.clue-card .category.cat-line {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  color: inherit;
}
.clue-card .cat-topic {
  font-size: 16px;
}
.clue-card .cat-cat {
  font-size: 13.5px;
}

/* ============== TOPIC PICKER (test card) ============== */
.topic-picker {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 4px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in oklab, var(--accent) 32%, var(--border));
  border-radius: var(--radius-md);
}
.topic-picker-lbl {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .02em;
}
.topic-picker .select {
  background: var(--bg-elev);
  border-color: color-mix(in oklab, var(--accent) 30%, var(--border));
  font-weight: 500;
  cursor: pointer;
}
.topic-picker .select:hover {
  border-color: var(--accent);
}

/* ============== STATS TAB ============== */
.stats-headline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.sh-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.sh-card.good { border-color: color-mix(in oklab, var(--good) 35%, var(--border)); }
.sh-card.bad  { border-color: color-mix(in oklab, var(--bad) 35%, var(--border)); }
.sh-label {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  color: var(--text-faint); text-transform: uppercase;
  margin-bottom: 6px;
}
.sh-value {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 500;
  color: var(--text);
  letter-spacing: -.01em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.sh-value .of { color: var(--text-faint); font-weight: 400; font-size: 18px; }
.sh-card.good .sh-value { color: var(--good); }
.sh-card.bad .sh-value { color: var(--bad); }
.sh-meta {
  margin-top: 4px;
  color: var(--text-dim); font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.topic-stats {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.ts-row {
  display: grid;
  grid-template-columns: 28px 1fr 180px 80px 50px;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.ts-row:last-child { border-bottom: 0; }
.ts-rank {
  font-family: var(--font-display);
  color: var(--text-faint);
  font-weight: 500;
  font-size: 14px;
}
.ts-name {
  font-weight: 600;
  color: var(--text);
  font-size: 14.5px;
}
.ts-bar-wrap {
  height: 8px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
}
.ts-bar {
  height: 100%;
  border-radius: 999px;
  transition: width .3s ease;
}
.ts-frac {
  color: var(--text-dim);
  font-size: 13px;
  text-align: right;
}
.ts-frac .of { color: var(--text-faint); }
.ts-pct {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  text-align: right;
}
@media (max-width: 640px) {
  .ts-row { grid-template-columns: 24px 1fr 70px 50px; }
  .ts-bar-wrap { display: none; }
  .stats-headline { grid-template-columns: 1fr; }
}

.mode-opt .radio {
  width: 18px; height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-input);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s ease;
}
.mode-opt .radio[data-on="true"] {
  border-color: var(--accent);
}
.mode-opt .radio[data-on="true"]::after {
  content: "";
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

/* ============== FOOTER ============== */
.ftr {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 92%, var(--bg-elev));
  padding: var(--space-5) var(--space-5);
}
.ftr-inner {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.ftr-copy {
  color: var(--text-faint);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ftr-fine {
  color: var(--text-faint);
  font-size: 11.5px;
  letter-spacing: .01em;
  line-height: 1.5;
  text-wrap: pretty;
}
.ftr-fine a {
  color: var(--text-dim);
  border-bottom: 1px dotted var(--text-faint);
  padding-bottom: 1px;
}
.ftr-fine a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.ftr-copy .j-mark {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  color: var(--accent);
  font-size: 14px;
}

/* ============== PLAY LAUNCHER (home card) ============== */
.play-launcher {
  display: flex; flex-direction: column;
  gap: var(--space-2);
}
.launch-opt {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: all .12s ease;
  appearance: none;
  font: inherit;
  color: inherit;
}
.launch-opt.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.lo-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.lo-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-elev);
  flex: 0 0 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
.lo-dot[data-on="true"] {
  border-color: var(--accent);
}
.lo-dot[data-on="true"]::after {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.lo-name {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
}
.lo-max {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 12px;
}
.lo-max b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.lo-desc { color: var(--text-dim); font-size: 13px; line-height: 1.4; padding-left: 26px; }
.launch-opt .input {
  margin-top: 6px;
  max-width: 240px;
  font-variant-numeric: tabular-nums;
}
.error-text {
  color: var(--bad);
  font-size: 12.5px;
  margin-top: 6px;
}
.error-text b { font-variant-numeric: tabular-nums; }

.resume-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(180deg, var(--accent-soft), transparent);
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--border));
  border-radius: var(--radius-md);
}
.rb-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 36px;
}
.rb-body { flex: 1; min-width: 0; }
.rb-title { font-weight: 600; color: var(--text); font-size: 14.5px; }
.rb-meta { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ============== GAME HUD ============== */
.game-page {
  max-width: 1200px;
  padding-top: var(--space-5);
}
.hud {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}
.hud-left, .hud-center, .hud-right { min-width: 0; }
.hud-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.hud-round-tag, .hud-coryat-lbl {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  color: var(--text-faint); text-transform: uppercase;
}
.hud-round-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 22px;
  color: var(--accent);
  letter-spacing: -.01em;
  margin-top: 2px;
}
.hud-coryat-val {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  color: var(--text);
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-top: 2px;
}
.hud-coryat-val.neg { color: var(--bad); }
.hud-progress-lbl {
  font-size: 11.5px; font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .04em;
  text-align: center;
  margin-bottom: 4px;
}
.hud-progress-bar {
  height: 4px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
}
.hud-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width .3s ease;
}
.hud-game-id {
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.hud-archive-link {
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-faint);
  padding-bottom: 1px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color .12s ease, border-color .12s ease;
}
.hud-archive-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}
.hud-archive-link svg { opacity: .8; }

/* ============== BOARD ============== */
.board-wrap {
  position: relative;
}
.board-skip {
  position: absolute;
  top: -36px;
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease;
  z-index: 5;
}
.board-skip:hover { color: var(--accent); border-color: var(--accent); }

.board {
  display: flex; flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: var(--board-bg);
  border-radius: var(--radius-md);
  --board-bg: color-mix(in oklab, var(--accent) 18%, var(--bg-elev));
}
.theme-light .board { --board-bg: color-mix(in oklab, var(--accent) 12%, var(--bg-elev)); }

.board-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.board-cell {
  aspect-ratio: 16 / 11;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--accent);
  color: white;
  font-family: var(--font-display);
  border: 0;
  cursor: pointer;
  transition: background .14s ease, transform .06s ease;
  padding: 12px;
}
.board-cell:focus-visible {
  outline: 3px solid color-mix(in oklab, var(--accent) 35%, white);
  outline-offset: -3px;
}
.board-cat {
  cursor: default;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .01em;
  line-height: 1.15;
  text-transform: uppercase;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,.25);
  position: relative;
  perspective: 800px;
  /* Category headers size to their text — long Alex/Ken comments grow the
     whole row to fit (grid stretches every cell to the tallest), like
     J-Archive, instead of clipping. Clue cells keep their aspect ratio. */
  aspect-ratio: auto;
  min-height: 64px;
}
.board-cat .cat-front,
.board-cat .cat-back {
  position: absolute;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform .55s cubic-bezier(.4,.1,.2,1);
}
.board-cat .cat-back {
  background: linear-gradient(160deg, #0a1d6e, #060CE9);
  border-radius: 4px;
  transform: rotateY(0deg);
}
.board-cat .cat-back-j {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 36px;
  color: #fbbf24;
  text-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.board-cat .cat-front {
  /* In flow (not absolute) so the category text drives the cell height;
     the back "J!" face stays absolutely positioned and overlays it. */
  position: relative;
  inset: auto;
  width: 100%;
  transform: rotateY(180deg);
}
.board-cat.cat-shown .cat-back  { transform: rotateY(-180deg); }
.board-cat.cat-shown .cat-front { transform: rotateY(0); animation: cat-flip-in .55s cubic-bezier(.4,.1,.2,1); }
.board-cat.no-anim .cat-back  { transition: none; transform: rotateY(-180deg); }
.board-cat.no-anim .cat-front { transition: none; transform: rotateY(0); animation: none; }
@keyframes cat-flip-in {
  0% { opacity: 0; }
  50% { opacity: 0; }
  60% { opacity: 1; }
  100% { opacity: 1; }
}
.board-clue {
  font-style: italic;
  font-weight: 700;
  font-size: clamp(22px, 3vw, 36px);
  color: #fbbf24; /* classic gold dollar values */
  text-shadow: 0 2px 6px rgba(0,0,0,.45);
}
.board-clue:hover:not(:disabled) {
  background: color-mix(in oklab, var(--accent) 80%, white);
  transform: scale(1.01);
}
.board-clue.locked {
  opacity: .4;
  pointer-events: none;
  filter: grayscale(.25);
}
.board-clue.done {
  background: color-mix(in oklab, var(--accent) 35%, #000 50%);
  color: transparent;
  cursor: default;
}
.theme-light .board-clue.done {
  background: color-mix(in oklab, var(--accent) 30%, white 30%);
}
.board-clue.done-good { box-shadow: inset 0 0 0 3px color-mix(in oklab, var(--good) 70%, transparent); }
.board-clue.done-bad  { box-shadow: inset 0 0 0 3px color-mix(in oklab, var(--bad) 70%, transparent); }
.board-clue.done-skip  { box-shadow: inset 0 0 0 3px color-mix(in oklab, white 30%, transparent); }
.theme-light .board-clue.done-skip { box-shadow: inset 0 0 0 3px color-mix(in oklab, var(--text-faint) 40%, transparent); }

@media (max-width: 720px) {
  .board-cat { font-size: 11px; }
  .board-clue { font-size: 18px; }
  .board-cell { padding: 6px; }
}

/* ============== FINAL ROUND ============== */
.final-round {
  background: var(--accent);
  color: white;
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-6);
  text-align: center;
  min-height: 320px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.fr-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.7);
  margin-bottom: 12px;
}
.fr-label .j-italic { font-style: italic; color: #fbbf24; text-transform: none; letter-spacing: 0; }
.fr-category {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 4vw, 44px);
  text-transform: uppercase;
  color: white;
  letter-spacing: .02em;
  text-shadow: 0 2px 6px rgba(0,0,0,.35);
  margin-bottom: var(--space-6);
}
.fr-play {
  font-size: 16px;
  padding: 14px 28px;
  background: white !important;
  color: var(--accent) !important;
}
.fr-result {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: white;
}
.fr-result.fr-good { color: #4ade80; }
.fr-result.fr-bad  { color: #fca5a5; }
.fr-answer {
  margin-top: 12px;
  font-size: 18px;
  color: white;
  font-weight: 400;
}
.fr-answer b { color: #fbbf24; }

/* ============== MODAL ============== */
.modal-veil {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: var(--space-5);
  animation: veil-in .15s ease-out;
}
@keyframes veil-in { from { opacity: 0; } to { opacity: 1; } }

.clue-modal {
  width: 100%;
  max-width: 760px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-xl);
  padding: var(--space-6) var(--space-6);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  animation: cm-in .2s ease-out;
}
@keyframes cm-in { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

.clue-modal.is-dd { background: linear-gradient(160deg, var(--accent), #1e3a8a); }
.clue-modal .cm-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.cm-category { display: inline-flex; gap: 6px; align-items: baseline; }
.cm-topic {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  color: #fbbf24;
  font-size: 16px;
}
.cm-topics { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.cm-topic-chip {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(251,191,36,.15);
  border: 1px solid rgba(251,191,36,.35);
  font-size: 14px;
}
.cm-topic-plus {
  color: rgba(255,255,255,.45);
  font-weight: 700;
  padding: 0 2px;
}
.cm-sep { color: rgba(255,255,255,.5); }
.cm-cat {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: rgba(255,255,255,.85);
}
.cm-value {
  margin-left: auto;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 26px;
  color: #fbbf24;
  font-variant-numeric: tabular-nums;
}
.clue-modal .badge.round {
  background: rgba(255,255,255,.15);
  color: white;
  border-color: rgba(255,255,255,.3);
  margin-left: auto;
}
.clue-modal .badge.dd {
  background: #fbbf24;
  color: #1e3a8a;
  border-color: #fbbf24;
  margin-left: auto;
}
/* Triple Stumper badge inside the clue modal — needs to read off the
   saturated blue board. White pill, red text, red leading dot — sits
   alongside the gold DD badge without competing with it. */
.clue-modal .badge.ts {
  background: #ffffff;
  color: #b91c1c;
  border-color: #ffffff;
  margin-left: auto;
  padding: 4px 10px 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  letter-spacing: .05em;
  box-shadow: 0 1px 0 rgba(0,0,0,.18);
}
.clue-modal .badge.ts::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b91c1c;
  flex: 0 0 7px;
}
/* If both DD and TS show up, only the first one floats right. */
.clue-modal .badge.dd + .badge.ts,
.clue-modal .badge.ts + .badge.dd { margin-left: 0; }
.cm-clue {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.35;
  color: white;
  text-shadow: 0 2px 6px rgba(0,0,0,.25);
  margin: var(--space-4) 0 var(--space-6);
  text-wrap: pretty;
}
.cm-response-block {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: var(--space-4);
  animation: cm-in .2s ease-out;
}
.cm-response-lbl {
  font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.7);
  margin-bottom: 4px;
}
.cm-response {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: #fbbf24;
  letter-spacing: -.005em;
}
.cm-actions { display: flex; gap: 10px; }
.cm-actions .btn { flex: 1; padding: 14px 18px; }
.cm-actions .mark-good { background: var(--good); color: white; }
.cm-actions .mark-bad { background: var(--bad); color: white; }
.cm-actions .mark-skip { background: rgba(255,255,255,.15); color: white; border: 1px solid rgba(255,255,255,.3); }
.cm-actions .mark-skip:hover { background: rgba(255,255,255,.22); }
.cm-actions .btn-primary { background: white; color: var(--accent); }
.cm-actions .btn-primary:hover { background: rgba(255,255,255,.92); }
.cm-note {
  margin-top: var(--space-4);
  text-align: center;
  color: rgba(255,255,255,.6);
  font-size: 12px;
  font-style: italic;
}

/* DD splash — navy blue with gold lettering (Jeopardy! show style) */
.dd-splash {
  background: linear-gradient(160deg, #0a1d6e 0%, #060CE9 50%, #1e3a8a 100%);
  color: #fbbf24;
  border-radius: var(--radius-xl);
  padding: var(--space-7) var(--space-6);
  box-shadow: var(--shadow-pop), inset 0 1px 0 rgba(255,255,255,.15);
  text-align: center;
  border: 2px solid #fbbf24;
  animation: dd-pop .35s cubic-bezier(.22,1.1,.4,1);
  position: relative;
}
.dd-splash::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(251,191,36,.35);
  border-radius: calc(var(--radius-xl) - 6px);
  pointer-events: none;
}
@keyframes dd-pop {
  0%   { transform: scale(.6) rotate(-2deg); opacity: 0; }
  60%  { transform: scale(1.04) rotate(.5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.dd-splash-inner { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.dd-lbl {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 42px;
  letter-spacing: .02em;
  line-height: 1;
  color: #fbbf24;
  text-shadow: 0 3px 0 rgba(0,0,0,.45), 0 6px 12px rgba(0,0,0,.4);
}
.dd-lbl.big {
  font-size: 78px;
  letter-spacing: -.005em;
}
.dd-sub {
  margin-top: 14px;
  font-size: 13px;
  color: rgba(255,255,255,.75);
  font-weight: 500;
  font-style: italic;
}
.dd-splash .btn {
  margin-top: 18px;
  background: #fbbf24;
  color: #0a1d6e;
  font-weight: 700;
}
.dd-splash .btn:hover {
  background: #fde047;
}

/* ============== CONFIRM DIALOG ============== */
.confirm-dialog {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-pop);
}
.confirm-dialog h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 8px;
  color: var(--text);
}
.confirm-dialog p {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 var(--space-5);
}
.cd-actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn-danger-solid {
  background: var(--bad);
  color: white;
}
.btn-danger-solid:hover { background: color-mix(in oklab, var(--bad) 88%, black); }

/* ============== GAME SUMMARY ============== */
.big-coryat {
  font-family: var(--font-display);
  font-size: clamp(64px, 9vw, 96px);
  font-weight: 500;
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.big-coryat .dollar { font-size: .7em; color: var(--text-dim); margin-right: 2px; }

.game-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin: var(--space-5) 0 var(--space-6);
}
@media (max-width: 640px) {
  .game-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
.gs-cell {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: center;
}
.gs-label {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  color: var(--text-faint); text-transform: uppercase;
  margin-bottom: 4px;
}
.gs-value {
  font-family: var(--font-display);
  font-weight: 500; font-size: 22px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.gs-value .of { color: var(--text-faint); font-weight: 400; }
.gs-value.gs-right { color: var(--good); }
.gs-value.gs-wrong { color: var(--bad); }
.gs-value.gs-skip { color: var(--text-dim); }

/* ============== PLAYED GAMES (profile tab) ============== */
.played-game {
  display: grid;
  grid-template-columns: 32px 1fr 200px auto;
  align-items: center;
  gap: var(--space-4);
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.played-game:last-child { border-bottom: 0; }
.played-game .pg-rank {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.played-game .pg-rank.gold { color: #fbbf24; }
.played-game .pg-main { min-width: 0; }
.played-game .pg-title {
  font-weight: 600;
  color: var(--text);
  font-size: 14.5px;
}
.played-game .pg-meta {
  color: var(--text-faint);
  font-size: 12.5px;
  margin-top: 2px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.played-game .pg-meta .sep { opacity: .5; }
.played-game .pg-progress { min-width: 0; }
.played-game .pg-progress-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.played-game .pg-progress-bar {
  height: 4px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
}
.played-game .pg-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width .3s ease;
}
.played-game .pg-coryat {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.played-game .pg-coryat.neg { color: var(--bad); }
.played-game .pg-resume {
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
}

.pg-finals {
  display: flex; align-items: center;
  gap: 8px;
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
}
.pg-mini-lbl {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.pg-mini-val {
  display: inline-flex; align-items: center; gap: 2px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.pg-mini-val.good { color: var(--good); }
.pg-mini-val.bad  { color: var(--bad); }
/* DD breakdown colors its right/wrong counts via <b> children (the mockup
   used inline green/red there), so target descendants too. */
.pg-mini-val .good { color: var(--good); }
.pg-mini-val .bad  { color: var(--bad); }
.pg-mini-slash {
  color: var(--text-faint);
  font-weight: 400;
  margin: 0 1px;
}
.pg-mini-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 2px;
}

/* ============== ANKI SUGGESTIONS ============== */
.anki-block {
  border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--accent) 4%, var(--bg-elev));
}
.anki-toggle {
  appearance: none; background: none; border: 0;
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  text-align: left;
}
.anki-toggle:hover { color: var(--text); }
.anki-toggle .chev {
  margin-left: auto;
  transition: transform .2s ease;
  color: var(--text-faint);
}
.anki-block.open .anki-toggle .chev { transform: rotate(180deg); color: var(--text-dim); }
.anki-toggle-text b {
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.anki-glyph {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #2e86d4;
  color: white;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 13px;
  border-radius: 5px;
  flex-shrink: 0;
}
.anki-body {
  padding: 0 16px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.anki-head-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
  gap: 12px;
}
.anki-help {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}
.anki-copy-all {
  appearance: none;
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .12s ease;
  white-space: nowrap;
}
.anki-copy-all:hover { background: color-mix(in oklab, var(--accent) 88%, white); }
.anki-card {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px 6px 10px;
}
.anki-text {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  background: transparent;
}
.anki-copy {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font: inherit; font-size: 11.5px; font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .12s ease;
  flex-shrink: 0;
}
.anki-copy:hover {
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 50%, var(--border-strong));
}

/* ============== SETTINGS TAB ============== */
.settings-pane {
  display: flex; flex-direction: column;
  gap: var(--space-4);
}
.setting-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-5);
  padding: var(--space-5);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.setting-main { flex: 1; min-width: 0; }
.setting-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -.005em;
  margin-bottom: 6px;
}
.setting-desc {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.55;
}
.setting-example {
  margin-top: var(--space-3);
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 4px;
}
.setting-example-label {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint);
}
.setting-example code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
}

/* iOS-style switch */
.switch {
  appearance: none;
  width: 44px; height: 24px;
  background: var(--border-strong);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  transition: background .15s ease;
  flex-shrink: 0;
  padding: 0;
}
.switch.on { background: var(--accent); }
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .18s cubic-bezier(.4,.0,.2,1);
}
.switch.on .switch-thumb { transform: translateX(20px); }

/* Replay banner on summary */
.replay-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: var(--space-4);
}
.replay-banner svg { color: var(--accent); flex-shrink: 0; }

.played-section-h {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 18px;
  color: var(--text);
  margin: var(--space-5) 0 var(--space-2);
  letter-spacing: -.005em;
}
.played-section-h:first-child { margin-top: 0; }

/* ============== TEST CARD — TWO-STEP ============== */
.step-block { display: flex; flex-direction: column; gap: var(--space-3); }
.step-label {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 2px;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.step-num.optional {
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.step-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -.01em;
  color: var(--text);
}
.step-req {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-left: 4px;
}
.step-req.optional { color: var(--text-faint); }
.step-help {
  color: var(--text-dim);
  font-size: 13px;
  margin: -2px 0 4px 30px;
}

.step-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-3) 0 var(--space-2);
}

/* ============== CLUE DECK / ITERATOR ============== */
.deck {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
}
.deck-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg-elev) 60%, var(--bg-elev-2));
  gap: var(--space-3);
}
.deck-title {
  display: flex; align-items: baseline; gap: 8px;
  min-width: 0;
}
.deck-explore {
  display: inline-flex; align-items: center; gap: 5px;
  flex-shrink: 0;
  font-size: 12px; font-weight: 500;
  color: var(--accent); text-decoration: none;
  white-space: nowrap;
}
.deck-explore:hover { text-decoration: underline; }
.deck-explore svg { opacity: .8; }
.deck-title .answer {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--accent);
  letter-spacing: -.005em;
}
.deck-title .label {
  font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint);
}
.deck-pager {
  display: flex; align-items: center; gap: 4px;
  color: var(--text-dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.deck-pager .count {
  padding: 0 8px;
  font-weight: 600;
  color: var(--text);
}
.deck-arrow {
  appearance: none; background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s ease;
}
.deck-arrow:hover:not(:disabled) {
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 50%, var(--border));
  background: var(--accent-soft);
}
.deck-arrow:disabled {
  opacity: .35; cursor: not-allowed;
}
.deck-body {
  padding: var(--row-pad-y) var(--row-pad-x);
}
.deck-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
}

/* the inner clue when shown inside a deck loses its own border */
.deck .clue-row {
  border: 0;
  padding: 0;
  background: transparent;
}
.deck .clue-row:hover { border: 0; }

/* dot pagination beneath the iterator (only when 2-5 cards) */
.deck-dots {
  display: flex; justify-content: center; gap: 6px;
  padding: 4px 0 12px;
}
.deck-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  border: 0; padding: 0; cursor: pointer;
  transition: background .12s ease, transform .12s ease;
}
.deck-dot.on { background: var(--accent); transform: scale(1.3); }

/* Answer-card carousel (clue_row.html). The deck CSS above was ported in
   Phase 2; these wire it to the in-card member pager. */
.deck-topbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.deck-slide.is-hidden { display: none; }

/* ============== SUMMARY — missed-response decks ============== */
.missed-deck {
  margin-bottom: var(--space-4);
}
.missed-deck .deck-title .answer { color: var(--bad); }
.missed-deck.is-archive .deck-title .answer { color: var(--accent); }
.missed-deck .your-clue {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: var(--space-2);
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}
.missed-deck .your-clue::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--bad);
  border-radius: 50%;
  display: inline-block;
}
.missed-deck .archive-clue::before { background: var(--accent); }

.row { display: flex; align-items: center; gap: var(--space-3); }
.row-wrap { flex-wrap: wrap; }
.sp { flex: 1; }
.muted { color: var(--text-dim); }
.tiny { font-size: 12px; }
.center { text-align: center; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }

/* hide focus rings except keyboard */
:focus:not(:focus-visible) { outline: none; }

/* ============================================================
   PER-CARD ACTIONS (cluster expander + Anki suggestion button)
   ============================================================ */
.clue-row-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.row-action-btn {
  appearance: none; background: transparent; border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.row-action-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev-2);
  color: var(--text);
}
.row-action-btn.on {
  background: color-mix(in oklab, var(--accent) 14%, var(--bg-elev-2));
  border-color: color-mix(in oklab, var(--accent) 35%, var(--border-strong));
  color: var(--text);
}
.row-action-btn b { color: var(--text); font-weight: 600; }
.row-action-btn .ra-icon {
  display: inline-flex; color: var(--text-faint);
}
.row-action-btn.on .ra-icon { color: var(--accent); }
.row-action-btn .ra-chev {
  width: 14px; height: 14px;
  color: var(--text-faint);
  transition: transform .18s ease;
}
.row-action-btn .ra-chev.open { transform: rotate(180deg); color: var(--text-dim); }
.row-action-btn.anki-action .anki-glyph {
  width: 18px; height: 18px;
  border-radius: 4px;
  background: color-mix(in oklab, var(--accent) 18%, var(--bg-elev-2));
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-style: italic;
  font-size: 11px;
}

/* Similar-clues expander */
.similar-panel {
  margin-top: 10px;
  padding: 10px 12px 4px;
  background: color-mix(in oklab, var(--accent) 4%, var(--bg-elev));
  border: 1px solid color-mix(in oklab, var(--accent) 18%, var(--border));
  border-radius: var(--radius-md);
}
.similar-head {
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 8px;
}
.similar-head b { color: var(--text); font-weight: 600; }
.similar-list {
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 6px;
}
.similar-mini {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.similar-mini .sm-head {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  margin-bottom: 4px;
}
.similar-mini .sm-value {
  font-size: 11px;
  padding: 1px 6px;
}
.similar-mini .sm-air {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 11px;
}
.similar-mini .sm-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

/* Inline anki block for a single card */
.anki-inline {
  margin-top: 10px;
  padding: 10px 12px;
  background: color-mix(in oklab, var(--accent) 6%, var(--bg-elev));
  border: 1px solid color-mix(in oklab, var(--accent) 22%, var(--border));
  border-radius: var(--radius-md);
}
.anki-inline-lbl {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 6px;
}
.anki-inline-lbl .anki-glyph {
  width: 18px; height: 18px;
  border-radius: 4px;
  background: color-mix(in oklab, var(--accent) 22%, var(--bg-elev-2));
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-style: italic;
  font-size: 11px;
}
.anki-inline-row {
  display: flex; gap: 8px; align-items: stretch;
}
.anki-inline-row .anki-text {
  flex: 1;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.anki-inline-row .anki-copy {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s ease;
}
.anki-inline-row .anki-copy:hover { background: color-mix(in oklab, var(--accent) 88%, white); }
.anki-inline-row .anki-copy.fail {
  background: var(--bad);
  color: white;
}
.anki-inline-row .anki-text {
  cursor: text;
  user-select: all;
}
.anki-fallback-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.anki-fallback-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-elev-2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
}

/* Multi-topic chips */
.cat-topics {
  display: inline-flex; align-items: center; gap: 4px;
  flex-wrap: wrap;
}
.cat-topic-chip {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid color-mix(in oklab, var(--accent) 28%, var(--border));
  background: color-mix(in oklab, var(--accent) 8%, var(--bg-elev-2));
  border-radius: 999px;
  font-style: italic;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}
.cat-topic-plus {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
}

/* Stats live-update note + per-row delta */
.stats-live-note {
  font-size: 12px;
  color: var(--text-dim);
  background: color-mix(in oklab, var(--accent) 5%, var(--bg-elev));
  border: 1px solid color-mix(in oklab, var(--accent) 16%, var(--border));
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin: 10px 0 14px;
}
.stats-live-note b { color: var(--text); font-weight: 600; }
.ts-delta {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  background: color-mix(in oklab, var(--good) 18%, var(--bg-elev-2));
  border-radius: 999px;
  color: var(--good);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}

/* Played game completed card is now a button */
.played-game-btn {
  width: 100%;
  text-align: left;
  appearance: none;
  cursor: pointer;
  color: inherit;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font: inherit;
  /* Inset the contents so the rank number / chevron aren't flush against the
     card border (the base .played-game row has padding: 14px 0). */
  padding: 14px 16px;
  transition: border-color .14s ease, background .14s ease, transform .12s ease;
}
.played-game-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev-2);
}
.played-game-btn:active { transform: translateY(1px); }
.played-game-btn .h-cta {
  display: inline-flex;
  color: var(--text-faint);
  margin-left: 8px;
}
/* :hover/:focus-visible .h-cta accent + nudge live in the consolidated
   pagination latent-fix block (one canonical rule). */

/* Small Anki toggle row inside the profile dropdown */
.pmenu-row-toggle {
  appearance: none;
  width: 100%;
  background: none;
  border: 0;
  display: flex; align-items: center; justify-content: space-between;
  text-align: left;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.pmenu-row-toggle:hover { background: var(--bg-elev-2); }
.anki-glyph-menu {
  width: 18px; height: 18px;
  border-radius: 4px;
  background: color-mix(in oklab, var(--accent) 18%, var(--bg-elev-2));
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-style: italic;
  font-size: 11px;
}
.switch.switch-sm {
  width: 32px;
  height: 18px;
  flex: 0 0 32px;
}
.switch.switch-sm .switch-thumb {
  top: 2px; left: 2px;
  width: 14px; height: 14px;
}
.switch.switch-sm.on .switch-thumb { transform: translateX(14px); }


/* ============================================================
   LOCKED CLUE MODAL — once you select a clue, you commit to it
   ============================================================ */
.modal-veil-locked {
  /* veil takes no clicks; only the modal's own buttons can dismiss */
  cursor: default;
}
.modal-veil-locked > * {
  cursor: auto;
}

/* ============================================================
   MOBILE / RESPONSIVE TIGHT-UPS
   ============================================================ */

/* Tablet / small laptop */
@media (max-width: 900px) {
  .page { padding: var(--space-5) var(--space-4) var(--space-6); }
  .game-page { padding-top: var(--space-4); }

  .hud {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "left right"
      "center center";
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }
  .hud-left  { grid-area: left; }
  .hud-right { grid-area: right; }
  .hud-center { grid-area: center; }
  .hud-game-id { margin-top: 4px; }
}

/* Phone */
@media (max-width: 640px) {
  :root {
    --space-7: 32px;
    --space-6: 24px;
  }

  .page { padding: var(--space-4) var(--space-3) var(--space-5); }

  /* Header */
  .hdr { padding: 0 var(--space-3); }
  .hdr-title { font-size: 18px; }
  .hdr-title .j { font-size: 22px; }

  /* Hero */
  .hero { margin: var(--space-5) 0 var(--space-4); }
  .hero h1 { font-size: clamp(28px, 8vw, 38px); }
  .hero p { font-size: 14px; padding: 0 var(--space-2); }

  /* Cards / forms */
  .card-head { padding: 12px 14px; gap: var(--space-3); }
  .card-icon { width: 38px; height: 38px; flex-basis: 38px; font-size: 19px; }
  .card-head-title { font-size: 15.5px; }
  .card-head-sub { font-size: 12.5px; }
  .card-body { padding: 4px 16px 18px; }

  .input, .select { font-size: 16px; padding: 12px 14px; } /* 16px prevents iOS zoom */
  .btn { padding: 12px 18px; font-size: 14px; }

  .launch-opt { padding: 12px 14px; }
  .launch-opt .input { max-width: 100%; }
  .lo-max { display: none; }
  .lo-desc { padding-left: 0; font-size: 12.5px; }

  /* Resume banner stacks */
  .resume-banner {
    flex-wrap: wrap;
    padding: 12px 14px;
    gap: 10px;
  }
  .resume-banner .btn { flex: 1 1 100%; }

  /* HUD — compact phone layout */
  .hud {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "left right"
      "center center";
    gap: var(--space-2) var(--space-3);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
  }
  .hud-round-tag, .hud-coryat-lbl { font-size: 10px; }
  .hud-round-name { font-size: 17px; }
  .hud-coryat-val { font-size: 22px; }
  .hud-right { gap: 4px; }
  .end-btn { padding: 5px 10px; font-size: 12px; }
  .hud-progress-lbl { font-size: 11px; margin-bottom: 3px; text-align: left; }
  .hud-game-id { text-align: left; font-size: 11px; }

  /* Board — switch to vertical scroll on tiny screens, but keep the 6×5 grid */
  .board { padding: 4px; gap: 3px; }
  .board-row { gap: 3px; }
  .board-cell { padding: 4px; aspect-ratio: 5 / 4; }
  .board-cat { font-size: 9.5px; line-height: 1.1; aspect-ratio: auto; min-height: 40px; }
  .board-cat .cat-back { inset: 4px; }
  .board-cat .cat-front { inset: auto; }
  .board-cat .cat-back-j { font-size: 22px; }
  .board-clue { font-size: 14px; }
  .board-skip { top: -32px; font-size: 11.5px; padding: 5px 10px; }

  /* Final round */
  .final-round { padding: var(--space-6) var(--space-4); min-height: 260px; }
  .fr-category { font-size: clamp(22px, 6vw, 32px); }
  .fr-result { font-size: 22px; }
  .fr-answer { font-size: 15px; }

  /* Modal */
  .modal-veil { padding: var(--space-3); align-items: flex-end; }
  .clue-modal {
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-lg);
    max-height: calc(100vh - 24px);
    overflow-y: auto;
  }
  .clue-modal .cm-meta { gap: 8px; margin-bottom: var(--space-3); }
  .cm-topic { font-size: 14px; }
  .cm-cat { font-size: 11.5px; }
  .cm-value { font-size: 22px; }
  .cm-clue { font-size: clamp(18px, 5vw, 24px); margin: var(--space-3) 0 var(--space-4); }
  .cm-response { font-size: 20px; }
  .cm-actions { flex-wrap: wrap; gap: 8px; }
  .cm-actions .btn { flex: 1 1 calc(50% - 4px); padding: 12px 14px; font-size: 13.5px; }
  .cm-actions .btn-primary.btn-block { flex: 1 1 100%; }
  .cm-actions .mark-skip { flex: 1 1 100%; order: 3; } /* "Didn't buzz" stacks below */

  /* DD splash */
  .dd-splash { padding: var(--space-6) var(--space-4); }
  .dd-lbl { font-size: 32px; }
  .dd-lbl.big { font-size: 56px; }

  /* Confirm dialog */
  .confirm-dialog { padding: var(--space-4); }
  .cd-actions { flex-direction: column-reverse; }
  .cd-actions .btn { width: 100%; }

  /* Score summary */
  .big-coryat { font-size: clamp(54px, 14vw, 80px); }
  .score-hero { margin: var(--space-4) 0 var(--space-5); }
  .score-breakdown { gap: var(--space-2); margin-bottom: var(--space-5); }
  .sb-cell { padding: 12px 8px; }
  .sb-cell .v { font-size: 24px; }
  .sb-cell .l { font-size: 10.5px; }

  .game-stats-grid { gap: var(--space-2); }
  .gs-cell { padding: 10px 12px; }
  .gs-value { font-size: 18px; }

  /* Profile */
  .profile-head { gap: var(--space-3); margin-bottom: var(--space-4); padding-bottom: var(--space-4); }
  .profile-head .avatar-lg { width: 56px; height: 56px; font-size: 22px; }
  .profile-head h1 { font-size: 24px; }
  .tabs { gap: 2px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab { padding: 10px 12px; font-size: 13px; white-space: nowrap; }

  /* Played-game card — stack into two rows */
  .played-game {
    grid-template-columns: 28px 1fr auto;
    grid-template-areas:
      "rank main score"
      "rank progress progress";
    gap: 8px 12px;
    padding: 12px 0;
  }
  .played-game .pg-rank     { grid-area: rank; align-self: center; }
  .played-game .pg-main     { grid-area: main; }
  .played-game .pg-coryat   { grid-area: score; font-size: 17px; }
  .played-game .pg-progress { grid-area: progress; }
  .played-game .pg-resume   { grid-area: score; }

  /* Results / history rows */
  .clue-row { padding: 12px 14px; }
  .results-summary { flex-wrap: wrap; gap: 8px; }

  /* Deck head */
  .deck-head { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .deck-title .answer { font-size: 15px; }

  /* Test page */
  .clue-card { padding: var(--space-5) var(--space-4); min-height: 0; }
  .clue-card .clue { font-size: clamp(20px, 5.5vw, 28px); margin: var(--space-3) 0 var(--space-5); }
  .test-actions { flex-wrap: wrap; gap: 8px; padding-top: var(--space-4); }
  .test-actions .btn { flex: 1 1 calc(50% - 4px); padding: 12px 14px; font-size: 13.5px; }
  .test-actions .mark-skip { flex: 1 1 100%; order: 3; }

  /* Footer */
  .ftr { padding: var(--space-4) var(--space-3); }
}

/* Very small phones */
@media (max-width: 380px) {
  .board-cat { font-size: 8.5px; }
  .board-clue { font-size: 12.5px; }
  .hud-round-name { font-size: 15px; }
  .hud-coryat-val { font-size: 19px; }
  .big-coryat { font-size: 48px; }
}

/* Touch — kill hover transforms that feel sticky on tap */
@media (hover: none) {
  .board-clue:hover:not(:disabled) { transform: none; }
  .btn:hover { background: inherit; }
  .btn-primary:hover { background: var(--accent); }
}

/* Landscape phones — keep modal scrollable */
@media (max-height: 560px) and (orientation: landscape) {
  .modal-veil { align-items: center; padding: 12px; }
  .clue-modal { max-height: calc(100vh - 24px); overflow-y: auto; padding: var(--space-4); }
  .cm-clue { margin: var(--space-2) 0 var(--space-3); font-size: 20px; }
  .dd-lbl { font-size: 28px; }
  .dd-lbl.big { font-size: 44px; }
}


/* ============================================================
   [hidden] respect — paired display:none rules
   ============================================================
   Several classes set `display: <something>` explicitly, which
   wins over the user-agent stylesheet's [hidden] { display: none }.
   The mockup never hit this because React conditionally rendered
   elements out of the DOM entirely; in the Jinja port these
   elements live in the DOM full-time and we toggle [hidden] via
   JS. Without these paired rules, [hidden] sets the attribute but
   the element still renders visible.

   Fixed earlier for .loading-screen and .card-body (see those
   rules above). Below are the remaining surfaces flagged by the
   audit:
     - .danger-confirm  → Delete-account confirm visible always
     - .name-edit       → Display-name editor visible always
     - .clue-card       → FOUC flash on test page load
     - .archive-chip    → FOUC flash on test page load
     - .badge           → DD/TS badges flash on test page load
     - .btn             → mark buttons flash on test page load
*/
.danger-confirm[hidden] { display: none; }
.name-edit[hidden]      { display: none; }
.clue-card[hidden]      { display: none; }
.archive-chip[hidden]   { display: none; }
.badge[hidden]          { display: none; }
.btn[hidden]            { display: none; }

/* ============================================================
   LOADING SCREEN — quiet brand pulse + board flip-in skeleton
   ============================================================ */

/* Shared overlay. Sits over everything, gentle fade-in so a sub-100ms flash
   never visually registers. */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  padding: var(--space-5);
  animation: ls-fade-in .22s ease-out both;
}
/* Server-rendered already-open (e.g. the test page continuing the home
   overlay): no entrance fade — it must look continuous with the prior page's
   overlay, not re-appear. */
.loading-screen.ls-instant { animation: none; }
/* The mockup conditionally rendered LoadingScreen via React, so the existing
   .loading-screen { display: flex } never collided with the [hidden] attr.
   In the Jinja version the overlay lives in the DOM at all times and we
   toggle visibility via [hidden] — so we need to make sure the attribute
   actually wins. */
.loading-screen[hidden] { display: none; }
@keyframes ls-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Mode switch — single overlay element carries both pulse + board markup;
   parent class on .loading-screen picks which wrapper renders. */
.ls-pulse-content,
.ls-board-content {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
}
.loading-screen.ls-pulse .ls-pulse-content { display: flex; }
.loading-screen.ls-board .ls-board-content { display: flex; }

.loading-screen .ls-label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -.005em;
  color: var(--text-dim);
  text-align: center;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  text-wrap: pretty;
}

/* ── Mode: pulse ─────────────────────────────────────────────── */
.ls-pulse .ls-mark {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(72px, 14vw, 120px);
  line-height: 1;
  color: var(--accent);
  letter-spacing: -.02em;
  display: inline-flex;
  align-items: baseline;
  filter: drop-shadow(0 8px 24px color-mix(in oklab, var(--accent) 35%, transparent));
  animation: ls-pulse 1.6s ease-in-out infinite;
}
.ls-pulse .ls-mark-j { color: var(--accent); }
.ls-pulse .ls-mark-bang {
  color: var(--accent);
  margin-left: 2px;
}
@keyframes ls-pulse {
  0%, 100% { transform: scale(1);    opacity: .85; }
  50%      { transform: scale(1.06); opacity: 1;   }
}

/* Animated trailing dots beside the label */
.ls-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 1px;
  align-items: baseline;
  position: relative;
  top: -2px;
}
.ls-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: ls-dot 1.4s ease-in-out infinite;
}
.ls-dots span:nth-child(2) { animation-delay: .18s; }
.ls-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes ls-dot {
  0%, 60%, 100% { transform: translateY(0);   opacity: .35; }
  30%           { transform: translateY(-3px); opacity: 1;   }
}

/* ── Mode: board ─────────────────────────────────────────────── */
.ls-board .ls-board-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  width: min(560px, 92vw);
  background: color-mix(in oklab, var(--accent) 18%, var(--bg-elev));
  padding: 8px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
}
.theme-light .ls-board .ls-board-grid {
  background: color-mix(in oklab, var(--accent) 12%, var(--bg-elev));
}
.ls-tile {
  aspect-ratio: 16 / 11;
  background: linear-gradient(160deg, #0a1d6e, #060CE9);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: rotateY(90deg);
  transform-origin: center;
  perspective: 600px;
  animation:
    ls-tile-flip-in .4s cubic-bezier(.4,.1,.2,1) forwards,
    ls-tile-pulse  2.4s ease-in-out 1s infinite;
}
.ls-tile-j {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(22px, 4.4vw, 36px);
  color: #fbbf24;
  text-shadow: 0 2px 6px rgba(0,0,0,.4);
  letter-spacing: -.01em;
}
@keyframes ls-tile-flip-in {
  from { opacity: 0; transform: rotateY(90deg) scale(.9); }
  to   { opacity: 1; transform: rotateY(0)   scale(1);    }
}
@keyframes ls-tile-pulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.18); }
}

@media (max-width: 640px) {
  .ls-board .ls-board-grid { gap: 4px; padding: 5px; }
  .ls-board .ls-tile-j     { font-size: clamp(16px, 5vw, 26px); }
  .loading-screen .ls-label { font-size: 15px; }
}

/* Honor reduced motion — kill the looping animations, keep the layout. */
@media (prefers-reduced-motion: reduce) {
  .ls-pulse .ls-mark { animation: none; opacity: 1; }
  .ls-dots span      { animation: none; opacity: .7; }
  .ls-tile {
    animation: none;
    opacity: 1;
    transform: none;
  }
}


/* ============================================================
   Settings — data block + danger zone
   ============================================================ */
.settings-block {
  margin-top: var(--space-5);
  padding: var(--card-pad);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.settings-block-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -.01em;
  color: var(--text);
  margin: 0 0 4px;
}
.settings-block-desc {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: var(--space-4);
  text-wrap: pretty;
}
.settings-block-foot {
  margin-top: var(--space-3);
  color: var(--text-faint);
  font-size: 12.5px;
}
.settings-block-foot a {
  color: var(--text-dim);
  border-bottom: 1px dotted var(--text-faint);
  padding-bottom: 1px;
}
.settings-block-foot a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.data-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.data-list li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: var(--space-3);
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.data-list li:first-child { border-top: none; padding-top: 0; }
.data-key {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.data-val {
  color: var(--text);
  font-size: 14px;
  text-wrap: pretty;
}

/* Danger zone */
.settings-block.danger {
  border-color: color-mix(in oklab, var(--bad) 35%, var(--border));
  background: color-mix(in oklab, var(--bad) 4%, var(--bg-elev));
}
.settings-block.danger .settings-block-title { color: var(--bad); }

.btn-danger-outline {
  background: transparent;
  color: var(--bad);
  border: 1px solid color-mix(in oklab, var(--bad) 55%, var(--border));
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-danger-outline:hover {
  background: color-mix(in oklab, var(--bad) 8%, transparent);
  border-color: var(--bad);
}

.btn-danger {
  background: var(--bad);
  color: #fff;
  border: 1px solid var(--bad);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: filter .15s, transform .08s;
}
.btn-danger:hover { filter: brightness(.92); }
.btn-danger:active { transform: translateY(1px); }

.danger-confirm {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg);
  border: 1px solid color-mix(in oklab, var(--bad) 30%, var(--border));
  border-radius: 10px;
}
.danger-confirm-msg {
  color: var(--text);
  font-size: 14px;
  text-wrap: pretty;
}
.danger-confirm-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  .data-list li { grid-template-columns: 1fr; gap: 4px; }
  .data-key { font-size: 10.5px; }
}

/* ── Phase 7: Profile additions ───────────────────────────────────── */

/* Tab panels — all rendered, only one visible at a time (hash-route). */
.tab-panel        { display: none; }
.tab-panel-on     { display: block; }

/* Inline status pills next to a session title. */
.tag {
  display: inline-block; padding: 1px 8px; margin-left: 8px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em; text-transform: uppercase; vertical-align: middle;
}
.tag-live  { background: color-mix(in oklab, var(--good) 14%, transparent); color: var(--good); }
.tag-muted { background: var(--bg-elev-2); color: var(--text-faint); }

/* Stats headline cards (top of Stats tab). */
.stats-headlines {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin: 20px 0 28px;
}
.stats-card {
  padding: 16px 18px; border-radius: 12px;
  background: var(--surface-1, rgba(255,255,255,0.04));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
}
.stats-card-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stats-card-value { font-family: 'Newsreader', serif; font-size: 32px; font-weight: 600; margin: 6px 0 2px; }
.stats-card-value.muted { color: var(--muted); }
.stats-card-sub   { font-size: 12.5px; color: var(--muted); }
/* Phase F mockup-parity: good/bad accent on Strongest/Weakest cards.
   Mirrors the .sh-card.good/.bad pattern at styles.css line 1233. */
.stats-card.good { border-color: color-mix(in oklab, var(--good) 35%, var(--border)); }
.stats-card.bad  { border-color: color-mix(in oklab, var(--bad)  35%, var(--border)); }
.stats-card.good .stats-card-value { color: var(--good); }
.stats-card.bad  .stats-card-value { color: var(--bad); }
@media (max-width: 720px) { .stats-headlines { grid-template-columns: 1fr; } }

.stats-threshold-note { text-align: center; margin: -6px 0 18px; max-width: 60ch; margin-inline: auto; }

/* Per-topic accuracy bars. */
.stats-bars     { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.stats-bar-row  {
  display: grid; grid-template-columns: 160px 1fr 130px;
  gap: 14px; align-items: center;
}
.stats-bar-name  { font-size: 13.5px; font-weight: 500; }
.stats-bar-track {
  position: relative; height: 10px; border-radius: 5px;
  background: var(--surface-2, rgba(255,255,255,0.06)); overflow: hidden;
}
.stats-bar-fill  { height: 100%; background: var(--good); }
/* Percentage and fraction sit in their own fixed-width, right-aligned
   sub-columns so the % values line up vertically regardless of how many
   digits the count has (6/6 vs 23/31 vs 234/567). */
.stats-bar-val   {
  display: grid; grid-template-columns: 34px 56px;
  justify-content: end; column-gap: 8px; align-items: baseline;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.stats-bar-val .sbv-pct  { text-align: right; }
.stats-bar-val .sbv-frac { text-align: right; }
@media (max-width: 520px) {
  .stats-bar-row { grid-template-columns: 1fr; gap: 4px; }
  .stats-bar-val { justify-content: start; }
}

/* ====================================================================
   PAGINATION (handoff) — numbered pager (Profile) + load-more (Search).
   Built on existing tokens; the .tag fix and the history-row-btn half of
   the row-hover fix already shipped (item 6 / above). What's added here:
   the played-game-btn half + chevron grid, the Primetime split styling,
   and the two pagination components.
   ==================================================================== */

/* a11y live-region utility (both surfaces) */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Latent fix 1a (played-game half): <a> rows never fired the chevron hover. */
.played-game-btn:hover,
.played-game-btn:focus-visible { text-decoration: none; }
.played-game-btn:hover  .h-cta,
.played-game-btn:focus-visible .h-cta {
  color: var(--accent);
  transform: translateX(2px);
}
/* Latent fix 1b: completed button variant has a 5th child (chevron) — give it
   a 5th grid column so it sits inline; drop it on mobile (tile is the target). */
.played-game-btn { grid-template-columns: 32px 1fr 200px auto auto; }
@media (max-width: 640px) { .played-game-btn .h-cta { display: none; } }

/* Primetime discriminator + the played-games split explainer line. */
.badge.tj-badge {
  background: color-mix(in oklab, var(--warn) 16%, transparent);
  color: var(--warn);
  border-color: color-mix(in oklab, var(--warn) 32%, var(--border));
  text-transform: none;
  letter-spacing: .02em;
  margin-left: 8px;   /* breathing room after the "Game #NNNN" title */
}
.played-section-note {
  color: var(--text-faint);
  font-size: 12.5px;
  margin: -2px 0 var(--space-3);
  line-height: 1.5;
  max-width: 60ch;
}

/* Primetime Celebrity game banner (game.js builds .primetime-banner /
   .pt-icon / .pt-text / .pt-dismiss — the CSS was the missing piece). The
   message is centered; the dismiss × is absolutely placed so it doesn't
   offset the centering. */
.primetime-banner {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap;
  text-align: center;
  margin: 0 0 var(--space-4);
  padding: 12px 44px;
  background: color-mix(in oklab, var(--warn) 12%, var(--bg-elev));
  border: 1px solid color-mix(in oklab, var(--warn) 32%, var(--border));
  border-radius: var(--radius-md);
  color: var(--text); font-size: 14px; line-height: 1.5;
}
.primetime-banner .pt-icon { color: var(--warn); font-size: 16px; }
.primetime-banner .pt-text b { color: var(--warn); }
.primetime-banner .pt-dismiss {
  position: absolute; top: 8px; right: 10px;
  background: none; border: 0; cursor: pointer;
  color: var(--text-faint); font-size: 20px; line-height: 1; padding: 0 4px;
}
.primetime-banner .pt-dismiss:hover { color: var(--text); }

/* ── Surface 1 — numbered pager (Profile tabs) ───────────────────────── */
.list-summary {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.list-summary .count { color: var(--text-dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.list-summary .count b { color: var(--text); font-weight: 600; }
.list-summary .count .range { color: var(--text); font-weight: 600; }

.pager {
  margin-top: var(--space-5);
  display: flex; align-items: center; justify-content: center;
  gap: var(--space-3); flex-wrap: wrap;
}
.pager-list { display: flex; align-items: center; gap: 4px; }
.pager a,
.pager span.pager-cell {
  --h: 38px;
  min-width: var(--h); height: var(--h); padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font: inherit; font-weight: 600; font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-decoration: none; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  user-select: none;
}
.pager a:hover {
  color: var(--text); border-color: var(--border-strong);
  background: var(--bg-elev-2); text-decoration: none;
}
.pager a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pager [aria-current="page"] {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-text); cursor: default;
}
.pager [aria-disabled="true"] { opacity: .4; cursor: not-allowed; pointer-events: none; }
.pager-gap { color: var(--text-faint); padding: 0 2px; min-width: 22px; text-align: center; user-select: none; }
.pager-edge svg { width: 15px; height: 15px; }
.pager-edge .edge-txt { display: inline; }
.pager-compact { display: none; }
@media (max-width: 560px) {
  .pager-list { display: none; }
  .pager-compact {
    display: inline-flex; align-items: center;
    height: 38px; padding: 0 14px;
    border-radius: 999px;
    background: var(--bg-elev-2); border: 1px solid var(--border);
    color: var(--text); font-weight: 600; font-size: 13.5px;
    font-variant-numeric: tabular-nums;
  }
  .pager-edge .edge-txt { display: none; }
}

/* ── Surface 2 — load more (Search results, per difficulty section) ───── */
.group-count { color: var(--text-faint); font-size: 13px; margin-left: auto; font-variant-numeric: tabular-nums; }
.group-count b { color: var(--text-dim); font-weight: 600; }
.load-more {
  appearance: none; width: 100%;
  margin-top: var(--space-3);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 12px 18px;
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.load-more:hover {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-soft); text-decoration: none;
}
.load-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.load-more .lm-count { color: var(--text-faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.load-more svg { width: 16px; height: 16px; }
.load-more-done {
  width: 100%; margin-top: var(--space-3);
  text-align: center; padding: 10px;
  color: var(--text-faint); font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  border-top: 1px dashed var(--border);
}
.clue-list .is-folded { display: none; }
