/* THE PURSUIT OF EXCELLENCE — Sports Listening Arena */
:root {
  --blue: #1e6bff; --purple: #7b2ff7; --turq: #00c9b7; --orange: #ff8a00; --lime: #a3e635;
  --white: #fff; --ink: #14143a; --soft: #eef2ff; --green: #16a34a; --red: #dc2626;
  --topbar-h: 80px; --radius: 18px;
  --shadow: 0 6px 0 rgba(20, 20, 58, .25), 0 10px 24px rgba(20, 20, 58, .25);
  font-size: clamp(16px, 1.15vw + 6px, 22px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Trebuchet MS", "Segoe UI", Verdana, Arial, sans-serif;
  color: var(--white);
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 20%, rgba(0, 201, 183, .35), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 138, 0, .3), transparent 40%),
    linear-gradient(160deg, #1638d9 0%, #6a24e0 55%, #0aa6b8 100%);
  background-attachment: fixed;
}
h1, h2, h3 { margin: .2em 0 .4em; line-height: 1.15; }
p { line-height: 1.45; }
.skip-link { position: absolute; left: -999px; top: 0; background: #ffe14d; color: var(--ink); padding: .6em 1em; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }
.noscript { background: #fff; color: var(--ink); padding: 1em; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  min-height: 52px; min-width: 52px; padding: .45em .9em;
  border: 3px solid var(--ink); border-radius: 14px;
  background: var(--white); color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .35em;
  text-decoration: none; transition: transform .08s, box-shadow .08s, background .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 5px solid #ffe14d; outline-offset: 3px;
}
.btn.lime { background: var(--lime); }
.btn.orange { background: var(--orange); }
.btn.turq { background: var(--turq); }
.btn.purple { background: var(--purple); color: #fff; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.danger { background: #ffd2d2; color: #7f1d1d; }
.btn.big { font-size: 1.25rem; min-height: 68px; padding: .5em 1.3em; border-radius: 18px; }
.btn.small { min-height: 46px; font-size: .9rem; padding: .3em .7em; }
.btn.icon { padding: 0; width: 52px; font-size: 1.2rem; }

/* ---------- Top bar (slim & distraction-free) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .8rem;
  padding: .35rem .9rem; background: #14143a; border-bottom: 3px solid var(--lime);
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand strong { font-size: .95rem; letter-spacing: .04em; color: var(--lime); white-space: nowrap; }
.stage-select {
  font: inherit; font-size: .88rem; font-weight: 700; min-height: 38px; padding: .2em .6em;
  border-radius: 10px; border: 2px solid var(--turq); background: #1e1b4b; color: #fff; cursor: pointer;
}
.nav { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.nav-btn { font-size: .85rem; min-height: 38px; min-width: auto; padding: .25em .75em; border-radius: 10px; box-shadow: 0 2px 0 var(--ink); }
.nav-btn.next { background: var(--lime); }
.nav-btn.teacher { background: #ffe14d; }
.nav-btn[aria-pressed="true"] { background: var(--turq); }
.timers { display: flex; align-items: center; gap: .35rem; }
.timer-box { background: #000; border: 2px solid var(--turq); border-radius: 10px; padding: .15em .55em; text-align: center; min-width: 68px; font-family: "Consolas", "Courier New", monospace; }
.timer-box span { font-size: 1.15rem; font-weight: 700; color: #fff; }
.timer-box.warn { border-color: var(--orange); }
.timer-box.over { border-color: #ff3d3d; animation: pulse 1s infinite; }
.timer-box.over span { color: #ff8080; }
.timers .btn.small { min-height: 38px; padding: .2em .65em; font-size: .85rem; border-radius: 10px; box-shadow: 0 2px 0 var(--ink); }

/* ---------- Layout ---------- */
main { padding: 1rem clamp(.6rem, 2vw, 2rem) 3rem; outline: none; transition: margin .3s; }
body.video-open main { margin-right: min(40vw, 600px); }
.screen { max-width: 1250px; margin: 0 auto; animation: slideIn .35s ease; }
.card { background: var(--white); color: var(--ink); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); border: 4px solid var(--ink); }
.card + .card { margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.center { text-align: center; justify-content: center; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.screen-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .8rem; }
.screen-head h1 { font-size: 2rem; text-shadow: 0 3px 0 var(--ink); margin: 0; }
.tag { display: inline-block; background: var(--orange); color: var(--ink); font-weight: 700; padding: .15em .7em; border-radius: 999px; border: 3px solid var(--ink); font-size: .85rem; }
.tag.lime { background: var(--lime); } .tag.turq { background: var(--turq); } .tag.warn { background: #ffe14d; }
.small-note { font-size: .85rem; opacity: .95; }
.card .small-note { color: #3b3b6b; }
.feedback { min-height: 2em; font-size: 1.2rem; font-weight: 700; margin: .5rem 0; }
.feedback.good { color: var(--green); } .feedback.bad { color: var(--red); }
.flag { display: block; background: #fff3c4; color: #7a4b00; border: 3px dashed #d97706; border-radius: 12px; padding: .55em .85em; font-weight: 700; font-size: 1rem; line-height: 1.4; margin: .4rem 0; }
.q5-inline-box { background: #fffbeb; border: 3px dashed #d97706; border-radius: 14px; padding: .75rem .9rem; margin: .5rem 0 .8rem; }
.q5-inline-box label { display: block; font-weight: 700; color: #7a4b00; margin-bottom: .35rem; font-size: .95rem; }
.q5-inline-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.q5-inline-row input[type="text"] { flex: 1 1 280px; font-size: 1.05rem; font-weight: 700; }

/* ---------- Welcome ---------- */
.hero { text-align: center; position: relative; padding-top: .5rem; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.6rem); text-shadow: 0 4px 0 var(--ink); }
.glow { color: var(--lime); }
.kicker { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; color: #ffe14d; margin: 0; }
.lesson-title { display: inline-block; background: var(--orange); color: var(--ink); padding: .2em .8em; border-radius: 14px; border: 4px solid var(--ink); box-shadow: var(--shadow); font-size: clamp(1.3rem, 2.4vw, 2rem); }
.balls { display: flex; justify-content: space-between; position: absolute; inset: 0 0 auto 0; pointer-events: none; }
.bounce { animation: bounce 1.2s ease-in-out infinite; display: inline-block; }
.bounce.b1 { animation-delay: .2s; } .bounce.b2 { animation-delay: .45s; } .bounce.b3 { animation-delay: .7s; }
.avatar-row { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; margin: 1rem 0 .3rem; }
.avatar-card {
  margin: 0; background: rgba(255, 255, 255, .96); color: var(--ink); border: 4px solid var(--ink); border-radius: 20px;
  padding: .45rem .65rem .45rem; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: .2rem;
  min-width: 138px; transition: transform .15s, box-shadow .2s, border-color .2s, background .2s;
}
.avatar-card figcaption { font-weight: 800; font-size: 1.05rem; line-height: 1.15; }
.avatar-card .char-role { font-size: .72rem; font-weight: 700; color: #475569; }
.avatar-card.sm { min-width: 124px; padding: .35rem .55rem; }
.avatar-card.sm svg { width: 66px; height: auto; }
.avatar-card .char-play-btn {
  font: inherit; font-size: .8rem; font-weight: 800; padding: .28em .65em; border-radius: 999px;
  border: 2.5px solid var(--ink); background: var(--lime); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; gap: .25rem; box-shadow: 0 2px 0 var(--ink); width: 100%; justify-content: center;
}
.avatar-card .char-play-btn:hover { background: #ffe14d; transform: translateY(-1px); }
.avatar-card .char-yt-link {
  font-size: .7rem; font-weight: 700; color: #1e40af; text-decoration: underline; margin-top: .05rem;
}
.avatar-card.speaking {
  background: #fef9c3; border-color: #16a34a; box-shadow: 0 0 0 5px var(--lime), var(--shadow);
  animation: bob .55s ease-in-out infinite alternate;
}
.avatar-card.speaking .char-play-btn { background: #22c55e; color: #fff; }
.avatar-svg .mouth { transform-origin: 60px 76px; transform-box: view-box; }
.avatar-card.speaking .avatar-svg .mouth { animation: talk .32s ease-in-out infinite alternate; }
body.talking:not(.has-active-speaker) .avatar-card { animation: bob .6s ease-in-out infinite alternate; }
body.talking:not(.has-active-speaker) .avatar-card:nth-child(2n) { animation-delay: .3s; }
body.talking:not(.has-active-speaker) .avatar-svg .mouth { animation: talk .35s ease-in-out infinite alternate; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: .4rem 0; justify-content: center; }
.chips li { background: var(--soft); border: 3px solid var(--purple); border-radius: 999px; padding: .3em .9em; font-weight: 700; font-size: 1.05rem; }
.timing-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .5rem; padding: 0; list-style: none; margin: .8rem 0 0; }
.timing-list li { background: var(--soft); border-radius: 12px; padding: .5em; font-weight: 700; text-align: center; border: 2px solid #c7d2fe; }
.timing-list li span { display: block; color: var(--purple); font-size: 1.3rem; }

/* ---------- Game 1 ---------- */
.clue-row { display: grid; grid-template-columns: repeat(3, 1fr) 1.1fr; gap: .8rem; margin: .8rem 0; }
.flip { perspective: 900px; min-height: 150px; }
.flip-inner { position: relative; width: 100%; height: 100%; min-height: 150px; transition: transform .6s; transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 16px; border: 4px solid var(--ink); display: flex; align-items: center; justify-content: center; text-align: center; padding: .6rem; font-weight: 700; }
.flip-front { background: repeating-linear-gradient(45deg, var(--purple), var(--purple) 14px, #8e4bff 14px, #8e4bff 28px); color: #fff; font-size: 1.4rem; }
.flip-back { background: #fff; color: var(--ink); transform: rotateY(180deg); font-size: 1.15rem; flex-direction: column; gap: .3rem; }
.mystery .flip-front { background: radial-gradient(circle, #ffb347, var(--orange)); color: var(--ink); font-size: 3rem; }
.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; margin-top: .8rem; }
.opt {
  font: inherit; font-size: 1.3rem; font-weight: 700; min-height: 78px; padding: .5em .8em; cursor: pointer;
  border: 4px solid var(--ink); border-radius: 18px; background: #fff; color: var(--ink); box-shadow: 0 5px 0 var(--ink);
  display: flex; align-items: center; gap: .6rem; text-align: left; transition: transform .1s, background .2s;
}
.opt:hover:not(:disabled) { transform: translateY(-2px); }
.opt:disabled { cursor: default; }
.opt .letter { flex: 0 0 auto; width: 2em; height: 2em; border-radius: 50%; display: grid; place-items: center; color: #fff; border: 3px solid var(--ink); }
.opt[data-v="a"] .letter { background: var(--blue); } .opt[data-v="b"] .letter { background: var(--purple); }
.opt[data-v="c"] .letter { background: #0d9488; } .opt[data-v="d"] .letter { background: #c2410c; }
.opt[aria-pressed="true"] { background: #fff7c2; outline: 5px solid var(--orange); }
.opt.correct { background: #bbf7d0; border-color: var(--green); }
.opt.wrong { background: #fecaca; text-decoration: line-through; opacity: .75; }
.opt.dim { opacity: .5; }
.opt .picks { margin-left: auto; display: flex; gap: .25rem; flex-wrap: wrap; }
.pick-dot { background: var(--tc); color: #fff; font-size: .75rem; border-radius: 999px; padding: .1em .5em; border: 2px solid var(--ink); }
.shake { animation: shake .4s; }
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.match-col { display: grid; gap: .6rem; }
.match-card { font: inherit; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .7rem; min-height: 72px; padding: .3em .8em; border: 4px solid var(--ink); border-radius: 16px; background: #fff; color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 var(--ink); }
.match-card[aria-pressed="true"] { background: #fff7c2; outline: 5px solid var(--orange); }
.match-card.done { background: #bbf7d0; border-color: var(--green); cursor: default; }
.match-card svg { flex: 0 0 auto; }

/* team picker */
.team-picker { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.team-picker > span { font-weight: 700; }
.team-chip { font: inherit; font-weight: 700; min-height: 52px; padding: .3em .9em; border-radius: 999px; border: 4px solid var(--tc); background: #fff; color: var(--ink); cursor: pointer; }
.team-chip[aria-pressed="true"] { background: var(--tc); color: #fff; border-color: var(--ink); box-shadow: 0 0 0 4px #ffe14d; }
.team-chip b { margin-left: .3em; }

/* ---------- Listening mission ---------- */
.progress { height: 18px; background: #e0e7ff; border-radius: 999px; border: 3px solid var(--ink); overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--turq), var(--lime)); transition: width .4s; }
.qdots { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.qdot { font: inherit; font-weight: 700; width: 48px; height: 48px; border-radius: 50%; border: 3px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; }
.qdot.answered { background: var(--turq); }
.qdot[aria-current="true"] { background: var(--orange); transform: scale(1.12); }
.qstem { font-size: 1.55rem; margin: .4rem 0; }
.results { list-style: none; padding: 0; display: grid; gap: .4rem; }
.results li { background: var(--soft); padding: .5em .8em; border-radius: 12px; border-left: 8px solid #94a3b8; }
.results li.ok { border-color: var(--green); } .results li.no { border-color: var(--red); } .results li.wait { border-color: #d97706; }

/* ---------- Champions ---------- */
.team-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .7rem; margin-top: 1rem; }
.team-card { background: #fff; color: var(--ink); border: 4px solid var(--tc); border-radius: 18px; padding: .6rem; box-shadow: var(--shadow); }
.team-card.active { box-shadow: 0 0 0 6px #ffe14d, var(--shadow); }
.team-card h3 { margin: 0; font-size: 1.1rem; color: var(--ink); display: flex; justify-content: space-between; gap: .4rem; }
.team-card .score { background: var(--tc); color: #fff; border-radius: 999px; padding: 0 .6em; }
.team-card .pick { font-size: 1.1rem; margin: .3rem 0; font-weight: 700; }
.team-card .btn { width: 100%; margin-top: .3rem; }
.banner { background: #fff3c4; color: #5c3b00; border: 4px dashed #d97706; padding: .6rem 1rem; border-radius: 14px; font-weight: 700; margin: .6rem 0; }
.scoreboard { display: grid; gap: .6rem; margin: 1rem 0; }
.sb-row { display: grid; grid-template-columns: 3rem minmax(120px, 14rem) 1fr 4rem; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.2rem; }
.sb-bar { height: 34px; border-radius: 999px; background: #e0e7ff; overflow: hidden; border: 3px solid var(--ink); }
.sb-bar > div { height: 100%; background: var(--tc); width: 0; transition: width 1.2s cubic-bezier(.2, .9, .3, 1.2); }

/* ---------- Challenge ---------- */
.game-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.game-card { font: inherit; text-align: center; cursor: pointer; background: #fff; color: var(--ink); border: 4px solid var(--ink); border-radius: 20px; padding: 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: .4rem; transition: transform .15s; }
.game-card:hover { transform: translateY(-4px) rotate(-1deg); }
.game-card strong { font-size: 1.3rem; }
.scene { position: relative; width: 100%; aspect-ratio: 16 / 10; border: 4px solid var(--ink); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); background: #0b6; }
.scene-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sprite { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
.sprite svg { display: block; width: 100%; height: 100%; }
.sprite.ball { width: 9%; aspect-ratio: 1; }
.opt.static { cursor: default; box-shadow: none; }
.sprite.keeper { width: 12%; aspect-ratio: 6 / 8; left: 50%; top: 46%; transition: left .45s, transform .45s; }
.sprite.target { width: 15%; aspect-ratio: 1; }
.scene-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0); background: #fff; color: var(--ink); border: 5px solid var(--ink); border-radius: 20px; padding: .3em .9em; font-size: clamp(1.4rem, 3.5vw, 2.6rem); font-weight: 900; transition: transform .35s cubic-bezier(.3, 1.6, .5, 1); white-space: nowrap; }
.scene-msg.show { transform: translate(-50%, -50%) scale(1); }
.pool { position: absolute; inset: 0; background: #0ea5e9; display: grid; grid-template-rows: repeat(4, 1fr); }
.lane { position: relative; border-bottom: 4px dashed #fef08a; background: linear-gradient(90deg, rgba(255, 255, 255, .15), transparent); }
.lane:nth-child(odd) { background-color: rgba(255, 255, 255, .08); }
.lane .label { position: absolute; left: .4rem; top: .2rem; font-size: .75rem; font-weight: 700; background: rgba(255, 255, 255, .9); color: var(--ink); border-radius: 8px; padding: 0 .4em; }
.lane .swimmer { position: absolute; top: 50%; width: 14%; aspect-ratio: 2 / 1; transform: translate(-50%, -40%); transition: left 1.2s ease-in-out; }
.lane .mascot { position: absolute; top: 50%; transform: translate(-50%, -110%); font-size: 1.2rem; transition: left 1.2s ease-in-out; }
.finish { position: absolute; right: 4%; top: 0; bottom: 0; width: 10px; background: repeating-linear-gradient(0deg, #fff 0 12px, var(--ink) 12px 24px); }
.counters { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-top: .6rem; }
.counter { background: #fff; color: var(--ink); border: 4px solid var(--tc); border-radius: 14px; text-align: center; font-weight: 700; padding: .3em; }
.counter.turn { box-shadow: 0 0 0 5px #ffe14d; }
.counter big { display: block; font-size: 1.6rem; }
.turn-banner { background: var(--tc); color: #fff; border: 4px solid var(--ink); border-radius: 16px; padding: .4em .8em; font-size: 1.4rem; font-weight: 900; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.aim-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-top: .6rem; }
.aim-row .btn { min-height: 76px; font-size: 1.25rem; }
.mascot-pick { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

/* ---------- Exit / finale ---------- */
textarea, input[type="text"], input[type="number"], select {
  font: inherit; font-size: 1rem; padding: .5em .6em; border: 3px solid var(--ink); border-radius: 12px; min-height: 50px; background: #fff; color: var(--ink);
}
textarea { width: 100%; min-height: 90px; }
.starters { display: flex; flex-wrap: wrap; gap: .4rem; }
.starters span { background: #ecfeff; border: 2px solid var(--turq); border-radius: 999px; padding: .25em .8em; font-weight: 700; }
.emoji-vote { display: flex; flex-wrap: wrap; gap: .6rem; }
.emoji-vote .btn { font-size: 1.1rem; min-height: 70px; }
.podium { font-size: clamp(2.5rem, 7vw, 5rem); text-align: center; animation: bounce 1.4s infinite; }

/* ---------- Video & Clear Audio panel ---------- */
.video-panel {
  position: fixed; right: 0; top: var(--topbar-h); bottom: 0; width: min(40vw, 600px); z-index: 25;
  background: rgba(20, 20, 58, .97); border-left: 5px solid var(--lime); padding: .7rem; overflow-y: auto;
  display: flex; flex-direction: column; gap: .55rem;
  transform: translateX(105%); visibility: hidden; transition: transform .3s, visibility .3s;
}
body.video-open .video-panel { transform: none; visibility: visible; }
.vp-head { display: flex; justify-content: space-between; align-items: center; font-size: 1.1rem; flex-shrink: 0; }
.vp-mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; flex-shrink: 0; }
.vp-tab { justify-content: center; background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .35); }
.vp-tab.active { background: var(--lime); color: var(--ink); border-color: var(--ink); box-shadow: 0 0 0 3px #ffe14d; }
.vp-frame { position: relative; width: 100%; flex-shrink: 0; background: #161542; border-radius: 14px; overflow: hidden; border: 3px solid var(--turq); }
.yt-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 200px; background: #000; }
.yt-wrap iframe, #ytPlayer { position: absolute; inset: 0; width: 100%; height: 100%; }
.vp-fallback { position: absolute; inset: 0; background: #1e1b4b; color: #fff; padding: .6rem .8rem; display: flex; flex-direction: column; justify-content: flex-start; gap: .35rem; text-align: center; overflow-y: auto; font-size: .85rem; }
.vp-fallback p { margin: 0; }
.clear-stage { padding: .65rem .75rem; display: flex; flex-direction: column; gap: .5rem; background: linear-gradient(135deg, #1e1b4b, #312e81); color: #fff; }
.cs-top { display: flex; align-items: center; gap: .7rem; }
.cs-avatar { width: 64px; height: 64px; flex: 0 0 auto; background: #fff; border: 3px solid var(--lime); border-radius: 16px; display: grid; place-items: center; padding: 3px; }
.cs-avatar svg { width: 54px; height: 54px; }
body.talking .cs-avatar { animation: bob .5s ease-in-out infinite alternate; }
body.talking .cs-avatar .avatar-svg .mouth { animation: talk .3s ease-in-out infinite alternate; }
.cs-info { flex: 1; min-width: 0; }
.cs-badge { display: inline-block; background: var(--lime); color: var(--ink); font-size: .72rem; font-weight: 800; padding: .1em .55em; border-radius: 999px; margin-bottom: .15rem; }
.cs-info strong { display: block; font-size: 1rem; color: #ffe14d; }
.cs-waves { display: flex; align-items: flex-end; gap: 4px; height: 16px; margin-top: .25rem; }
.cs-waves span { width: 5px; height: 5px; background: var(--turq); border-radius: 3px; transition: height .15s; }
body.talking .cs-waves span { animation: waveBar .45s ease-in-out infinite alternate; }
body.talking .cs-waves span:nth-child(2) { animation-delay: .1s; }
body.talking .cs-waves span:nth-child(3) { animation-delay: .2s; }
body.talking .cs-waves span:nth-child(4) { animation-delay: .15s; }
body.talking .cs-waves span:nth-child(5) { animation-delay: .25s; }
@keyframes waveBar { from { height: 4px; background: var(--turq); } to { height: 16px; background: var(--lime); } }
.clear-audio-el { width: 100%; height: 38px; border-radius: 999px; }
.cs-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem; font-size: .82rem; font-weight: 700; }
.cs-speed { display: inline-flex; align-items: center; gap: .3rem; color: #e0e7ff; }
.cs-speed select { min-height: 32px; padding: .15em .45em; font-size: .8rem; font-weight: 700; border-radius: 8px; }
.cs-transcript { background: rgba(255, 255, 255, .96); color: var(--ink); border: 2px solid var(--ink); border-radius: 10px; padding: .5rem .65rem; font-size: .85rem; line-height: 1.4; max-height: 150px; overflow-y: auto; }
.cs-transcript p { margin: .25rem 0; }
.cs-transcript p.active-line { background: #fef08a; padding: .2rem .4rem; border-radius: 6px; border-left: 4px solid #16a34a; font-weight: 700; }
.vp-controls { display: flex; flex-wrap: wrap; gap: .4rem; flex-shrink: 0; }
.vp-speakers { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: .35rem; background: rgba(255, 255, 255, .08); padding: .45rem; border-radius: 12px; border: 2px solid rgba(255, 255, 255, .2); flex-shrink: 0; }
.vp-speakers-title { grid-column: 1 / -1; font-size: .78rem; font-weight: 700; color: #ffe14d; margin-bottom: .1rem; }
.vp-char-btn {
  font: inherit; font-size: .78rem; font-weight: 700; padding: .3em .5em; border-radius: 10px;
  border: 2px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer;
  display: flex; align-items: center; gap: .3rem; text-align: left;
}
.vp-char-btn svg { width: 28px; height: 28px; flex: 0 0 auto; }
.vp-char-btn small { display: block; font-size: .68rem; color: #475569; font-weight: 700; }
.vp-char-btn.speaking { background: var(--lime); border-color: #fff; box-shadow: 0 0 0 3px #ffe14d; }
.bookmarks { display: flex; flex-wrap: wrap; gap: .4rem; }
.bookmarks:empty::before { content: "No bookmarks yet. Press 🔖 while the video plays to mark a useful moment."; font-size: .85rem; color: #c7d2fe; }
.yt-link { background: #ff3d3d; color: #fff; }
.vp-note { font-size: .8rem; color: #c7d2fe; margin: 0; }

/* ---------- Dialogs ---------- */
dialog { border: 5px solid var(--ink); border-radius: 22px; padding: 1.2rem; max-width: min(960px, 94vw); width: 100%; max-height: 92vh; overflow-y: auto; color: var(--ink); background: #fff; }
dialog::backdrop { background: rgba(10, 10, 40, .7); }
#resetDialog { max-width: 520px; }
.dialog-actions { display: grid; gap: .6rem; }
.tp-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.tp-tabs .btn[aria-selected="true"] { background: var(--turq); }
.tp-table { width: 100%; border-collapse: collapse; }
.tp-table td, .tp-table th { border-bottom: 2px solid #e0e7ff; padding: .45em .3em; text-align: left; vertical-align: middle; }
.tp-table select, .tp-table input[type="text"] { width: 100%; }
.tp-foot { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; margin-top: 1rem; position: sticky; bottom: -1.2rem; background: #fff; padding: .6rem 0; }
.warn-box { background: #fff3c4; border: 3px solid #d97706; border-radius: 12px; padding: .5em .8em; }
input[type="color"] { width: 64px; height: 50px; border: 3px solid var(--ink); border-radius: 10px; padding: 2px; cursor: pointer; }

/* ---------- Toast, popups, confetti ---------- */
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translate(-50%, 200%); background: var(--ink); color: #fff; border: 4px solid var(--lime); padding: .6em 1.2em; border-radius: 16px; font-weight: 700; font-size: 1.1rem; z-index: 60; transition: transform .3s; max-width: 92vw; text-align: center; }
.toast.show { transform: translate(-50%, 0); }
.pop { position: fixed; z-index: 70; font-weight: 900; font-size: 2rem; color: #ffe14d; text-shadow: 0 3px 0 var(--ink); pointer-events: none; animation: popUp 1.1s forwards; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 80; }

/* ---------- Animations ---------- */
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-22px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-8px); } }
@keyframes talk { from { transform: scaleY(.35); } to { transform: scaleY(1.1); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes popUp { from { opacity: 1; transform: translateY(0) scale(.8); } to { opacity: 0; transform: translateY(-80px) scale(1.3); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .clue-row { grid-template-columns: repeat(3, 1fr); }
  .clue-row .mystery { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  body.video-open main { margin-right: 0; padding-bottom: 50vh; }
  .video-panel { top: auto; left: 0; width: 100%; height: 48vh; border-left: 0; border-top: 5px solid var(--lime); transform: translateY(105%); }
  .nav-btn span { display: none; }
  .nav-btn.next span { display: inline; }
}
@media (max-width: 640px) {
  .options, .match-cols { grid-template-columns: 1fr; }
  .clue-row { grid-template-columns: 1fr; }
  .counters { grid-template-columns: repeat(2, 1fr); }
  .sb-row { grid-template-columns: 2rem 1fr 3rem; }
  .sb-row .sb-bar { display: none; }
}
