/* Knowledge Keep — styles (v4: bold modern cartoon).
   Look: deep navy game chrome around a bright board (the board is the brightest thing on screen), one
   strong accent per subject, gold for streaks, score and the main action. Corners are 8-12px; raised
   things (buttons, chips, rows) sit on a solid 2px darker bottom edge instead of soft shadows.
   Readability floor (Chromebook at arm's length): nothing under 14px, body/labels 16px, answers 18px,
   question prompt 22-26px, stat values 18px+, tap targets 44px+. Every text color pair below is WCAG AA
   (4.5:1+) on the surface it sits on (checked with a contrast script; the lowest is white on the
   deepened chemistry orange, 4.86:1). Lexend (500/700/800) for all UI text; DM Mono only for small
   decorative kickers. */
:root {
  --kk-page: #0e1424;          /* behind everything */
  --kk-chrome: #141b2d;        /* header, bars, the frame around the board */
  --kk-panel: #1a2340;         /* cards and columns */
  --kk-raised: #243056;        /* buttons, chips, rows, answers */
  --kk-raised-hover: #2d3b69;
  --kk-edge: #0a0f1c;          /* the solid bottom edge under raised things */
  --kk-line: #33406a;
  --kk-line-soft: #27325a;
  --kk-ink: #f2f5fc;           /* 14.2:1 on panel */
  --kk-muted: #aeb8d4;         /* 7.8:1 on panel, 6.5:1 on raised */
  --kk-gold: #ffc53d;          /* streaks, score, the main action (9.8:1 as text on panel) */
  --kk-gold-edge: #b9820c;
  --kk-gold-ink: #1d1400;      /* text on gold: 11.6:1 */
  --kk-gold-tint: #3a3014;
  --kk-blue: #9fb0ff;          /* accent outlines on navy (7.5:1) */
  --kk-good: #3ddc97;          /* 8.8:1 on panel */
  --kk-good-bg: #10392c;
  --kk-bad: #ff8a8a;           /* 6.8:1 on panel */
  --kk-bad-bg: #401a22;
  --kk-focus: #7cc4ff;
  --kk-font: 'Lexend', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --kk-mono: 'DM Mono', ui-monospace, monospace;
  --game-header-h: 60px;
  font-family: var(--kk-font);
  font-size: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--kk-ink); background: var(--kk-page); min-height: 100vh; font-size: 16px; line-height: 1.45; }
.app-shell { color: var(--kk-ink); background: var(--kk-page); font-family: var(--kk-font); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-weight: 800; letter-spacing: -.02em; }
b, strong { font-weight: 700; }
:where(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid var(--kk-focus); outline-offset: 3px; }
.hidden { display: none !important; }
.kk-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
kbd { padding: 1px 6px; font: 500 14px/1.3 var(--kk-mono); color: inherit; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .22); border-bottom-width: 2px; border-radius: 6px; }
.kicker, .card-kicker { color: var(--kk-muted); font-family: var(--kk-mono); font-size: 14px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
svg { flex: 0 0 auto; }

/* While a run is on screen the game owns the whole viewport; on the start screen the site footer steps
   aside so the three columns fit 1366x768 without scrolling. */
body.kk-playing .tlg-header, body.kk-playing .tlg-footer, body.kk-playing .tlg-skip { display: none; }
body.kk-playing { overflow: hidden; }
body.kk-start .tlg-footer { display: none; }
.screen { min-height: 100vh; }

/* ---- buttons: flat fills on a solid 2px darker bottom edge ("game buttons") ---------------------- */
.primary-button, .secondary-button, .play-button, .check-button, .upgrade-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 10px;
  font-weight: 800; transition: transform .08s, box-shadow .08s, background .12s;
}
.primary-button, .play-button, .check-button, .upgrade-button { color: var(--kk-gold-ink); background: var(--kk-gold); box-shadow: 0 3px 0 var(--kk-gold-edge); }
.primary-button:hover:not(:disabled), .play-button:hover:not(:disabled), .check-button:hover:not(:disabled), .upgrade-button:hover:not(:disabled) { background: #ffd162; }
.primary-button:active:not(:disabled), .play-button:active:not(:disabled), .check-button:active:not(:disabled), .upgrade-button:active:not(:disabled), .secondary-button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--kk-gold-edge); }
.primary-button { width: 100%; min-height: 52px; padding: 0 22px; font-size: 18px; }
.secondary-button { min-height: 52px; padding: 0 22px; color: var(--kk-ink); background: var(--kk-raised); font-size: 18px; box-shadow: 0 3px 0 var(--kk-edge); }
.secondary-button:hover:not(:disabled) { background: var(--kk-raised-hover); }
.secondary-button:active:not(:disabled) { box-shadow: 0 1px 0 var(--kk-edge); }
.primary-button span, .secondary-button span { font-size: 20px; }
.primary-button:disabled, .play-button:disabled { cursor: progress; opacity: .7; }
.text-button { min-height: 44px; padding: 8px 14px; color: var(--kk-muted); background: transparent; border: 0; border-radius: 10px; font-size: 16px; font-weight: 700; }
.text-button:hover { color: var(--kk-ink); background: rgba(255, 255, 255, .06); }
.icon-button { display: grid; place-items: center; width: 48px; height: 48px; color: var(--kk-ink); background: var(--kk-raised); border: 0; border-radius: 10px; box-shadow: 0 3px 0 var(--kk-edge); }
.icon-button:hover { background: var(--kk-raised-hover); }
.icon-button svg { width: 24px; height: 24px; }
.text-input { width: 100%; min-height: 48px; padding: 10px 14px; color: var(--kk-ink); background: #0f1629; border: 2px solid var(--kk-line); border-radius: 10px; font-size: 18px; font-weight: 500; }
.text-input::placeholder { color: #8f9abb; }
.text-input:focus { border-color: var(--kk-blue); outline: none; box-shadow: 0 0 0 3px rgba(159, 176, 255, .25); }
.card { background: var(--kk-panel); border: 2px solid var(--kk-line-soft); border-radius: 12px; }

/* ---- start screen: title bar + three columns (subject, topic, leaderboard + Play). At 980px and
   below the columns stack in the same order and the page scrolls. ------------------------------- */
.start-screen { display: flex; flex-direction: column; gap: 12px; height: calc(100vh - var(--tlg-header-h, 68px) - 1px); height: calc(100dvh - var(--tlg-header-h, 68px) - 1px); min-height: 520px; padding: 12px clamp(16px, 2.4vw, 32px) 16px; overflow: hidden; background: var(--kk-page); }
.start-bar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; max-width: 1320px; margin: 0 auto; }
.crumbs { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crumbs h1 { margin: 0; font-size: 26px; line-height: 1.1; white-space: nowrap; }
.crumb-sep { color: var(--kk-muted); font-size: 20px; font-weight: 700; }
.bar-actions { display: flex; gap: 10px; }
.brand, .game-brand a { color: var(--kk-ink); text-decoration: none; font-size: 16px; font-weight: 800; letter-spacing: .12em; white-space: nowrap; }
.brand span, .game-brand a span { color: var(--kk-gold); }
.start-columns { flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.15fr) minmax(0, 1.1fr); gap: 16px; width: 100%; max-width: 1320px; min-height: 0; margin: 0 auto; }
.start-col { display: flex; flex-direction: column; min-height: 0; padding: 16px; background: var(--kk-panel); border: 2px solid var(--kk-line-soft); border-radius: 12px; }
.step-heading { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 20px; line-height: 1.2; }
.step-num { display: grid; flex: 0 0 32px; place-items: center; width: 32px; height: 32px; color: var(--kk-gold-ink); background: var(--kk-gold); border-radius: 8px; box-shadow: 0 2px 0 var(--kk-gold-edge); font-size: 17px; font-weight: 800; }
.subject-picker { flex: 1 1 auto; display: grid; grid-auto-rows: minmax(64px, 112px); align-content: start; gap: 12px; min-height: 0; }
.subject-option { display: flex; align-items: center; gap: 16px; min-width: 0; padding: 12px 16px; color: var(--kk-ink); background: var(--kk-raised); border: 2px solid transparent; border-radius: 12px; box-shadow: 0 3px 0 var(--kk-edge); font-size: 22px; font-weight: 800; line-height: 1.2; text-align: left; }
.subject-option .subject-icon { display: grid; flex: 0 0 60px; place-items: center; width: 60px; height: 60px; color: #fff; background: var(--subject-color); border-radius: 10px; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25); }
.subject-icon svg { width: 36px; height: 36px; }
.subject-option:hover { background: var(--kk-raised-hover); }
.subject-option.selected { background: color-mix(in srgb, var(--subject-color) 30%, var(--kk-raised)); border-color: var(--subject-color); box-shadow: 0 3px 0 color-mix(in srgb, var(--subject-color) 55%, #000); }
.topic-list { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; margin: 0 -6px; padding: 0 6px 6px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--kk-line) transparent;
  /* Scroll shadows: a soft edge appears at the top or bottom only while there is more list that way. */
  background: linear-gradient(var(--kk-panel) 30%, rgba(26, 35, 64, 0)) top / 100% 24px no-repeat local, linear-gradient(rgba(26, 35, 64, 0), var(--kk-panel) 70%) bottom / 100% 24px no-repeat local, radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, .55), transparent) top / 100% 12px no-repeat scroll, radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, .55), transparent) bottom / 100% 12px no-repeat scroll; }
.unit-heading { margin: 6px 0 0; color: var(--kk-muted); font-size: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.unit-heading:first-child { margin-top: 0; }
.bank-option { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 46px; padding: 4px 12px 4px 6px; color: var(--kk-ink); background: var(--kk-raised); border: 2px solid transparent; border-radius: 10px; box-shadow: 0 2px 0 var(--kk-edge); text-align: left; font-size: 16px; font-weight: 700; line-height: 1.2; }
.bank-option .bank-icon { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--bank-color); border-radius: 8px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25); font-size: 19px; }
.bank-option:hover { background: var(--kk-raised-hover); }
.bank-option.selected { background: color-mix(in srgb, var(--bank-color) 26%, var(--kk-raised)); border-color: var(--kk-gold); }
.bank-best { color: var(--kk-gold); font-size: 16px; font-weight: 800; white-space: nowrap; }
.bank-best.none { color: var(--kk-muted); font-size: 14px; font-weight: 500; }
.play-col .start-leaderboard { flex: 1 1 auto; min-height: 0; margin: 0; padding: 0; overflow-y: auto; background: transparent; border: 0; }
.play-dock { flex: 0 0 auto; display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 2px solid var(--kk-line-soft); }
.your-best { margin: 0; padding: 10px 14px; color: var(--kk-ink); background: var(--kk-gold-tint); border: 2px solid var(--kk-gold); border-radius: 10px; font-size: 18px; font-weight: 700; }
.your-best b { color: var(--kk-gold); font-size: 21px; font-weight: 800; }
.your-rank { margin-left: 6px; color: var(--kk-muted); font-size: 16px; font-weight: 500; }
.name-prompt { display: grid; gap: 6px; }
.name-prompt label { font-size: 16px; font-weight: 700; }
.play-button { width: 100%; min-height: 62px; font-size: 26px; box-shadow: 0 4px 0 var(--kk-gold-edge); }
.play-button svg { width: 26px; height: 26px; }
.question-set .lgq-picker { margin: 0 0 4px; }
.topic-list.is-overridden { opacity: .45; }
.play-status { margin: 0; color: var(--kk-muted); font-size: 16px; font-weight: 700; text-align: center; }
.play-status:empty { display: none; }
.play-status.error { color: var(--kk-bad); }
#play-retry { width: 100%; }

/* ---- game screen ----------------------------------------------------------------------------- */
.game-screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; background: var(--kk-page); }
.game-header { flex: 0 0 var(--game-header-h); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 clamp(12px, 2vw, 28px); background: var(--kk-chrome); border-bottom: 2px solid var(--kk-edge); }
.game-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.game-brand h2 { margin: 0; font-size: 21px; white-space: nowrap; }
.game-divider { width: 2px; height: 26px; background: var(--kk-line); }
.game-header-actions { display: flex; align-items: center; gap: 10px; }
.level-pill { display: flex; align-items: baseline; gap: 8px; padding: 6px 14px; color: var(--kk-muted); background: var(--kk-raised); border-radius: 10px; box-shadow: 0 2px 0 var(--kk-edge); font-size: 16px; font-weight: 700; }
.level-pill b { color: var(--kk-gold); font-size: 23px; font-weight: 800; }
.header-button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 14px; color: var(--kk-ink); background: var(--kk-raised); border: 0; border-radius: 10px; box-shadow: 0 2px 0 var(--kk-edge); font-size: 16px; font-weight: 700; }
.header-button:hover { background: var(--kk-raised-hover); }
.header-button svg, .game-menu svg { width: 20px; height: 20px; }
.game-layout { flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, 1fr) clamp(380px, 35vw, 520px); gap: 14px; min-height: 0; padding: 12px clamp(12px, 1.6vw, 24px); }
.play-column { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.side-column { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }

.game-stats-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.stat-chip { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 12px; background: var(--kk-panel); border: 2px solid var(--kk-line-soft); border-radius: 10px; }
.stat-icon { display: grid; flex: 0 0 36px; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: #fff; background: #5b48c0; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25); --kk-icon-cut: #8a5a00; }
.stat-icon svg { width: 22px; height: 22px; }
.score-chip .stat-icon { color: var(--kk-gold-ink); background: var(--kk-gold); }
.money-chip .stat-icon { color: #ffe07a; background: #9a5b0a; --kk-icon-cut: #9a5b0a; }
.health-chip .stat-icon { background: #c8364d; }
.wave-chip .stat-icon { background: #178066; }
.streak-chip .stat-icon { color: var(--kk-gold-ink); background: #ff9a3d; }
.stat-chip small { display: block; color: var(--kk-muted); font-size: 14px; font-weight: 500; line-height: 1.1; }
.stat-chip strong { display: block; font-size: 22px; font-weight: 800; line-height: 1.15; white-space: nowrap; }
.score-chip strong { color: var(--kk-gold); }
.stat-chip em { color: var(--kk-muted); font-size: 16px; font-style: normal; font-weight: 500; }
.stat-chip.bump strong { animation: stat-bump .45s ease-out; }
.stat-chip.hurt { border-color: var(--kk-bad); animation: chip-hurt .45s ease-out; }
@keyframes stat-bump { 30% { transform: scale(1.18); color: var(--kk-good); } }
@keyframes chip-hurt { 30% { background: var(--kk-bad-bg); } }

.board-frame { position: relative; flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: var(--kk-chrome); border: 2px solid var(--kk-edge); border-radius: 12px; }
.board-stage { position: relative; flex: 1 1 auto; display: grid; place-items: center; min-height: 0; background: #0b101d; }
.canvas-wrap { position: relative; width: 100%; aspect-ratio: 5 / 3; }
.canvas-wrap canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.canvas-wrap canvas:focus-visible { outline: 3px solid var(--kk-focus); outline-offset: -3px; }
/* Build window: countdown + "Start now" in the board's top-left corner, above the portal. Only the
   button takes clicks, so towers can still be placed around it. */
.build-phase { position: absolute; z-index: 4; left: 1.6%; top: 2%; display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 14px; color: var(--kk-ink); background: rgba(14, 20, 36, .88); border: 2px solid var(--kk-gold); border-radius: 12px; box-shadow: 0 4px 0 var(--kk-edge); pointer-events: none; }
.build-count { font-size: 20px; font-weight: 800; white-space: nowrap; }
.build-count b { display: inline-block; min-width: 1.2em; color: var(--kk-gold); font-variant-numeric: tabular-nums; text-align: center; }
.build-count b.tick { animation: build-tick .45s ease-out; }
@keyframes build-tick { 0% { transform: scale(1.35); } 100% { transform: none; } }
.build-start-now { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px; color: var(--kk-gold-ink); background: var(--kk-gold); border: 0; border-radius: 10px; box-shadow: 0 3px 0 var(--kk-gold-edge); font-size: 18px; font-weight: 800; pointer-events: auto; }
.build-start-now:hover { background: #ffd162; }
.build-start-now kbd { border-color: rgba(0, 0, 0, .25); background: rgba(0, 0, 0, .08); font-size: 13px; }
.board-guide { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 14px; background: var(--kk-chrome); border-top: 2px solid var(--kk-edge); font-size: 16px; font-weight: 700; }
.board-guide .level-name { flex: 0 0 auto; color: var(--kk-gold); font-weight: 800; }
.board-guide .guide-divider { flex: 0 0 2px; height: 22px; background: var(--kk-line); }
.live-dot { flex: 0 0 auto; width: 10px; height: 10px; background: var(--kk-good); border-radius: 50%; box-shadow: 0 0 0 4px rgba(61, 220, 151, .2); }
.board-hint { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--kk-muted); text-overflow: ellipsis; white-space: nowrap; }
.board-hint.valid { color: var(--kk-good); }
.board-hint.invalid { color: var(--kk-bad); }
.board-hint.gate { color: var(--kk-gold); }
.cancel-placement { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; color: var(--kk-bad); background: var(--kk-bad-bg); border: 0; border-radius: 10px; font-size: 16px; font-weight: 800; }

/* Tower shop: one bar under the board. */
.shop-bar { flex: 0 0 auto; }
.tower-menu { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tower-choice { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 62px; padding: 8px 10px; color: var(--kk-ink); background: var(--kk-raised); border: 2px solid transparent; border-radius: 10px; box-shadow: 0 3px 0 var(--kk-edge); text-align: left; }
.tower-choice:hover:not(.cant-afford) { background: var(--kk-raised-hover); }
.tower-choice:active:not(.cant-afford) { transform: translateY(2px); box-shadow: 0 1px 0 var(--kk-edge); }
.tower-choice.selected { border-color: var(--kk-gold); background: color-mix(in srgb, var(--tower-color) 24%, var(--kk-raised)); }
.tower-choice.cant-afford { background: var(--kk-panel); box-shadow: none; border: 2px dashed var(--kk-line); }
.tower-choice.cant-afford .tower-choice-icon { filter: grayscale(1); opacity: .5; }
.tower-choice-icon { display: grid; flex: 0 0 38px; place-items: center; width: 38px; height: 38px; color: #fff; background: var(--tower-color); border-radius: 8px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .28); }
.tower-choice-icon svg { width: 24px; height: 24px; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .35)); }
.tower-choice-info { display: flex; flex-direction: column; min-width: 0; }
.tower-choice-info strong { font-size: 16px; font-weight: 700; line-height: 1.15; }
.tower-choice-info .tower-cost { color: var(--kk-gold); font-size: 15px; font-weight: 800; white-space: nowrap; }
.tower-choice.cant-afford .tower-cost { color: var(--kk-bad); }

/* Upgrade window: anchored beside the selected tower, on the board itself. */
.tower-panel { position: absolute; z-index: 5; width: 276px; padding: 14px; color: var(--kk-ink); background: var(--kk-panel); border: 2px solid var(--kk-line); border-radius: 12px; box-shadow: 0 4px 0 var(--kk-edge), 0 16px 36px rgba(0, 0, 0, .45); }
.tower-panel-head { display: flex; align-items: center; gap: 10px; padding-right: 36px; }
.tower-panel-head .tower-choice-icon { flex-basis: 38px; }
.tower-panel-head strong { display: block; font-size: 18px; font-weight: 800; line-height: 1.1; }
.tower-panel-head span { color: var(--kk-muted); font-size: 15px; font-weight: 500; }
.tower-panel-close { position: absolute; right: 6px; top: 6px; display: grid; place-items: center; width: 44px; height: 44px; color: var(--kk-muted); background: transparent; border: 0; border-radius: 8px; font-size: 26px; line-height: 1; }
.tower-panel-close:hover { color: var(--kk-ink); background: rgba(255, 255, 255, .08); }
.tower-stats { display: grid; gap: 4px; margin: 12px 0; }
.tower-stat { display: flex; justify-content: space-between; gap: 8px; font-size: 16px; }
.tower-stat span { color: var(--kk-muted); font-weight: 500; }
.tower-stat b { font-weight: 800; }
.tower-stat .next { margin-left: 4px; color: var(--kk-good); }
.upgrade-button { width: 100%; min-height: 48px; font-size: 17px; }
.upgrade-button:disabled { cursor: not-allowed; color: var(--kk-muted); background: var(--kk-raised); box-shadow: 0 2px 0 var(--kk-edge); }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.sell-button { min-height: 44px; padding: 0 12px; color: var(--kk-bad); background: var(--kk-bad-bg); border: 0; border-radius: 10px; font-size: 16px; font-weight: 800; }
.targeting { margin-top: 10px; }
.targeting-label { display: block; margin-bottom: 6px; color: var(--kk-muted); font-size: 15px; font-weight: 500; }
.targeting-toggles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.targeting-toggles button { min-height: 44px; padding: 0 4px; color: var(--kk-ink); background: var(--kk-raised); border: 0; border-radius: 8px; box-shadow: 0 2px 0 var(--kk-edge); font-size: 14px; font-weight: 700; }
.targeting-toggles button[aria-pressed="true"] { color: var(--kk-gold-ink); background: var(--kk-gold); box-shadow: 0 2px 0 var(--kk-gold-edge); }

/* Question card: owns the right column. */
.question-card { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding: 18px 20px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--kk-line) transparent; }
.question-card > * { flex-shrink: 0; }
.question-topline { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; }
.topic-badge { flex: 0 1 auto; max-width: 100%; min-width: 0; overflow: hidden; padding: 4px 10px; color: var(--kk-good); background: var(--kk-good-bg); border-radius: 8px; font-size: 15px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.question-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: var(--kk-muted); font-size: 15px; font-weight: 500; }
.focus-question-button { min-height: 44px; padding: 0 12px; color: var(--kk-ink); background: var(--kk-raised); border: 0; border-radius: 8px; box-shadow: 0 2px 0 var(--kk-edge); font-size: 14px; font-weight: 700; }
.question-card h3 { margin: 16px 0 18px; font-size: clamp(22px, 1.75vw, 26px); font-weight: 700; line-height: 1.32; letter-spacing: -.01em; }
.prompt-blank { display: inline-block; width: 5.2em; margin: 0 .12em; border-bottom: 3px solid var(--kk-gold); vertical-align: -.08em; }
.question-image { display: block; width: min(100%, 180px); max-height: 120px; margin: 0 0 12px; object-fit: contain; border: 2px solid var(--kk-line); border-radius: 10px; background: #fff; }
/* Question Banks v2 pictures in the narrow question card (shared/question-media.css sets the rest). */
#question-title .tlg-qmedia { margin: 0 0 10px; }
#question-title .tlg-qmedia img { max-height: min(24vh, 190px); border: 2px solid var(--kk-line); }
#question-title .tlg-qmedia-credit { font-weight: 400; }
.answer-options { display: grid; gap: 10px; }
.answer-button { position: relative; width: 100%; min-height: 56px; padding: 12px 16px 12px 56px; color: var(--kk-ink); background: var(--kk-raised); border: 2px solid transparent; border-radius: 10px; box-shadow: 0 3px 0 var(--kk-edge); text-align: left; font-size: 18px; font-weight: 500; line-height: 1.3; }
.answer-button:hover:not(:disabled) { background: var(--kk-raised-hover); border-color: var(--kk-blue); }
.answer-button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--kk-edge); }
.answer-letter { position: absolute; left: 12px; top: 50%; display: grid; place-items: center; width: 32px; height: 32px; margin-top: -16px; color: var(--kk-ink); background: #33406a; border-radius: 8px; font-size: 16px; font-weight: 800; }
.answer-button:disabled { cursor: default; }
.answer-button.correct { color: #eafff5; background: var(--kk-good-bg); border-color: var(--kk-good); }
.answer-button.correct .answer-letter { color: #062519; background: var(--kk-good); }
.answer-button.incorrect { color: #ffecec; background: var(--kk-bad-bg); border-color: var(--kk-bad); }
.answer-button.incorrect .answer-letter { color: #3a0c14; background: var(--kk-bad); }
.answer-options[data-type="true-false"] { grid-template-columns: 1fr 1fr; }
.tf-button { min-height: 76px; padding-left: 16px; text-align: center; font-size: 22px; font-weight: 700; }
.tf-button .answer-letter { position: static; display: inline-grid; margin: 0 10px 0 0; vertical-align: middle; }
.fill-in-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.fill-in-input { width: 100%; min-height: 58px; padding: 10px 16px; color: var(--kk-ink); background: #0f1629; border: 2px solid var(--kk-line); border-radius: 10px; font-size: 20px; font-weight: 500; }
.fill-in-input::placeholder { color: #8f9abb; }
.fill-in-input:focus { border-color: var(--kk-blue); outline: none; box-shadow: 0 0 0 3px rgba(159, 176, 255, .25); }
.fill-in-input.correct { color: #eafff5; background: var(--kk-good-bg); border-color: var(--kk-good); }
.fill-in-input.incorrect { color: #ffecec; background: var(--kk-bad-bg); border-color: var(--kk-bad); }
.check-button { min-height: 58px; padding: 0 24px; font-size: 18px; }
.check-button:disabled { cursor: default; color: var(--kk-muted); background: var(--kk-raised); box-shadow: 0 2px 0 var(--kk-edge); }
.answer-hint { margin: 10px 0 0; color: var(--kk-muted); font-size: 15px; }
.answer-feedback { min-height: 0; margin-top: 14px; color: var(--kk-muted); font-size: 17px; line-height: 1.5; }
.answer-feedback:empty { display: none; }
.answer-feedback strong { display: block; margin-bottom: 2px; font-size: 19px; font-weight: 800; }
.answer-feedback.good strong { color: var(--kk-good); }
.answer-feedback.good strong b { color: var(--kk-gold); }
.answer-feedback.bad strong { color: var(--kk-bad); }
.answer-feedback.hint { color: var(--kk-gold); font-weight: 700; }
.answer-feedback .correct-answer { color: var(--kk-ink); }
.answer-feedback .retry-note { display: block; margin-top: 6px; color: var(--kk-muted); font-size: 15px; }
.question-card .secondary-button { width: 100%; margin-top: 14px; }
.streak-card { flex: 0 0 auto; padding: 10px 18px 14px; }
/* Streak ladder: current multiplier, the next tier, and one pill per tier (KK_CONFIG.streakTiers). */
.streak-head { display: flex; align-items: center; gap: 12px; }
.streak-multiplier { flex: 0 0 auto; min-width: 66px; padding: 4px 10px; color: var(--tier-ink, var(--kk-gold-ink)); background: var(--tier-bg, var(--kk-gold)); border-radius: 10px; box-shadow: 0 3px 0 var(--tier-edge, var(--kk-gold-edge)); font-size: 26px; font-weight: 800; line-height: 1.15; text-align: center; transition: background .2s, color .2s; }
.streak-copy { display: flex; flex-direction: column; min-width: 0; }
.streak-copy strong { color: var(--kk-ink); font-size: 16px; font-weight: 700; line-height: 1.25; }
.streak-copy span { color: var(--kk-muted); font-size: 15px; font-weight: 500; }
.tier-ladder { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; margin: 10px 0 0; padding: 0; list-style: none; }
.tier-ladder li { padding: 3px 0; color: var(--kk-muted); background: var(--kk-raised); border-radius: 6px; font-size: 14px; font-weight: 700; text-align: center; }
.tier-ladder li.reached { color: var(--tier-ink, var(--kk-gold-ink)); background: var(--tier-fill, var(--kk-gold)); }
.tier-ladder li.current { box-shadow: 0 0 0 2px var(--kk-panel), 0 0 0 4px var(--tier-fill, var(--kk-gold)); }
/* Tier colors heat up as the streak climbs: gold, orange, hot orange, red. Text on each fill is 4.5:1+. */
.streak-meter[data-tier="1"], .streak-meter[data-tier="2"] { --tier-fill: #ffc53d; --tier-bg: #ffc53d; --tier-ink: #1d1400; --tier-edge: #b9820c; }
.streak-meter[data-tier="3"], .streak-meter[data-tier="4"] { --tier-fill: #ffa12e; --tier-bg: #ffa12e; --tier-ink: #1d0f00; --tier-edge: #b3620a; }
.streak-meter[data-tier="5"], .streak-meter[data-tier="6"] { --tier-fill: #ff7a2e; --tier-bg: #ff7a2e; --tier-ink: #1d0800; --tier-edge: #a8420a; }
.streak-meter[data-tier="7"], .streak-meter[data-tier="8"] { --tier-fill: #ff4d5e; --tier-bg: #ff4d5e; --tier-ink: #1d0005; --tier-edge: #9c1626; }
.streak-meter[data-tier="0"] .streak-multiplier, .streak-meter:not([data-tier]) .streak-multiplier { color: var(--kk-ink); background: var(--kk-raised); box-shadow: 0 3px 0 var(--kk-edge); }
.question-card.shake { animation: card-shake .38s ease-in-out; }
/* While the level-complete / knowledge-gate card is up the question is covered (the game is frozen then). */
.question-card.question-hidden > :not(.question-hidden-panel) { visibility: hidden; }
.question-hidden-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 160px; margin: auto 0; color: var(--kk-muted); text-align: center; }
.question-hidden-panel strong { color: var(--kk-ink); font-size: 22px; font-weight: 800; }
@keyframes card-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.focus-question-mode .board-frame, .focus-question-mode .shop-bar { opacity: .5; }
.focus-question-mode .question-card h3 { font-size: 30px; }
.focus-question-mode .answer-button { font-size: 21px; }
.focus-question-mode .fill-in-input { font-size: 23px; }

/* Coin pop and banners (motion; skipped under Reduce motion). */
.coin-pop { position: fixed; z-index: 60; pointer-events: none; color: var(--kk-gold); font-size: 22px; font-weight: 800; text-shadow: 0 2px 0 var(--kk-edge), 0 0 2px var(--kk-edge); animation: coin-pop 1s ease-out forwards; }
@keyframes coin-pop { 0% { opacity: 0; transform: translateY(6px) scale(.8); } 20% { opacity: 1; transform: translateY(-4px) scale(1.1); } 100% { opacity: 0; transform: translateY(-46px) scale(1); } }
.level-banner { position: fixed; z-index: 55; left: 50%; top: 18%; padding: 12px 28px; color: var(--kk-gold-ink); background: var(--kk-gold); border: 3px solid var(--kk-edge); border-radius: 12px; box-shadow: 0 5px 0 var(--kk-edge); font-size: 26px; font-weight: 800; white-space: nowrap; pointer-events: none; transform: translateX(-50%); animation: level-banner 1.8s ease-out forwards; }
@keyframes level-banner { 0% { opacity: 0; transform: translate(-50%, -16px) scale(.9); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.04); } 25% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -10px); } }
.level-banner.on-board { position: absolute; top: 12%; }
.level-banner.boss { color: #fff; background: #c8364d; }
.level-banner.good { color: #062519; background: var(--kk-good); }
.level-banner.tier { font-size: 34px; letter-spacing: .02em; }
.level-banner.tier-1 { background: #ffc53d; }
.level-banner.tier-2 { background: #ffa12e; }
.level-banner.tier-3 { background: #ff7a2e; }
.level-banner.tier-4 { color: #fff; background: #d8283b; }

/* ---- overlays, Settings popover, ⋯ menu, coach marks ------------------------------------------ */
.overlay { position: fixed; z-index: 1001; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(6, 9, 18, .72); }
.overlay-card { position: relative; width: min(100%, 560px); max-height: calc(100vh - 40px); overflow-y: auto; padding: 30px; color: var(--kk-ink); background: var(--kk-panel); border: 2px solid var(--kk-line); border-radius: 12px; box-shadow: 0 6px 0 var(--kk-edge), 0 24px 60px rgba(0, 0, 0, .5); text-align: center; }
.overlay-orb { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 14px; color: var(--kk-gold-ink); background: var(--kk-gold); border-radius: 12px; box-shadow: 0 4px 0 var(--kk-gold-edge); }
.overlay-orb svg { width: 34px; height: 34px; }
.overlay-orb.cool { color: #fff; background: #178066; box-shadow: 0 4px 0 #0c4a3b; }
.overlay-card h2 { margin: 8px 0; font-size: 32px; }
.overlay-card p:not(.card-kicker) { color: var(--kk-muted); font-size: 17px; line-height: 1.5; }
.transition-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 22px 0; }
.transition-stats div { padding: 12px 6px; background: var(--kk-raised); border-radius: 10px; box-shadow: 0 2px 0 var(--kk-edge); }
.transition-stats b, .transition-stats span { display: block; }
.transition-stats b { color: var(--kk-gold); font-size: 20px; font-weight: 800; }
.transition-stats span { margin-top: 3px; color: var(--kk-muted); font-size: 14px; font-weight: 500; }
.small-overlay { width: min(100%, 420px); }
.overlay-actions { display: grid; gap: 12px; margin-top: 20px; }
.close-button { position: absolute; right: 12px; top: 10px; width: 44px; height: 44px; color: var(--kk-muted); background: transparent; border: 0; border-radius: 10px; font-size: 28px; }
.close-button:hover { color: var(--kk-ink); background: rgba(255, 255, 255, .08); }
.tutorial-card { width: min(100%, 720px); text-align: left; }
.tutorial-card > h2, .tutorial-card > .card-kicker { text-align: center; }
.tutorial-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0; }
.tutorial-grid > div { padding: 16px; background: var(--kk-raised); border-radius: 10px; }
.tutorial-grid span { display: grid; float: left; place-items: center; width: 30px; height: 30px; margin: 0 10px 8px 0; color: var(--kk-gold-ink); background: var(--kk-gold); border-radius: 8px; font-weight: 800; }
.tutorial-grid strong { display: block; padding-top: 3px; font-size: 18px; font-weight: 800; }
.tutorial-grid p { clear: both; margin: 10px 0 0; font-size: 16px; }
.overlay-card .tutorial-grid p { color: var(--kk-muted); font-size: 16px; }
.tutorial-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.tutorial-actions .primary-button { width: auto; min-width: 160px; }
.popover { position: fixed; z-index: 1002; width: 290px; padding: 14px 16px; color: var(--kk-ink); background: var(--kk-panel); border: 2px solid var(--kk-line); border-radius: 12px; box-shadow: 0 4px 0 var(--kk-edge), 0 16px 36px rgba(0, 0, 0, .45); }
.popover h2 { margin: 0 0 6px; font-size: 18px; }
.toggle-row { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 16px; font-weight: 500; cursor: pointer; }
.toggle-row input { width: 22px; height: 22px; accent-color: var(--kk-gold); }
.settings-name { display: grid; gap: 6px; margin-top: 6px; font-size: 16px; font-weight: 700; }
.menu-wrap { position: relative; }
.game-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; display: grid; min-width: 200px; padding: 6px; background: var(--kk-panel); border: 2px solid var(--kk-line); border-radius: 12px; box-shadow: 0 4px 0 var(--kk-edge), 0 16px 36px rgba(0, 0, 0, .45); }
.game-menu button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; color: var(--kk-ink); background: transparent; border: 0; border-radius: 8px; font-size: 16px; font-weight: 700; text-align: left; }
.game-menu button:hover, .game-menu button:focus-visible { background: var(--kk-raised); }
.coach { position: fixed; z-index: 1003; inset: 0; cursor: pointer; }
.coach-spot { position: fixed; border-radius: 12px; box-shadow: 0 0 0 4px var(--kk-gold), 0 0 0 9999px rgba(6, 9, 18, .7); pointer-events: none; transition: all .25s ease; }
.coach-bubble { position: fixed; width: min(340px, calc(100vw - 16px)); padding: 16px 18px; color: var(--kk-ink); background: var(--kk-panel); border: 3px solid var(--kk-gold); border-radius: 12px; box-shadow: 0 5px 0 var(--kk-edge), 0 16px 40px rgba(0, 0, 0, .5); cursor: default; }
.coach-step { margin: 0 0 4px; color: var(--kk-gold); font-family: var(--kk-mono); font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.coach-text { margin: 0 0 14px; font-size: 18px; font-weight: 500; line-height: 1.4; }
.coach-bubble .primary-button { min-height: 48px; }

/* ---- results --------------------------------------------------------------------------------- */
.results-screen { display: grid; place-items: center; padding: 36px 18px; background: var(--kk-page); }
.results-shell { position: relative; width: min(100%, 940px); text-align: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; color: var(--kk-muted); font-family: var(--kk-mono); font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow-dot { flex: 0 0 auto; width: 10px; height: 10px; background: var(--kk-gold); border-radius: 50%; }
.results-shell h1 { max-width: none; margin: 14px 0 10px; font-size: clamp(2.6rem, 6vw, 4.8rem); line-height: 1; }
.results-shell h1 span { color: var(--kk-gold); }
.results-lede { color: var(--kk-muted); font-size: 18px; }
.results-layout { display: grid; grid-template-columns: .8fr 1.2fr; gap: 14px; margin: 26px 0 18px; text-align: left; }
.results-score-card { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 300px; padding: 26px; color: var(--kk-gold-ink); background: var(--kk-gold); border: 0; box-shadow: 0 5px 0 var(--kk-gold-edge); }
.score-label { font-family: var(--kk-mono); font-size: 14px; letter-spacing: .1em; text-transform: uppercase; }
.results-score-card > strong { margin: 12px 0 0; font-size: 80px; font-weight: 800; line-height: .95; letter-spacing: -.02em; }
.score-caption { font-size: 16px; font-weight: 700; }
.results-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.results-badges span { padding: 7px 11px; color: var(--kk-gold-ink); background: rgba(255, 255, 255, .35); border-radius: 8px; font-size: 15px; font-weight: 700; }
.results-detail-card { padding: 14px 22px; }
.detail-row { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 2px solid var(--kk-line-soft); font-size: 16px; }
.detail-row:last-child { border-bottom: 0; }
.detail-row span { color: var(--kk-muted); }
.detail-row b { text-align: right; }
.detail-group { margin: 0 -10px 4px; padding: 0 10px; background: var(--kk-raised); border-radius: 10px; }
.detail-group .detail-row { border-bottom-color: var(--kk-line); }
.detail-total b { color: var(--kk-gold); font-size: 20px; font-weight: 800; }
.completion-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.completion-actions .primary-button { width: auto; }
.completion-summary { display: block; width: min(100%, 740px); min-height: 96px; margin: 16px auto 0; padding: 13px; color: var(--kk-muted); background: #0f1629; border: 2px solid var(--kk-line); border-radius: 10px; font-size: 15px; line-height: 1.45; resize: vertical; }
.submit-success { color: var(--kk-good); font-size: 16px; font-weight: 700; }
.missed-summary { margin-bottom: 18px; padding: 20px; text-align: left; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.section-heading h3 { margin: 4px 0 0; font-size: 20px; }
.question-label { color: var(--kk-muted); font-family: var(--kk-mono); font-size: 14px; letter-spacing: .08em; }
.build-count { color: var(--kk-muted); font-size: 15px; font-weight: 500; }
.missed-list { display: grid; gap: 8px; margin-top: 12px; }
.missed-item { padding: 10px 12px; color: var(--kk-muted); background: var(--kk-raised); border-left: 4px solid var(--kk-bad); border-radius: 8px; font-size: 16px; line-height: 1.45; }
.missed-item strong { color: var(--kk-bad); }

/* ---- leaderboard ----------------------------------------------------------------------------- */
.kk-leaderboard { padding: 18px 20px; margin-top: 14px; text-align: left; }
.lb-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.lb-tab { min-height: 44px; padding: 6px 12px; color: var(--kk-muted); background: var(--kk-raised); border: 2px solid transparent; border-radius: 8px; box-shadow: 0 2px 0 var(--kk-edge); font-size: 15px; font-weight: 700; }
.lb-tab.active { color: var(--kk-ink); border-color: var(--kk-gold); }
.lb-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 18px; font-weight: 800; }
.lb-title svg { width: 22px; height: 22px; color: var(--kk-gold); }
.lb-note, .lb-empty { color: var(--kk-muted); font-size: 16px; }
.lb-signin { margin-top: 6px; }
.lb-signin a { color: var(--kk-gold); font-size: 16px; font-weight: 700; }
.lb-celebrate { margin-bottom: 8px; padding: 6px 10px; color: var(--kk-gold-ink); background: var(--kk-gold); border-radius: 8px; font-size: 16px; font-weight: 800; }
/* rank, flag, name, country (Game Over only), level, points */
/* Rows: rank, avatar head, flag, username, score (shared/leaderboard.js rowsHtml), same order as Asteroid Blasters. */
.lb-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; font-size: 16px; }
.lb-med { flex: 0 0 34px; }
.lb-row:nth-child(odd) { background: rgba(255, 255, 255, .03); }
.lb-row.hi { background: var(--kk-gold-tint); box-shadow: inset 0 0 0 2px var(--kk-gold); }
.lb-med { color: var(--kk-muted); font-size: 15px; font-weight: 700; }
.lb-row:nth-child(-n+3) .lb-med { color: var(--kk-gold); }
.lb-name { flex: 1; min-width: 0; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.lb-country { display: none; color: var(--kk-muted); font-size: 14px; }
.lb-level { color: var(--kk-muted); font-size: 14px; font-weight: 500; }
.lb-pts { flex: none; font-weight: 800; }
.lb-you { margin-top: 8px; padding-top: 8px; color: var(--kk-muted); font-size: 15px; border-top: 2px dashed var(--kk-line); }
.start-leaderboard .lb-level { display: none; }

/* ---- v3 game feel: streak spectacle, toasts, Game Over celebration (all decoration: Reduce Motion
   hides or freezes it, see below) ------------------------------------------------------------------ */
.streak-card.tier-up { animation: tier-glow 1.1s ease-out; }
@keyframes tier-glow { 0% { box-shadow: 0 0 0 0 var(--tier-fill, var(--kk-gold)); } 30% { box-shadow: 0 0 0 4px var(--tier-fill, var(--kk-gold)), 0 0 24px 4px color-mix(in srgb, var(--tier-fill, var(--kk-gold)) 45%, transparent); } 100% { box-shadow: none; } }
.streak-card:has(.streak-meter[data-tier="1"]), .streak-card:has(.streak-meter[data-tier="2"]) { --tier-fill: #ffc53d; }
.streak-card:has(.streak-meter[data-tier="3"]), .streak-card:has(.streak-meter[data-tier="4"]) { --tier-fill: #ffa12e; }
.streak-card:has(.streak-meter[data-tier="5"]), .streak-card:has(.streak-meter[data-tier="6"]) { --tier-fill: #ff7a2e; }
.streak-card:has(.streak-meter[data-tier="7"]), .streak-card:has(.streak-meter[data-tier="8"]) { --tier-fill: #ff4d5e; }
.tier-ladder.shatter li { animation: pill-drop .6s ease-in; }
.tier-ladder.shatter li:nth-child(odd) { animation-name: pill-drop-left; }
@keyframes pill-drop { 0% { transform: none; opacity: 1; } 40% { transform: translateY(-3px) rotate(8deg); } 100% { transform: translateY(10px) rotate(18deg); opacity: .2; } }
@keyframes pill-drop-left { 0% { transform: none; opacity: 1; } 40% { transform: translateY(-3px) rotate(-8deg); } 100% { transform: translateY(10px) rotate(-18deg); opacity: .2; } }
/* x20 and up: a slow animated gold border around the board. */
.board-frame.streak-hot { border-color: var(--kk-gold); box-shadow: 0 0 0 2px var(--kk-gold), 0 0 22px 4px rgba(255, 197, 61, .45); animation: hot-border 1.6s ease-in-out infinite alternate; }
@keyframes hot-border { from { box-shadow: 0 0 0 2px #ffc53d, 0 0 14px 2px rgba(255, 197, 61, .35); } to { box-shadow: 0 0 0 2px #ff7a2e, 0 0 26px 6px rgba(255, 122, 46, .5); } }
.kk-toast { position: absolute; z-index: 7; left: 50%; bottom: 14px; padding: 10px 20px; color: var(--kk-gold-ink); background: var(--kk-gold); border: 3px solid var(--kk-edge); border-radius: 12px; box-shadow: 0 4px 0 var(--kk-edge); font-size: 20px; font-weight: 800; pointer-events: none; transform: translateX(-50%); animation: toast-in 2.6s ease-out forwards; }
.kk-toast.info { width: max-content; max-width: calc(100% - 32px); color: var(--kk-ink); background: #1a2340; border-color: var(--kk-gold); font-size: 18px; text-align: center; animation-duration: 4s; }
@keyframes toast-in { 0% { opacity: 0; transform: translate(-50%, 16px); } 12% { opacity: 1; transform: translate(-50%, 0); } 85% { opacity: 1; } 100% { opacity: 0; } }
.lb-row.slide-in { animation: row-in .7s cubic-bezier(.2, .8, .2, 1.1) .2s both; }
@keyframes row-in { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: none; } }
.kk-confetti { position: absolute; z-index: 5; top: -10px; width: 9px; height: 14px; border-radius: 2px; pointer-events: none; animation: confetti-fall 2.6s ease-in forwards; }
@keyframes confetti-fall { from { opacity: 1; transform: translate(0, 0) rotate(0); } to { opacity: 0; transform: translate(var(--drift), 620px) rotate(var(--spin)); } }

/* Answers ignore clicks for a moment after a question appears (a double-clicked Start or Next must not answer it). */
.answer-options.arming .answer-button, .answer-options.arming .check-button { opacity: .6; cursor: default; }

/* ---- reduced motion -------------------------------------------------------------------------- */
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
body.reduced-motion .coin-pop, body.reduced-motion .level-banner, body.reduced-motion .kk-toast, body.reduced-motion .kk-confetti { display: none; }
/* Information toasts (e.g. "The keep kept fighting while you were away.") still show, just without motion. */
body.reduced-motion .kk-toast.info { display: block; animation: none !important; }
body.reduced-motion .board-frame.streak-hot { animation: none; }

/* ---- smaller screens: layout changes only; text never drops below the floor above ------------ */
@media (max-width: 980px), (max-height: 560px) {
  /* Too small for a one-screen layout: stack, and let the page scroll instead. */
  .start-screen { height: auto; overflow: visible; }
  .start-columns { grid-template-columns: 1fr; }
  .subject-picker { grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: auto; }
  .subject-option { flex-direction: column; justify-content: center; gap: 8px; min-height: 112px; padding: 12px 8px; font-size: 18px; text-align: center; }
  .topic-list, .play-col .start-leaderboard { overflow: visible; }
  body.kk-playing { overflow: auto; }
  .game-screen { height: auto; min-height: 100vh; overflow: visible; }
  .game-layout { grid-template-columns: 1fr; }
  .board-stage { flex: 0 0 auto; }
  .question-card { overflow: visible; }
  .tower-menu { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .subject-picker { grid-template-columns: 1fr 1fr; }
  .game-brand h2, .game-divider { display: none; }
  .header-button span { display: none; }
  .game-stats-row { grid-template-columns: 1fr 1fr; }
  .tower-menu { grid-template-columns: 1fr 1fr; }
  .results-layout { grid-template-columns: 1fr; }
  .completion-actions { flex-direction: column; }
  .completion-actions .primary-button, .completion-actions .secondary-button { width: 100%; }
  .tutorial-grid { grid-template-columns: 1fr; }
  .transition-stats { grid-template-columns: repeat(2, 1fr); }
  .overlay-card { padding: 26px 18px; }
}
@media (max-height: 700px) { .tower-panel { width: 240px; padding: 10px; } .tower-stats { margin: 8px 0; } .tower-stat { font-size: 15px; } }

/* ---- print: the certificate prints light, whatever the screen theme ------------------------- */
@media print {
  body, .app-shell, .results-screen { color: #17213b; background: #fff; }
  .tlg-header, .tlg-footer { display: none; }
  .results-screen { padding: 0; }
  .results-shell h1 span { color: #4a3aa6; }
  .results-lede, .detail-row span, .eyebrow { color: #4f5873; }
  .card, .results-detail-card { color: #17213b; background: #fff; border-color: #d6dbe8; }
  .detail-group { background: #f0edff; }
  .completion-actions, .completion-summary, .submit-success, .kk-leaderboard, .missed-summary { display: none !important; }
  .results-score-card { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* The player's avatar in the game header (review games only; see shared/avatar/). 48x48 at x1 in a 64px slot, never smoothed. */
.kk-avatar-slot { width: 64px; height: 64px; flex: none; display: grid; place-items: end center; margin: -10px 0; overflow: hidden; }
.kk-avatar-slot canvas { width: 48px; height: 48px; image-rendering: pixelated; }

/* Build window on a narrow board: smaller, and no keyboard hint (the button stays >= 44 px). */
@media (max-width: 640px) {
  .build-phase { gap: 8px; padding: 4px 4px 4px 10px; }
  .build-count { font-size: 16px; }
  .build-start-now { min-height: 44px; padding: 0 12px; font-size: 16px; }
  .build-start-now kbd { display: none; }
}
