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

:root {
  --purple: #7B2FF7; --deep: #2b0a5c; --pink: #FF4F79; --sun: #FFD60A; --mint: #52D273; --sky: #4CC9F0; --orange: #FF8C42;
  --bg1: #3a0ca3; --bg2: #7209b7;
  --c0: #FF8C42; --c1: #4CC9F0; --c2: #52D273; --c3: #FF4F79;
  font-family: 'Fredoka', 'Baloo 2', 'Nunito', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: radial-gradient(circle at 50% 30%, var(--bg2), var(--bg1) 70%); background-attachment: fixed; color: #fff; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
img { display: block; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 99; background: #fff; color: var(--deep); padding: .5rem 1rem; border-radius: 1rem; }
:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; }

/* ---------- The House stage (TV + Mirror mode) ---------- */
.house { position: relative; height: 100%; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.scorebar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 1vw; padding: 1.6vh 2.5vw; }
.score { display: flex; align-items: center; gap: .8vw; font-weight: 700; }
.score .lbl { font-size: 2.4vmin; font-size: clamp(14px, 2.4vmin, 34px); letter-spacing: .08em; opacity: .9; }
.score .pts { font-size: 6.5vmin; font-size: clamp(28px, 6.5vmin, 90px); line-height: 1; padding: .1em .45em; border-radius: .45em; color: var(--deep); min-width: 2.6em; text-align: center; }
.score.team .pts { background: var(--sun); box-shadow: 0 .12em 0 #c9a400; }
.score.hs { justify-content: flex-end; }
.score.hs .pts { background: #fff; box-shadow: 0 .12em 0 #c8b8ef; }
.score .mini { width: 6vmin; width: clamp(28px, 6vmin, 80px); }
.round { font-weight: 600; font-size: 2.8vmin; font-size: clamp(14px, 2.8vmin, 38px); background: rgba(0,0,0,.22); padding: .3em 1em; border-radius: 99px; white-space: nowrap; }

.stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.2vh; padding: 0 3vw; min-height: 0; text-align: center; }
.title-card, .end-card { display: flex; flex-direction: column; align-items: center; gap: 1vh; }
.mascot.big { width: 24vmin; width: clamp(90px, 24vmin, 320px); animation: bob 2.4s ease-in-out infinite; }
.logo { margin: 0; font-size: 13vmin; font-size: clamp(44px, 13vmin, 190px); line-height: .95; font-weight: 700; color: var(--sun); text-shadow: 0 .06em 0 var(--pink), 0 .12em 0 var(--deep); letter-spacing: .01em; }
.logo span { color: #fff; }
.tag { margin: 0; font-size: 5vmin; font-size: clamp(20px, 5vmin, 70px); font-weight: 600; }
.team-row { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 2vmin; padding: 0; margin: 1vh 0 0; }
.team-row li { display: flex; flex-direction: column; align-items: center; font-weight: 600; font-size: 2.8vmin; font-size: clamp(14px, 2.8vmin, 38px); }
.team-row img { width: 10vmin; width: clamp(40px, 10vmin, 140px); background: rgba(255,255,255,.18); border-radius: 50%; padding: 1vmin; }

.captain { display: flex; align-items: center; gap: 1.5vw; background: rgba(255,255,255,.14); padding: .8vmin 2.4vmin .8vmin .8vmin; border-radius: 99px; }
.captain img { width: 10vmin; width: clamp(44px, 10vmin, 130px); background: #fff; border-radius: 50%; padding: .8vmin; }
.captain div { display: flex; flex-direction: column; text-align: left; line-height: 1.05; }
.captain small { font-size: 2.2vmin; font-size: clamp(12px, 2.2vmin, 30px); text-transform: uppercase; letter-spacing: .1em; opacity: .85; }
.captain b { font-size: 4.6vmin; font-size: clamp(20px, 4.6vmin, 64px); }
.captain em { font-style: normal; font-size: 2.4vmin; font-size: clamp(12px, 2.4vmin, 32px); opacity: .85; }

.find { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: .3em; font-weight: 700; font-size: 9vmin; font-size: clamp(30px, 9vmin, 140px); line-height: 1.1; transition: font-size .3s; }
.find.small { font-size: 5.6vmin; font-size: clamp(22px, 5.6vmin, 80px); }
.find-lbl { color: #fff; }
.find-word, .find-colour { background: var(--hl); color: var(--ink); padding: 0 .3em; border-radius: .25em; box-shadow: 0 .08em 0 rgba(0,0,0,.3); }
.find-colour { font-size: .8em; }
.page-hint { flex-basis: 100%; font-size: .38em; font-weight: 600; opacity: .9; }
.ask { margin: 0; font-size: 4vmin; font-size: clamp(18px, 4vmin, 56px); font-weight: 600; }
.ask.big { font-size: 6vmin; font-size: clamp(24px, 6vmin, 84px); animation: bob 2s ease-in-out infinite; }

.choices { list-style: none; display: grid; gap: 2vmin; padding: 0; margin: 0; width: min(100%, 150vmin); }
.choices.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, 110vmin); }
.choices.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choices.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice { width: 100%; height: 100%; border: 0; border-radius: 3vmin; padding: 1.6vmin; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1vmin; color: var(--deep); font-weight: 700; position: relative; box-shadow: 0 1vmin 0 rgba(0,0,0,.28); transition: transform .2s, opacity .3s, box-shadow .2s; min-height: 18vmin; }
.choice.c0 { background: var(--c0); } .choice.c1 { background: var(--c1); } .choice.c2 { background: var(--c2); } .choice.c3 { background: var(--c3); }
.choice .letter { position: absolute; top: 1vmin; left: 1.4vmin; font-size: 3vmin; font-size: clamp(14px, 3vmin, 42px); background: rgba(255,255,255,.75); border-radius: 50%; width: 1.6em; height: 1.6em; display: grid; place-items: center; }
.choice img { width: 17vmin; width: clamp(50px, 17vmin, 240px); filter: drop-shadow(0 .6vmin 0 rgba(0,0,0,.18)); }
.choice .word { font-size: 5.4vmin; font-size: clamp(20px, 5.4vmin, 78px); line-height: 1; letter-spacing: .02em; }
.choices.n4 .choice img { width: 12vmin; width: clamp(40px, 12vmin, 170px); }
.choices.n4 .choice .word { font-size: 4.2vmin; font-size: clamp(22px, 4.2vmin, 60px); }
.choice.textonly .word { font-size: 7vmin; font-size: clamp(26px, 7vmin, 96px); }
.choice.selected { transform: translateY(-1.2vmin) scale(1.04); box-shadow: 0 0 0 1vmin #fff, 0 2vmin 0 rgba(0,0,0,.3); }
.choice.correct { box-shadow: 0 0 0 1.2vmin var(--sun), 0 0 6vmin var(--sun); animation: wiggle .6s ease 2; }
.choice.wrong { opacity: .55; }
.choice.dim { opacity: .35; }
.verdict { font-size: 9vmin; font-size: clamp(30px, 9vmin, 130px); font-weight: 700; animation: pop .5s ease; }
.verdict.right { color: var(--sun); text-shadow: 0 .07em 0 var(--pink); }
.verdict.wrong { color: #fff; font-size: 5.5vmin; font-size: clamp(22px, 5.5vmin, 80px); }

.caption { display: flex; align-items: center; gap: 1.6vmin; padding: 1.2vh 3vw 2.2vh; min-height: 9vh; }
.caption .host { width: 7vmin; width: clamp(34px, 7vmin, 100px); flex: none; }
.caption p { margin: 0; background: #fff; color: var(--deep); font-weight: 600; font-size: 3.4vmin; font-size: clamp(16px, 3.4vmin, 48px); padding: .35em .9em; border-radius: 1em; border-bottom-left-radius: .2em; min-height: 1em; flex: 1; }
.caption p:empty { visibility: hidden; }
.talking .caption .mouth, .talking .mascot .mouth { animation: talk .22s ease-in-out infinite alternate; transform-origin: 60px 96px; }
[data-result="wrong"] .score.hs .mini, [data-phase="end"] .end-card.house .mascot { animation: wiggle .6s ease 3; }

.end-card h1 { margin: 0; font-size: 11vmin; font-size: clamp(40px, 11vmin, 160px); color: var(--sun); text-shadow: 0 .06em 0 var(--pink); }
.end-card .final { display: flex; gap: 3vw; margin: 0; font-size: 6vmin; font-size: clamp(22px, 6vmin, 84px); font-weight: 700; }
.end-card .final .t { background: var(--sun); color: var(--deep); padding: 0 .5em; border-radius: .4em; }
.end-card .final .h { background: #fff; color: var(--deep); padding: 0 .5em; border-radius: .4em; }

.confetti { position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -4vh; width: 1.6vmin; height: 2.6vmin; border-radius: .4vmin; animation: fall 2.2s cubic-bezier(.3,.6,.6,1) forwards; }

@keyframes bob { 50% { transform: translateY(-1.5vmin); } }
@keyframes talk { from { transform: scaleY(.5); } to { transform: scaleY(1.15); } }
@keyframes wiggle { 25% { transform: rotate(-4deg) scale(1.05); } 75% { transform: rotate(4deg) scale(1.05); } }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(540deg); } }

/* Phone in portrait: stack the answers two by two */
@media (orientation: portrait) {
  .choices.n3, .choices.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice { min-height: 22vmin; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .confetti { display: none; }
}

/* ---------- Leader controls on the phone ---------- */
.app { height: 100%; }
.screen[hidden] { display: none !important; }
.game { position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: grid; grid-template-rows: 1fr auto; }
.game .house { height: auto; min-height: 0; }
.leader { display: flex; align-items: center; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: rgba(20, 4, 50, .78); }
.leader .go { flex: 1; min-height: 52px; border: 0; border-radius: 16px; background: var(--sun); color: var(--deep); font-weight: 700; font-size: 20px; box-shadow: 0 4px 0 #c9a400; }
.leader .go:disabled { background: rgba(255,255,255,.18); color: #fff; box-shadow: none; font-weight: 500; font-size: 16px; cursor: default; }
.leader .icon { width: 52px; min-height: 52px; border: 0; border-radius: 16px; background: rgba(255,255,255,.16); color: #fff; font-size: 22px; }
.leader .status { font-size: 13px; opacity: .8; white-space: nowrap; }
/* Mirror mode on a sideways phone: shrink the leader bar into a corner so the House stays the star */
.mode-mirror .game { grid-template-rows: 1fr; }
.mode-mirror .leader { position: absolute; right: 10px; bottom: 10px; border-radius: 18px; padding: 6px; background: rgba(20, 4, 50, .55); }
.mode-mirror .leader .go { min-height: 44px; font-size: 16px; padding: 0 16px; flex: none; }
.mode-mirror .leader .go:disabled { display: none; }
.mode-mirror .leader .icon { width: 44px; min-height: 44px; }
.mode-mirror .leader .status { display: none; }
.mode-mirror .caption { padding-right: 260px; }
@media (orientation: portrait) { .mode-mirror .caption { padding-right: 3vw; padding-bottom: 72px; } }

.menu { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(10, 0, 30, .6); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.menu[hidden] { display: none; }
.menu .sheet { background: #fff; color: var(--deep); width: min(520px, 100%); border-radius: 24px 24px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.menu .sheet button { min-height: 52px; border: 0; border-radius: 14px; background: #f1ebff; color: var(--deep); font-weight: 600; font-size: 18px; text-align: left; padding: 0 16px; }
.menu .sheet button.danger { background: #ffe3ea; }
.menu .sheet button.close { background: var(--purple); color: #fff; text-align: center; }
.menu h2 { margin: 4px 4px 0; font-size: 18px; }

/* ---------- Setup screen ---------- */
.setup { max-width: 640px; margin: 0 auto; padding: 18px 16px 120px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mascot { width: 72px; animation: bob 2.4s ease-in-out infinite; }
.brand h1 { margin: 0; font-size: 44px; line-height: .9; color: var(--sun); text-shadow: 0 3px 0 var(--pink), 0 6px 0 var(--deep); }
.brand h1 span { color: #fff; }
.brand p { margin: 6px 0 0; font-weight: 600; }
.card { background: rgba(255,255,255,.12); border-radius: 22px; padding: 14px; margin-top: 16px; }
.card h2 { margin: 0 0 10px; font-size: 22px; }
.card p.help { margin: 0 0 10px; opacity: .9; font-size: 16px; line-height: 1.35; }
.players { display: grid; gap: 10px; }
.player { background: rgba(255,255,255,.95); color: var(--deep); border-radius: 18px; padding: 10px; display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; }
.player .ava { width: 64px; height: 64px; border: 0; border-radius: 50%; background: #f1ebff; padding: 6px; }
.player .ava img { width: 100%; }
.player input, .player select, .field input, .field select { font: inherit; font-size: 17px; width: 100%; min-height: 44px; border: 2px solid #d9ccff; border-radius: 12px; padding: 6px 10px; color: var(--deep); background: #fff; }
.player .fields { display: grid; gap: 6px; }
.player .del { width: 44px; height: 44px; border: 0; border-radius: 12px; background: #ffe3ea; color: var(--deep); font-size: 20px; }
.add { width: 100%; min-height: 52px; border: 3px dashed rgba(255,255,255,.6); background: transparent; color: #fff; border-radius: 18px; font-weight: 600; font-size: 18px; margin-top: 10px; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.seg button { min-height: 64px; border: 0; border-radius: 16px; background: rgba(255,255,255,.18); color: #fff; font-weight: 700; font-size: 20px; line-height: 1.05; padding: 6px; }
.seg button small { display: block; font-weight: 500; font-size: 13px; opacity: .9; }
.seg button[aria-pressed="true"] { background: var(--sun); color: var(--deep); box-shadow: 0 4px 0 #c9a400; }
.seg.rounds { grid-template-columns: repeat(5, 1fr); }
.how { display: grid; gap: 10px; }
.how .cast-row { display: flex; align-items: center; gap: 12px; }
google-cast-launcher { width: 48px; height: 48px; --connected-color: #FFD60A; --disconnected-color: #fff; cursor: pointer; display: inline-block; }
.cast-state { font-weight: 600; }
.cast-state.on { color: var(--sun); }
.mirror-steps { margin: 0; padding-left: 1.3em; line-height: 1.45; font-size: 16px; }
.play-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(30, 5, 80, .95) 30%); display: flex; justify-content: center; }
.play-bar button { width: min(608px, 100%); min-height: 64px; border: 0; border-radius: 22px; background: var(--sun); color: var(--deep); font-weight: 700; font-size: 26px; box-shadow: 0 6px 0 #c9a400; }
.links { display: grid; gap: 8px; }
.links a { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px; border-radius: 16px; background: rgba(255,255,255,.95); color: var(--deep); text-decoration: none; font-weight: 600; font-size: 17px; }
.picker { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(10, 0, 30, .6); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.picker[hidden] { display: none; }
.picker .sheet { background: #fff; color: var(--deep); width: min(520px, 100%); border-radius: 24px 24px 0 0; padding: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.picker .sheet h2 { grid-column: 1 / -1; margin: 0; font-size: 20px; }
.picker .sheet button { border: 0; background: #f1ebff; border-radius: 16px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; color: var(--deep); }
.picker .sheet button[disabled] { opacity: .3; }
.picker .sheet img { width: 56px; }
.foot { margin-top: 18px; font-size: 13px; opacity: .75; line-height: 1.4; }
.foot a { color: #fff; }
.rotate-hint { display: none; }
.mode-mirror .rotate-hint { display: none; }
@media (orientation: portrait) {
  .mode-mirror .rotate-hint { display: block; position: absolute; top: 64px; left: 50%; transform: translateX(-50%); background: var(--sun); color: var(--deep); font-weight: 600; padding: 6px 14px; border-radius: 99px; font-size: 14px; z-index: 5; white-space: nowrap; }
}

/* Narrow phones: tighten the score bar so nothing runs off the edge */
@media (max-width: 480px) {
  .scorebar { padding: 10px 8px; gap: 6px; }
  .score { gap: 4px; }
  .score .pts { min-width: 2.2em; }
  .score .mini { display: none; }
  .round { padding: .3em .6em; }
  .stage { padding: 0 10px; }
  .caption { padding-left: 10px; padding-right: 10px; }
}
.house, .stage, .choices { max-width: 100%; }
