@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=Fredoka:wght@600;700&display=swap');

:root {
  --navy: #17324d;
  --cream: #fffaf0;
  --paper: #ffffff;
  --ink: #132437;
  --muted: #607083;
  --yellow: #ffd84d;
  --orange: #f47b35;
  --green: #2e9b68;
  --red: #d84747;
  --blue: #2474c6;
  --purple: #7654c4;
  --shadow: 0 12px 0 rgba(19, 36, 55, .16);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background-color: var(--navy);
  background-image:
    radial-gradient(circle at 12% 16%, rgba(255,216,77,.18) 0 3px, transparent 4px),
    radial-gradient(circle at 88% 82%, rgba(255,255,255,.10) 0 3px, transparent 4px);
  background-size: 36px 36px, 44px 44px;
  font-family: "Atkinson Hyperlegible", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button { touch-action: manipulation; }

.app-shell {
  width: min(100%, 900px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
}

.screen {
  position: relative;
  width: 100%;
  max-width: 760px;
  padding: clamp(26px, 5vw, 52px);
  border: 4px solid var(--ink);
  border-radius: 30px;
  background: var(--cream);
  box-shadow: var(--shadow);
  overflow: hidden;
}

[hidden] { display: none !important; }

.start-screen, .feedback-screen, .results-content { text-align: center; }

.brand-mark {
  width: 74px;
  height: 74px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  transform: rotate(-5deg);
  border: 4px solid var(--ink);
  border-radius: 20px 28px 18px 24px;
  background: var(--yellow);
  box-shadow: 5px 6px 0 var(--ink);
  font: 700 46px/1 "Fredoka", sans-serif;
}
.brand-mark span { transform: rotate(5deg); }

.eyebrow, .question-count {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2 { font-family: "Fredoka", sans-serif; text-wrap: balance; }
h1 { margin: 0; font-size: clamp(56px, 11vw, 88px); line-height: .95; letter-spacing: -.035em; }
h2 { margin: 12px 0 28px; font-size: clamp(30px, 5vw, 48px); line-height: 1.12; }
.quiz-title { margin: 12px 0 32px; font-size: clamp(22px, 4vw, 30px); font-weight: 700; }

.team-picker { padding: 0; margin: 0 0 26px; border: 0; }
.team-picker legend { width: 100%; margin-bottom: 14px; font-size: 20px; font-weight: 700; }
.team-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.team-option {
  min-height: 102px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 4px solid var(--ink);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 6px 0 var(--ink);
  cursor: pointer;
  font: 700 24px/1 "Fredoka", sans-serif;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.team-option input { position: absolute; opacity: 0; pointer-events: none; }
.team-letter { width: 50px; height: 50px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 50%; background: var(--yellow); }
.team-b .team-letter { background: #82d7ff; }
.team-option:has(input:checked) { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); background: #fff2b2; }
.team-b:has(input:checked) { background: #d8f3ff; }
.team-option:focus-within { outline: 5px solid var(--orange); outline-offset: 4px; }

.primary-button {
  width: 100%;
  min-height: 70px;
  padding: 16px 26px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  color: var(--ink);
  background: var(--orange);
  box-shadow: 0 7px 0 var(--ink);
  font: 700 28px/1 "Fredoka", sans-serif;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.primary-button:not(:disabled):active { transform: translateY(6px); box-shadow: 0 1px 0 var(--ink); }
.primary-button:not(:disabled):hover { filter: brightness(1.06); }
.primary-button:focus-visible { outline: 5px solid var(--yellow); outline-offset: 5px; }
.primary-button:disabled { opacity: .42; cursor: not-allowed; }
.helper-text { min-height: 24px; margin: 17px 0 0; color: var(--muted); font-weight: 700; }

.quiz-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 18px; font-weight: 700; }
.team-badge { padding: 9px 14px; border: 3px solid var(--ink); border-radius: 999px; background: var(--yellow); }
.team-badge[data-team="B"] { background: #82d7ff; }
.score-label { font-size: 19px; }
.progress-track { height: 15px; overflow: hidden; border: 3px solid var(--ink); border-radius: 999px; background: white; }
.progress-track span { display: block; width: 8.333%; height: 100%; background: var(--green); transition: width .3s ease; }
.question-count { margin-top: 22px; }
.quiz-timer {
  margin: 12px 0 18px;
  padding: 12px 16px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #fff2b2;
}
.quiz-timer.answering { background: #d8f3ff; }
.timer-copy { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 20px; font-weight: 700; }
.timer-copy strong { min-width: 52px; font: 700 28px/1 "Fredoka", sans-serif; text-align: right; }
.timer-track { height: 9px; margin-top: 9px; overflow: hidden; border: 2px solid var(--ink); border-radius: 999px; background: white; }
.timer-track span { display: block; width: 100%; height: 100%; background: var(--orange); }
.quiz-timer.answering .timer-track span { background: var(--blue); }
.quiz-screen h2 { min-height: 108px; }
.answer-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.answers-locked { visibility: hidden; opacity: 0; pointer-events: none; }

.answer-button {
  min-height: 100px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  border: 4px solid var(--ink);
  border-radius: 18px;
  color: var(--ink);
  background: white;
  box-shadow: 0 6px 0 var(--ink);
  font-size: clamp(18px, 2.8vw, 24px);
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease, background .1s ease;
}
.answer-button::before { content: attr(data-letter); flex: 0 0 42px; width: 42px; height: 42px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 12px; background: var(--answer-color); font-family: "Fredoka", sans-serif; }
.answer-button:nth-child(1) { --answer-color: #ffd84d; }
.answer-button:nth-child(2) { --answer-color: #82d7ff; }
.answer-button:nth-child(3) { --answer-color: #a8e49b; }
.answer-button:nth-child(4) { --answer-color: #ffaaa2; }
.answer-button:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.answer-button:focus-visible { outline: 5px solid var(--orange); outline-offset: 4px; }

.number-wrap { grid-column: 1 / -1; }
.number-input {
  width: 100%;
  min-height: 108px;
  padding: 12px 20px;
  border: 4px solid var(--ink);
  border-radius: 20px;
  background: white;
  color: var(--ink);
  text-align: center;
  font: 700 clamp(42px, 9vw, 72px)/1 "Fredoka", sans-serif;
  box-shadow: inset 0 -6px 0 #e7e0d5;
}
.number-input:focus { outline: 5px solid var(--yellow); outline-offset: 4px; }
.number-submit { margin-top: 18px; }

.feedback-screen { padding-top: clamp(34px, 6vw, 62px); }
.feedback-symbol { width: 94px; height: 94px; margin: 0 auto 20px; display: grid; place-items: center; border: 5px solid var(--ink); border-radius: 50%; color: white; font: 700 60px/1 "Fredoka", sans-serif; box-shadow: 5px 7px 0 var(--ink); }
.feedback-screen.correct .feedback-symbol { background: var(--green); }
.feedback-screen.incorrect .feedback-symbol { background: var(--red); }
.feedback-result { margin: 0; font-size: 22px; font-weight: 700; }
.feedback-heading { margin: 6px 0 24px; font-size: clamp(44px, 8vw, 66px); }
.correct-answer-card { margin-bottom: 30px; padding: 20px; border: 3px dashed var(--ink); border-radius: 18px; background: white; }
.correct-answer-card span { display: block; color: var(--muted); font-weight: 700; }
.correct-answer-card strong { display: block; margin-top: 6px; font: 700 clamp(24px, 4vw, 34px)/1.2 "Fredoka", sans-serif; }

.results-screen { background: var(--yellow); }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.results-content { position: relative; z-index: 1; }
.results-content h2 { margin: 8px 0 22px; font-size: clamp(42px, 8vw, 66px); }
.score-ring { width: clamp(190px, 42vw, 250px); aspect-ratio: 1; margin: 0 auto 22px; display: grid; place-content: center; border: 6px solid var(--ink); border-radius: 50%; background: var(--paper); box-shadow: 8px 10px 0 var(--ink); transform: rotate(-2deg); }
.score-ring strong { font: 700 clamp(72px, 15vw, 104px)/.85 "Fredoka", sans-serif; }
.score-ring span { margin-top: 12px; font-size: 20px; font-weight: 700; }
#final-message { margin: 24px auto 30px; max-width: 500px; font-size: 24px; font-weight: 700; }

@media (max-width: 620px) {
  .screen { padding: 24px 18px 28px; border-radius: 22px; }
  .team-options, .answer-options { grid-template-columns: 1fr; gap: 13px; }
  .team-option { min-height: 82px; }
  .quiz-screen h2 { min-height: auto; margin-bottom: 22px; }
  .answer-button { min-height: 78px; }
  h1 { font-size: 62px; }
}

@media (max-height: 760px) and (min-width: 621px) {
  .screen { padding: 24px 34px 28px; }
  .brand-mark { width: 58px; height: 58px; margin-bottom: 10px; font-size: 36px; }
  .quiz-title { margin-bottom: 20px; }
  .team-option { min-height: 82px; }
  .answer-button { min-height: 82px; }
  .quiz-screen h2 { min-height: 88px; margin-bottom: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  #confetti { display: none; }
}
