@font-face {
  font-family: "Fredoka";
  src: url("/fonts/fredoka-latin-wght.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --night: #0b1f3a;      /* stadium sky after kick-off */
  --night-2: #142f57;    /* raised panels */
  --pitch: #1d6a3b;
  --pitch-2: #237a46;
  --chalk: #f5f7f2;      /* text, pitch lines */
  --husky: #7de2f0;      /* the mascot's eyes: main actions */
  --husky-deep: #3aa9bb;
  --card: #ffd43b;       /* the referee's yellow card */
  --card-deep: #d9a900;
  --glow: #fff4c9;
  --error: #ffb4a8;
  --radius-btn: 999px;
  --font: "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--night);
  color: var(--chalk);
  font-family: var(--font);
  font-weight: 450;
  font-size: 1.0625rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* ---------- Stadium backdrop ---------- */
.stadium { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.floodlight {
  position: absolute; top: -18vh; width: 70vmax; height: 70vmax; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 201, 0.16), rgba(255, 244, 201, 0) 60%);
}
.floodlight-left { left: -30vmax; }
.floodlight-right { right: -30vmax; }
.pitch {
  position: absolute; left: -25%; right: -25%; bottom: -6vh; height: 34vh;
  background: repeating-linear-gradient(90deg, var(--pitch) 0 9vw, var(--pitch-2) 9vw 18vw);
  transform: perspective(60vh) rotateX(52deg);
  transform-origin: bottom center;
  box-shadow: 0 -2px 0 rgba(245, 247, 242, 0.5);
}
.pitch .box {
  position: absolute; left: 36%; right: 36%; top: 0; height: 58%;
  border: 0.5vh solid rgba(245, 247, 242, 0.7); border-top: 0;
}
.pitch::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; top: 0;
  background: linear-gradient(to top, rgba(11, 31, 58, 0), rgba(11, 31, 58, 0.7));
}

/* ---------- Brand ---------- */
.brand {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: clamp(20px, 5vh, 48px) 16px 8px;
  text-align: center;
}
.badge { width: clamp(64px, 11vh, 104px); height: auto; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35)); }
.wordmark { margin: 12px 0 0; line-height: 0; }
.wordmark img { width: clamp(240px, 42vw, 440px); height: auto; }
.tagline { margin: 10px 0 0; font-size: 1.05rem; font-weight: 500; opacity: 0.85; }

/* ---------- Screens ---------- */
main {
  position: relative; z-index: 1;
  width: 100%; max-width: 36rem;
  padding: 8px 16px 120px;
  flex: 1;
}
.screen { text-align: center; padding-top: 12px; }
.screen h2 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 650;
  line-height: 1.12;
  margin: 8px 0 16px;
  text-wrap: balance;
}
.screen h2:focus { outline: none; }
.say { margin: 0 auto 20px; max-width: 30rem; font-size: 1.15rem; text-wrap: pretty; }
.soft { display: block; font-size: 0.55em; font-weight: 500; margin-top: 4px; }
.choices { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* ---------- Buttons: chunky toy keys ---------- */
.btn {
  font: inherit; font-weight: 650; font-size: 1.3rem; letter-spacing: 0.01em;
  min-height: 56px; min-width: 132px; padding: 12px 30px;
  border-radius: var(--radius-btn); border: 3px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out, background-color 150ms;
  touch-action: manipulation;
}
.btn-yes { background: var(--husky); color: var(--night); box-shadow: 0 6px 0 var(--husky-deep); }
.btn-no { background: transparent; color: var(--chalk); border-color: var(--chalk); box-shadow: 0 6px 0 rgba(245, 247, 242, 0.35); }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--husky-deep); }
.btn-no:active { box-shadow: 0 2px 0 rgba(245, 247, 242, 0.35); }
.btn-wide { width: 100%; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

:focus-visible { outline: 3px solid var(--card); outline-offset: 4px; }

.link-btn {
  font: inherit; background: none; border: 0; color: var(--chalk);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
  min-height: 44px; min-width: 44px; padding: 0 8px;
}
a { color: var(--husky); text-underline-offset: 3px; }

/* ---------- The yellow card (wrong answers) ---------- */
.ref-card {
  display: inline-block;
  margin: 8px auto 20px;
  padding: 22px 26px 26px;
  background: var(--card);
  color: var(--night);
  border-radius: 14px;
  box-shadow: 0 8px 0 var(--card-deep), 0 18px 40px rgba(0, 0, 0, 0.35);
  transform: rotate(-5deg);
  max-width: 22rem;
}
.ref-card h2 { margin: 0; }
.screen:not([hidden]) .ref-card { animation: card-up 420ms cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes card-up {
  from { transform: translateY(40px) rotate(8deg) scale(0.7); opacity: 0; }
  to { transform: rotate(-5deg); opacity: 1; }
}

/* ---------- Form ---------- */
.signup {
  text-align: left;
  margin: 8px auto 0;
  max-width: 26rem;
  background: var(--night-2);
  border: 2px solid rgba(125, 226, 240, 0.35);
  border-radius: 22px;
  padding: 20px;
}
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.signup input[type="email"] {
  width: 100%; min-height: 52px; padding: 10px 14px;
  font: inherit; font-size: 1.1rem; color: var(--chalk);
  background: var(--night); border: 2px solid rgba(245, 247, 242, 0.55); border-radius: 14px;
}
.signup input[type="email"]:focus-visible { border-color: var(--husky); outline-offset: 2px; }
.signup input[aria-invalid="true"] { border-color: var(--error); }
.check { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; }
.check input { width: 28px; height: 28px; margin: 8px; flex: none; accent-color: var(--husky); }
.check label { padding: 8px 0; min-height: 44px; }
.error { color: var(--error); font-weight: 550; margin: 6px 0 0; }
.turnstile { margin: 16px 0 12px; min-height: 65px; }
.small { font-size: 0.95rem; margin: 14px 0 0; text-align: center; }
.small a { display: inline-block; padding: 10px 4px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Demo stage ---------- */
.screen-demo { padding-top: 0; }
.screen-demo:not([hidden]) { display: flex; flex-direction: column; gap: 8px; height: min(78svh, 680px); }
.screen-demo .stage { flex: 1; height: auto; min-height: 0; }
/* Solid bar above the game after a loss: nothing shows through it. */
.loss-bar {
  flex: none;
  background: var(--night-2); color: var(--chalk);
  border: 2px solid rgba(255, 212, 59, 0.6); border-radius: 14px;
  padding: 8px 14px; text-align: center; font-size: 1rem;
}
.loss-bar[hidden] { display: none; }
.loss-bar p { margin: 0; }
.loss-bar strong { color: var(--card); font-weight: 650; }
.progress-label { margin: 8px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.progress-label[hidden] { display: none; }
body.in-demo main { max-width: 1100px; }
body.in-demo .brand { padding-top: 10px; }
body.in-demo .badge { display: none; }
body.in-demo .tagline { margin-top: 4px; font-size: 0.95rem; }
body.in-demo .wordmark img { width: 200px; }
body.compact .badge { width: 56px; }
body.compact .tagline { margin-top: 6px; font-size: 0.95rem; }
body.compact .wordmark img { width: clamp(200px, 30vw, 280px); }
.stage {
  position: relative;
  width: 100%;
  height: min(72svh, 620px);
  border-radius: 20px;
  overflow: hidden;
  background: #06142a;
  border: 3px solid rgba(245, 247, 242, 0.25);
}
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.loading {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; background: var(--night);
}
.loading[hidden] { display: none; }
.loading-line { font-size: 1.35rem; font-weight: 600; margin: 18px 0 6px; min-height: 2em; }
.hint { opacity: 0.85; margin: 6px 0 0; max-width: 22rem; }
.bounce { position: relative; width: 60px; height: 90px; }
.mini-ball {
  position: absolute; left: 10px; top: 0; width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--night) 0 22%, transparent 23%), var(--chalk);
  animation: hop 700ms cubic-bezier(0.5, 0, 0.5, 1) infinite alternate;
}
.shadow {
  position: absolute; left: 14px; bottom: 0; width: 32px; height: 8px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.45); animation: squash 700ms cubic-bezier(0.5, 0, 0.5, 1) infinite alternate;
}
@keyframes hop { to { transform: translateY(44px) rotate(180deg); } }
@keyframes squash { from { transform: scaleX(0.55); opacity: 0.4; } }
.progress { width: min(260px, 80%); height: 12px; border-radius: 999px; background: rgba(245, 247, 242, 0.2); overflow: hidden; margin-top: 8px; }
.progress[hidden] { display: none; }
.progress-fill { height: 100%; width: 0; background: var(--husky); transition: width 200ms; }

/* ---------- Win celebration ---------- */
/* Everything decorative sits in layers behind the headline (z-index 0),
   so confetti can fly around the score but never across it. */
.win { position: relative; isolation: isolate; margin: 4px auto 8px; }
.win h2 { position: relative; z-index: 2; margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0; }
.win-burst {
  position: absolute; z-index: 0; left: 50%; top: 55%; width: 340px; height: 340px; margin: -170px 0 0 -170px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 212, 59, 0.38), rgba(125, 226, 240, 0.14) 45%, rgba(125, 226, 240, 0) 70%);
}
.screen:not([hidden]) .win-burst { animation: burst 900ms cubic-bezier(0.2, 1.3, 0.4, 1) both; }
.win-shout {
  font-size: clamp(2.2rem, 8vw, 3.4rem); font-weight: 700; color: var(--card);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
.win-line { font-size: clamp(1.2rem, 4vw, 1.6rem); font-weight: 600; margin-top: 2px; }
.win-score {
  font-size: clamp(4.5rem, 20vw, 8.5rem); font-weight: 700; line-height: 0.95;
  color: var(--husky); letter-spacing: 0.02em;
  text-shadow: 0 7px 0 var(--husky-deep), 0 16px 40px rgba(0, 0, 0, 0.45);
}
.win-score:empty { display: none; }
.screen:not([hidden]) .win h2 { animation: score-in 650ms cubic-bezier(0.2, 1.5, 0.4, 1) both; }
@keyframes burst { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes score-in { from { transform: scale(0.5); opacity: 0; } to { transform: none; opacity: 1; } }
.confetti { position: absolute; z-index: 1; left: 50%; top: 55%; width: 0; height: 0; }
.confetti i {
  position: absolute; left: -6px; top: -10px; width: 12px; height: 20px; border-radius: 3px;
  animation: pop 1300ms cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}
.win + .say { position: relative; z-index: 2; }
.tagline { text-wrap: balance; }
@keyframes pop {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; }
}

/* ---------- Footer ---------- */
.foot {
  position: relative; z-index: 1;
  display: flex; gap: 20px; align-items: center; justify-content: center;
  padding: 8px 16px 20px; font-size: 0.95rem;
}
.foot a { color: var(--chalk); display: inline-flex; align-items: center; min-height: 44px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Intro: lights out, glow, ball, flash, logo ---------- */
.skip-intro {
  position: fixed; right: 16px; bottom: 16px; z-index: 20;
  font: inherit; font-weight: 600; font-size: 1rem;
  min-height: 48px; padding: 8px 20px; border-radius: 999px;
  color: var(--chalk); background: rgba(245, 247, 242, 0.1);
  border: 2px solid rgba(245, 247, 242, 0.6); cursor: pointer;
}
body[data-phase="done"] .skip-intro { display: none; }

.intro {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: #000;
  pointer-events: none;
  transition: opacity 700ms ease-out;
}
.glow {
  position: absolute; width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0 18%, rgba(255, 244, 201, 0.55) 35%, rgba(255, 244, 201, 0) 70%);
  opacity: 0; transform: scale(0.2);
}
.ball { position: absolute; width: 120px; height: 120px; opacity: 0; transform: scale(0.6); }
.flash { position: absolute; inset: 0; background: var(--glow); opacity: 0; }

body[data-phase="glow"] .glow { animation: glow-in 1400ms ease-out forwards; }
body[data-phase="ball"] .glow { opacity: 1; transform: scale(30); animation: glow-swell 1100ms ease-in-out forwards; }
body[data-phase="ball"] .ball { animation: ball-in 1100ms cubic-bezier(0.2, 1.2, 0.4, 1) forwards; }
body[data-phase="flash"] .glow { opacity: 1; transform: scale(60); transition: transform 600ms ease-in; }
body[data-phase="flash"] .ball { opacity: 1; transform: scale(1.15); }
body[data-phase="flash"] .flash { animation: flash 700ms ease-out forwards; }
body[data-phase="flash"] .intro { background: var(--night); transition: background-color 300ms; }
body[data-phase="reveal"] .intro, body[data-phase="done"] .intro { opacity: 0; }

@keyframes glow-in {
  0% { opacity: 0; transform: scale(0.2); }
  40% { opacity: 0.8; transform: scale(4); }
  100% { opacity: 1; transform: scale(30); }
}
@keyframes glow-swell { from { transform: scale(30); } to { transform: scale(38); } }
@keyframes ball-in {
  from { opacity: 0; transform: scale(0.4) rotate(-120deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes flash {
  0% { opacity: 0; }
  35% { opacity: 0.95; }
  100% { opacity: 0; }
}

/* Logo and content stay hidden until the lights come on. */
body[data-phase="dark"] .brand, body[data-phase="glow"] .brand, body[data-phase="ball"] .brand,
body[data-phase="dark"] main, body[data-phase="glow"] main, body[data-phase="ball"] main, body[data-phase="flash"] main, body[data-phase="reveal"] main,
body[data-phase="dark"] .foot, body[data-phase="glow"] .foot, body[data-phase="ball"] .foot, body[data-phase="flash"] .foot, body[data-phase="reveal"] .foot {
  visibility: hidden;
}
body[data-phase="flash"] .brand { visibility: hidden; }
body[data-phase="reveal"] .brand { animation: brand-in 900ms cubic-bezier(0.2, 1.3, 0.4, 1) both; }
body[data-phase="done"] main { animation: fade-up 450ms ease-out both; }
@keyframes brand-in { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Reduced motion: no glow, ball or flash. A plain fade instead. */
@media (prefers-reduced-motion: reduce) {
  .glow, .ball, .flash { display: none; animation: none !important; }
  body[data-phase] .glow { animation: none !important; }
  .intro { transition: opacity 500ms linear; }
  body[data-phase="reveal"] .brand, body[data-phase="done"] main { animation: fade 500ms linear both; }
  .screen:not([hidden]) .ref-card { animation: none; }
  .mini-ball, .shadow { animation-duration: 1400ms; }
  .confetti { display: none; }
  .screen:not([hidden]) .win-burst, .screen:not([hidden]) .win h2 { animation: none; }
  .btn { transition: none; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
}

@media (max-width: 480px) {
  .btn { min-width: 120px; font-size: 1.2rem; }
  .signup { padding: 16px; }
  body.in-demo .wordmark img { width: 160px; }
  .stage { border-radius: 14px; }
  .screen-demo:not([hidden]) { height: calc(100svh - 160px); }
}

/* ---------- Plain pages (privacy, 404) ---------- */
.h2like { font-size: clamp(1.75rem, 5vw, 2.5rem); font-weight: 650; line-height: 1.12; margin: 8px 0 16px; text-wrap: balance; }
.prose { text-align: left; max-width: 38rem; padding-bottom: 40px; }
.prose h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); font-weight: 650; line-height: 1.1; margin: 8px 0 12px; }
.prose h2 { font-size: 1.35rem; font-weight: 600; margin: 28px 0 6px; }
.prose p, .prose li { max-width: 34rem; }
.prose ul { padding-left: 1.2em; }
.updated { margin: 0 0 20px; opacity: 0.85; }
body.plain main { max-width: 40rem; padding-bottom: 60px; animation: none; }
