:root {
  color-scheme: light;
  font-family: Heebo, sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #28253b;
  --muted: #6d6978;        /* 4.81:1 on the page, 5.24:1 on paper */
  --muted-strong: #5f5b6b; /* tinted surfaces: >= 4.69:1 on every tile and podium color */
  --success-text: #38734d; /* 5.54:1 on paper, 4.89:1 on the green tint */
  --danger-text: #a8412c;  /* 5.97:1 on paper, 5.17:1 on the coral tint */
  --paper: #fffdf7;
  --line: #ded9ce;
  --coral: #f16d50;
  --blue: #5146c8;
  --yellow: #f2c64e;
  --green: #52a979;
  --motion: cubic-bezier(.22, 1, .36, 1);
  /* Surfaces */
  --page: #f7f3e9;
  --paper-raised: #fffefa;
  --sunken: #f1eee7;
  --track: #e7e2d8;
  --line-strong: #d8d2c8;
  --control-border: #aaa4b4;
  --hairline: #28253b22;
  --hairline-strong: #28253b38;
  --shadow: #28253b20;
  --scrim: #28253b88;
  --dots: #81796616;
  /* Tints behind selected and status states */
  --tint-accent: #e9e5fb;
  --tint-accent-soft: #efecf8;
  --tint-success: #e6f2e9;
  --tint-danger: #ffe8df;
  --tint-warn: #fff3ce;
  --podium-gold: #f7df8e;
  --podium-silver: #d9e9e3;
  --podium-bronze: #f3d3cb;
  --amber-border: #d4a322;
  /* Text per difficulty (>= 4.5:1 on paper and on the selected tint) */
  --level-easy: #2f7a4f;
  --level-medium: #8a5e0b;
  --level-hard: #b5452c;
  /* Fills whose text color stays the same in both themes */
  --success-solid: #38734d;  /* white text 5.63:1 */
  --on-bright: #28253b;      /* text on coral (4.97:1) and yellow (9.14:1) */
  --button-bg: #28253b;
  --button-text: #ffffff;
  --button-hover: #5146c8;
  --button-accent: #f2c64e; /* arrows on buttons */
  --focus: #8175dd;
}

/* Dark theme, switched on by the toggle in the top bar (app.js sets data-theme on <html>).
   Same roles, measured against the dark surfaces (every text pair >= 5.7:1). Light is the default. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --ink: #f1ece2;
    --muted: #b1aabe;
    --muted-strong: #cac3d6;
    --paper: #211e2b;
    --line: #3b3549;
    --blue: #a99ff7;
    --green: #62c08b;
    --success-text: #7fd6a3;
    --danger-text: #ff9f88;
    --page: #17151f;
    --paper-raised: #252231;
    --sunken: #2c2838;
    --track: #353042;
    --line-strong: #4a435a;
    --control-border: #7a7290;
    --hairline: #f1ece21f;
    --hairline-strong: #f1ece233;
    --shadow: #00000059;
    --scrim: #0b0a10b3;
    --dots: #ffffff0f;
    --tint-accent: #2f2952;
    --tint-accent-soft: #29243f;
    --tint-success: #1d3427;
    --tint-danger: #3e2119;
    --tint-warn: #3a2f12;
    --podium-gold: #4a3c12;
    --podium-silver: #1f3631;
    --podium-bronze: #45261f;
    --amber-border: #b8902a;
    --level-easy: #7fd6a3;
    --level-medium: #f2c64e;
    --level-hard: #ff9f88;
    --button-bg: #f1ece2;
    --button-text: #17151f;
    --button-hover: #c8c1ff;
    --button-accent: #5146c8;
    --focus: #b3aaff;
}
/* Illustrations: outlines follow the text color, pastel fills become dark tints. */
:root[data-theme="dark"] svg [stroke="#28253B" i], :root[data-theme="dark"] svg [stroke="#25213A" i] { stroke: var(--ink); }
:root[data-theme="dark"] svg [fill="#E6F3E9" i] { fill: var(--tint-success); }
:root[data-theme="dark"] svg [fill="#E9E5FB" i] { fill: var(--tint-accent); }
:root[data-theme="dark"] svg [stroke="#fffdf7" i] { stroke: var(--paper); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background-color: var(--page);
  background-image: radial-gradient(var(--dots) .7px, transparent .7px);
  background-size: 9px 9px;
}
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.skip-link { position: absolute; top: -60px; right: 16px; z-index: 30; padding: 12px; background: var(--yellow); color: var(--on-bright); }
.skip-link:focus { top: 12px; }

.topbar {
  max-width: 1180px;
  height: 78px;
  margin: auto;
  padding: 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 7px; font-size: 24px; font-weight: 900; letter-spacing: -1.7px; }
.brand-symbol { width: 43px; height: 43px; overflow: visible; transition: transform .35s var(--motion); }
.brand-symbol path { stroke: var(--ink); }
.brand:hover .brand-symbol { transform: translateY(-1px) rotate(-2deg); }
.topbar nav { display: flex; align-items: center; gap: 30px; }
.nav-link { white-space: nowrap; font-size: 15px; font-weight: 600; color: var(--muted); transition: color .2s; }
.nav-link:hover, .nav-link.active { color: var(--blue); }
button.nav-link, .footer-contact { padding: 0; background: none; border: 0; cursor: pointer; }
.footer-contact { color: inherit; font-size: inherit; text-decoration: underline; text-underline-offset: 3px; }
.footer-contact:hover { color: var(--blue); }
button.nav-link:focus-visible, .footer-contact:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
/* Light/dark switch: icon-only, so it carries an aria-label; aria-pressed says whether dark is on. */
.top-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle { width: 40px; height: 40px; flex: none; display: grid; place-items: center; color: var(--ink); background: transparent; border: 1px solid var(--hairline-strong); border-radius: 50%; transition: background-color .2s ease, border-color .2s ease; }
.theme-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-sun, .theme-toggle[aria-pressed="true"] .icon-moon { display: none; }
.theme-toggle[aria-pressed="true"] .icon-sun { display: block; }
@media (hover: hover) and (pointer: fine) { .theme-toggle:hover { background: var(--tint-accent-soft); border-color: var(--blue); } }
.theme-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.top-cta { padding: 11px 17px; border: 1px solid var(--button-bg); border-radius: 3px 15px 3px 15px; background: var(--button-bg); color: var(--button-text); font-size: 14px; font-weight: 700; transition: transform .25s var(--motion), background .2s; }
.top-cta span { margin-right: 10px; color: var(--button-accent); font-size: 17px; }
.top-cta:hover { transform: translateY(-2px); background: var(--button-hover); color: var(--button-text); }

.hero {
  max-width: 1180px;
  min-height: 470px;
  margin: auto;
  padding: 30px 38px 36px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  border-bottom: 1px solid var(--hairline);
}
.hero-copy { position: relative; z-index: 1; padding-right: 32px; animation: arrive .6s var(--motion) both; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--blue); font-size: 13px; font-weight: 800; }
.eyebrow-line { width: 24px; height: 3px; background: var(--coral); }
.hero h1 { max-width: none; margin: 18px 0; color: var(--ink); font: 400 clamp(43px, 6.2vw, 78px)/1.15 'Secular One', Heebo, sans-serif; letter-spacing: -.8px; white-space: nowrap; }
.hero h1 { -webkit-text-stroke: .35px var(--ink); text-shadow: 2px 2px 0 var(--yellow), 4px 4px 0 #f16d5033; }
.headline-mark { position: relative; z-index: 0; color: var(--blue); }
.headline-mark::after { position: absolute; z-index: -1; right: 3%; bottom: -2px; width: 94%; height: 8px; content: ''; border-bottom: 6px solid var(--yellow); border-radius: 0 0 52% 46%; transform: rotate(-1.8deg); }
.hero-copy > p { max-width: 440px; margin: 19px 0 22px; color: var(--muted); font-size: 17px; line-height: 1.75; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.hero-button { padding: 13px 18px; display: inline-flex; align-items: center; background: var(--coral); color: var(--on-bright); font-size: 15px; font-weight: 800; border-radius: 3px 16px 3px 16px; transition: transform .25s var(--motion), background .2s; }
.hero-button span { margin-right: 17px; color: var(--paper); font-size: 18px; }
.hero-button:hover { transform: translateY(-3px) rotate(-1deg); background: var(--ink); color: var(--paper); }
.hero-button:hover span { color: var(--yellow); }
.hero-caption { color: var(--muted); font-size: 12px; white-space: nowrap; }
.hero-caption strong { margin-left: 4px; color: var(--ink); font: 700 19px 'Space Grotesk', sans-serif; }
.hero-proof { margin-top: 25px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.hero-proof span { color: var(--ink); font: 700 15px 'Space Grotesk', sans-serif; }
.hero-proof i { width: 1px; height: 15px; margin: 0 8px; background: var(--line-strong); }

.hero-art { position: relative; min-height: 390px; display: grid; place-items: center; }
.question-collage { width: min(100%, 520px); overflow: visible; }
.hero-art:hover .quiz-note { transform: translate(-50%, -53%) rotate(-2deg); box-shadow: 7px 9px 0 var(--shadow); }
.quiz-note { transition: transform .4s var(--motion), box-shadow .4s var(--motion); }
.back-card { transform-box: fill-box; transform-origin: center; animation: card-settle .65s .12s var(--motion) both; }
.collage-star { transform-box: fill-box; transform-origin: center; animation: star-pop .5s .3s var(--motion) both; }
.quiz-note { position: absolute; top: 50%; left: 50%; width: min(72%, 340px); padding: 14px 17px 12px; background: var(--paper); border: 2px solid var(--ink); border-radius: 4px 12px 4px 12px; box-shadow: 5px 6px 0 var(--shadow); transform: translate(-50%, -50%) rotate(-4deg); animation: card-settle .65s var(--motion) both; }
.quiz-note-top { display: flex; justify-content: space-between; padding-bottom: 8px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 12px; }
.quiz-note-top span:last-child { color: var(--blue); font-family: 'Space Grotesk', sans-serif; font-weight: 700; direction: ltr; unicode-bidi: isolate; }
.quiz-note h2 { margin: 12px 0 14px; color: var(--ink); font-size: 23px; line-height: 1.3; }
.quiz-answer { min-height: 34px; margin-top: 6px; padding: 6px 9px; display: flex; align-items: center; gap: 9px; color: var(--muted); background: var(--sunken); border-radius: 3px 8px 3px 8px; font-size: 13px; }
.quiz-answer span { width: 20px; height: 20px; display: grid; place-items: center; color: var(--blue); background: var(--paper-raised); border-radius: 50%; font-size: 12px; }
.quiz-answer.correct { color: var(--success-text); background: var(--tint-success); outline: 1px solid var(--green); }
.quiz-answer.correct span { color: white; background: var(--success-solid); }
.quiz-answer i { margin-right: auto; color: var(--green); font-style: normal; font-weight: 800; }
.quiz-note-bottom { margin-top: 10px; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.quiz-note-bottom span { width: 6px; height: 6px; background: var(--coral); border-radius: 50%; }
.art-caption { position: absolute; bottom: 18px; left: 5%; padding: 10px 15px; background: var(--paper); border: 1px solid var(--ink); border-radius: 2px 12px 2px 12px; color: var(--muted); font-size: 12px; transform: rotate(-3deg); }
.art-caption b { color: var(--ink); }

.play-layout { max-width: 980px; margin: 32px auto 0; padding: 0 28px; scroll-margin-top: 22px; }
.setup-card { padding: 25px 0 36px; }
.section-heading, .leader-heading { display: flex; align-items: center; justify-content: space-between; }
.section-heading h2, .leader-heading h2 { margin: 5px 0 0; font-size: 29px; letter-spacing: -.8px; }
.section-heading .eyebrow, .leader-heading .eyebrow { font-size: 13px; }
.mode-options { margin-top: 20px; display: flex; gap: 11px; }
.mode-option {
  position: relative;
  min-height: 78px;
  flex: 1 1 0;
  padding: 12px 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: right;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-bottom-color: var(--hairline-strong);
  border-radius: 2px 14px 2px 14px;
  transition: transform .25s var(--motion), background .2s, border-color .2s;
}
.mode-option:hover { transform: translateY(-3px) rotate(-.5deg); background: var(--paper); }
.mode-option.selected { background: var(--tint-accent); border-color: #5146c866; border-bottom: 3px solid var(--blue); }
.mode-icon { width: 29px; flex: none; color: var(--blue); font-size: 21px; text-align: center; }
.mode-art { width: 42px; height: 42px; flex: none; overflow: visible; transition: transform .35s var(--motion); }
.mode-option:hover .mode-art { transform: rotate(-5deg) scale(1.08); }
.mode-option.selected .mode-art { transform: rotate(3deg); }
.duel-icon { font-size: 24px; }
.mode-option strong, .mode-option small { display: block; }
.mode-option strong { font-size: 15px; }
.mode-option small { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.radio { width: 14px; height: 14px; flex: none; margin-right: auto; border: 1px solid var(--control-border); border-radius: 50%; transition: border .2s, box-shadow .2s; }
.selected .radio { border: 4px solid var(--blue); box-shadow: 0 0 0 3px #5146c81c; }
.players { max-width: 650px; margin-top: 15px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; animation: arrive .3s var(--motion) both; }
.players label { color: var(--muted); font-size: 13px; }
.players input { width: 100%; margin-top: 5px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 3px 10px 3px 10px; background: var(--paper); color: var(--ink); font-size: 16px; }
.players input:focus { border-color: var(--blue); }
.hidden { display: none !important; }
.divider { height: 1px; margin: 26px 0; background: var(--hairline); }
.difficulty-heading { margin-bottom: 15px; }
.difficulty-options { display: flex; flex-wrap: wrap; gap: 9px; }
.difficulty {
  min-height: 56px;
  flex: 1 1 20%;
  position: relative;
  padding: 9px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: right;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px 20px 20px 5px;
  transition: transform .25s var(--motion), background .2s, border-color .2s;
}
.difficulty:nth-child(even) { border-radius: 5px 20px 20px 20px; }
.difficulty:hover { transform: translateY(-3px) rotate(-1deg); }
.difficulty.selected { border-color: var(--blue); background: var(--tint-accent); box-shadow: 0 4px 0 #5146c81a; }
.difficulty[data-level=easy].selected { border-color: var(--green); background: var(--tint-success); box-shadow: 0 4px 0 #52a97922; }
.difficulty[data-level=medium].selected { border-color: var(--amber-border); background: var(--tint-warn); box-shadow: 0 4px 0 #d4a32222; }
.difficulty[data-level=hard].selected { border-color: var(--coral); background: var(--tint-danger); box-shadow: 0 4px 0 #f16d5022; }
.difficulty-emoji { min-width: 25px; color: var(--blue); font: 700 14px 'Space Grotesk', sans-serif; }
.difficulty[data-level=easy] .difficulty-emoji { color: var(--level-easy); }
.difficulty[data-level=medium] .difficulty-emoji { color: var(--level-medium); }
.difficulty[data-level=hard] .difficulty-emoji { color: var(--level-hard); }
.difficulty strong { font-size: 14px; white-space: nowrap; }
.difficulty small { color: var(--muted); font-size: 12px; }
.difficulty.selected small, .mode-option.selected small { color: var(--muted-strong); }
.difficulty-dot { position: absolute; top: 8px; left: 9px; width: 7px; height: 7px; border: 1px solid var(--control-border); border-radius: 50%; }
.difficulty.selected .difficulty-dot { background: var(--blue); border-color: var(--blue); }
.difficulty[data-level=easy].selected .difficulty-dot { background: var(--green); border-color: var(--green); }
.difficulty[data-level=medium].selected .difficulty-dot { background: var(--level-medium); border-color: var(--level-medium); }
.difficulty[data-level=hard].selected .difficulty-dot { background: var(--coral); border-color: var(--coral); }
.primary-button { width: min(100%, 340px); margin-top: 22px; padding: 14px 19px; display: flex; align-items: center; justify-content: space-between; color: var(--button-text); background: var(--button-bg); border: 0; border-radius: 3px 18px 3px 18px; font-size: 16px; font-weight: 800; transition: transform .25s var(--motion), background .2s; }
.primary-button:hover { transform: translateY(-3px); background: var(--button-hover); }
.primary-button:active { transform: scale(.99); }
.primary-button:focus-visible, .secondary-button:focus-visible, .next-button:focus-visible, .end-now:focus-visible, .leader-tab:focus-visible, .mode-option:focus-visible, .difficulty:focus-visible, .choice:focus-visible, .close-game:focus-visible, .players input:focus-visible, .review summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.button-arrow { color: var(--button-accent); font-size: 21px; }
.fine-print { margin: 10px 2px 0; color: var(--muted); font-size: 12px; }

.leader-card { padding: 32px 0 26px; border-top: 1px solid var(--hairline-strong); scroll-margin-top: 20px; }
.leader-heading h2 { font-size: 27px; }
.trophy { width: 42px; height: 42px; display: grid; place-items: center; color: var(--on-bright); background: var(--yellow); border: 1px solid var(--ink); border-radius: 50% 50% 50% 4px; font-size: 21px; transform: rotate(7deg); }
.leader-tabs { margin-top: 17px; display: flex; gap: 18px; border-bottom: 1px solid var(--hairline); }
.leader-tab { padding: 0 0 8px; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; font-size: 13px; }
.leader-tab.active { color: var(--blue); border-color: var(--blue); font-weight: 800; }
.leader-list { min-height: 190px; padding: 14px 0 0; }
.podium { min-height: 180px; padding: 8px 6px 0; display: flex; align-items: flex-end; justify-content: center; gap: 14px; }
.podium-place { min-height: 145px; flex: 0 1 160px; position: relative; padding: 13px 9px 15px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; background: var(--tint-accent); border: 1px solid var(--ink); border-radius: 55px 55px 4px 4px; animation: podium-up .4s var(--motion) both; }
.podium-place.place-1 { min-height: 177px; flex-basis: 175px; order: 1; background: var(--podium-gold); }
.podium-place.place-2 { order: 2; background: var(--podium-silver); }
.podium-place.place-3 { order: 3; background: var(--podium-bronze); }
.podium-medal { position: absolute; top: 10px; right: 13px; color: var(--muted-strong); font: 700 12px 'Space Grotesk', sans-serif; }
.podium-avatar { width: 43px; height: 43px; display: grid; place-items: center; color: var(--ink); background: var(--paper); border: 1px solid var(--ink); border-radius: 50%; font-size: 17px; font-weight: 800; }
.place-1 .podium-avatar { width: 51px; height: 51px; }
.podium-place strong { max-width: 100%; overflow: hidden; color: var(--ink); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.podium-place b { font: 700 16px 'Space Grotesk', sans-serif; }
.podium-place i { color: var(--muted-strong); font-size: 12px; font-style: normal; }
.runner-ups { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.runner-chip { padding: 8px 12px; display: inline-flex; align-items: center; gap: 7px; color: var(--muted-strong); background: var(--paper); border: 1px solid var(--line); border-radius: 20px; font-size: 13px; }
.runner-chip small { color: var(--blue); font: 700 12px 'Space Grotesk', sans-serif; }
.runner-chip b { color: var(--ink); font: 700 12px 'Space Grotesk', sans-serif; }
.leader-footer { padding-top: 12px; color: var(--muted); font-size: 12px; }
.globe { margin-left: 5px; color: var(--blue); }
.leader-empty { min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: var(--muted); text-align: center; }
.leader-empty > span { font-size: 25px; }
.leader-empty strong { color: var(--ink); font-size: 15px; }
.leader-empty small { font-size: 13px; }

.how { max-width: 1060px; margin: 72px auto 66px; padding: 0 28px; display: grid; grid-template-columns: .65fr 1.35fr; gap: 48px; align-items: start; }
.how-intro h2 { margin: 10px 0; font-size: 40px; line-height: 1.12; letter-spacing: -1px; }
.how-intro h2 span { color: var(--blue); }
.how-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.how-steps article { position: relative; padding-top: 13px; }
.step-art { width: 72px; height: 53px; margin: 0 0 10px; display: block; overflow: visible; transition: transform .35s var(--motion); }
.how-steps article:hover .step-art { transform: translateY(-4px) rotate(-4deg) scale(1.05); }
.how-steps article::before { width: 44px; height: 4px; position: absolute; top: 0; right: 0; content: ''; background: var(--coral); }
.how-steps article:nth-child(2)::before { background: var(--yellow); }
.how-steps article:nth-child(3)::before { background: var(--green); }
.how-steps article > span { color: var(--blue); font: 700 12px 'Space Grotesk', sans-serif; }
.how-steps h3 { margin: 9px 0 5px; font-size: 16px; }
.how-steps p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
footer { max-width: 1120px; margin: auto; padding: 18px 25px 24px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); border-top: 1px solid var(--hairline); font-size: 12px; }
footer .brand { font-size: 22px; }
footer .brand-symbol { width: 39px; height: 39px; }

.game-panel, .result-panel, .contact-panel { position: relative; width: min(100%, 520px); padding: 31px; background: var(--paper); border: 1px solid var(--ink); border-radius: 4px 18px 4px 18px; box-shadow: 7px 8px 0 var(--hairline); animation: arrive .3s var(--motion) both; }
.close-game { position: absolute; top: 12px; left: 13px; width: 31px; height: 31px; color: var(--ink); background: var(--sunken); border: 1px solid var(--line-strong); border-radius: 50%; font-size: 20px; transition: transform .25s var(--motion); }
.close-game:hover { transform: rotate(90deg); }
.game-top { display: flex; align-items: center; justify-content: space-between; }
.game-level { padding: 6px 10px; color: var(--blue); background: var(--tint-accent); border-radius: 20px; font-size: 13px; font-weight: 800; }
.turn-label { color: var(--muted-strong); font-size: 14px; font-weight: 700; }
.timer { padding: 5px 10px; color: var(--danger-text); background: var(--tint-danger); border-radius: 5px; font: 700 15px 'Space Grotesk', sans-serif; }
.progress-track { height: 5px; margin-top: 20px; overflow: hidden; background: var(--track); border-radius: 5px; }
.progress-track span { width: 10%; height: 100%; display: block; background: var(--coral); border-radius: 5px; transition: width .35s var(--motion); }
.game-meta { margin-top: 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.question-count { color: var(--muted); font-size: 13px; }
.end-now { min-height: 32px; padding: 4px 2px; color: var(--muted-strong); background: none; border: 0; font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.end-now:hover { color: var(--blue); }
.game-question { margin: 8px 0 17px; color: var(--ink); font-size: 28px; line-height: 1.4; }
.choices { display: grid; gap: 8px; }
.choice { width: 100%; padding: 13px; display: flex; align-items: center; gap: 11px; color: var(--ink); background: var(--paper-raised); border: 1px solid var(--line); border-radius: 6px 14px 6px 14px; text-align: right; font-size: 16px; transition: transform .2s var(--motion), background .2s, border .2s; }
.choice:hover:not(:disabled) { transform: translateX(-3px); border-color: var(--blue); background: var(--tint-accent-soft); }
.choice-key { width: 28px; height: 28px; flex: none; display: grid; place-items: center; color: var(--blue); background: var(--tint-accent); border-radius: 50%; font-size: 12px; }
.choice.correct { border-color: var(--green); background: var(--tint-success); }
.choice.correct .choice-key { color: white; background: var(--success-solid); }
.choice.wrong { border-color: var(--coral); background: var(--tint-danger); }
.choice:disabled { cursor: default; }
.feedback { min-height: 23px; margin: 10px 0 0; color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.6; }
.answer-source { margin-right: 7px; color: var(--blue); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.result-panel { padding: 35px 29px 25px; text-align: center; }
.result-icon { margin-bottom: 8px; font-size: 39px; }
/* Contact form: same card as the result panel; fields match the player-name inputs. */
.contact-panel h2 { margin: 4px 0 6px; color: var(--ink); font-size: 26px; text-wrap: balance; }
.contact-intro { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.55; text-wrap: pretty; }
.field { display: block; margin-top: 12px; color: var(--muted); font-size: 13px; }
.field small { font-size: 12px; font-weight: 400; }
.field input, .field textarea { display: block; width: 100%; margin-top: 5px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 3px 10px 3px 10px; background: var(--paper); color: var(--ink); font: inherit; font-size: 16px; }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus { border-color: var(--blue); }
.field input:focus-visible, .field textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.field [aria-invalid="true"] { border-color: var(--danger-text); }
.contact-trap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.contact-status { min-height: 1.4em; margin: 10px 0 0; color: var(--danger-text); font-size: 14px; }
.contact-panel .primary-button { width: 100%; margin-top: 6px; }
.contact-panel .primary-button[aria-busy="true"] { opacity: .7; cursor: progress; }
.contact-done { padding: 14px 0 4px; text-align: center; }
.contact-done h2:focus { outline: none; }
.contact-done p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.contact-done .primary-button { margin-top: 22px; }
.result-panel h2 { margin: 3px 0; color: var(--ink); font-size: 29px; }
.result-panel > p { margin: 4px; color: var(--muted); font-size: 14px; }
.result-points { margin: 14px auto 5px; display: flex; align-items: baseline; justify-content: center; gap: 7px; }
.result-points strong { color: var(--blue); font: 700 40px 'Space Grotesk', sans-serif; }
.result-points span { color: var(--muted); font-size: 13px; }
.result-scores { margin: 11px auto; display: flex; justify-content: center; gap: 9px; }
.result-player { padding: 8px 11px; background: var(--tint-accent-soft); border-radius: 7px; font-size: 13px; }
.result-player b { margin-top: 2px; display: block; font-size: 16px; }
.secondary-button { margin-top: 4px; padding: 10px; color: var(--muted); background: none; border: 0; font-size: 14px; }
.secondary-button:hover { color: var(--blue); }

/* Native dialogs: the browser makes the page behind them inert and handles Escape. */
dialog.modal { width: min(100% - 24px, 540px); max-width: none; max-height: calc(100dvh - 24px); margin: auto; padding: 10px; overflow: auto; overscroll-behavior: contain; color: var(--ink); background: transparent; border: 0; }
dialog.modal::backdrop { background: var(--scrim); backdrop-filter: blur(5px); }
body:has(dialog[open]) { overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* After every font shorthand, which resets font-variant. */
.timer, .result-points strong, .hero-caption strong, .podium-place b, .runner-chip b, .result-player b, .question-count { font-variant-numeric: tabular-nums; }

.lives { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.lives-player { padding: 3px 9px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted-strong); border-radius: 20px; font-size: 13px; font-weight: 700; }
.lives-player.current { color: var(--ink); background: var(--tint-accent-soft); }
.hearts { display: inline-flex; gap: 2px; }
.heart { width: 18px; height: 18px; fill: var(--coral); stroke: var(--danger-text); stroke-width: 1.5; }
.heart.lost { fill: none; stroke: var(--muted); }

.choice-text { flex: 1; }
.choice-mark { min-width: 1em; font-size: 18px; font-weight: 800; line-height: 1; }
.choice.correct .choice-mark { color: var(--success-text); }
.choice.wrong .choice-mark { color: var(--danger-text); }
.feedback.is-correct { color: var(--success-text); }
.feedback.is-wrong, .feedback.is-error { color: var(--danger-text); }
.next-button { margin-top: 12px; padding: 11px 18px; color: var(--button-text); background: var(--button-bg); border: 0; border-radius: 3px 14px 3px 14px; font-size: 15px; font-weight: 800; transition: background .2s; }
.next-button:hover { background: var(--button-hover); }

.overlay { position: absolute; inset: 0; z-index: 2; padding: 31px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; background: var(--paper); border-radius: inherit; }
.overlay h2 { margin: 0; font-size: 26px; }
.overlay p { margin: 0 0 8px; color: var(--muted); font-size: 15px; }
.leave-actions { width: min(100%, 300px); display: grid; gap: 4px; }
.leave-actions .primary-button { width: 100%; margin-top: 8px; justify-content: center; }

.handover .primary-button { width: min(100%, 300px); margin-top: 10px; }

/* Answer timer: the number turns coral at 5 seconds and the bar drains (app.js animates its scaleX). */
.timer { transition: background-color 200ms ease, color 200ms ease; }
.timer.is-urgent { color: var(--on-bright); background: var(--coral); }
.timer-track { height: 4px; margin-top: 14px; overflow: hidden; background: var(--track); border-radius: 4px; }
.timer-bar { height: 100%; display: block; background: var(--blue); border-radius: inherit; transform-origin: right; transition: background-color 200ms ease; }
.timer-track.is-urgent .timer-bar { background: var(--danger-text); }   /* 3:1+ against the track in both themes */

.life-hint { min-height: 18px; margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.lives-player.out .lives-name { text-decoration: line-through; }
/* A lost heart shakes once, a regained one grows in. Occasional state changes, so keyframes are fine. */
.heart.just-lost { animation: heart-lose 260ms var(--motion); }
.heart.just-gained { animation: heart-gain 250ms var(--motion); }
.personal-best { margin: 6px 2px 0; color: var(--blue); font-size: 13px; font-weight: 700; }
.result-badge { margin: 8px auto 2px; padding: 4px 12px; display: inline-block; color: var(--on-bright); background: var(--yellow); border-radius: 20px; font-size: 13px; font-weight: 800; }

.start-feedback { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.start-status { margin: 0; color: var(--danger-text); font-size: 14px; font-weight: 600; }
.start-fallback { margin: 0; padding: 6px 0; color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }

.result-panel .primary-button { margin-inline: auto; }
.result-player small { margin-top: 2px; display: block; color: var(--muted-strong); font-size: 12px; }
.review { margin: 12px 0 4px; text-align: start; background: var(--paper-raised); border: 1px solid var(--line); border-radius: 4px 12px 4px 12px; }
.review summary { padding: 10px 14px; color: var(--ink); cursor: pointer; font-size: 14px; font-weight: 700; }
.review ol { margin: 0; padding-block: 0 12px; padding-inline: 34px 14px; display: grid; gap: 10px; font-size: 14px; }
.review li p { margin: 2px 0; }
.review-question { font-weight: 700; }
.review-choice { color: var(--muted); font-size: 13px; }
.review-player { margin-bottom: 2px; padding: 1px 8px; display: inline-block; color: var(--blue); background: var(--tint-accent); border-radius: 20px; font-size: 12px; font-weight: 700; }

@keyframes heart-lose { 0% { transform: scale(1.25) rotate(-10deg); } 45% { transform: scale(1.08) rotate(7deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes heart-gain { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
@keyframes heart-fade { from { opacity: .3; } to { opacity: 1; } }
@keyframes arrive { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes card-settle { from { opacity: 0; transform: translateY(14px) rotate(0); } to { opacity: 1; } }
@keyframes star-pop { from { opacity: 0; transform: scale(.4) rotate(-20deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes podium-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 780px) {
  .topbar { height: 70px; padding: 0 20px; }
  .topbar nav { gap: 17px; }
  .hero { grid-template-columns: 1fr; padding: 30px 26px 20px; text-align: center; }
  .hero-copy { padding: 0; }
  .hero h1 { margin: 16px auto; font-size: clamp(48px, 8.5vw, 68px); }
  .hero-copy > p { margin: 14px auto 19px; font-size: 16px; }
  .hero-actions, .hero-proof { justify-content: center; }
  .hero-art { min-height: 315px; margin-top: 4px; }
  .question-collage { width: min(100%, 450px); }
  .quiz-note { width: min(72%, 325px); }
  .art-caption { bottom: 7px; left: 7%; }
  .play-layout { max-width: 630px; margin-top: 10px; padding: 0 22px; }
  .mode-options { gap: 5px; }
  .mode-option { flex-direction: column; align-items: flex-start; min-height: 105px; }
  .mode-icon { text-align: right; }
  .mode-option .radio { position: absolute; top: 14px; left: 13px; }
  .difficulty { flex-basis: 42%; }
  .how { grid-template-columns: 1fr; gap: 20px; margin: 55px auto; padding: 0 24px; }
  .how-intro h2 { font-size: 35px; }
}

@media (max-width: 520px) {
  .topbar { gap: 8px; padding: 0 14px; }
  .brand { gap: 4px; font-size: 21px; }
  .brand-symbol { width: 37px; height: 37px; }
  .topbar nav { gap: 12px; }
  .nav-link { font-size: 12px; }
  .topbar nav .nav-link:first-child, .topbar nav a[href="#how"], .topbar nav .nav-contact { display: none; }
  .top-cta { padding: 9px 11px; font-size: 12px; white-space: nowrap; }
  .top-actions { gap: 6px; }
  .theme-toggle { width: 36px; height: 36px; }
  .hero { padding: 25px 18px 17px; }
  .hero h1 { font-size: clamp(39px, 10.7vw, 49px); letter-spacing: -.5px; text-shadow: 1px 1px 0 var(--yellow), 2px 2px 0 #f16d5033; }
  .hero-copy > p { font-size: 15px; line-height: 1.65; }
  .hero-actions { gap: 10px; }
  .hero-button { padding: 12px 14px; font-size: 13px; white-space: nowrap; }
  .hero-button span { margin-right: 9px; }
  .hero-caption { font-size: 12px; white-space: nowrap; }
  .hero-caption strong { font-size: 16px; }
  .hero-proof { gap: 4px; margin-top: 18px; font-size: 12px; flex-wrap: wrap; justify-content: center; }
  .hero-proof span { font-size: 12px; }
  .hero-proof i { margin: 0 5px; }
  .hero-art { min-height: 285px; margin-top: 5px; }
  .question-collage { width: 100%; max-width: 390px; }
  .quiz-note { width: min(78%, 310px); padding: 12px 14px 10px; }
  .quiz-note h2 { margin: 10px 0 11px; font-size: 20px; }
  .quiz-answer { min-height: 32px; font-size: 12px; }
  .quiz-note-top { font-size: 12px; }
  .art-caption { bottom: -1px; left: 2%; padding: 8px 11px; font-size: 12px; }
  .play-layout { padding: 0 17px; }
  .section-heading h2 { font-size: 25px; }
  .mode-options { flex-direction: column; gap: 6px; }
  .mode-option { min-height: 65px; flex-direction: row; align-items: center; padding: 10px 11px; }
  .mode-art { width: 37px; height: 37px; }
  .mode-icon { text-align: center; }
  .mode-option .radio { position: static; margin-right: auto; }
  .mode-option strong { font-size: 15px; }
  .mode-option small { font-size: 12px; }
  .difficulty { flex-basis: 44%; min-height: 58px; padding: 8px 10px; gap: 7px; }
  .difficulty strong { font-size: 13px; }
  .difficulty small { font-size: 12px; white-space: normal; }
  .primary-button { width: 100%; font-size: 15px; }
  .fine-print { font-size: 12px; }
  .leader-heading h2 { font-size: 24px; }
  .podium { min-height: 155px; gap: 7px; }
  .podium-place { min-height: 124px; flex-basis: 32%; padding: 10px 4px; }
  .podium-place.place-1 { min-height: 151px; flex-basis: 35%; }
  .podium-avatar { width: 35px; height: 35px; font-size: 14px; }
  .place-1 .podium-avatar { width: 43px; height: 43px; }
  .podium-place strong { font-size: 12px; }
  .podium-place b { font-size: 12px; }
  .podium-place i { font-size: 12px; }
  .runner-chip, .runner-chip small, .runner-chip b { font-size: 12px; }
  .how-steps { gap: 11px; }
  .how-steps h3 { font-size: 14px; }
  .how-steps p { font-size: 12px; }
  footer { gap: 8px; flex-wrap: wrap; padding: 15px 16px 20px; font-size: 12px; }
  footer > span:nth-child(2) { order: 3; width: 100%; }
  .game-panel, .result-panel, .contact-panel { padding: 28px 17px; }
  .game-question { font-size: 23px; }
  .choice { font-size: 14px; }
}

/* The narrowest phones keep the logo, the theme switch and the call to action; the leaderboard is a scroll away. */
@media (max-width: 360px) {
  .topbar nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .heart.just-lost, .heart.just-gained { animation: heart-fade 200ms ease !important; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
