/* wasitbefore.com — the AcademiaGames "Night Arcade" theme: dark by default,
   one gold accent, Unbounded for display and Atkinson Hyperlegible for body,
   full-bleed layout with a gutter token instead of a page shell. Light mode is
   opt-in through body[data-scheme='light'], as on AcademiaGames. */
:root {
  --ink-950: #05070d;
  --ink-900: #090d17;
  --ink-800: #0d1322;
  --ink-700: #131b30;
  --ink-600: #1b2542;
  --line: rgba(160, 178, 220, 0.13);
  --line-strong: rgba(160, 178, 220, 0.25);
  --text: #edf1fb;
  --text-dim: #98a2bd;
  --text-faint: #5c6680;
  --gold: #ffc24b;
  --gold-hot: #ffaa1e;
  --gold-soft: rgba(255, 194, 75, 0.16);
  --gold-glow: 0 0 24px rgba(255, 194, 75, 0.35), 0 0 64px rgba(255, 170, 30, 0.18);
  --on-gold: #2b1c00;
  --correct: #57d98a;
  --wrong: #ff7d6e;
  /* The colour the strike is drawn in before it cools to --wrong: lighter than
     the page in the dark theme, darker than it in the light one. */
  --wrong-hot: #ffdbd4;
  --before: rgba(87, 217, 138, 0.14);
  --after: rgba(255, 125, 110, 0.14);
  --font-display: 'Unbounded', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --radius-pill: 999px;
  --shadow-card: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 18px 50px rgba(0, 0, 0, 0.6);
  --ease-snap: cubic-bezier(0.2, 0.9, 0.25, 1.2);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 150ms;
  --t-med: 320ms;
  --t-slow: 700ms;
  --topbar-h: 64px;
  --gutter: clamp(10px, 2vw, 28px);
  --page-top: 12px;
}
body[data-scheme='light'] {
  --ink-950: #dfe4f1;
  --ink-900: #eef1f8;
  --ink-800: #f6f8fc;
  --ink-700: #ffffff;
  --ink-600: #e6ebf6;
  --line: rgba(28, 40, 82, 0.12);
  --line-strong: rgba(28, 40, 82, 0.22);
  --text: #141a2e;
  --text-dim: #515b78;
  --text-faint: #8b93ac;
  --gold: #e08c00;
  --gold-hot: #c97a00;
  --gold-soft: rgba(224, 140, 0, 0.14);
  --gold-glow: 0 0 20px rgba(224, 140, 0, 0.26), 0 0 56px rgba(201, 122, 0, 0.12);
  --correct: #1c9a55;
  --wrong: #d9483a;
  --wrong-hot: #7d1a0f;
  --before: rgba(28, 154, 85, 0.14);
  --after: rgba(217, 72, 58, 0.14);
  --shadow-card: 0 6px 22px rgba(28, 40, 82, 0.12);
  --shadow-pop: 0 18px 48px rgba(28, 40, 82, 0.2);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100vh; min-height: 100dvh; }
body {
  background:
    radial-gradient(1100px 600px at 80% -10%, rgba(255, 170, 30, 0.07), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(63, 214, 208, 0.05), transparent 60%),
    var(--ink-900);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: 0.01em; }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--gold); color: var(--on-gold); }
[hidden] { display: none !important; }
.muted { color: var(--text-dim); }
.small { font-size: 13px; }

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  min-height: 60px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 10px var(--gutter);
  background: color-mix(in srgb, var(--ink-900) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 17px; font-weight: 800; text-decoration: none; min-width: 0; overflow-wrap: anywhere; }
/* The mark is the logo; the wordmark is bicolor the AcademiaGames way, "it" in gold. */
.topbar__mark { height: 30px; width: auto; flex: 0 0 auto; display: block; object-fit: contain; filter: drop-shadow(0 0 10px rgba(255, 194, 75, 0.35)); }
.topbar__brand b { color: var(--gold); font-weight: inherit; }
.topbar__nav { display: flex; gap: clamp(14px, 1.7vw, 24px); font-weight: 700; color: var(--text-dim); white-space: nowrap; }
.topbar__nav button { background: none; color: inherit; padding: 6px 0; font-weight: 700; font-size: 15px; }
.topbar__nav button:hover { color: var(--text); }
.topbar__nav button.is-active { color: var(--gold); }
.topbar__side { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
/* The filter sits at the right end, just before the Topic button, and only on
   the two pages it filters: the timeline list and the topic tiles. */
/* The box is sized here rather than by flex-basis: the side's intrinsic width
   counts the input's own content width, so a basis wider than the input left
   the side short and shrank the Topic button every time the filter appeared. */
.topbar__search { flex: 0 0 auto; display: flex; justify-content: flex-end; min-width: 0; }
/* Same 38px pill as the Topic button beside it, whatever the font metrics. */
.topbar__search input { width: 240px; max-width: 100%; height: 38px; padding-block: 0; }
.icon-btn { flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; background: var(--ink-600); border: 1px solid var(--line-strong); color: var(--text); font-size: 16px; display: grid; place-items: center; }
.icon-btn:hover { border-color: var(--gold); }

/* Language dropdown (native selects cannot be themed) */
.lang { position: relative; }
.lang__btn { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: var(--radius-pill); background: var(--ink-600); border: 1px solid var(--line-strong); color: var(--text); font-weight: 700; font-size: 14px; }
.lang__menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 170px; margin: 0; padding: 6px; list-style: none; background: var(--ink-700); border: 1px solid var(--line-strong); border-radius: var(--radius-m); box-shadow: var(--shadow-pop); }
.lang__menu li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-s); cursor: pointer; font-weight: 600; }
.lang__menu li:hover, .lang__menu li[aria-selected='true'] { background: var(--gold-soft); color: var(--gold); }

/* ── Page ── */
main { flex: 1; padding: var(--page-top) var(--gutter) 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; }

/* Topic button in the top bar, and the page it opens */
.topic-btn { min-width: 0; height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: var(--radius-pill); background: var(--ink-600); border: 1px solid var(--line-strong); color: var(--text); font-size: 14px; }
.topic-btn:hover { border-color: var(--gold); }
/* Open, it reads like the active tab beside it. */
.topic-btn.is-open { border-color: var(--gold); background: var(--gold-soft); }
.topic-btn.is-open .topic-btn__l { color: var(--gold); }
.topic-btn__l { color: var(--text-dim); font-weight: 700; }
.topic-btn__v { color: var(--gold); font-weight: 800; max-width: min(22ch, 24vw); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topics-page { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 9; overflow: auto; padding: var(--page-top) var(--gutter) 40px; background: color-mix(in srgb, var(--ink-900) 94%, transparent); backdrop-filter: blur(10px); animation: rise var(--t-med) var(--ease-out); }
.topics-page__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.topics-page__head h2 { margin: 0; font-size: 20px; }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 10px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  padding: 12px 14px; border-radius: var(--radius-m);
  background: var(--ink-700); border: 1px solid var(--line); color: var(--text);
  transition: transform var(--t-fast) var(--ease-snap), border-color var(--t-fast);
}
.tile:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.tile.is-active { border-color: var(--gold); background: var(--gold-soft); box-shadow: var(--gold-glow); }
.tile__name { font-family: var(--font-display); font-weight: 600; font-size: 13px; line-height: 1.25; }
.tile--all { border-style: dashed; border-color: var(--line-strong); }
.tile--all .tile__name::before { content: "✦ "; color: var(--gold); }

/* ── Quiz: controls, full-width question, then answer history ── */
.quiz { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.card {
  background: var(--ink-700); border: 1px solid var(--line); border-radius: var(--radius-l);
  box-shadow: var(--shadow-card); padding: 32px clamp(12px, 2vw, 24px) 14px; text-align: center;
  position: relative; transition: border-color var(--t-fast), box-shadow var(--t-med); min-height: 0;
  display: flex; flex-direction: column; justify-content: center;
  min-width: 0; scroll-margin-top: calc(var(--topbar-h) + 18px);
}
.card.right { border-color: var(--correct); box-shadow: 0 0 0 1px var(--correct), 0 0 40px rgba(87, 217, 138, 0.25), var(--shadow-card); animation: pop var(--t-med) var(--ease-snap); }
.card.wrong { border-color: var(--wrong); box-shadow: 0 0 0 1px var(--wrong), var(--shadow-card); animation: shake 420ms var(--ease-out); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); }
}
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.018); } 100% { transform: scale(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(87, 217, 138, 0.6); } 100% { box-shadow: 0 0 0 14px rgba(87, 217, 138, 0); } }
/* One line when it fits: the page lifts the nowrap when the sentence is wider than the card. */
.ask { font-family: var(--font-display); font-size: clamp(16px, 2vw, 26px); line-height: 1.3; margin: 0 auto; max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
.ask.wrap { white-space: normal; max-width: 100%; }
.ask .name { color: var(--gold); }
/* The two answers are the card: Yes holds item A, No holds item B. */
.answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 4px; }
.answer {
  display: grid; grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; min-width: 0; min-height: 0; padding: 10px 10px 8px; text-align: center;
  border-radius: var(--radius-m); background: var(--ink-800); border: 2px solid var(--line); color: var(--text); cursor: pointer;
  transition: transform var(--t-fast) var(--ease-snap), border-color var(--t-fast), box-shadow var(--t-fast);
}
.answer .side { grid-row: 3; align-self: end; }
/* Plain words, not inner buttons: the whole frame is the button. */
.answer__label { grid-row: 2; justify-self: center; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 34px; letter-spacing: .02em; }
.answer.yes .answer__label, .answer.no .answer__label { color: var(--text); }
.answer:hover:not(:disabled), .answer.selected:not(:disabled) { transform: translateY(-2px); border-color: var(--gold); box-shadow: var(--gold-glow); }
.answer:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(240, 190, 80, 0.35); }
.answer:disabled { cursor: default; }
.answer:disabled .answer__label { opacity: .45; }
.answer.chosen .answer__label { opacity: 1; }
/* Answered. Right: the frame goes green with a check. Wrong: the frame you
   picked goes red with a cross and a struck-out word, and the frame that was
   right lights up green a beat later. `fresh` = just answered: the animations
   run once; revisiting an answered question shows the colours only. */
.answer { position: relative; }
.answer__mark { position: absolute; top: 10px; right: 12px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-size: 26px; font-weight: 900; line-height: 1; opacity: 0; transform: scale(.4); pointer-events: none; }
.answer.chosen.ok { border-color: var(--correct); background: color-mix(in srgb, var(--correct) 12%, var(--ink-800)); box-shadow: 0 0 0 1px var(--correct), 0 0 32px color-mix(in srgb, var(--correct) 35%, transparent); }
.answer.chosen.ok .answer__label { color: var(--correct); }
.answer.chosen.ok .answer__mark { opacity: 1; transform: none; background: var(--correct); color: #08241a; }
.answer.chosen.ok .answer__mark::before { content: "✓"; }
.answer.chosen.ko { border-color: var(--wrong); background: color-mix(in srgb, var(--wrong) 12%, var(--ink-800)); box-shadow: 0 0 0 1px var(--wrong); }
.answer.chosen.ko .answer__label { color: var(--wrong); background-image: linear-gradient(var(--wrong) 0 0); background-repeat: no-repeat; background-position: left center; background-size: 100% 4px; }
.answer.chosen.ko .answer__mark { opacity: 1; transform: none; background: var(--wrong); color: #2b0a06; }
.answer.chosen.ko .answer__mark::before { content: "✗"; }
.answer.correct:not(.chosen) { border-color: var(--correct); }
.answer.correct:not(.chosen) .answer__label { color: var(--correct); opacity: 1; }
.answer.correct:not(.chosen) .answer__mark { opacity: 1; transform: none; border: 2px solid var(--correct); color: var(--correct); }
.answer.correct:not(.chosen) .answer__mark::before { content: "✓"; }
.answer.fresh.chosen.ok { animation: answer-right 700ms var(--ease-snap); }
.answer.fresh.chosen.ok .answer__mark { animation: mark-pop 520ms var(--ease-snap) 100ms both; }
.answer.fresh.chosen.ko { animation: answer-wrong 620ms var(--ease-out); }
.answer.fresh.chosen.ko .answer__mark { animation: mark-pop 420ms var(--ease-snap) 80ms both; }
.answer.fresh.chosen.ko .answer__label { animation: strike-wipe 300ms var(--ease-out) 140ms both; }
.answer.fresh.correct:not(.chosen) { animation: reveal-right 900ms var(--ease-out) 380ms both; }
.answer.fresh.correct:not(.chosen) .answer__mark { animation: mark-pop 420ms var(--ease-snap) 480ms both; }
@keyframes answer-right {
  0% { transform: scale(1); background: var(--ink-800); }
  30% { transform: scale(1.035); background: color-mix(in srgb, var(--correct) 40%, var(--ink-800)); }
  100% { transform: scale(1); background: color-mix(in srgb, var(--correct) 12%, var(--ink-800)); }
}
@keyframes answer-wrong {
  0% { background: color-mix(in srgb, var(--wrong) 45%, var(--ink-800)); }
  10%, 90% { transform: translateX(-3px); } 20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); }
  100% { transform: none; background: color-mix(in srgb, var(--wrong) 12%, var(--ink-800)); }
}
@keyframes mark-pop {
  0% { opacity: 0; transform: scale(.3) rotate(-25deg); }
  60% { opacity: 1; transform: scale(1.25) rotate(4deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes reveal-right {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--correct) 70%, transparent); }
  100% { box-shadow: 0 0 0 16px transparent; }
}
/* The score ticks up with a bump on a right answer. */
#stat-right.bump, #stat-streak.bump, .player-level.bump { animation: bump 500ms var(--ease-snap); }
#stat-streak.drop { animation: drop 700ms var(--ease-out); }
@keyframes drop { 0% { transform: scale(1.4); color: var(--wrong); } 55% { transform: scale(.8) translateY(5px); color: var(--wrong); } 100% { transform: none; } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.5); color: var(--correct); } 100% { transform: scale(1); } }
.side {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 4px 2px; min-width: 0; min-height: 130px; overflow-wrap: anywhere;
}
.side img { max-height: 130px; max-width: 100%; border-radius: var(--radius-s); object-fit: contain; }
.side .name { font-family: var(--font-display); font-weight: 600; font-size: clamp(15px, 1.4vw, 19px); line-height: 1.2; text-align: center; justify-self: center; }
.side .name__item { color: var(--gold); }
.side .name__first { color: var(--text); }
.side .topic { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
/* The date line is always in the layout — blank until the answer — so the
   card never grows. */
.side .date { min-height: 1.5em; font-size: 15px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.side .date.show { color: var(--text); animation: rise var(--t-med) var(--ease-out); }
/* The item that was not first has its "was first" line struck out — and that
   strike is the payoff of the answer, so it is drawn rather than switched on.
   The bar is a background on the inline run, not text-decoration, because only
   a background can be wiped in: `clone` gives every wrapped line a bar of its
   own, the stroke goes down thick and white-hot and cools to a thin red as it
   lands, and the sentence flinches from the hit before it fades back. The end
   state is the plain rule below, so revisiting an answered question (no
   `.fresh`, and likewise under prefers-reduced-motion) just shows the strike. */
.side .name__ink {
  -webkit-box-decoration-break: clone; box-decoration-break: clone; color: var(--wrong);
  background-image: linear-gradient(currentColor 0 0); background-repeat: no-repeat;
  background-position: left center; background-size: 0 3px;
}
.side.later .name { opacity: .55; }
.side.later .name__ink { background-size: 100% 3px; }
.answer.fresh .side.later .name__ink { animation: strike-draw 380ms cubic-bezier(.22, .68, .21, 1) 170ms both; }
.answer.fresh .side.later .name { animation: strike-hit 820ms var(--ease-out) 170ms both; }
@keyframes strike-draw {
  0% { background-size: 0 7px; color: var(--wrong-hot); }
  72% { background-size: 107% 7px; color: var(--wrong-hot); }
  100% { background-size: 100% 3px; color: var(--wrong); }
}
/* The flinch is timed to the stroke landing: a breath of tension, the hit, a
   small counter-swing, then the sentence settles back dimmed. */
@keyframes strike-hit {
  0% { opacity: 1; transform: none; }
  30% { opacity: 1; transform: scale(1.02); }
  46% { opacity: 1; transform: translateX(3px) scale(1.055); text-shadow: 0 0 18px color-mix(in srgb, var(--wrong) 65%, transparent); }
  60% { transform: translateX(-2px) scale(.99); }
  100% { opacity: .55; transform: none; text-shadow: none; }
}
@keyframes strike-wipe { 0% { background-size: 0 4px; } 70% { background-size: 108% 4px; } 100% { background-size: 100% 4px; } }
/* The earlier item is shown by its whole frame turning green (.answer.chosen.ok /
   .answer.correct); the inner .side block gets no ring of its own, or the lower
   half of the frame would read as a separate box. */
.gapline { margin: 8px 0 0; min-height: 1.6em; font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--text-dim); }
.gapline.show { animation: rise var(--t-med) var(--ease-out); }
.gapline.ok { color: var(--correct); } .gapline.ko { color: var(--wrong); }
.gapline .pts { margin-left: 10px; color: var(--gold); }
/* EXP earned reads as a gold pill, the streak bonus as a green one; both pop in a beat after the line. */
.gapline .xp { display: inline-block; margin-left: 10px; padding: 1px 10px; border-radius: var(--radius-pill); border: 1px solid var(--gold); background: var(--gold-soft); color: var(--gold); font-size: 13px; font-weight: 800; vertical-align: middle; line-height: 1.4; }
.gapline .xp i { font-style: normal; color: var(--text); margin-left: 4px; }
.gapline .xp--bonus { border-color: var(--correct); background: color-mix(in srgb, var(--correct) 16%, transparent); color: var(--correct); }
.gapline.show .xp { animation: mark-pop 500ms var(--ease-snap) 250ms both; }
.gapline.show .xp--bonus { animation-delay: 450ms; }
/* Challenge over: the leaderboard covers the card until "Play again". */
.finish { position: absolute; inset: 0; z-index: 3; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 10px; padding: 18px 20px; background: var(--ink-700); border-radius: inherit; text-align: center; }
.finish__head { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: clamp(20px, 2.4vw, 30px); color: var(--gold); }
.finish__sub { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.lb { list-style: none; margin: 0; padding: 0 2px; min-height: 0; overflow-y: auto; display: grid; gap: 6px; align-content: start; }
.lb li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 12px; border-radius: var(--radius-m); background: var(--ink-800); border: 1px solid var(--line); text-align: left; }
.lb li.you { border-color: var(--gold); }
.lb .rank { font-family: var(--font-display); font-weight: 800; color: var(--text-dim); }
.lb .who { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .who small { display: block; font-weight: 500; font-size: 11px; color: var(--text-dim); }
.lb .meta { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.lb .score { font-family: var(--font-display); font-weight: 800; color: var(--gold); font-size: 18px; font-variant-numeric: tabular-nums; }
.finish__again { justify-self: center; height: 44px; padding: 0 24px; border-radius: var(--radius-pill); background: var(--gold); color: var(--on-gold); font-family: var(--font-display); font-weight: 800; font-size: 15px; box-shadow: var(--gold-glow); }
.finish__again:hover { background: var(--gold-hot); }
@media (max-width: 640px) {
  .finish { padding: 14px 12px; }
  .lb li { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; padding: 6px 10px; }
  .lb .meta { display: none; }
}
/* Bottom strip: Previous | verdict line | Next. */
.strip { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); align-items: center; gap: 8px; margin: 8px 0 4px; }
.nav { padding: 12px 18px; border-radius: var(--radius-pill); background: var(--ink-700); border: 1px solid var(--line-strong); color: var(--text-dim); font-family: var(--font-display); font-weight: 700; font-size: 13px; visibility: hidden; white-space: nowrap; }
.nav.prev { justify-self: start; }
.nav.next { justify-self: end; border-color: var(--gold); color: var(--gold); font-weight: 800; font-size: 15px; }
.nav.show { visibility: visible; }
.nav.next.show { animation: rise var(--t-med) var(--ease-out); }
.nav:hover { color: var(--text); border-color: var(--gold); }
.verdict.big { font-family: var(--font-display); font-weight: 600; font-size: clamp(18px, 2.2vw, 26px); margin: 0; }
.verdict.yes { color: var(--correct); } .verdict.no { color: var(--wrong); } .verdict.undecided { color: var(--text-dim); }
.tag { align-self: flex-end; margin: -20px 0 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--ink-600); color: var(--text-dim); }
.tag.hard { color: var(--wrong); } .tag.medium { color: var(--gold); } .tag.easy { color: var(--correct); }

/* One shared box; the internal groups have no separate card borders. */
.quiz-controls { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 2fr) minmax(220px, 1fr); gap: 12px 20px; align-items: center; padding: 12px 16px; background: var(--ink-700); border: 1px solid var(--line); border-radius: var(--radius-m); }
.control-group { min-width: 0; display: grid; gap: 6px; }
.score-group { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.score-group .stat { min-width: 0; text-align: center; overflow-wrap: anywhere; }
.score-group .stat--wide { grid-column: auto; flex-direction: column; justify-content: center; align-items: center; border: 0; padding: 0; }
.score-group .bar { grid-column: 1 / -1; grid-row: 2; }
.score-group .stat__n { font-size: 20px; }
.score-group .stat__n--small { font-size: 13px; }
.stat-card { background: var(--ink-700); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; display: grid; gap: 8px; grid-template-columns: repeat(3, 1fr); }
.stat-card > :not(.stat) { grid-column: 1 / -1; }
.stat-card__title { margin: 0; font-family: var(--font-display); font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat__n { font-family: var(--font-display); font-size: 24px; font-weight: 800; color: var(--gold); }
.stat__l { font-size: 12px; color: var(--text-dim); }
/* "Wrong by 3 years" wants a whole row: value right, label left. */
.stat--wide { grid-column: 1 / -1; flex-direction: row-reverse; justify-content: space-between; align-items: baseline; padding-top: 4px; border-top: 1px solid var(--line); }
.stat__n--small { font-size: 15px; color: var(--text); }
.bar { height: 6px; border-radius: 3px; background: var(--ink-600); overflow: hidden; }
.bar__fill { height: 100%; width: 0; background: var(--gold); transition: width var(--t-med) var(--ease-out); }
/* ── Level card: EXP, level and rank on the AcademiaGames scale ── */
.level-card { grid-template-columns: 1fr; border-color: var(--line-strong); }
.level-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.level-card__lv { font-family: var(--font-display); font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }
.level-card__lv b { font-size: 22px; font-weight: 800; color: var(--gold); margin-left: 4px; letter-spacing: 0; }
.level-card__title { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--text); text-align: right; }
.level-card__foot { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-dim); }
.level-card__foot b { color: var(--text); font-family: var(--font-display); }
.bar--level { height: 8px; }
.level-card.level-up { animation: glow 900ms var(--ease-out); border-color: var(--gold); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; background: var(--ink-600); border-radius: var(--radius-pill); }
.seg button { padding: 7px 4px; border-radius: var(--radius-pill); background: transparent; color: var(--text-dim); font-weight: 700; font-size: 13px; }
.seg button.is-active { background: var(--gold); color: var(--on-gold); }
.recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.recent .ranswer__go { width: 100%; text-align: left; padding: 10px; border: 1px solid transparent; border-radius: var(--radius-s); background: transparent; font: inherit; display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: baseline; color: var(--text-dim); }
.recent .ranswer__go:hover, .recent .ranswer__go:focus-visible { background: var(--ink-600); border-color: var(--gold); }
.recent .ranswer__go[aria-current="true"] { border-color: var(--gold); background: var(--gold-soft); }
.recent li b { color: var(--text); font-weight: 600; }
.recent .ok { color: var(--correct); font-weight: 800; } .recent .ko { color: var(--wrong); font-weight: 800; }

/* ── Timeline: a grid of cards in date order ── */
.tl-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
select, input[type=search], input[list] {
  font: inherit; padding: 9px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
  background: var(--ink-600); color: var(--text);
}
select:focus, input:focus { border-color: var(--gold); outline: none; }
.link { background: none; color: var(--gold); font-weight: 700; padding: 0; }
.hint { color: var(--text-dim); margin: 0; flex-basis: 100%; }
.tl { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 8px; }
.tl li {
  display: grid; gap: 2px; padding: 10px 12px; cursor: pointer; border-radius: var(--radius-s);
  background: var(--ink-700); border: 1px solid var(--line); position: relative; transition: border-color var(--t-fast);
}
.tl li:hover { border-color: var(--line-strong); }
.tl li.before { background: var(--before); } .tl li.after { background: var(--after); }
.tl li.pivot { border-color: var(--gold); background: var(--gold-soft); box-shadow: var(--gold-glow); }
.tl li.pivot .what { color: var(--gold); font-weight: 700; }
.tl li.undecided { opacity: .55; }
.tl .when { color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.tl .what { font-weight: 600; line-height: 1.25; }
.tl .rel { position: absolute; top: 8px; right: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }

/* ── Compare ── */
.cmp { background: var(--ink-700); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-card); padding: clamp(14px, 2vw, 24px); display: grid; gap: 22px; }
.cmp-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 14px; align-items: end; }
.cmp-field { min-width: 0; display: grid; gap: 6px; font-family: var(--font-display); font-size: 14px; color: var(--text-dim); }
.cmp-field input { font-family: var(--font-body); font-size: 16px; width: 100%; min-width: 0; }
#cmp-go { width: 46px; height: 46px; border-radius: 50%; background: var(--gold); color: var(--on-gold); font-family: var(--font-display); font-weight: 800; font-size: 20px; box-shadow: var(--gold-glow); }
/* The scale: a ruler zoomed on the two items, so a gap of months and a gap of
   millennia both read at a glance. A is named above the line and B below it,
   each over its own dot, with the measured span between them; the year ticks
   give the zoom its unit, and the thin strip underneath says where that window
   falls in the topic's whole range. */
.scale { display: grid; gap: 16px; }
.scale__plot { display: grid; }
.scale__lane { position: relative; min-height: 54px; }
.scale__mark { position: absolute; bottom: 7px; transform: translateX(-50%); display: grid; justify-items: center; gap: 2px; width: max-content; max-width: min(44%, 230px); text-align: center; line-height: 1.25; }
.scale__lane--b .scale__mark { bottom: auto; top: 7px; }
/* A pointer instead of a leader line: it stays inside its own lane, so it can
   never cross the gap label or a year tick on the way to the dot. */
.scale__mark::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%); border: 6px solid transparent; }
.scale__lane--a .scale__mark::after { top: 100%; border-top-color: var(--gold); border-bottom-width: 0; }
.scale__lane--b .scale__mark::after { bottom: 100%; border-bottom-color: var(--text); border-top-width: 0; }
.scale__who { font-family: var(--font-display); font-size: 10px; font-weight: 800; letter-spacing: .1em; padding: 1px 8px; border-radius: var(--radius-pill); background: var(--gold); color: var(--on-gold); }
.scale__lane--b .scale__who { background: var(--text); color: var(--ink-900); }
.scale__name { font-family: var(--font-display); font-size: 13px; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.scale__when { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.scale__gaprow { position: relative; height: 20px; }
.scale__gap { position: absolute; bottom: 0; transform: translateX(-50%); padding: 0 8px; white-space: nowrap; font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--gold); background: var(--ink-700); border-radius: var(--radius-pill); }
.scale__track { position: relative; height: 8px; border-radius: 4px; background: var(--ink-600); border: 1px solid var(--line); }
.scale__span { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--gold); opacity: .45; }
.scale__dot { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; transform: translate(-50%, -50%); border: 2px solid var(--ink-700); }
.scale__dot.a { background: var(--gold); } .scale__dot.b { background: var(--text); }
/* Dates the data cannot tell apart put the dots on one another: show both. */
.scale.is-tied .scale__dot.a { margin-left: -7px; } .scale.is-tied .scale__dot.b { margin-left: 7px; }
.scale__ticks { position: relative; height: 22px; }
.scale__tick { position: absolute; top: 7px; transform: translateX(-50%); white-space: nowrap; font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.scale__tick::before { content: ''; position: absolute; left: 50%; bottom: 100%; width: 1px; height: 5px; background: var(--line-strong); }
.scale__context { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.scale__end { white-space: nowrap; }
.scale__ctrack { position: relative; height: 4px; border-radius: 2px; background: var(--ink-600); border: 1px solid var(--line); }
.scale__window { position: absolute; top: -2px; bottom: -2px; min-width: 3px; border-radius: 3px; background: var(--gold); }

/* ── Streak record, bragging, challenges ── */
.brag { padding: 10px 16px; border-radius: var(--radius-pill); background: var(--ink-600); border: 1px solid var(--line-strong); color: var(--text); font-weight: 700; font-size: 14px; }
.brag:hover { border-color: var(--gold); color: var(--gold); }
.brag:disabled { opacity: .45; cursor: default; }
.challenge { margin: 0; padding: 12px 18px; border-radius: var(--radius-m); background: var(--gold-soft); border: 1px solid var(--gold); color: var(--gold); font-family: var(--font-display); font-size: 14px; font-weight: 600; text-align: center; }

/* ── Footer: a nudge towards AcademiaGames, then the credits ── */
footer { padding: 8px var(--gutter); font-size: 12px; border-top: 1px solid var(--line); color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 4px 24px; align-items: baseline; }
footer p { margin: 0; }
.promo { color: var(--text); font-size: 13px; }
.promo__link { color: var(--gold); font-weight: 800; text-decoration: none; margin-left: 4px; }
.promo__link:hover { text-decoration: underline; }
/* Wrap to available space without hiding controls or clipping content. */
.panel, .cmp, .recent li, .recent .ranswer__go > span, footer p { min-width: 0; overflow-wrap: anywhere; }
.level-card__head, .level-card__foot { flex-wrap: wrap; gap: 4px 10px; }
@media (max-width: 1050px) {
  .quiz-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .difficulty-group { grid-column: 2; grid-row: 1; }
  .score-group { grid-column: 1 / -1; }
  .topbar__brand { flex: 1 1 240px; }
  .topbar__nav { order: 3; flex-basis: 100%; justify-content: center; }
}
@media (max-width: 640px) {
  .quiz-controls { padding: 10px 12px; gap: 10px; }
  .topbar { gap: 6px 12px; }
  .topbar__brand { flex-basis: 100%; font-size: 15px; }
  .topbar__mark { height: 26px; }
  .topbar__side { width: 100%; margin: 0; }
  .topbar__search { flex: 1 1 100%; }
  .topbar__search input { width: 100%; }
  .topic-btn { flex: 1; }
  .topic-btn__v { max-width: none; }
  .lang__btn { padding: 7px 10px; }
  .topbar__nav { gap: 24px; }
  .topbar__nav button { min-height: 36px; font-size: 14px; }
  .nav { white-space: normal; padding: 8px; font-size: 12px; min-width: 0; }
  .answers { gap: 8px; margin-top: 12px; }
  .answer { padding: 8px 8px 6px; grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; }
  .answer__label { font-size: 28px; }
  .side { padding: 4px 2px; gap: 8px; }
  .side .name { font-size: 15px; }
  .side img { max-height: 100px; }
  .side .date { font-size: 13px; }
  .gapline { font-size: 13px; }
  .cmp-form { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .scale__mark { max-width: min(62%, 160px); }
  .scale__name { font-size: 12px; }
  .scale__context { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .scale__ctrack { grid-column: 1 / -1; grid-row: 2; }
  .scale__end:last-child { text-align: right; }
  .topics-page__head h2 { font-size: 17px; }
}
@media (max-width: 460px) {
  .quiz-controls { grid-template-columns: minmax(0, 1fr); }
  .difficulty-group { grid-column: 1; grid-row: auto; grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .difficulty-group .stat-card__title { font-size: 10px; }
  .score-group { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .score-group .stat { grid-column: span 2; }
  .score-group .stat--wide { grid-column: span 3; flex-direction: row-reverse; gap: 6px; }
  .score-group .bar { grid-row: auto; }
  .seg { gap: 2px; padding: 3px; }
  .seg button { font-size: 12px; min-height: 32px; overflow-wrap: anywhere; }
}
/* ── Juice: what plays on top of the frames when an answer lands ──
   Sparks and a floating EXP tag on a right answer, a red edge flash, a jolt
   and a "streak lost" tag on a wrong one, a pulse on the header ring whenever
   EXP lands, and a full-screen card when a level is passed. #fx is a fixed
   layer that pointer events fall through; app.js drops short-lived elements
   in it and removes them once their animation is over. */
#fx { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; }
.spark { position: absolute; width: var(--size, 8px); height: var(--size, 8px); margin: -4px 0 0 -4px; border-radius: 50%; background: var(--spark, var(--gold)); box-shadow: 0 0 8px var(--spark, var(--gold)); animation: spark 1000ms cubic-bezier(0.1, 0.7, 0.4, 1) forwards; }
@keyframes spark {
  0% { opacity: 1; transform: translate(0, 0) scale(.6); }
  20% { opacity: 1; transform: translate(calc(var(--dx) * .5), calc(var(--dy) * .5)) scale(1.1); }
  65% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), calc(var(--dy) + 40px)) scale(.3); }
}
.float { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-family: var(--font-display); font-weight: 900; font-size: 30px; text-shadow: 0 2px 14px rgba(0, 0, 0, .7); animation: float-up 1400ms var(--ease-out) forwards; }
.float small { display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: var(--radius-pill); font-size: 15px; font-weight: 800; vertical-align: middle; text-shadow: none; }
.float.ok { color: var(--gold); text-shadow: 0 2px 14px rgba(0, 0, 0, .7), 0 0 28px rgba(255, 194, 75, .7); }
.float.ok small { background: var(--gold); color: var(--on-gold); }
.float.bonus { color: #fff3c4; font-size: 22px; animation-duration: 1800ms; }
.float.bonus small { background: var(--correct); color: #08241a; }
.float.ko { color: var(--wrong); font-size: 22px; }
.float.ko small { background: var(--wrong); color: #2b0a06; }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  30% { transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -300%) scale(1); }
}
.flash { position: absolute; inset: 0; opacity: 0; animation: flash 650ms var(--ease-out) forwards; }
.flash.ok { background: radial-gradient(ellipse at center, transparent 45%, rgba(87, 217, 138, .28) 100%); }
.flash.ko { background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 70, 50, .6) 100%); animation-duration: 750ms; }
@keyframes flash { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }
/* The EXP earned flies as gold orbs from the answer to the header ring along
   an arc (a motion path in viewport coordinates); the ring holds its old fill
   until they land, then bounces and fills up to the new share. */
.orb { position: absolute; left: 0; top: 0; width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff7d6, var(--gold) 55%, var(--gold-hot)); box-shadow: 0 0 10px 3px rgba(255, 194, 75, .75); offset-rotate: 0deg; animation: orb 750ms cubic-bezier(.45, 0, .55, 1) both; }
@keyframes orb {
  0% { offset-distance: 0%; opacity: 0; transform: scale(.4); }
  12% { opacity: 1; transform: scale(1.35); }
  100% { offset-distance: 100%; opacity: 1; transform: scale(.7); }
}
.float.ring { font-size: 18px; color: var(--gold); animation: ring-pop 1100ms var(--ease-out) forwards; }
@keyframes ring-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.25); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}
@property --ring { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
.player-ring { transition: --ring 900ms var(--ease-out); }
.player-ring.gain { animation: ring-gain 900ms var(--ease-snap); }
@keyframes ring-gain { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 194, 75, .7); } 40% { transform: scale(1.18); } 100% { transform: scale(1); box-shadow: 0 0 0 16px rgba(255, 194, 75, 0); } }
.player-ring.fill { animation: ring-fill 800ms var(--ease-snap); }
@keyframes ring-fill {
  0% { transform: scale(1); }
  25% { transform: scale(1.3) rotate(-7deg); filter: brightness(1.7) drop-shadow(0 0 14px rgba(255, 194, 75, .95)); }
  55% { transform: scale(.92) rotate(5deg); filter: brightness(1.2) drop-shadow(0 0 6px rgba(255, 194, 75, .6)); }
  80% { transform: scale(1.06) rotate(-2deg); }
  100% { transform: scale(1); filter: none; }
}
/* Level passed. */
.levelup { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; overflow: hidden; background: rgba(5, 7, 13, .72); backdrop-filter: blur(4px); cursor: pointer; animation: fade-in 250ms var(--ease-out); }
.levelup[hidden] { display: none; }
.levelup__rays { position: absolute; width: 140vmax; height: 140vmax; border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(255, 194, 75, .22) 0 6deg, transparent 6deg 18deg); -webkit-mask: radial-gradient(circle, #000 0, transparent 60%); mask: radial-gradient(circle, #000 0, transparent 60%); animation: spin 24s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.levelup__box { position: relative; display: grid; justify-items: center; gap: 2px; padding: 32px 56px 28px; border-radius: var(--radius-l); border: 2px solid var(--gold); background: var(--ink-800); box-shadow: var(--gold-glow), var(--shadow-pop); text-align: center; animation: levelup-in 700ms var(--ease-snap) both; }
.levelup__kicker { margin: 0; font-family: var(--font-display); font-size: 14px; font-weight: 800; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); }
.levelup__n { margin: 0; font-family: var(--font-display); font-size: clamp(80px, 16vw, 132px); line-height: 1.05; font-weight: 900; color: var(--gold); text-shadow: 0 0 40px rgba(255, 194, 75, .6); animation: levelup-n 900ms var(--ease-snap) 150ms both; }
.levelup__title { margin: 0; font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--text-dim); }
.levelup__title b { color: var(--text); font-size: 18px; }
@keyframes levelup-in { 0% { opacity: 0; transform: scale(.6) translateY(30px); } 60% { opacity: 1; transform: scale(1.06) translateY(0); } 100% { transform: scale(1); } }
@keyframes levelup-n { 0% { opacity: 0; transform: scale(2.4); } 60% { opacity: 1; transform: scale(.92); } 100% { transform: scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
/* ── Topic badges: a medal per topic, bronze, silver or gold ── */
.medal { --m1: #f3b57e; --m2: #c26f22; --m3: #6e3608; position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--m1), var(--m2) 55%, var(--m3)); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .18), inset 0 -3px 6px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .4); color: rgba(0, 0, 0, .45); font-size: 16px; line-height: 1; flex: 0 0 auto; }
.medal i { font-style: normal; }
.medal--silver { --m1: #ffffff; --m2: #c3cbd8; --m3: #6f7987; }
.medal--gold { --m1: #fff3b0; --m2: #ffc24b; --m3: #a86a05; }
.medal--locked { background: var(--ink-600); box-shadow: inset 0 0 0 2px var(--line-strong); color: var(--text-faint); }
.medal--locked i { opacity: .5; }
.medal--big { width: 128px; height: 128px; font-size: 62px; box-shadow: inset 0 0 0 8px rgba(255, 255, 255, .2), inset 0 -10px 20px rgba(0, 0, 0, .35), 0 12px 40px rgba(0, 0, 0, .5); overflow: hidden; }
.medal--big::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .75) 48%, transparent 60%); background-size: 250% 100%; animation: shine 1400ms var(--ease-out) 600ms both; }
@keyframes shine { 0% { background-position: 120% 0; } 100% { background-position: -80% 0; } }
.levelup--badge .medal--big { margin: 10px 0 14px; animation: levelup-n 900ms var(--ease-snap) 150ms both; }
/* In the player menu: every topic, earned or not, with the count towards the next tier. */
.pmenu__badges { display: grid; gap: 8px; padding: 12px 12px 14px; border-bottom: 1px solid var(--line); }
.pmenu__badges-head { margin: 0; display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.pmenu__badges-head b { color: var(--text-dim); }
/* One line for the three tiers: the medal, and how many topics stand at it. */
.badge-tally { display: flex; align-items: center; gap: 16px; }
.tally { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tally b { font-size: 12px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.tally.is-empty { opacity: .4; }
.tally.is-empty b { color: var(--text-dim); font-weight: 400; }
/* On the topic tiles: the medal at the right, the count to go under the name. */
.tile { position: relative; padding-right: 56px; }
.tile__medal { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); }
.tile__prog { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.tile.is-earned .tile__prog { color: var(--text-dim); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Viewport shell: only the middle region can scroll; the footer stays visible. */
html, body { height: 100%; min-height: 0; overflow: hidden; }
body { height: 100vh; height: 100dvh; }
.topbar, footer { flex: 0 0 auto; }
footer { position: relative; z-index: 11; background: var(--ink-900); padding-block: 5px; }
main { min-height: 0; overflow: auto; display: flex; flex-direction: column; padding-block: 8px; gap: 8px; }
main > .panel { flex: 1 0 auto; }
main > .quiz { flex: 1 0 0; }
.challenge { flex: 0 0 auto; }
.topics-page { bottom: var(--footer-h, 50px); }

/* Full-width question with space reserved for images, wrapped text and answers.
   Height changes only at the mobile breakpoint, never between questions.
   Short viewports scroll main while the footer remains visible. */
.quiz {
  --controls-height: 88px;
  --question-height: 480px;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "controls" "question";
  grid-template-rows: var(--controls-height) var(--question-height);
  gap: 8px; align-items: stretch;
}
.quiz-controls { grid-area: controls; height: var(--controls-height); grid-template-rows: 64px; gap: 8px 20px; padding: 12px 16px; }
.control-group { min-height: 0; }
.level-card { grid-template-rows: 26px 6px 20px; gap: 4px; }
.level-card__head, .level-card__foot { flex-wrap: nowrap; min-width: 0; }
.level-card__head > *, .level-card__foot > *, .stat__n, .stat__l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-group { height: 64px; grid-template-rows: 52px 6px; gap: 6px; }
.score-group .stat { justify-content: center; }
.score-group .stat > * { max-width: 100%; }
.difficulty-group { grid-template-rows: 18px 40px; }

#question-card { grid-area: question; width: 100%; height: var(--question-height); max-height: var(--question-height); display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 20px 54px minmax(0, 1fr) 48px; gap: 6px; padding: 12px; align-content: stretch; justify-content: stretch; }
#question-card.right, #question-card.wrong { animation: none; }
/* A wrong answer jolts the card (translate only: the fixed layout never reflows). */
#question-card.hit { animation: jolt 500ms var(--ease-out); }
@keyframes jolt { 0%, 100% { transform: none; } 15% { transform: translate(-7px, 2px); } 30% { transform: translate(7px, -2px); } 45% { transform: translate(-5px, 1px); } 60% { transform: translate(4px, -1px); } 75% { transform: translate(-2px, 0); } }
.card-head { display: flex; justify-content: space-between; align-items: center; height: 20px; }
#q-difficulty { margin: 0 0 0 auto; width: 110px; height: 20px; padding: 0 8px; overflow: hidden; }
#q-progress { margin: 0; height: 20px; padding: 0 8px; color: var(--gold); border: 1px solid var(--gold); background: transparent; align-content: center; }
.ask { width: 100%; height: 54px; margin: 0; overflow: hidden; align-content: start; }
.answers { min-height: 0; margin: 0; }
.side { min-height: 0; height: auto; display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; grid-template-rows: auto 40px 18px 22px; justify-items: center; gap: 2px; padding: 0 2px 2px; }
.side .item-media { width: 100%; height: 64px; min-height: 0; display: flex; justify-content: center; margin-bottom: 6px; }
.side img { width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
.side .name, .side .topic, .side .date { width: 100%; height: 100%; min-height: 0; overflow: hidden; align-content: center; }
.side .name { font-size: clamp(14px, 1.3vw, 18px); }
.gapline { height: 48px; min-height: 0; margin: 0; overflow: hidden; align-content: center; }
.strip { margin: 0; height: 48px; gap: 8px; }
.nav { width: min(100%, 230px); height: 44px; padding: 6px 10px; white-space: normal; font-size: 12px; }
.nav.next { font-size: 12px; }


@media (max-width: 1050px) {
  .quiz { --controls-height: 160px; }
  .quiz-controls { grid-template-rows: 64px 64px; }
}
@media (max-width: 640px) {
  .quiz { --question-height: 660px; }
  #question-card { grid-template-rows: 20px 54px minmax(0, 1fr) 84px; }
  .answers { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); margin: 0; }
  /* Image on the left, the words centered in the column beside it. */
  .answer .side { grid-template-columns: 72px minmax(0, 1fr); grid-template-rows: 36px 16px 20px; column-gap: 10px; row-gap: 1px; justify-items: center; text-align: center; }
  .answer .side .item-media { grid-column: 1; grid-row: 1 / -1; height: 100%; margin: 0; }
  .answer .side .name, .answer .side .topic, .answer .side .date { grid-column: 2; }
  .answer .side .name { grid-row: 1; font-size: 16px; }
  .answer .side .topic { grid-row: 2; }
  .answer .side .date { grid-row: 3; }
  .answer .side.no-media { grid-template-columns: minmax(0, 1fr); }
  .answer .side.no-media .item-media { display: none; }
  .answer .side.no-media .name, .answer .side.no-media .topic, .answer .side.no-media .date { grid-column: 1; }
  .answer .side.no-media .name { grid-row: 1; height: 100%; font-size: 16px; }
  .answer:hover:not(:disabled) { transform: none; }
  .answer__mark { width: 34px; height: 34px; font-size: 20px; top: 8px; right: 8px; }
  /* Verdict line above, Previous and Next side by side below, each full width for the thumb. */
  .strip { height: 84px; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: 36px 44px; gap: 4px 8px; }
  .gapline { grid-column: 1 / -1; grid-row: 1; height: 36px; }
  .nav { width: 100%; height: 44px; grid-row: 2; padding: 4px 4px; font-size: 11px; letter-spacing: 0; }
  .nav.prev { grid-column: 1; } .nav.next { grid-column: 2; }
}
@media (max-width: 460px) {
  .quiz { --controls-height: 244px; }
  .quiz-controls { grid-template-rows: 64px 76px 64px; padding: 12px; }
  .score-group { height: 76px; grid-template-rows: 38px 6px 20px; }
  .score-group .bar { grid-row: 2; }
  .difficulty-group { grid-template-rows: 40px; }
}
@media (max-height: 700px) and (min-width: 680px) {
  .quiz { --controls-height: 88px; }
  .quiz-controls { grid-template-columns: minmax(140px, 1fr) minmax(0, 1.5fr) minmax(180px, 1fr); grid-template-rows: 64px; gap: 8px 12px; }
  .difficulty-group { grid-column: 3; grid-row: 1; }
  .score-group { grid-column: 2; grid-row: 1; }
}

/* Difficulty and sharing share the top summary; neither needs a footer row. */
.difficulty-group { position: relative; grid-template-columns: minmax(0, 1fr); grid-template-rows: 32px 28px; gap: 4px; }
.difficulty-field { display: flex; align-items: center; gap: 8px; min-width: 0; }
.difficulty-group .brag { height: 28px; padding: 2px 12px; font-size: 13px; }
#brag-note { position: absolute; top: 100%; right: 0; z-index: 5; width: min(320px, 80vw); margin: 4px 0 0; padding: 8px; overflow-wrap: anywhere; background: var(--ink-700); border: 1px solid var(--line-strong); border-radius: var(--radius-s); }

/* The difficulty picker shares the language menu's surface and selection style. */
.difficulty-picker { position: relative; flex: 1; min-width: 0; }
.difficulty-btn { width: 100%; height: 32px; padding: 3px 10px; gap: 6px; }
#difficulty-label { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.difficulty-menu { width: max-content; min-width: 100%; z-index: 12; }
.difficulty-menu li { display: block; padding: 0; }
.difficulty-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--radius-s); background: transparent; color: var(--text); font: inherit; text-align: left; }
.difficulty-menu button:hover, .difficulty-menu button:focus-visible, .difficulty-menu button[aria-selected="true"] { background: var(--gold-soft); color: var(--gold); }
.score-group .stat, .score-group .stat--wide { flex-direction: column; gap: 0; }
.difficulty-group .brag { padding-inline: 6px; font-size: 12px; line-height: 1.1; }
@media (max-width: 460px) {
  .quiz { --controls-height: 262px; }
  .quiz-controls { grid-template-rows: 64px 94px 64px; }
  .score-group { height: 94px; grid-template-rows: 38px 6px 38px; }
}

/* Fill the question's single grid column, including the navigation row. */
#question-card > .answers, #question-card > .strip { width: 100%; min-width: 0; }
.side > * { grid-column: 1; }
.side .item-media { grid-row: 1; }
.side .name { grid-row: 2; }
.side .topic { grid-row: 3; }
.side .date { grid-row: 4; }
/* Without an image, center the name in the same reserved content area. */
.side.no-media .item-media { display: none; }

/* Compact difficulty action: one label, one value, one clear selection. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.difficulty-field { width: 100%; }
.difficulty-btn { height: 32px; background: var(--ink-800); border-color: var(--line-strong); font-size: 13px; padding-inline: 12px; }
.difficulty-btn:hover, .difficulty-btn[aria-expanded="true"] { border-color: var(--gold); }
.difficulty-menu { min-width: 100%; padding: 5px; }
.difficulty-menu button { min-height: 36px; font-size: 13px; }
.difficulty-check { margin-left: auto; width: 16px; color: var(--gold); }

/* AcademiaGames profile: a pixel portrait, a gold EXP ring and level badge. */
.player-menu { position: relative; flex: 0 0 auto; }
.player-ring { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; list-style: none; background: conic-gradient(var(--gold) var(--ring, 0%), var(--line-strong) 0); }
.player-ring::-webkit-details-marker { display: none; }
.player-ring::before { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--ink-900); }
.player-ring canvas { position: relative; width: 36px; height: 36px; image-rendering: pixelated; border-radius: 50%; }
.player-level { position: absolute; right: -2px; bottom: -3px; min-width: 20px; padding: 0 4px; line-height: 18px; text-align: center; border: 1px solid var(--gold); border-radius: 12px; background: var(--ink-900); color: var(--gold); font-size: 11px; font-weight: 700; }
.player-popover { position: absolute; top: calc(100% + 10px); right: 0; z-index: 20; width: min(300px, calc(100vw - 20px)); padding: 14px; display: grid; gap: 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-m); background: var(--ink-700); box-shadow: var(--shadow-pop); }
.player-popover .level-card { display: grid; height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: 28px 6px 20px; }
.player-popover .level-card__lv b { font-size: 20px; }
.player-popover .level-card__title { font-size: 12px; }
.player-popover .level-card__foot { font-size: 11px; }
.avatar-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.avatar-choices button { padding: 0; height: 68px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--ink-800); }
.avatar-choices button:hover, .avatar-choices button[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); }
.avatar-choices canvas { width: 100%; max-width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }
.avatar-credits { font-size: 10px; color: var(--text-dim); text-align: center; }

/* EXP has moved to the header; give its former space back to the quiz. */
.quiz { --controls-height: 88px; }
.quiz-controls { grid-template-columns: minmax(0, 1fr) minmax(200px, 260px); grid-template-rows: 64px; padding: 12px 16px; gap: 8px 20px; }
.score-group { grid-column: 1; grid-row: 1; }
.difficulty-group { grid-column: 2; grid-row: 1; }
@media (max-width: 640px) {
  .topbar__side { gap: 6px; }
  #lang-label { display: none; }
  .lang__btn { padding-inline: 8px; }
  .quiz { --controls-height: 144px; }
  .quiz-controls { grid-template-columns: minmax(0, 1fr); grid-template-rows: 76px 36px; padding: 12px; gap: 8px; }
  .difficulty-group { grid-column: 1; grid-row: 2; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 36px; gap: 8px; align-items: center; }
  .difficulty-group .brag, .difficulty-btn { height: 34px; }
}
@media (max-width: 460px) {
  .quiz { --controls-height: 162px; }
  .quiz-controls { grid-template-rows: 94px 36px; }
}

/* Dated events sit on a continuous line, with an explicit link into their quiz. */
.tl { display: block; position: relative; margin: 16px 0 0; padding: 0; }
.tl::before { content: ''; position: absolute; top: 0; bottom: 0; left: 174px; width: 2px; background: var(--line-strong); }
.tl li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 0; margin: 0 0 8px; border: 0; background: transparent; border-radius: var(--radius-s); }
.timeline-event { display: grid; grid-template-columns: 150px minmax(0, 1fr) 24px; gap: 32px; align-items: center; position: relative; padding: 12px; color: var(--text); text-decoration: none; border-radius: var(--radius-s); }
.timeline-event::before { content: ''; position: absolute; left: 169px; top: calc(50% - 5px); width: 12px; height: 12px; border: 2px solid var(--gold); border-radius: 50%; background: var(--ink-900); }
.timeline-event:focus-visible { background: var(--gold-soft); }
/* The highlight belongs to the ROW, not to its link, now that the row ends in
   two buttons the link cannot hold. */
.tl li:hover { background: var(--gold-soft); }
/* The card and the bookmark sit BESIDE the row's link, never inside it: the
   whole row is one <a>, and a link cannot hold buttons. */
.tl-actions { display: flex; align-items: center; gap: 6px; padding-right: 8px; }
.tl-actions .act { height: 28px; }
.timeline-event .when { text-align: right; }
.timeline-event .what { padding-left: 8px; }
.timeline-play { color: var(--gold); }
.tl .rel { display: none; }
.cmp-side { display: grid; gap: 6px; min-width: 0; }
.cmp-side__title { color: var(--gold); font-family: var(--font-display); font-weight: 800; }
.cmp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.search-picker { position: relative; min-width: 0; }
.search-picker input { width: 100%; min-width: 0; }
.search-options { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 8; max-height: min(300px, 40vh); overflow-y: auto; margin: 0; padding: 5px; list-style: none; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--ink-700); box-shadow: var(--shadow-pop); }
.search-options button { width: 100%; text-align: left; display: grid; gap: 2px; padding: 8px 10px; border-radius: 8px; font: inherit; background: transparent; color: var(--text); }
.search-options small { color: var(--text-dim); }
.search-options button:hover, .search-options button.is-focused, .search-options button[aria-selected="true"] { background: var(--gold-soft); color: var(--gold); }
.search-empty { padding: 10px; color: var(--text-dim); }
#compare { padding-bottom: min(300px, 40vh); }
@media (max-width: 900px) {
  .tl-actions .act { width: 30px; padding: 0; justify-content: center; }
  .tl-actions .act span { display: none; }
}
@media (max-width: 640px) {
  .tl li { grid-template-columns: minmax(0, 1fr); }
  .tl-actions { padding: 0 8px 10px 28px; }
  .tl::before { left: 6px; }
  .timeline-event { grid-template-columns: minmax(0, 1fr) 20px; gap: 4px 10px; padding-left: 28px; }
  .timeline-event::before { left: 1px; }
  .timeline-event .when { grid-column: 1; text-align: left; }
  .timeline-event .what { grid-column: 1; padding: 0; }
  .timeline-play { grid-column: 2; grid-row: 1 / 3; }
}

/* Profile menu follows AcademiaGames; unsupported account controls stay disabled. */
.player-popover { width: min(340px, calc(100vw - 20px)); max-height: calc(100dvh - var(--topbar-h) - var(--footer-h, 40px) - 18px); overflow-y: auto; gap: 12px; }
.profile-identity { display: flex; align-items: center; gap: 12px; }
.profile-identity canvas { width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%; background: var(--ink-800); image-rendering: pixelated; }
.profile-identity strong, .profile-identity small { display: block; }
.profile-identity small { font-size: 11px; color: var(--text-dim); }
.avatar-choices button { height: 86px; }
.avatar-choices canvas { width: 80px; max-width: 100%; height: 80px; }
.profile-links { display: grid; border-block: 1px solid var(--line); padding-block: 6px; }
.profile-links button, .profile-logout { display: flex; align-items: center; gap: 10px; text-align: left; padding: 7px 8px; color: var(--text); background: transparent; font-size: 13px; }
.player-popover button:disabled { opacity: .35; cursor: not-allowed; }
.profile-prefs { display: grid; grid-template-columns: 70px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.profile-prefs select { min-width: 0; width: 100%; padding: 5px 8px; font-size: 12px; }
.profile-options { display: flex; gap: 3px; padding: 3px; border-radius: var(--radius-pill); background: var(--ink-800); }
.profile-options button { flex: 1; padding: 5px; border-radius: var(--radius-pill); background: transparent; color: var(--text-dim); font-size: 11px; }
.profile-options button[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); }

.profile-avatar-button { flex: 0 0 46px; width: 46px; height: 46px; padding: 0; border-radius: 50%; background: transparent; }
.profile-avatar-button:hover { outline: 1px solid var(--gold); outline-offset: 2px; }
.profile-avatar-button canvas { display: block; }
.avatar-picker { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--ink-800); }
.avatar-picker__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-dim); }
.avatar-picker__head button { background: transparent; color: var(--text); padding: 4px 6px; }
.profile-links svg, .profile-logout svg { width: 18px; height: 18px; flex: 0 0 18px; }

/* The punctuation is the action: choose A/B, then reveal their chronology. */
.cmp-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cmp-question { display: flex; align-items: center; justify-content: center; gap: 8px; padding-block: 12px; font-family: var(--font-display); font-size: clamp(17px, 2vw, 26px); line-height: 1.4; text-align: center; }
.cmp-question .name { color: var(--gold); }
#cmp-go { flex: 0 0 46px; }
#cmp-go:disabled { opacity: .4; cursor: default; box-shadow: none; }
#cmp-go:hover:not(:disabled) { background: var(--gold-hot); }
@media (max-width: 640px) { .cmp-form { grid-template-columns: minmax(0, 1fr); } }

/* ── Fit the screen ──
   The question card takes what is left under the top bar and the controls:
   nothing follows it now that the recent answers are a menu page of their
   own. Under its floor, main scrolls the card as before. */
.quiz {
  --avail: calc(100dvh - var(--topbar-h, 64px) - var(--footer-h, 50px) - 24px - var(--controls-height));
  --question-height: clamp(320px, var(--avail), 480px);
  grid-template-rows: var(--controls-height) var(--question-height);
}
main > .quiz { flex: 1 0 auto; }
/* Stacked answers need more: two frames of about 135px plus the question and the strip. */
@media (max-width: 640px) { .quiz { --question-height: clamp(470px, var(--avail), 660px); } }
/* Inside a frame the item block is content-sized and sits at the bottom; the
   word is centered in whatever room is left above it, which is what gives way
   when the frame is short. */
.answer { grid-template-rows: minmax(0, 1fr) auto; }
.answer__label { grid-row: 1; }
.answer .side { grid-row: 2; align-self: end; }
/* Short viewports: no room for the pictures, a smaller word. */
@media (max-height: 620px) {
  .side .item-media { display: none; }
  .answer { gap: 4px; }
  .answer__label { font-size: 26px; }
}
/* Phones: one row of stats (the two averages are in the recent answers card's
   spirit, not needed here), and the top bar on three rows — brand and player,
   tabs, then filter and topic side by side. */
@media (max-width: 640px) {
  .quiz { --controls-height: 116px; }
  .quiz-controls { grid-template-rows: 52px 36px; padding: 10px 12px; gap: 8px; }
  .score-group { height: 52px; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: 46px 6px; gap: 0 8px; }
  .score-group .stat { grid-column: auto; }
  .score-group .stat--wide { display: none; }
  .score-group .bar { grid-column: 1 / -1; grid-row: 2; }
  .difficulty-group { grid-row: 2; grid-template-rows: 36px; }
  .topbar { gap: 8px 10px; }
  .topbar__brand { flex: 1 1 auto; order: 0; }
  .topbar__side { display: contents; }
  .player-menu { order: 1; }
  .topbar__nav { order: 2; flex-basis: 100%; }
  .topbar__search { order: 3; flex: 1 1 150px; }
  .topbar__search input { width: 100%; }
  .topic-btn { order: 4; flex: 1 1 120px; min-width: 0; }
}

/* Recent answers carry what each one paid: the EXP pill, the streak bonus, and
   the medal when that answer reached a badge tier. */
.recent .ranswer__go { grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; }
.recent__gain { display: flex; align-items: center; gap: 6px; justify-self: end; white-space: nowrap; }
.recent__gain .xp { display: inline-block; padding: 0 8px; border-radius: var(--radius-pill); border: 1px solid var(--gold); background: var(--gold-soft); color: var(--gold); font-size: 11px; font-weight: 800; line-height: 1.6; }
.recent__gain .xp i { font-style: normal; color: var(--text); margin-left: 3px; }
.recent__gain .xp--bonus { border-color: var(--correct); background: color-mix(in srgb, var(--correct) 16%, transparent); color: var(--correct); }
.medal--tiny { width: 20px; height: 20px; font-size: 10px; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .18), inset 0 -2px 4px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .4); }

/* ---- "Learn more" / "Save for later" ------------------------------------
   Two small buttons per answer half, shown once the question is answered
   (the frames turn green/red; these ride in with them). They are siblings of
   the answer buttons — a button cannot contain buttons — and are laid out by
   the same grid, so they never sit over the item's date.

   Side by side, each half gets a labelled row of its own under it, part of
   the card's height budget rather than taken out of the answers' room: the
   row is there from the first question, its buttons merely invisible, so
   answering moves nothing. With no knowledge bank the row and its allowance
   are gone. */
.act { height: 30px; padding: 0 10px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--ink-700); color: var(--text-dim); font-family: var(--font-display); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; cursor: pointer; text-decoration: none; }
.act:hover { color: var(--text); border-color: var(--gold); }
.act:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(240, 190, 80, 0.35); }
.act svg { width: 14px; height: 14px; flex-shrink: 0; }
.act-save.is-saved { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.act-save.is-saved svg { fill: currentColor; }
.side-actions { display: flex; justify-content: center; align-items: center; gap: 6px; height: 34px; visibility: hidden; }
.side-actions[hidden], body.no-knowledge .side-actions,
.cmp-actions[hidden], body.no-knowledge .cmp-actions, body.no-knowledge .tl-actions { display: none; }
.card.right .side-actions, .card.wrong .side-actions { visibility: visible; animation: rise var(--t-med) var(--ease-out) 300ms both; }
.answers { grid-template-rows: minmax(0, 1fr) auto; }
.answer.yes { grid-area: 1 / 1; }
.answer.no { grid-area: 1 / 2; }
.side-actions[data-side="a"] { grid-area: 2 / 1; }
.side-actions[data-side="b"] { grid-area: 2 / 2; }
.quiz { --actions-h: 46px; --question-height: clamp(calc(320px + var(--actions-h)), var(--avail), calc(480px + var(--actions-h))); }
body.no-knowledge .quiz { --actions-h: 0px; }
/* The Yes / No word keeps a row at least its own height whatever the frame:
   the item block below it is pinned to the frame's bottom, so a row allowed
   to collapse lets the block climb over the word. */
.answer { grid-template-rows: minmax(min-content, 1fr) auto; }
@media (max-width: 640px) {
  /* Stacked halves. A frame needs the word (35px), the item block (64px),
     the row gap and its padding — 125px — and two of those, the question and
     the strip already come to more than a phone screen holds. So here the
     buttons take no height of their own: they share their frame's grid cell
     and sit as icons in its free top-left corner, opposite the ✓ / ✗ mark. */
  .quiz { --actions-h: 0px; --question-height: clamp(462px, var(--avail), 660px); }
  .answers { grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .answer .side { grid-template-rows: 32px 14px 18px; }
  .answer.yes, .side-actions[data-side="a"] { grid-area: 1 / 1; }
  .answer.no, .side-actions[data-side="b"] { grid-area: 2 / 1; }
  .side-actions { align-self: start; justify-self: start; margin: 7px; height: 30px; z-index: 2; }
  .side-actions .act { width: 30px; padding: 0; justify-content: center; }
  .side-actions .act span { display: none; }
}

/* The card itself: a modal over the page, the picture beside the text. */
.about { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(5, 7, 13, .72); backdrop-filter: blur(6px); animation: fade-in 200ms var(--ease-out); }
.about[hidden] { display: none; }
.about__box { width: min(760px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--ink-800); border: 1px solid var(--line-strong); border-radius: var(--radius-l); box-shadow: var(--shadow-pop); animation: levelup-in 400ms var(--ease-snap) both; text-align: left; }
.about__head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 10px; }
.about__head h2 { margin: 0; flex: 1; min-width: 0; font-family: var(--font-display); font-size: clamp(18px, 2.4vw, 24px); color: var(--gold); overflow-wrap: anywhere; }
/* The picture floats, so a long lead wraps under it instead of leaving a
   column of empty space beside it. */
.about__body { overflow: auto; overscroll-behavior: contain; padding: 0 18px 12px; }
.about__fig { float: left; width: 200px; margin: 2px 16px 10px 0; }
.about__fig img { display: block; width: 100%; height: auto; border-radius: var(--radius-m); border: 1px solid var(--line); background: var(--ink-700); }
.about__fig figcaption { margin-top: 6px; font-size: 11px; color: var(--text-faint); overflow-wrap: anywhere; }
.about__fig figcaption a { color: inherit; }
.about__text p { margin: 0 0 10px; line-height: 1.55; }
.about__desc { color: var(--text); font-weight: 700; }
.about__meta { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.about__note { font-size: 12px; color: var(--gold); }
.about__credit { font-size: 12px; color: var(--text-dim); }
.about__credit a { color: var(--text-dim); text-decoration: underline; }
.about__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 18px 16px; border-top: 1px solid var(--line); }
.about__foot .act { height: 38px; font-size: 13px; padding: 0 14px; }
.about__foot .spacer { flex: 1; }
@media (max-width: 640px) {
  .about { padding: 0; align-items: end; }
  .about__box { max-height: 92vh; max-height: 92dvh; border-radius: var(--radius-l) var(--radius-l) 0 0; }
  .about__fig { float: none; width: auto; margin: 0 0 12px; }
  .about__fig img { max-height: 200px; object-fit: contain; }
}

/* Saved for later, in the player menu: the bookmarked items, newest first. */
.pmenu__saved { display: grid; gap: 6px; }
body.no-knowledge .pmenu__saved { display: none; }
.saved { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 220px; overflow-y: auto; overscroll-behavior: contain; }
.saved li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px; }
.saved__open { display: grid; text-align: left; padding: 6px 10px; border-radius: var(--radius-m); background: var(--ink-800); border: 1px solid var(--line); color: var(--text); min-width: 0; cursor: pointer; }
.saved__open b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved__open small { font-size: 11px; color: var(--text-dim); }
.saved__open:hover { border-color: var(--gold); }
.saved__remove { width: 28px; height: 28px; border-radius: 50%; background: transparent; border: 1px solid transparent; color: var(--text-faint); cursor: pointer; }
.saved__remove:hover { color: var(--wrong); border-color: var(--wrong); }
.saved__empty { font-size: 12px; padding: 4px 2px; }


/* ---- Recent answers: the menu page -------------------------------------
   The list the quiz card used to carry underneath it, on a page of its own
   and with the room to say more. A row is the verdict — the button back to
   that question — and under it the two items, the one that came first in
   gold, each with its date and the same card-and-bookmark pair the quiz puts
   over an answered half. */
.recent-btn__i { width: 16px; height: 16px; flex: 0 0 auto; color: var(--text-dim); }
.recent-btn.is-open .recent-btn__i { color: var(--gold); }
.recent-page .recent { gap: 10px; }
.ranswer { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--ink-700); }
.ranswer.is-current { border-color: var(--gold); }
.recent .ranswer__go { padding: 4px 6px; line-height: 1.35; }
.ranswer__verdict { font-weight: 800; }
.ranswer__verdict.ok { color: var(--correct); } .ranswer__verdict.ko { color: var(--wrong); }
.ranswer__tag { margin-left: 6px; padding: 0 7px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.ranswer__pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ranswer__item { display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: center; gap: 6px 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--ink-800); }
/* The one that was first wears the gold — the page says which in words too,
   but the pair reads at a glance. */
.ranswer__item.is-first { border-color: var(--gold); background: var(--gold-soft); }
.ranswer__who { grid-row: 1 / span 2; align-self: start; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--ink-600); color: var(--text-dim); font-family: var(--font-display); font-size: 10px; font-weight: 800; }
.ranswer__item.is-first .ranswer__who { background: var(--gold); color: var(--on-gold); }
.ranswer__name { min-width: 0; display: grid; }
.ranswer__name b { color: var(--text); font-weight: 700; line-height: 1.25; }
.ranswer__name small { color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.ranswer__acts { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.ranswer__acts .act { height: 26px; font-size: 10px; }
.recent__empty { padding: 14px; }

/* ---- The card takes the page -------------------------------------------
   Nothing follows the question any more, so it takes everything the top bar,
   the controls and the footer leave, and the Yes / No word grows with the
   frame instead of floating in it. The floor keeps the answers, the buttons
   and the ruler on screen; below it, main scrolls. */
.quiz {
  --scale-h: 116px;
  --question-height: max(calc(320px + var(--actions-h) + var(--scale-h)), var(--avail));
  grid-template-rows: var(--controls-height) var(--question-height);
}
#question-card { grid-template-rows: 20px 54px minmax(0, 1fr) 48px var(--scale-h); }
.answer__label { font-size: clamp(30px, 5vh, 58px); }
@media (max-height: 620px) { .answer__label { font-size: 26px; } }

/* ---- The Compare ruler, compact, under the quiz's verdict --------------
   Everything a Compare mark says about a date is already in the frame above
   it here, so the mark is only the A / B pill and the name, on one line. The
   ruler holds its row from the first question and merely becomes visible
   with the answer, like the dates and the two buttons: the card is the same
   height on every question. */
.scale--mini { gap: 6px; grid-template-rows: auto 16px; align-content: end; visibility: hidden; }
.card.right .scale--mini, .card.wrong .scale--mini { visibility: visible; animation: rise var(--t-med) var(--ease-out) 260ms both; }
.scale--mini .scale__lane { min-height: 26px; }
.scale--mini .scale__mark { bottom: 5px; display: flex; align-items: center; gap: 5px; max-width: min(46%, 240px); white-space: nowrap; }
.scale--mini .scale__lane--b .scale__mark { top: 5px; bottom: auto; }
.scale--mini .scale__who { font-size: 9px; padding: 0 6px; }
.scale--mini .scale__name { min-width: 0; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.scale--mini .scale__when { display: none; }
.scale--mini .scale__gaprow { height: 16px; }
.scale--mini .scale__gap { font-size: 10px; padding: 0 6px; }
.scale--mini .scale__track { height: 6px; }
.scale--mini .scale__dot { width: 12px; height: 12px; }
.scale--mini .scale__ticks { height: 16px; }
.scale--mini .scale__tick { top: 4px; font-size: 9px; }
.scale--mini .scale__context { font-size: 10px; gap: 8px; }

@media (max-width: 640px) {
  /* The top bar is already three rows deep: Recent answers keeps its icon
     and its count, and gives up its name. */
  .recent-btn { order: 4; flex: 0 0 auto; }
  .recent-btn .topic-btn__l { display: none; }
  .ranswer__pair { grid-template-columns: minmax(0, 1fr); }
  /* Stacked halves leave no room for the strip that places the window in the
     whole topic; the ruler itself stays. */
  .quiz { --scale-h: 88px; --question-height: max(calc(462px + var(--scale-h)), var(--avail)); }
  #question-card { grid-template-rows: 20px 54px minmax(0, 1fr) 84px var(--scale-h); }
  .answer__label { font-size: clamp(26px, 4.4vh, 40px); }
  .scale--mini { grid-template-rows: auto; }
  .scale--mini .scale__context { display: none; }
  .scale--mini .scale__lane { min-height: 22px; }
  .scale--mini .scale__mark { max-width: min(60%, 170px); }
}


/* ---- Choose your character: a submenu, not a drawer --------------------
   It used to open inside the player menu, pushing the account links and the
   preferences down a panel that then had to be scrolled. It now opens beside
   that panel, level with the portrait that opens it and pointing at it, on
   the left: the menu is pinned to the right edge of the window, so the left
   is the side with room. */
.player-menu { --pmenu-w: 258px; }
.avatar-picker {
  position: absolute; z-index: 21;
  top: calc(100% + 30px); right: calc(var(--pmenu-w) + 8px);
  width: 300px; padding: 12px;
  border-radius: var(--radius-m); background: var(--ink-700); box-shadow: var(--shadow-pop);
  animation: rise var(--t-fast) var(--ease-out);
}
.avatar-picker::after { content: ''; position: absolute; top: 14px; left: 100%; border: 7px solid transparent; border-left-color: var(--line-strong); }
.avatar-picker__head { font-family: var(--font-display); font-weight: 700; }
.avatar-choices { gap: 8px; }
/* Too narrow for anything beside the menu: it sits under the top bar instead. */
@media (max-width: 760px) {
  .avatar-picker { position: fixed; top: calc(var(--topbar-h) + 10px); right: 10px; left: 10px; width: auto; }
  .avatar-picker::after { display: none; }
}


/* ---- The two buttons move into the frame ------------------------------
   "Learn more" and "Save for later" used to sit on a row of their own under
   the answers, 46px of the card spent beside the frame the item is in. They
   now ride in the frame's top-left corner, opposite the ✓ / ✗ mark, the way
   the phone has always shown them — with their labels, and bigger, since the
   room the row gave back is theirs to spend. The allowance stays, as the
   frame's own top padding, so the Yes / No word can never rise into them,
   and it is still nothing at all when there is no knowledge bank. */
.quiz { --actions-h: 40px; }
.answers { grid-template-rows: minmax(0, 1fr); }
.answer { padding-top: calc(10px + var(--actions-h)); }
.answer.yes, .side-actions[data-side="a"] { grid-area: 1 / 1; }
.answer.no, .side-actions[data-side="b"] { grid-area: 1 / 2; }
.side-actions {
  align-self: start; justify-self: start; z-index: 2;
  margin: 10px; height: auto; gap: 8px; flex-wrap: wrap;
  max-width: calc(100% - 76px);   /* clear of the mark in the other corner */
}
.side-actions .act { height: 38px; padding: 0 14px; gap: 7px; font-size: 13px; }
.side-actions .act svg { width: 18px; height: 18px; }

/* ---- What a wrong answer cost -----------------------------------------
   The gap flies from the frame to "Wrong by" and the two stats take their
   new reading as it lands (app.js flyGap). */
.gapfly {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  font-family: var(--font-display); font-weight: 900; font-size: 22px; color: var(--wrong);
  text-shadow: 0 2px 14px rgba(0, 0, 0, .7), 0 0 24px color-mix(in srgb, var(--wrong) 65%, transparent);
  offset-rotate: 0deg; offset-anchor: 50% 50%; animation: gapfly 860ms cubic-bezier(.45, 0, .55, 1) both;
}
@keyframes gapfly {
  0% { offset-distance: 0%; opacity: 0; transform: scale(.55); }
  14% { opacity: 1; transform: scale(1.18); }
  72% { opacity: 1; transform: scale(1); }
  100% { offset-distance: 100%; opacity: 0; transform: scale(.4); }
}
#stat-wrong.cost, #stat-avg.cost { animation: cost-up 620ms var(--ease-snap); }
@keyframes cost-up {
  0% { transform: scale(1); }
  35% { transform: scale(1.4); color: var(--wrong); text-shadow: 0 0 18px color-mix(in srgb, var(--wrong) 60%, transparent); }
  100% { transform: scale(1); }
}

/* Half a card is not wide enough for two labelled pills much below a
   laptop, and a wrapped second row would reach the Yes / No word: from here
   down they are the icons alone, which say the same in a corner. */
@media (max-width: 1000px) {
  .side-actions .act { width: 38px; padding: 0; justify-content: center; }
  .side-actions .act span { display: none; }
}
@media (max-width: 640px) {
  /* Stacked halves: the frames are too short to give the buttons an
     allowance, so they overlay the corner outright, as they always have. */
  .quiz { --actions-h: 0px; }
  .answer { padding-top: 8px; }
  .answers { grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .answer.yes, .side-actions[data-side="a"] { grid-area: 1 / 1; }
  .answer.no, .side-actions[data-side="b"] { grid-area: 2 / 1; }
  .side-actions { margin: 7px; gap: 6px; }
  .side-actions .act { width: 34px; height: 34px; padding: 0; justify-content: center; }
  .side-actions .act svg { width: 17px; height: 17px; }
}
