:root {
  --navy: #12181f;
  --navy-2: #1c2530;
  --blue: #0a5edb;
  --blue-dark: #084aad;
  --green: #1a7a3c;
  --red: #c0281f;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --border: #d7dbe0;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-soft);
  font-family: var(--sans);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

/* Leave room for the disclaimer footer under every screen. */
:root { --footer-h: 48px; }
.screen {
  min-height: calc(100vh - var(--footer-h));
  display: flex;
  align-items: center;
  justify-content: center;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ---------- Nav (signed-in users) ---------- */
:root { --nav-h: 56px; }
body.has-nav .screen { min-height: calc(100vh - var(--nav-h) - var(--footer-h)); }
.app-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--navy);
  color: #fff;
}
.app-nav-inner {
  max-width: 960px;
  margin: 0 auto;
  min-height: var(--nav-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.app-nav-brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-nav-brand .login-brand-mark { margin: 0; background: var(--blue); }
.app-nav-links { display: flex; gap: 4px; flex: 1; }
.app-nav-links a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 6px;
}
.app-nav-links a:hover { color: #fff; background: var(--navy-2); }
.app-nav-links a.active { color: #fff; background: var(--navy-2); }
.app-nav-user { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.nav-greeting { color: rgba(255,255,255,0.9); }
.app-nav .nav-logout { color: #9cc2ff; }
@media (max-width: 640px) {
  .app-nav-inner { gap: 4px 12px; padding: 8px 16px; }
  .app-nav-links { order: 3; flex-basis: 100%; margin: 0 -12px; }
  .app-nav-user { margin-left: auto; }
  .nav-greeting { display: none; }
}

/* ---------- Pages (history, profile) ---------- */
.page-screen { align-items: flex-start; padding: 32px 16px; box-sizing: border-box; }
.page-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.06);
  padding: 28px 32px;
  width: 720px;
  max-width: 100%;
  box-sizing: border-box;
}
.page-title { margin: 0 0 16px; font-size: 22px; }
.page-empty { color: var(--ink-soft); font-size: 14px; text-align: center; padding: 24px 0; margin: 0; }
.page-footnote { color: var(--ink-soft); font-size: 12px; margin: 16px 0 0; text-align: center; }

.history-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-chip {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
}
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item { border-top: 1px solid var(--border); }
.history-item:first-child { border-top: none; }
.history-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 14px;
  align-items: center;
  padding: 14px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}
.history-link:hover { background: var(--bg-soft); }
.history-link:hover .history-opponent { color: var(--blue); }
.result-badge {
  grid-row: span 2;
  width: 64px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 6px 0;
  border-radius: 6px;
  text-transform: uppercase;
}
.result-badge.win { background: #eaf7ee; color: var(--green); }
.result-badge.loss { background: #fdecea; color: var(--red); }
.result-badge.draw, .result-badge.abandoned { background: var(--bg-soft); color: var(--ink-soft); }
.history-opponent { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.history-score { font-weight: 800; font-size: 16px; text-align: right; white-space: nowrap; }
.history-meta, .history-correct { font-size: 12px; color: var(--ink-soft); }
.history-correct { text-align: right; white-space: nowrap; }
.history-more { display: block; margin: 16px auto 0; }

.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-name { margin: 0; font-size: 22px; }
.profile-username { color: var(--ink-soft); font-size: 14px; margin-top: 2px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.stat-value { font-size: 24px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.profile-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 20px;
  margin: 0 0 24px;
  font-size: 14px;
}
.profile-details dt { color: var(--ink-soft); font-weight: 600; }
.profile-details dd { margin: 0; overflow-wrap: anywhere; }
.profile-history-link { display: inline-block; text-decoration: none; }
.end-history-link { display: block; margin-top: 14px; color: var(--blue); font-size: 14px; font-weight: 600; text-decoration: none; }
.end-history-link:hover { text-decoration: underline; }
@media (max-width: 520px) {
  .page-card { padding: 20px 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Login ---------- */
.login-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 40px 44px 44px;
  width: 420px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand-mark {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
}
.login-brand h1 { margin: 0 0 6px; font-size: 24px; }
.login-sub { margin: 0; color: var(--ink-soft); font-size: 14px; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-soft);
  margin: 18px 0 6px;
}
.text-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  outline: none;
}
.text-input:focus { border-color: var(--blue); }

.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-pill {
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.choice-pill.selected {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.primary-btn {
  width: 100%;
  margin-top: 26px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
}
.primary-btn:disabled { background: #9fb8d8; cursor: not-allowed; }
.primary-btn:not(:disabled):hover { background: var(--blue-dark); }

.secondary-btn {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.secondary-btn:hover { border-color: var(--ink-soft); }

.error-text { color: var(--red); font-size: 13px; margin: 12px 0 0; text-align: center; }

/* ---------- Auth ---------- */
.auth-tabs {
  display: flex;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 4px;
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}
.auth-tab.selected { color: var(--blue); border-bottom-color: var(--blue); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 16px;
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.google-btn { display: flex; justify-content: center; min-height: 44px; }
.google-btn:empty { display: none; }
.google-placeholder-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  color: #3c4043;
  font-size: 14px;
  font-weight: 500;
}
.google-placeholder-btn:hover { background: #f8faff; border-color: #d2e3fc; }

.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.guest-note { margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }
.guest-note .link-btn { padding: 0; font-size: 13px; }
.auth-back { display: block; margin: -16px 0 12px -4px; }
.account-name { font-weight: 700; font-size: 15px; }
.account-stats { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.link-btn {
  background: none;
  border: none;
  padding: 4px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

.field-hint { margin: 6px 0 0; min-height: 18px; font-size: 12px; color: var(--ink-soft); }
.field-hint.ok { color: var(--green); }
.field-hint.bad { color: var(--red); }
.auth-forgot { display: block; margin: 8px 0 0 auto; padding: 0; font-size: 13px; }
.auth-panel-title { margin: 0 0 8px; font-size: 18px; text-align: center; }
.auth-panel-text { margin: 0 0 4px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; text-align: center; }
.auth-panel-back { display: block; margin: 16px auto 0; }
.auth-notice { text-align: center; }
.auth-notice-icon { font-size: 34px; color: var(--blue); margin-bottom: 4px; }
.auth-resend { margin-top: 18px; }

.auth-terms { margin: 18px 0 0; font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.5; }
.auth-terms a { color: var(--blue); }

/* ---------- Legal pages (terms.html) ---------- */
.legal-body { height: auto; background: var(--bg-soft); }
.legal-page {
  max-width: 720px;
  margin: 32px auto;
  padding: 32px 36px 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  line-height: 1.6;
  font-size: 15px;
  box-sizing: border-box;
}
.legal-page h1 { margin: 16px 0 4px; font-size: 28px; }
.legal-page h2 { margin: 28px 0 8px; font-size: 18px; }
.legal-page ul { padding-left: 22px; }
.legal-page li { margin-bottom: 4px; }
.legal-updated { color: var(--ink-soft); font-size: 13px; margin: 0 0 20px; }
.legal-callout {
  background: var(--bg-soft);
  border-left: 3px solid var(--blue);
  border-radius: 6px;
  padding: 12px 16px;
}
.legal-back { color: var(--blue); font-size: 14px; font-weight: 600; text-decoration: none; }
.legal-back:hover { text-decoration: underline; }
@media (max-width: 760px) {
  .legal-page { margin: 0; border-radius: 0; border-left: none; border-right: none; padding: 24px 16px 32px; }
}

/* ---------- Queue ---------- */
.queue-card { text-align: center; }
.spinner {
  width: 46px; height: 46px;
  border: 4px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.queue-detail { color: var(--ink-soft); margin-bottom: 22px; }

/* ---------- Exam ---------- */
#screen-exam { display: flex; flex-direction: column; align-items: stretch; min-height: calc(100vh - var(--footer-h)); padding: 0; }

.exam-topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.topbar-sep { opacity: 0.4; }
.topbar-center { position: absolute; left: 50%; transform: translateX(-50%); }
.timer-pill {
  background: var(--navy-2);
  border-radius: 20px;
  padding: 6px 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.timer-pill.low-time { background: var(--red); }
.topbar-right { display: flex; align-items: flex-end; gap: 12px; }
.topbar-right .hud-vs { padding-bottom: 4px; }
/* Opponent is color-coded light red throughout the match (header, progress bar, results). */
.hud-opponent { color: #ff9b94; }
.hud-opponent .hud-name, .hud-opponent .hud-role { opacity: 0.9; }
.hud-player { text-align: right; line-height: 1.15; }
.hud-name { display: block; font-size: 11px; opacity: 0.75; }
.hud-role {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  opacity: 0.55;
}
.hud-score { display: block; font-size: 18px; font-weight: 800; }
.hud-vs { font-size: 11px; opacity: 0.6; }

.exam-toolbar {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 20px;
  flex-shrink: 0;
}
.tool-btn {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-btn:hover { border-color: var(--ink-soft); }
.exit-btn { margin-left: auto; color: var(--red); }
.exit-btn:hover { border-color: var(--red); }
.tool-btn .tool-icon { font-size: 13px; font-weight: 800; }
.tool-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.exam-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--bg);
}

/* highlight mode gives a text-selection cursor cue over highlightable text */
.highlight-mode-active .passage-text,
.highlight-mode-active .question-stem {
  cursor: text;
}
mark.user-highlight {
  background: #ffe066;
  color: inherit;
  border-radius: 2px;
  cursor: pointer;
  padding: 0 1px;
}
mark.user-highlight:hover { background: #ffd43b; }

/* ---------- Answer eliminator ---------- */
.mcq-option { position: relative; }
.mcq-option.crossed .content { text-decoration: line-through; opacity: 0.45; }
.mcq-option.crossed .bubble { opacity: 0.45; }
.eliminate-toggle {
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-soft);
  background: #fff;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
  margin-left: auto;
}
.eliminator-active .eliminate-toggle { display: flex; }
.mcq-option.crossed .eliminate-toggle {
  border-color: var(--red);
  color: var(--red);
  background: #fdecea;
}

/* ---------- Desmos calculator panel ---------- */
.calculator-panel {
  position: fixed;
  top: 80px;
  right: 24px;
  width: 400px;
  height: 420px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.18);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.calculator-header {
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
  user-select: none;
}
.calculator-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}
.calculator-mount { flex: 1; }

.stimulus-pane {
  width: 48%;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 32px 36px;
  background: #fff;
}
.passage-text {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  color: var(--ink);
}

.question-pane { flex: 1; overflow-y: auto; }
.question-pane-inner { max-width: 640px; margin: 0 auto; padding: 32px 36px 60px; }

.question-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.q-number-badge {
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  width: 26px; height: 26px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.mark-review-btn {
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  display: flex; align-items: center; gap: 5px;
}
.mark-review-btn.marked { color: #b8860b; }
.flag-icon { font-size: 15px; }

.question-stem {
  font-size: 17px;
  line-height: 1.6;
  margin-bottom: 22px;
}
.question-stem p:first-child { margin-top: 0; }
.question-stem img, .question-stem svg { max-width: 100%; height: auto; }

.mcq-options { display: flex; flex-direction: column; gap: 12px; }
.mcq-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
  text-align: left;
  font-size: 15px;
  line-height: 1.5;
}
.mcq-option:not(.disabled):hover { border-color: #9db8d8; }
.mcq-option .bubble {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.mcq-option .content p { margin: 0; }
.mcq-option.selected { border-color: var(--blue); background: #eaf2ff; }
.mcq-option.selected .bubble { background: var(--blue); border-color: var(--blue); color: #fff; }
.mcq-option.correct { border-color: var(--green); background: #eaf7ee; }
.mcq-option.correct .bubble { background: var(--green); border-color: var(--green); color: #fff; }
.mcq-option.incorrect { border-color: var(--red); background: #fdecea; }
.mcq-option.incorrect .bubble { background: var(--red); border-color: var(--red); color: #fff; }
.mcq-option.disabled { cursor: default; pointer-events: none; }

.spr-input-wrap { max-width: 280px; }
.spr-submit-btn { margin-top: 14px; }

.waiting-banner {
  margin-top: 22px;
  padding: 12px 16px;
  background: #fff7e6;
  border: 1px solid #f0d68a;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #7a5a00;
}

.result-banner {
  margin-top: 24px;
  padding: 18px 20px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.result-headline { font-size: 16px; font-weight: 800; margin-bottom: 6px; }
.result-headline.correct { color: var(--green); }
.result-headline.incorrect { color: var(--red); }
.result-points { font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.rationale-details summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--blue); }
.rationale-content { margin-top: 10px; font-size: 14px; line-height: 1.6; color: var(--ink-soft); }
.next-countdown { margin-top: 12px; font-size: 12px; color: var(--ink-soft); font-style: italic; }

.exam-bottombar {
  background: var(--navy);
  color: #fff;
  height: 50px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.nav-dots { display: flex; gap: 6px; }
.nav-dot {
  width: 22px; height: 22px;
  border-radius: 4px;
  background: var(--navy-2);
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
}
.nav-dot.current { outline: 2px solid #fff; }
.nav-dot.correct { background: var(--green); color: #fff; }
.nav-dot.incorrect { background: var(--red); color: #fff; }
.opp-progress { width: 240px; max-width: 45%; }
.opp-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 5px;
  color: rgba(255,255,255,0.85);
}
.opp-progress-label span:first-child { font-weight: 700; }
.opp-progress-track {
  height: 8px;
  border-radius: 4px;
  background: var(--navy-2);
  overflow: hidden;
}
.opp-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: #ff9b94;
  transition: width 0.4s ease;
}
.opp-progress-label span:first-child { color: #ff9b94; }

/* ---------- Trademark disclaimer footer ---------- */
.site-footer {
  min-height: var(--footer-h);
  box-sizing: border-box;
  padding: 10px 16px;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.site-footer a { color: var(--ink-soft); margin-left: 8px; white-space: nowrap; }
.site-footer a:hover { color: var(--blue); }
.legal-body .site-footer { margin-bottom: 8px; }
body.in-match .site-footer {
  background: var(--navy);
  color: rgba(255,255,255,0.6);
  border-top: 1px solid var(--navy-2);
}
body.in-match .site-footer a { color: rgba(255,255,255,0.6); }
body.in-match .site-footer a:hover { color: #fff; }

/* ---------- Match review ---------- */
.review-back { color: var(--blue); font-size: 14px; font-weight: 600; text-decoration: none; }
.review-back:hover { text-decoration: underline; }
.review-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 14px;
  align-items: center;
  margin: 16px 0;
}
.review-header .history-opponent { font-size: 20px; }
.review-header .history-score { font-size: 20px; }
.review-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.review-summary { font-weight: 700; font-size: 15px; }
.review-filter { font-size: 14px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.review-list { list-style: none; margin: 0; padding: 0; }
.review-q { padding: 22px 0; border-top: 1px solid var(--border); }
.review-q:first-child { border-top: none; }
.review-q-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; }
.review-status { font-size: 12px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; padding: 4px 10px; border-radius: 6px; }
.review-status.correct { background: #eaf7ee; color: var(--green); }
.review-status.incorrect { background: #fdecea; color: var(--red); }
.review-status.timeout, .review-status.not-reached { background: var(--bg-soft); color: var(--ink-soft); }
.review-meta { font-size: 12px; color: var(--ink-soft); }
.review-stimulus {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  background: var(--bg-soft);
  border-left: 3px solid var(--border);
  padding: 12px 16px;
  margin-bottom: 14px;
  overflow-x: auto;
}
.review-stem { font-size: 15px; line-height: 1.6; margin-bottom: 14px; overflow-x: auto; }
.review-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.review-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
}
.review-option .bubble {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.review-option .content { flex: 1; overflow-x: auto; }
/* Question-bank HTML wraps text in <p>; drop the outer margins so it lines up with the label. */
.review-option .content > :first-child,
.review-stem > :first-child,
.review-stimulus > :first-child { margin-top: 0; }
.review-option .content > :last-child,
.review-stem > :last-child,
.review-stimulus > :last-child { margin-bottom: 0; }
.review-option .content { padding-top: 3px; }
.review-option .tag { flex-shrink: 0; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.3px; padding-top: 4px; }
.review-option.correct { border-color: var(--green); background: #eaf7ee; }
.review-option.correct .bubble { background: var(--green); border-color: var(--green); color: #fff; }
.review-option.correct .tag { color: var(--green); }
.review-option.wrong { border-color: var(--red); background: #fdecea; }
.review-option.wrong .bubble { background: var(--red); border-color: var(--red); color: #fff; }
.review-option.wrong .tag { color: var(--red); }
.review-spr { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 14px; margin-bottom: 12px; }
.review-spr strong { font-weight: 700; }
.review-spr .wrong { color: var(--red); }
.review-spr .right { color: var(--green); }
@media (max-width: 520px) {
  .review-header .history-opponent, .review-header .history-score { font-size: 17px; }
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(18, 24, 31, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--bg);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 28px;
  width: 400px;
  max-width: 100%;
  box-sizing: border-box;
}
.modal-title { margin: 0 0 8px; font-size: 19px; }
.modal-text { margin: 0 0 24px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.danger-btn {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
}
.danger-btn:hover { background: #a3211a; }

/* ---------- End screen ---------- */
.end-card {
  background: #fff;
  border-radius: 12px;
  padding: 44px;
  width: 460px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}
.end-headline { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.end-subtitle { font-size: 14px; color: var(--ink-soft); margin-bottom: 24px; min-height: 1em; }
.end-stats { font-size: 13px; color: var(--ink); margin-top: 6px; }
.end-scores { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 30px; }
.end-score-block { flex: 1; }
.end-score-label { font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
.end-score-value { font-size: 34px; font-weight: 800; }
.end-elo { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.end-opponent .end-score-label,
.end-opponent .end-score-value { color: #d9534f; }
.end-score-divider { font-size: 22px; color: var(--ink-soft); }

.toast {
  position: fixed;
  bottom: calc(var(--footer-h) + 16px); /* above the disclaimer footer */
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 100;
}

@media (max-width: 860px) {
  .stimulus-pane { display: none !important; }
  .topbar-center { display: none; }
}
