:root {
  --blue: #005BBF;
  --blue-2: #2D6BE4;
  --blue-soft: #E8F0FC;
  --navy: #1A1A2E;
  --ink: #414754;
  --bg: #FCF8FF;
  --card: #FFFFFF;
  --line: #E4E2EE;
  --good: #16A34A;
  --good-soft: #DCFCE7;
  --bad: #DC2626;
  --bad-soft: #FEE2E2;
  --marker-blue: #1D4ED8;
  --radius: 20px;
  --shadow: 0 20px 50px rgba(0, 91, 191, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, #DCE8FB 0%, transparent 60%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
a { color: var(--blue); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 40px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--blue); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 14px; letter-spacing: .5px;
}
.brand-text { font-weight: 600; font-size: 17px; }
.brand-text b { color: var(--blue); }
.top-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 18px;
}
.pill-link {
  text-decoration: none; font-weight: 700; font-size: 14px; padding: 10px 16px; border-radius: 999px;
  background: var(--navy); color: #fff;
}

.screen { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 32px; }

/* ---------- buttons ---------- */
.btn-primary {
  background: var(--blue); color: #fff; border: 0; border-radius: 16px; padding: 13px 22px;
  font-weight: 700; box-shadow: 0 14px 34px rgba(0, 91, 191, .28); text-decoration: none; display: inline-block;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary.big { font-size: 18px; padding: 16px 28px; width: 100%; margin-top: 8px; }
.btn-ghost {
  background: #fff; color: var(--blue); border: 1px solid #D6E0F5; border-radius: 16px; padding: 12px 18px; font-weight: 600;
}

/* ---------- setup ---------- */
.hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 24px; align-items: center; margin: 8px 0 24px; }
.eyebrow { display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--blue); background: var(--blue-soft); padding: 6px 12px; border-radius: 999px; }
h1 { color: var(--navy); font-size: clamp(34px, 5.4vw, 58px); line-height: 1.05; margin: 16px 0 14px; letter-spacing: -.02em; }
.hl { color: var(--blue); }
.lede { font-size: clamp(16px, 1.6vw, 19px); line-height: 1.6; max-width: 560px; margin: 0; }
.hero-mascot { position: relative; display: grid; place-items: end center; min-height: 340px; }
.hero-mascot .mascot-slot { width: min(220px, 60vw); margin-top: 110px; }
.speech-bubble {
  position: absolute; top: 0; left: 0; max-width: 230px; background: #fff; border: 2px solid var(--navy);
  border-radius: 18px 18px 18px 4px; padding: 10px 14px; font-family: "Caveat", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; font-size: 21px; line-height: 1.15; color: var(--navy);
  box-shadow: 4px 4px 0 var(--navy); z-index: 2; animation: bob 4s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-6px); } }

.setup-card { background: var(--card); border-radius: 28px; padding: clamp(20px, 3vw, 32px); box-shadow: var(--shadow); border: 1px solid var(--line); }
.setup-card h2 { color: var(--navy); font-size: 18px; margin: 4px 0 14px; }
.setup-card h2 + * { margin-bottom: 24px; }
.track-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.track {
  border: 2px solid var(--line); background: #fff; border-radius: 18px; padding: 16px 12px; text-align: left; color: var(--navy);
  display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, transform .15s, background .15s;
}
.track .em { font-size: 26px; }
.track b { font-size: 15px; line-height: 1.25; }
.track small { color: var(--ink); font-size: 12px; }
.track:hover { transform: translateY(-2px); }
.track[aria-checked="true"] { border-color: var(--blue); background: var(--blue-soft); }

.spice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.spice label { cursor: pointer; }
.spice input { position: absolute; opacity: 0; pointer-events: none; }
.spice span {
  display: flex; flex-direction: column; gap: 2px; border: 2px solid var(--line); border-radius: 16px; padding: 14px; font-weight: 700; color: var(--navy);
}
.spice small { font-weight: 500; color: var(--ink); }
.spice input:checked + span { border-color: var(--blue); background: var(--blue-soft); }
.spice input:focus-visible + span { outline: 3px solid #97B9E5; }
.fineprint { font-size: 13px; text-align: center; margin: 14px 0 0; }

/* ---------- game ---------- */
.game { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; align-items: stretch; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); }
.question-panel { padding: 24px; display: flex; flex-direction: column; }
.q-meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; }
.track-pill { background: var(--blue-soft); color: var(--blue); padding: 6px 12px; border-radius: 999px; }
.q-count { color: var(--ink); }
.progress { height: 6px; background: var(--line); border-radius: 99px; margin: 14px 0 18px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--blue); border-radius: inherit; transition: width .4s ease; }
.q-text { color: var(--navy); font-size: clamp(20px, 2.2vw, 26px); line-height: 1.3; margin: 0 0 18px; }

.options { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; }
.opt {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; background: #fff; color: var(--navy);
  border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; font-weight: 600; font-size: 15px; line-height: 1.35;
  transition: border-color .15s, background .15s, transform .15s;
}
.opt:hover:not(:disabled) { border-color: var(--blue); transform: translateX(2px); }
.opt .key {
  flex: 0 0 30px; height: 30px; border-radius: 10px; background: var(--blue-soft); color: var(--blue);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
}
.opt .tag { margin-left: auto; font-size: 11px; font-weight: 800; padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .key { background: var(--bad); color: #fff; }
.opt.wrong .tag { background: var(--bad); color: #fff; }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .key { background: var(--good); color: #fff; }
.opt.right .tag { background: var(--good); color: #fff; }
.opt:disabled { cursor: default; }
.opt.dim { opacity: .55; }

.answer-bar { display: flex; gap: 10px; margin-top: auto; }
.mic-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 18px; padding: 14px;
  background: var(--navy); color: #fff; font-weight: 700; position: relative; overflow: hidden;
}
.mic-btn .mic-ico { font-size: 20px; }
.mic-btn.listening { background: var(--bad); }
.mic-btn.listening::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 rgba(220, 38, 38, .6); animation: ping 1.2s infinite;
}
@keyframes ping { to { box-shadow: 0 0 0 18px rgba(220, 38, 38, 0); } }
.mic-btn:disabled, .btn-ghost:disabled { opacity: .5; cursor: default; }
.heard { min-height: 22px; font-size: 14px; font-style: italic; margin: 10px 2px 0; }
.score-row { display: flex; align-items: center; gap: 18px; margin-top: 12px; font-size: 14px; }
.score-row b { color: var(--navy); font-size: 18px; }
.score-row .btn-primary { margin-left: auto; }

/* ---------- whiteboard ---------- */
.board-panel { display: flex; flex-direction: column; overflow: hidden; position: relative; min-height: 540px; }
.board-head { display: flex; align-items: center; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #FAFAFD; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.r { background: #FF6159; } .dot.y { background: #FFBD2E; } .dot.g { background: #28C941; }
.board-title { margin-left: 8px; font-size: 13px; font-weight: 700; color: var(--ink); }
.board {
  flex: 1; position: relative; padding: 22px 24px 150px;
  background-image: radial-gradient(#E6E8F0 1.2px, transparent 1.2px); background-size: 22px 22px;
  font-family: "Caveat", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; color: var(--navy);
}
.board-empty { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; color: #A3A8B8; padding: 0 20px 120px; text-align: center; }
.board-content { display: flex; flex-direction: column; gap: 8px; }

.b-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: clamp(24px, 2.4vw, 30px); line-height: 1.15; }
.b-row .tick { font-weight: 700; }
.b-wrong { position: relative; color: var(--bad); }
.b-right { position: relative; color: var(--good); padding: 2px 10px; }
.b-right.long { padding: 0 0 8px; }
.scribble { position: absolute; inset: -8px -12px; width: calc(100% + 24px); height: calc(100% + 16px); overflow: visible; pointer-events: none; }
.scribble path { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .7s ease forwards; }
.b-wrong .scribble path { stroke: var(--bad); }
.b-right .scribble path { stroke: var(--good); }
@keyframes draw { to { stroke-dashoffset: 0; } }

.b-note { font-size: clamp(23px, 2.2vw, 29px); line-height: 1.2; color: var(--marker-blue); white-space: pre-wrap; min-height: 1.2em; }
.b-note:first-of-type { margin-top: 6px; }
.b-note .u { background: linear-gradient(transparent 62%, #FDE68A 62%); }

.flow { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.flow-box {
  font-size: clamp(20px, 2vw, 25px); padding: 6px 14px; border: 2.5px solid var(--navy); border-radius: 12px 16px 10px 14px / 14px 10px 16px 12px;
  background: #fff; opacity: 0; transform: scale(.85) rotate(-1deg); animation: pop .35s ease forwards;
}
.flow-box:nth-of-type(even) { transform: rotate(1deg); }
.flow-arrow { font-size: 30px; color: var(--navy); opacity: 0; animation: pop .3s ease forwards; }
@keyframes pop { to { opacity: 1; transform: scale(1) rotate(0); } }

.bridget-dock { position: absolute; right: 18px; bottom: 54px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bridget-dock .mascot-slot { width: 128px; }
.wave { display: flex; gap: 3px; height: 22px; align-items: center; opacity: .2; transition: opacity .2s; }
.wave i { display: block; width: 4px; height: 6px; border-radius: 3px; background: var(--blue-2); }
.wave.on { opacity: 1; }
.wave.on i { animation: eq .6s ease-in-out infinite; }
.wave.on i:nth-child(odd) { animation-duration: .45s; }
.wave.on i:nth-child(3n) { animation-duration: .7s; }
@keyframes eq { 50% { height: 22px; } }

.caption {
  position: absolute; left: 16px; right: 16px; bottom: 12px; min-height: 36px; text-align: center; font-weight: 700; font-size: 15px;
  color: var(--navy); padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, .92); border: 1px solid var(--line);
}
.caption:empty { visibility: hidden; }
.caption .hot { color: var(--bad); }

/* ---------- mascot ---------- */
.mascot { width: 100%; height: auto; display: block; overflow: visible; }
.mascot .body-g { transform-origin: 100px 190px; animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.025, .975); } }
.mascot .lid { transform: scaleY(0); transform-origin: center top; transform-box: fill-box; transition: transform .2s; }
.mascot.blink .lid { transform: scaleY(1); transition-duration: .06s; }
.mascot.unimpressed .lid { transform: scaleY(.5); }
.mascot .pupil { transition: transform .25s ease; }
.mascot.thinking .pupil { transform: translate(5px, -7px); }
.mascot.unimpressed .pupil { transform: translate(0, 4px); }
.mascot .mouth { display: none; }
.mascot .m-neutral { display: inline; }
.mascot.talking .m-neutral, .mascot.happy .m-neutral, .mascot.unimpressed .m-neutral { display: none; }
.mascot.talking .m-talk { display: inline; animation: talk .22s steps(2) infinite; }
.mascot.happy:not(.talking) .m-happy { display: inline; }
.mascot.unimpressed:not(.talking) .m-flat { display: inline; }
@keyframes talk { 50% { transform: scaleY(.35); } }
.mascot .m-talk { transform-origin: 100px 142px; transform-box: view-box; }
.mascot .brow { transition: transform .25s; transform-box: fill-box; transform-origin: center; }
.mascot.unimpressed .brow-l { transform: translateY(6px) rotate(10deg); }
.mascot.unimpressed .brow-r { transform: translateY(6px) rotate(-10deg); }
.mascot.happy .brow { transform: translateY(-5px); }
.mascot.thinking .brow-r { transform: translateY(-6px); }
.mascot .blush { opacity: 0; transition: opacity .3s; }
.mascot.happy .blush { opacity: .55; }
.mascot .spark { opacity: 0; }
.mascot.thinking .spark { animation: spark 1s ease-in-out infinite; }
.mascot.thinking .spark:nth-of-type(2) { animation-delay: .2s; }
.mascot.thinking .spark:nth-of-type(3) { animation-delay: .4s; }
@keyframes spark { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }

/* ---------- results ---------- */
.results { display: grid; place-items: center; }
.result-card { max-width: 620px; width: 100%; text-align: center; background: #fff; border-radius: 28px; padding: 28px clamp(20px, 4vw, 40px); box-shadow: var(--shadow); border: 1px solid var(--line); }
.result-card .mascot-slot { width: 160px; margin: 0 auto; }
.res-score { font-size: 72px; margin: 6px 0; }
.res-score small { font-size: 28px; color: var(--ink); }
.res-verdict { font-family: "Caveat", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; font-size: 30px; color: var(--navy); line-height: 1.2; margin: 0 0 20px; }
.res-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.cta { margin-top: 26px; padding: 22px; border-radius: 22px; background: var(--navy); color: #D9DCEA; }
.cta h3 { color: #fff; margin: 0 0 6px; font-size: 19px; }
.cta p { margin: 0 0 16px; font-size: 14px; }

.foot { text-align: center; font-size: 12px; padding: 18px; color: #7A7F8F; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .track-grid { grid-template-columns: repeat(3, 1fr); }
  .game { grid-template-columns: 1fr; }
  .board-panel { min-height: 420px; order: -1; }
  .bridget-dock .mascot-slot { width: 96px; }
}
@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; }
  .hero-mascot { min-height: 220px; order: -1; }
  .hero-mascot .mascot-slot { width: 150px; margin-top: 100px; }
  .hero-mascot { min-height: 0; place-items: end center; }
  .speech-bubble { left: 0; right: 0; margin: 0 auto; font-size: 19px; max-width: 280px; }
  .track-grid { grid-template-columns: repeat(2, 1fr); }
  .spice { grid-template-columns: 1fr; }
  .brand-text { display: none; }
  .board { padding: 16px 16px 130px; }
  .board-panel { min-height: 310px; }
  .question-panel { padding: 18px; }
  .answer-bar { flex-direction: column; }
  .score-row { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.res-next { margin: 0 0 14px; }
.voice-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; font-weight: 700; color: var(--navy); }
.voice-row select { flex: 1; min-width: 200px; font: inherit; font-weight: 500; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--navy); }
