/* Sergeant Exam Practice Quiz — dual theme.
   Light (default): "Clean Editorial" — warm paper, serif display type, hairlines.
   Dark: "Midnight Precinct" — deep navy, glowing gold accents.
   Switched via data-theme on <html> (see assets/js/theme.js). */

/* ============ LIGHT — Clean Editorial ============ */
:root {
  --bg: #faf8f4;
  --card: #ffffff;
  --ink: #1c1710;
  --ink-soft: #4a443a;
  --muted: #8a8175;
  --brand: #1d4ed8;
  --brand-dark: #173fae;
  --brand-ink: #ffffff;
  --green: #157f3d;
  --green-bg: #e9f5ee;
  --red: #c81e1e;
  --red-bg: #fdeeee;
  --amber: #b45309;
  --amber-bg: #fdf3e3;
  --line: #e9e2d4;
  --track: #ece5d5;
  --panel: #f4f1e9;
  --panel-line: #d8cdae;
  --chip-bg: #efe9da;
  --chip-ink: #5c5546;
  --scen-bg: #e3e9fb;
  --scen-ink: #2c3a9e;
  --cite-bg: #dbe4fa;
  --cite-ink: #1a3fa0;
  --opt-active: #eef2ff;
  --letter-bg: #efe9da;
  --selected-bg: #e8effe;
  --info-bg: #e8effe;
  --info-ink: #1a3fa0;
  --info-line: #bcd0f7;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(28, 23, 16, 0.07);
  --display-font: Georgia, 'Palatino Linotype', 'Times New Roman', serif;
  --display-weight: 700;
  --kicker: #8a8175;
  --topbar-bg: #ffffff;
  --topbar-ink: #1c1710;
  --topbar-muted: #8a8175;
  --topbar-line: #e9e2d4;
  --strip-bg: #14110c;
  --strip-num: #ffffff;
  --strip-dim: #a89f8d;
  --strip-lbl: #b7ad9c;
  --strip-div: rgba(255, 255, 255, 0.13);
  --strip-btn-bg: transparent;
  --strip-btn-ink: #ffffff;
  --strip-btn-line: rgba(255, 255, 255, 0.45);
  --strip-btn-hover: rgba(255, 255, 255, 0.14);
  --mini-btn-bg: #1c1710;
  --mini-btn-ink: #ffffff;
}

/* ============ DARK — Midnight Precinct ============ */
[data-theme="dark"] {
  --bg: #070b16;
  --card: #0f1626;
  --ink: #f3eee1;
  --ink-soft: #c6c0ae;
  --muted: #8b95ad;
  --brand: #e2ab3c;
  --brand-dark: #f0c05a;
  --brand-ink: #14100a;
  --green: #4ade80;
  --green-bg: #12351f;
  --red: #f87171;
  --red-bg: #3c1518;
  --amber: #fbbf24;
  --amber-bg: #3a2a10;
  --line: rgba(255, 255, 255, 0.10);
  --track: rgba(255, 255, 255, 0.09);
  --panel: #141d33;
  --panel-line: #33415e;
  --chip-bg: #1c2742;
  --chip-ink: #c6d2e8;
  --scen-bg: #2c3560;
  --scen-ink: #b9c6ff;
  --cite-bg: #1e2c4d;
  --cite-ink: #bcd0f7;
  --opt-active: #1a2440;
  --letter-bg: #1c2742;
  --selected-bg: #1e2c4d;
  --info-bg: #1e2c4d;
  --info-ink: #bcd0f7;
  --info-line: #33415e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --display-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display-weight: 800;
  --kicker: #e2ab3c;
  --topbar-bg: rgba(7, 11, 22, 0.9);
  --topbar-ink: #f3eee1;
  --topbar-muted: #8b95ad;
  --topbar-line: rgba(255, 255, 255, 0.09);
  --strip-bg: linear-gradient(160deg, #182238 0%, #0e1528 70%);
  --strip-num: #e2ab3c;
  --strip-dim: #8b95ad;
  --strip-lbl: #8b95ad;
  --strip-div: rgba(255, 255, 255, 0.09);
  --strip-btn-bg: linear-gradient(180deg, #f0c05a, #e2ab3c);
  --strip-btn-ink: #14100a;
  --strip-btn-line: transparent;
  --strip-btn-hover: #f0c05a;
  --mini-btn-bg: #e2ab3c;
  --mini-btn-ink: #14100a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
[data-theme="dark"] body {
  background-image: radial-gradient(1200px 500px at 50% -120px, #101a36 0%, rgba(16, 26, 54, 0) 60%);
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
a { color: var(--brand); }

/* Display type — serif in Editorial, heavy sans in Midnight */
h1, h2, .hero-title, .qb-head h2, .score-hero .pct, .wordmark {
  font-family: var(--display-font);
  font-weight: var(--display-weight);
  letter-spacing: -0.01em;
}
h1 { font-size: 24px; margin: 18px 0 8px; }
h2 { font-size: 19px; margin: 22px 0 10px; }
h3 { font-size: 16px; margin: 14px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Top bar */
.topbar {
  background: var(--topbar-bg);
  color: var(--topbar-ink);
  border-bottom: 1px solid var(--topbar-line);
  position: sticky; top: 0; z-index: 50;
}
[data-theme="dark"] .topbar { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; gap: 8px; flex-wrap: wrap; }
.brand { color: var(--topbar-ink); text-decoration: none; font-size: 20px; }
.brand em { font-style: normal; color: var(--brand); }
.nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nav a { color: var(--topbar-muted); text-decoration: none; font-size: 14px; }
.nav a:hover { color: var(--topbar-ink); }
.who { color: var(--topbar-ink); font-size: 14px; font-weight: 600; }
.theme-btn {
  background: transparent; border: 1px solid var(--topbar-line); color: var(--topbar-ink);
  border-radius: 999px; font-size: 15px; padding: 4px 10px; cursor: pointer;
}
.theme-btn:hover { opacity: 0.75; }

/* Cards & layout */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

/* Flash messages */
.flash { border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 15px; }
.flash.info { background: var(--info-bg); color: var(--info-ink); border: 1px solid var(--info-line); }
.flash.success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.flash.error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }

/* Forms */
.form label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
.form input[type=text], .form input[type=email], .form input[type=password] {
  width: 100%; padding: 13px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
}
.form input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.btn {
  display: inline-block; border: 0; cursor: pointer; text-decoration: none;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 16px;
  padding: 13px 22px; border-radius: 12px; margin-top: 14px; text-align: center;
}
.btn:hover { background: var(--brand-dark); }
.btn.block { display: block; width: 100%; }
.btn.secondary { background: var(--chip-bg); color: var(--ink); }
.btn.small-btn { font-size: 14px; padding: 9px 14px; margin-top: 8px; }
.btn.danger { background: var(--red); color: #fff; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Timer choice (start screen) */
.timer-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
@media (min-width: 640px) { .timer-choices { grid-template-columns: repeat(4, 1fr); } }
.timer-choice input { display: none; }
.timer-choice span {
  display: block; text-align: center; padding: 12px 8px; font-weight: 700; font-size: 15px;
  border: 2px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--card); color: var(--ink);
}
.timer-choice input:checked + span { border-color: var(--brand); background: var(--selected-bg); }

/* Quiz stat strip — 3-segment bar (score · timer · question). */
.quiz-strip { margin: 0 0 12px; }
.quiz-strip .hero-stat strong { font-variant-numeric: tabular-nums; }
.quiz-strip .hero-stat.danger strong { color: #ff9d9d; }
#blitz-score-stat { position: relative; }
#blitz-score-stat .score-float { color: #7dffa8; }

/* Quiz options — big tappable buttons */
.q-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.q-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; }
.chip {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px;
  border-radius: 999px; background: var(--chip-bg); color: var(--chip-ink);
}
.chip.scenario { background: var(--scen-bg); color: var(--scen-ink); }
.q-text { font-size: 18px; font-weight: 600; margin: 8px 0 14px; }
.flag-btn {
  flex-shrink: 0; background: var(--card); border: 2px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 700;
  cursor: pointer; color: var(--muted); margin-top: 6px;
}
.flag-btn.active { border-color: var(--amber); color: var(--amber); background: var(--amber-bg); }
.opt-btn {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px; margin: 10px 0; font-size: 16px; color: var(--ink);
  min-height: 60px;
}
.opt-btn .letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; background: var(--letter-bg);
  font-weight: 800; margin-right: 10px; flex-shrink: 0; color: var(--ink);
}
.opt-btn .opt-text { vertical-align: middle; }
.opt-btn:not(:disabled):active { background: var(--opt-active); }
.opt-btn:disabled { cursor: default; opacity: 1; }
.opt-btn.is-correct { border-color: var(--green); background: var(--green-bg); }
.opt-btn.is-correct .letter { background: var(--green); color: #fff; }
.opt-btn.is-wrong { border-color: var(--red); background: var(--red-bg); }
.opt-btn.is-wrong .letter { background: var(--red); color: #fff; }
.opt-btn.is-selected { border-color: var(--brand); background: var(--selected-bg); }
.opt-btn.is-selected .letter { background: var(--brand); color: var(--brand-ink); }
.opt-btn.eliminated { opacity: 0.45; }
.opt-btn.eliminated .opt-text { text-decoration: line-through; }
.opt-btn .why {
  display: none; margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--line); font-size: 14px; color: var(--muted);
}
.explain-panel {
  display: none; background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: var(--radius); padding: 14px; margin-top: 14px; font-size: 15px;
}
.explain-panel .citation, .explain-panel .proc-chip {
  display: none; margin-top: 8px; margin-right: 6px; font-size: 13px; font-weight: 700;
  background: var(--cite-bg); color: var(--cite-ink); padding: 4px 10px; border-radius: 999px;
}
.quiz-nav { display: none; gap: 10px; margin-top: 16px; }
.quiz-nav.always { display: flex; }
.progress { height: 10px; background: var(--track); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width 0.25s; }
.hint-btn {
  background: var(--card); border: 2px dashed var(--amber); color: var(--amber);
  border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.hint-btn:disabled { opacity: 0.4; cursor: default; }
.hint-used { font-size: 13px; color: var(--amber); font-weight: 700; }

/* Dashboard */
.set-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .set-grid { grid-template-columns: 1fr 1fr; } }
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.set-card h3 { margin: 0 0 6px; font-size: 15px; }
.set-card .best { font-size: 26px; font-weight: 800; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.new { background: var(--chip-bg); color: var(--muted); }
.badge.progress { background: var(--amber-bg); color: var(--amber); }
.badge.done { background: var(--green-bg); color: var(--green); }
.bar { height: 12px; background: var(--track); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.bar.good > span { background: var(--green); }
.bar.mid > span { background: var(--amber); }
.bar.bad > span { background: var(--red); }
.bar.big { height: 22px; }
.weak-row { margin: 10px 0; }
.weak-row .lbl { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
/* Resume table: 3 invisible columns — quiz name | number | resume button. */
.resume-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.resume-table td { padding: 7px 6px; vertical-align: middle; border: 0; }
.resume-table .rt-title { font-weight: 700; }
.resume-table .rt-num { white-space: nowrap; }
.resume-table .rt-btn { text-align: right; white-space: nowrap; }
.btn.resume-btn {
  font-size: 12px; padding: 6px 12px; margin-top: 0; border-radius: 8px;
  background: var(--mini-btn-bg); color: var(--mini-btn-ink);
}
.btn.resume-btn:hover { filter: brightness(1.1); }
.final-overall { text-align: center; padding: 18px; }
.final-overall .pct { font-size: 40px; font-weight: 800; }
.final-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 640px) { .final-mini { grid-template-columns: 1fr 1fr 1fr; } }
.final-mini .mini { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 13px; }
.final-mini .mini .t { font-weight: 700; margin-bottom: 4px; }

/* Tables (admin) */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
table.tbl th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.inline-form { display: inline; }
.link-btn { background: none; border: 0; color: var(--brand); cursor: pointer; font-size: 14px; padding: 4px 6px; text-decoration: underline; }
.link-btn.danger { color: var(--red); }

/* Question navigator */
.navigator { margin: 12px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.navigator summary { padding: 12px 14px; cursor: pointer; font-weight: 700; list-style: none; color: var(--ink); }
.navigator summary::-webkit-details-marker { display: none; }
.navigator summary::before { content: "▸ "; color: var(--muted); }
.navigator[open] summary::before { content: "▾ "; }
.nav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 2px 12px 8px; }
@media (min-width: 640px) { .nav-grid { grid-template-columns: repeat(10, 1fr); } }
.nav-cell {
  text-align: center; padding: 8px 2px; border-radius: 8px; border: 1px solid var(--line);
  text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 700; background: var(--card);
}
.nav-cell.answered { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.nav-cell.current { outline: 2px solid var(--brand); outline-offset: 1px; }
.legend { display: inline-block; margin-right: 12px; }
.legend.answered::before { content: "■ "; color: var(--green); }
.legend.unanswered::before { content: "■ "; color: var(--muted); }

/* One-page results */
.result-list { margin: 8px 0 20px; }
.result-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; margin: 6px 0;
  text-decoration: none; color: var(--ink); background: var(--card); font-size: 15px;
}
.result-row:hover { border-color: var(--brand); }
.result-row .rr-mark { font-weight: 800; width: 22px; text-align: center; }
.result-row.is-right .rr-mark { color: var(--green); }
.result-row.is-missed .rr-mark { color: var(--red); }
.result-row .rr-num { font-weight: 800; min-width: 44px; }
.result-row .rr-answers { flex: 1; }
.result-row .rr-go { color: var(--muted); font-weight: 800; }

/* Score screen */
.score-hero { text-align: center; padding: 26px 12px; }
.score-hero .pct { font-size: 56px; }
.score-hero .sub { color: var(--muted); font-size: 16px; }
.show-filter { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.show-filter a {
  font-size: 14px; font-weight: 700; text-decoration: none; color: var(--muted);
  border: 2px solid var(--line); border-radius: 999px; padding: 6px 14px; background: var(--card);
}
.show-filter a.on { border-color: var(--brand); color: var(--brand); }
.flag-mark { color: var(--amber); font-weight: 800; }

/* Review */
.rev-q { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 14px 0; background: var(--card); }
.rev-opt { padding: 8px 10px; border-radius: 8px; margin: 6px 0; font-size: 15px; border: 1px solid transparent; }
.rev-opt.user { border-color: var(--brand); background: var(--selected-bg); }
.rev-opt.correct { border-color: var(--green); background: var(--green-bg); }
.rev-opt.user.correct { border-color: var(--green); background: var(--green-bg); }
.rev-opt.user.wrong { border-color: var(--red); background: var(--red-bg); }
.rev-why { font-size: 13px; color: var(--muted); margin-top: 2px; }

.footer { margin: 30px 0 20px; color: var(--muted); font-size: 13px; text-align: center; }
.center { text-align: center; }
.mt { margin-top: 16px; }

/* Question bank — numbered row list (dashboard Practice / Final Exams) */
.qb-kicker {
  font-size: 11px; font-weight: 800; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--kicker); margin: 26px 0 2px;
}
.qb-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 4px; }
.qb-head h2 { font-size: 26px; margin: 0; }
.qb-count { color: var(--muted); font-size: 14px; white-space: nowrap; }
.qb-rows { margin: 0 0 8px; display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .qb-rows { grid-template-columns: 1fr 1fr; } }
.qb-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 0;
}
.qb-num {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: var(--brand);
}
.qb-main { flex: 1; min-width: 0; }
.qb-title { font-size: 16px; font-weight: 700; }
.qb-sub { font-size: 13px; color: var(--muted); margin: 2px 0 8px; }
.qb-bar { height: 10px; background: var(--track); border-radius: 999px; overflow: hidden; }
.qb-bar > span { display: block; height: 100%; border-radius: 999px; }
.qb-bar.good > span { background: var(--green); }
.qb-bar.mid > span { background: var(--amber); }
.qb-bar.bad > span { background: var(--red); }
.qb-bar.na > span { background: var(--track); }
.qb-side { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.qb-label { font-size: 13px; font-weight: 700; white-space: nowrap; }
.qb-label.good { color: var(--green); }
.qb-label.na { color: var(--muted); font-weight: 600; }
.qb-btn { margin-top: 0; min-height: 44px; display: inline-flex; align-items: center; }
@media (min-width: 640px) {
  .qb-head h2 { font-size: 30px; }
  .qb-num { width: 60px; height: 60px; font-size: 20px; }
}

/* Study dashboard hero (mobile-first) */
.hero { margin: 24px 0 4px; }
.hero-top { display: flex; flex-direction: column; gap: 14px; }
.hero-title { font-size: 30px; margin: 2px 0 6px; }
.hero-text p { margin: 0; color: var(--ink-soft); }
.hero-ring { position: relative; width: 104px; height: 104px; flex-shrink: 0; }
.hero-ring svg { width: 100%; height: 100%; display: block; }
.hero-ring .track { stroke: var(--track); }
.hero-ring .fg { stroke: var(--red); }
.hero-ring.ring-good .fg { stroke: var(--green); }
.hero-ring.ring-mid .fg { stroke: var(--amber); }
.hero-ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
.hero-ring-label strong { font-size: 21px; }
.hero-ring-label span { font-size: 11px; color: var(--muted); }
.hero-rule { border: 0; border-top: 2px solid var(--ink); margin: 14px 0 0; opacity: 0.8; }
/* Stat strip — signature element: near-black in Editorial, glowing navy/gold in Midnight */
.hero-stats {
  display: grid; grid-template-columns: 1fr; background: var(--strip-bg);
  border-radius: 12px; margin: 14px 0 4px; overflow: hidden;
}
[data-theme="dark"] .hero-stats {
  border: 1px solid rgba(226, 171, 60, 0.28);
  box-shadow: 0 0 44px rgba(226, 171, 60, 0.10), 0 18px 50px rgba(0, 0, 0, 0.5);
}
.hero-stat { padding: 18px 20px; border-top: 1px solid var(--strip-div); }
.hero-stat:first-child { border-top: 0; }
.hero-stat strong {
  display: block; color: var(--strip-num); font-size: 30px; line-height: 1.1;
  font-family: var(--display-font); font-weight: var(--display-weight);
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .hero-stat strong { text-shadow: 0 0 26px rgba(226, 171, 60, 0.35); }
.hero-stat strong .dim { font-size: 16px; font-weight: 600; color: var(--strip-dim); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.hero-stat .lbl {
  display: block; margin-top: 4px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--strip-lbl);
}
/* Buttons sitting on the dark strip */
.hero-stat .btn {
  background: var(--strip-btn-bg); color: var(--strip-btn-ink);
  border: 1px solid var(--strip-btn-line);
  font-size: 13px; padding: 8px 18px; border-radius: 999px; margin-top: 12px;
}
.hero-stat .btn:hover { background: var(--strip-btn-hover); }
[data-theme="dark"] .hero-stat .btn { box-shadow: 0 4px 18px rgba(226, 171, 60, 0.35); }
@media (min-width: 640px) {
  .hero-top { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .hero-title { font-size: 34px; }
  .hero-stats { grid-template-columns: repeat(3, 1fr); }
  .hero-stat { border-top: 0; border-left: 1px solid var(--strip-div); }
  .hero-stat:first-child { border-left: 0; }
}

/* Quiz top bar (every quiz view) */
.quiz-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0 12px; }
.qtb-back { font-weight: 700; text-decoration: none; font-size: 15px; }
.qtb-form { margin: 0; }
.qtb-restart {
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  font-weight: 700; font-size: 14px; padding: 10px 16px;
  min-height: 44px; cursor: pointer;
}
.qtb-restart:hover { border-color: var(--brand); color: var(--brand); }

/* ---- Interactive feedback for buttons & tappable controls ----------------- */
.btn,
.qb-btn,
.qtb-restart,
.qtb-back,
.opt-btn,
.hint-btn,
.flag-btn,
.nav-cell,
.timer-choice span,
.link-btn,
.show-filter a,
.result-row,
.theme-btn {
  transition: background-color .15s ease, border-color .15s ease, color .15s ease,
    transform .15s ease, box-shadow .15s ease, opacity .15s ease, filter .15s ease;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
@media (hover: hover) {
  .btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
  }
  .qtb-restart:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, .12);
  }
  .qtb-back:hover { opacity: .8; }
  .opt-btn:not(:disabled):not(.is-correct):not(.is-wrong):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .10);
  }
  .hint-btn:not(:disabled):hover,
  .flag-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .10);
  }
  .nav-cell:hover {
    border-color: var(--brand);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .10);
  }
  .timer-choice span:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .10);
  }
  .link-btn:hover { opacity: .75; }
  .show-filter a:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .10);
  }
  .result-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
  }
  .theme-btn:hover { transform: translateY(-1px); }
  .hero-stat .btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  }
}
.btn:not(:disabled):active,
.qtb-restart:not(:disabled):active,
.hint-btn:not(:disabled):active,
.flag-btn:not(:disabled):active,
.nav-cell:active,
.timer-choice span:active,
.show-filter a:active,
.result-row:active,
.theme-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}
.opt-btn:not(:disabled):not(.is-correct):not(.is-wrong):active {
  transform: translateY(1px);
  box-shadow: none;
}
.qtb-back:active,
.link-btn:active { opacity: .6; }
.btn:focus-visible,
.qb-btn:focus-visible,
.qtb-restart:focus-visible,
.opt-btn:focus-visible,
.hint-btn:focus-visible,
.flag-btn:focus-visible,
.nav-cell:focus-visible,
.link-btn:focus-visible,
.show-filter a:focus-visible,
.result-row:focus-visible,
.theme-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.btn:disabled,
.qtb-restart:disabled,
.hint-btn:disabled,
.flag-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* --- Interactive features: TTS, Daily/Blitz/Flashcards, leaderboard --- */
.streak { font-weight: 700; }
.streak-line { margin: 10px 0; font-size: 1.05rem; }
.hero-stat .mode-btn { margin-top: 10px; }

/* ---- Responsiveness & smoothness polish ---- */
html { scroll-behavior: smooth; }
a, button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.btn, .opt-btn {
  transition: transform .08s ease, background-color .15s ease,
              border-color .15s ease, box-shadow .15s ease;
}
.btn:active, .opt-btn:active { transform: scale(.985); }
@keyframes opt-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.018); }
  100% { transform: scale(1); }
}
.opt-btn.is-correct, .opt-btn.is-wrong,
.opt-btn.is-selected, .opt-btn.picked { animation: opt-pop .22s ease; }
.opt-btn.picked { background: var(--opt-active); border-color: var(--brand); }
#progress-fill, .bar > span, .progress > span { transition: width .45s ease; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.card { animation: card-in .25s ease; }
@keyframes blitz-pulse { 50% { opacity: .55; } }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.blitz-timer { font-family: ui-monospace, monospace; font-size: 2.5rem; font-weight: 800; text-align: center; }
.flashcard { perspective: 1000px; cursor: pointer; }
.fc-inner { position: relative; transform-style: preserve-3d; transition: transform .5s; }
.flashcard.flipped .fc-inner { transform: rotateY(180deg); }
.fc-front, .fc-back { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.fc-back { position: absolute; inset: 0; transform: rotateY(180deg); }
tr.lb-row.me, .lb-row.me { background: var(--selected-bg, #eef); font-weight: 700; }
.daily-q { margin: 12px 0; }
.daily-q .opt-btn { margin: 8px 0; }
.tts-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#tts-auto-wrap { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
/* Blitz HUD (legacy card styles — kept for compatibility) */
.blitz-hud { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 12px; }
.blitz-ring { position: relative; width: 78px; height: 78px; flex: 0 0 auto; }
.blitz-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--track); stroke-width: 8; }
.ring-fill { fill: none; stroke: var(--brand); stroke-width: 8; stroke-linecap: round;
  transition: stroke-dashoffset .3s linear, stroke .3s ease; }
.blitz-ring .blitz-timer { position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  font-family: ui-monospace, monospace; font-size: 1.55rem; font-weight: 800; }
.blitz-ring.low .ring-fill { stroke: var(--red); }
.blitz-ring.low .blitz-timer { color: var(--red); animation: blitz-pulse 1s ease infinite; }
.blitz-scorebox { position: relative; flex: 1 1 auto; min-width: 110px; }
.blitz-score { font-size: 2rem; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.blitz-score-label { font-size: 11px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted); }
.score-float { position: absolute; left: 2px; top: -8px; font-weight: 800;
  font-size: 1.15rem; color: var(--green); pointer-events: none;
  animation: score-float 1s ease forwards; }
@keyframes score-float { to { transform: translateY(-26px); opacity: 0; } }
.blitz-combo { display: flex; align-items: center; gap: 6px;
  font-size: 1.35rem; font-weight: 800; }
.combo-flame { display: inline-block; font-size: 1.7rem;
  filter: grayscale(1); opacity: .4; transition: transform .2s ease, filter .2s ease, opacity .2s ease; }
.blitz-combo.lit .combo-flame { filter: none; opacity: 1; }
.combo-mult { font-variant-numeric: tabular-nums; }
@keyframes combo-pop { 0% { transform: scale(1); } 40% { transform: scale(1.4); } 100% { transform: scale(1); } }
.blitz-combo.pop .combo-flame { animation: combo-pop .3s ease; }
.blitz-progress { flex: 1 1 100%; height: 8px; background: var(--track);
  border-radius: 999px; overflow: hidden; }
.blitz-progress-fill { height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #7aa5f8);
  transition: width .4s ease; }
.blitz-count { flex: 1 1 100%; font-size: 13px; color: var(--muted);
  text-align: right; margin-top: -10px; }

/* --- Exam countdown + cheat sheets (v33) --- */
.countdown-card { border-left: 4px solid var(--gold); }
.countdown-main { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 8px; flex-wrap: wrap; }
.countdown-main strong { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; color: var(--gold); line-height: 1; font-variant-numeric: tabular-nums; }
.countdown-main span { font-size: 1.05rem; color: var(--ink); }
.countdown-open { border-left-color: var(--red); }
.countdown-open .countdown-main strong { color: var(--red); }
[data-theme="dark"] .countdown-main strong { text-shadow: 0 0 18px rgba(212,175,55,.45); }
.sheet-promo h2 { font-family: var(--font-display); }
.sheet h3 { font-family: var(--font-display); font-size: 1.05rem; margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.sheet h3:first-of-type { margin-top: 8px; }
.sheet ul { margin: 6px 0 12px; padding-left: 20px; }
.sheet li { margin: 4px 0; font-size: .95rem; line-height: 1.45; }
.sheet li b { color: var(--gold); }
[data-theme="dark"] .sheet li b { text-shadow: 0 0 12px rgba(212,175,55,.35); }

/* --- Print: cheat sheets come out clean on paper --- */
@media print {
  .topbar, .footer, .no-print, .flash, #theme-toggle { display: none !important; }
  html, body { background: #fff !important; color: #000 !important; }
  [data-theme="dark"] body { background: #fff !important; color: #000 !important; }
  .wrap, main, .card.sheet { box-shadow: none !important; border: none !important; background: #fff !important; color: #000 !important; max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
  .sheet h1, .sheet h3 { color: #000 !important; border-color: #999 !important; }
  .sheet li, .sheet p, .qb-kicker { color: #000 !important; }
  .sheet li b, .countdown-main strong { color: #000 !important; text-shadow: none !important; }
  .sheet a { color: #000 !important; text-decoration: none !important; }
  @page { margin: 14mm; }
}
