/* Head Case: a retro 1970s TV game show. Deep purple stage, marquee gold, sunbursts, chunky Bungee type.
   The menu is portrait; the play screens are landscape (the phone is sideways on a forehead) and readable
   from across the room: one huge word, a thin timer bar, a tiny score. */
@font-face { font-family: 'Bungee'; src: url('/fonts/bungee.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Rubik'; src: url('/fonts/rubik.woff2') format('woff2'); font-weight: 400 900; font-display: swap; }

:root {
  --deep: #25104f; --purple: #4a1f96; --violet: #8b54e0; --gold: #ffe14d; --gold-edge: #b89a10; --cream: #fff6e0;
  --ok: #1fa563; --ok-edge: #0e6a3c; --no: #ff8a1f; --no-edge: #a8510a; --pink: #ff4fa3; --red: #e23b3b;
  --display: 'Bungee', 'Arial Black', 'Impact', sans-serif;
  --body: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --t0: #8b54e0; --t1: #ffc21a; --t2: #ff4fa3; --t3: #1fc6b0;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--deep); color: var(--cream); font-family: var(--body); overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { display: block; }

#app { position: fixed; inset: 0; overflow: hidden; display: flex; flex-direction: column; }
.bg { position: absolute; inset: 0; background: var(--grain), radial-gradient(120% 70% at 50% 0%, var(--violet), var(--purple) 45%, var(--deep)); }
.bg.stage { background: var(--grain), linear-gradient(rgba(37, 16, 79, .35), rgba(37, 16, 79, .75)), url('/art/stage.webp') center / cover no-repeat, var(--deep); }
.bg.play { background: var(--grain), radial-gradient(90% 90% at 50% 50%, #5a28b4, var(--deep)); }
.bg.red { background: var(--grain), radial-gradient(90% 90% at 50% 50%, #ff5a4a, #a4161a); }

.flash { position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: 0; }
.flash.on.ok { background: var(--ok); animation: flash .6s ease-out both; }
.flash.on.no { background: var(--no); animation: flash .6s ease-out both; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }

/* top bar */
.bar { position: relative; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px)); }
.bar-title { font-family: var(--display); font-size: 17px; color: var(--gold); text-shadow: 0 2px 0 var(--deep); }
.round-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 246, 224, .14); box-shadow: inset 0 0 0 2px rgba(255, 225, 77, .5); display: grid; place-items: center; cursor: pointer; }
.round-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.round-btn .spk { fill: var(--gold); }
#sound[aria-pressed="true"] .mute, #sound[aria-pressed="false"] .wave { display: none; }
.round-btn:active { transform: scale(.94); }

/* screens */
#stage { position: relative; z-index: 2; flex: 1; min-height: 0; container-type: size; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; gap: 14px; overflow-y: auto; overflow-x: hidden;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 16px) max(16px, env(safe-area-inset-left, 0px));
  animation: in .32s cubic-bezier(.2, .9, .3, 1.15) both; scrollbar-width: none; }
.screen::-webkit-scrollbar { display: none; }
.screen.out { animation: out .2s ease-in both; pointer-events: none; }
.screen > * { flex: none; }
.spacer { flex: 1 1 0 !important; min-height: 6px; }
.sticky-foot { position: sticky; bottom: 0; z-index: 2; width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 10px; }
.sticky-foot::before { content: ''; position: absolute; inset: -24px -40px calc(-1 * (env(safe-area-inset-bottom, 0px) + 16px)); background: linear-gradient(rgba(37, 16, 79, 0), rgba(37, 16, 79, .92) 40%); z-index: -1; pointer-events: none; }
@keyframes in { from { opacity: 0; transform: translateY(22px) scale(.98); } }
@keyframes out { to { opacity: 0; transform: scale(.98); } }

/* landscape play screens: when the browser did not rotate, the stage is turned by hand */
#app.land .bar { display: none; }
#app.rot #stage { position: fixed; top: 50%; left: 50%; width: 100vh; height: 100vw; flex: none; transform: translate(-50%, -50%) rotate(var(--rot, 90deg)); }

h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; line-height: 1; text-wrap: balance; }
.lead { font-size: 17px; font-weight: 600; line-height: 1.35; text-align: center; max-width: 32ch; margin: 0; }
.kicker { font-weight: 800; font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.panel { background: rgba(37, 16, 79, .78); border: 2px solid rgba(255, 225, 77, .55); border-radius: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); backdrop-filter: blur(6px); }
.sheet { width: 100%; max-width: 460px; padding: 18px; }

/* buttons */
.btn { appearance: none; border: 0; cursor: pointer; width: 100%; max-width: 420px; min-height: 60px; border-radius: 999px; padding: 12px 22px;
  font-family: var(--display); font-size: 24px; letter-spacing: .04em; color: var(--deep); background: var(--gold);
  box-shadow: 0 5px 0 var(--gold-edge), 0 0 26px rgba(255, 225, 77, .35); transition: transform .08s, box-shadow .08s; display: flex; align-items: center; justify-content: center; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-edge); }
.btn.go { font-size: 30px; min-height: 66px; }
.btn.ghost { background: rgba(255, 246, 224, .14); color: var(--cream); box-shadow: inset 0 0 0 2px rgba(255, 246, 224, .35); }
.link { appearance: none; background: none; border: 0; padding: 8px 10px; font-weight: 700; font-size: 15px; color: var(--cream); opacity: .85; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ------------------------------------------------------------------ menu */
.logo { margin-top: calc(env(safe-area-inset-top, 0px) + 6px); display: flex; flex-direction: column; align-items: center; transform: rotate(-3deg); }
.logo span { display: block; font-size: clamp(50px, 17vw, 84px); line-height: .9; color: var(--gold); text-shadow: 0 4px 0 #d2581e, 0 8px 0 var(--deep), 0 0 30px rgba(255, 225, 77, .45); }
.logo span + span { color: var(--cream); text-shadow: 0 4px 0 var(--pink), 0 8px 0 var(--deep), 0 0 30px rgba(255, 79, 163, .45); }
.decks { width: 100%; max-width: 460px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.deck { appearance: none; position: relative; border: 0; padding: 0; cursor: pointer; border-radius: 14px; overflow: hidden; aspect-ratio: 3 / 4; background: var(--c);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .35); transition: transform .12s, box-shadow .12s; display: flex; flex-direction: column; justify-content: flex-end; text-align: left; }
.deck img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.deck::after { content: ''; position: absolute; inset: 45% 0 0; background: linear-gradient(transparent, rgba(20, 8, 44, .92)); }
.deck .name, .deck .n { position: relative; z-index: 1; padding: 0 8px; }
.deck .name { font-family: var(--display); font-size: clamp(12px, 3.6vw, 16px); line-height: 1.02; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .6); }
.deck .n { font-size: 11px; font-weight: 700; opacity: .85; padding-bottom: 7px; padding-top: 2px; }
.deck .tick { position: absolute; z-index: 2; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; background: var(--gold); display: none; box-shadow: 0 2px 0 var(--gold-edge); }
.deck .tick::after { content: ''; position: absolute; left: 9px; top: 4px; width: 6px; height: 12px; border: solid var(--deep); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.deck[aria-checked="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--gold), 0 0 26px rgba(255, 225, 77, .6); transform: scale(1.03); z-index: 1; }
.deck[aria-checked="true"] .tick { display: block; }
.deck:active { transform: scale(.97); }
.pills { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pill { appearance: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 999px; font-weight: 800; font-size: 15px;
  background: rgba(37, 16, 79, .8); box-shadow: inset 0 0 0 2px rgba(255, 225, 77, .55); }
.pill svg { width: 18px; height: 18px; fill: none; stroke: var(--gold); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pill[aria-pressed="true"] { background: var(--gold); color: var(--deep); }
.pill[aria-pressed="true"] svg { stroke: var(--deep); }

/* manual */
.manual h2 { font-size: 30px; text-align: center; margin-bottom: 14px; color: var(--gold); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; font-size: 16px; font-weight: 500; line-height: 1.35; }
.steps li::before { content: counter(s); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 17px; background: var(--gold); color: var(--deep); }
.steps b { color: var(--gold); }

/* ------------------------------------------------------------------ ready */
.turn-tag { font-family: var(--display); font-size: 18px; padding: 6px 16px; border-radius: 999px; background: var(--pink); color: #fff; transform: rotate(-2deg); box-shadow: 0 4px 0 rgba(0, 0, 0, .3); }
.turn-tag[data-team="0"] { background: var(--t0); } .turn-tag[data-team="1"] { background: var(--t1); color: var(--deep); }
.turn-tag[data-team="2"] { background: var(--t2); } .turn-tag[data-team="3"] { background: var(--t3); color: var(--deep); }
.forehead { position: relative; width: 170px; height: 150px; }
.forehead .head { position: absolute; left: 35px; top: 30px; width: 100px; height: 120px; border-radius: 50px 50px 44px 44px; background: #f2c9a0; box-shadow: inset -8px -6px 0 rgba(0, 0, 0, .12); }
.forehead .ph { position: absolute; left: 30px; top: 6px; width: 110px; height: 58px; border-radius: 12px; background: var(--gold); border: 4px solid var(--deep); display: grid; place-items: center; animation: lift 2.4s ease-in-out infinite; }
.forehead .ph span { font-family: var(--display); font-size: 28px; color: var(--deep); }
@keyframes lift { 0%, 20% { transform: translateY(70px) rotate(-8deg); opacity: .4; } 55%, 100% { transform: none; opacity: 1; } }
.big-call { font-size: clamp(28px, 9vw, 42px); text-align: center; color: var(--gold); text-shadow: 0 3px 0 var(--deep); max-width: 14ch; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.legend span { font-weight: 800; font-size: 14px; padding: 6px 12px; border-radius: 999px; }
.legend .ok { background: var(--ok); } .legend .no { background: var(--no); color: var(--deep); }
.deck-line { margin: 0; font-weight: 700; font-size: 13px; opacity: .75; }

/* ------------------------------------------------------------------ countdown + play (landscape) */
[data-screen="count"], [data-screen="play"], [data-screen="timeup"] { justify-content: center; padding: 0; gap: 0; }
.count { font-family: var(--display); font-size: min(60cqh, 40cqw); line-height: 1; color: var(--gold); text-shadow: 0 8px 0 #d2581e, 0 14px 0 var(--deep); animation: slam .55s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes slam { from { transform: scale(2.2); opacity: 0; } 60% { opacity: 1; } }
.timebar { position: absolute; left: 0; right: 0; top: 0; height: max(10px, 2.4cqh); background: rgba(255, 246, 224, .12); }
.timebar span { display: block; height: 100%; background: var(--gold); transform-origin: left; box-shadow: 0 0 16px rgba(255, 225, 77, .7); }
[data-screen="play"].hurry .timebar span { background: var(--red); box-shadow: 0 0 16px rgba(226, 59, 59, .8); }
[data-screen="play"].hurry::after { content: ''; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 1.6cqh var(--red); animation: hurry 1s ease-in-out infinite; }
@keyframes hurry { 50% { opacity: .2; } }
.rule { position: absolute; top: 6cqh; left: 0; right: 0; text-align: center; font-weight: 800; font-size: max(14px, 5cqh); letter-spacing: .08em; text-transform: uppercase; color: var(--gold); opacity: .85; padding: 0 4cqw; }
.word-wrap { width: 92cqw; height: 66cqh; display: grid; place-items: center; }
.word { font-family: var(--display); font-size: min(24cqh, 15cqw); line-height: 1.02; text-align: center; color: #fff; text-shadow: 0 6px 0 var(--deep), 0 0 40px rgba(139, 84, 224, .8); overflow-wrap: break-word; max-width: 100%; }
.word.pop { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.score { position: absolute; right: 4cqw; bottom: 5cqh; font-family: var(--display); font-size: max(16px, 7cqh); color: var(--gold); opacity: .9; }
.verdict { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; font-family: var(--display); font-size: min(26cqh, 16cqw); color: #fff; text-shadow: 0 8px 0 rgba(0, 0, 0, .25); animation: pop .3s cubic-bezier(.2, 1.6, .4, 1) both; }
.verdict.ok { background: var(--ok); } .verdict.no { background: var(--no); }
.tapzone { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 4; border: 0; background: none; cursor: pointer; display: flex; align-items: flex-end; padding: 0 3cqw 5cqh; }
.tapzone.left { left: 0; } .tapzone.right { right: 0; justify-content: flex-end; }
.tapzone span { font-weight: 800; font-size: max(13px, 4.4cqh); text-transform: uppercase; letter-spacing: .1em; padding: 6px 14px; border-radius: 999px; }
.tapzone.left span { background: rgba(255, 138, 31, .85); color: var(--deep); } .tapzone.right span { background: rgba(31, 165, 99, .9); }
.tapzone.right span::after { content: ' ▶'; } .tapzone.left span::before { content: '◀ '; }
.tapzone:active { background: rgba(255, 255, 255, .06); }
.tapzone:focus-visible { outline: none; }
[data-screen="play"]:has(.tapzone) .score { bottom: 16cqh; }
.putdown { font-family: var(--display); font-size: min(22cqh, 14cqw); line-height: .95; text-align: center; color: #fff; text-shadow: 0 8px 0 #7d0f12; animation: slam .5s cubic-bezier(.2, 1.6, .4, 1) both; }
[data-screen="timeup"] .lead { margin-top: 3cqh; font-size: max(16px, 6cqh); font-family: var(--display); font-weight: 400; color: var(--gold); }

/* ------------------------------------------------------------------ results */
.big-score { font-family: var(--display); text-align: center; color: var(--gold); font-size: 20px; line-height: 1; }
.big-score span { display: block; font-size: clamp(90px, 30vw, 140px); line-height: .9; text-shadow: 0 6px 0 #d2581e, 0 11px 0 var(--deep); animation: slam .55s cubic-bezier(.2, 1.6, .4, 1) both; }
.best { font-family: var(--display); font-size: 18px; color: var(--deep); background: var(--gold); padding: 4px 14px; border-radius: 8px; transform: rotate(-3deg); }
.drink { font-weight: 800; font-size: 17px; text-align: center; background: var(--no); color: var(--deep); padding: 10px 16px; border-radius: 14px; max-width: 420px; }
.words { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 460px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.words li { font-weight: 800; font-size: 15px; padding: 7px 12px; border-radius: 999px; }
.words .got { background: var(--ok); }
.words .got::before { content: '✓ '; }
.words .missed { background: rgba(255, 246, 224, .14); color: rgba(255, 246, 224, .6); text-decoration: line-through; }
.board { padding: 8px 16px; }
.board .row { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid rgba(255, 225, 77, .25); font-weight: 800; font-size: 17px; }
.board .row:first-child { border-top: 0; }
.board .dot { width: 14px; height: 14px; border-radius: 50%; }
.board .row[data-team="0"] .dot { background: var(--t0); } .board .row[data-team="1"] .dot { background: var(--t1); }
.board .row[data-team="2"] .dot { background: var(--t2); } .board .row[data-team="3"] .dot { background: var(--t3); }
.board .ct { font-family: var(--display); font-size: 24px; color: var(--gold); }
.winner { font-size: clamp(40px, 13vw, 64px); text-align: center; color: #fff; }
.winner [data-team="0"] { color: var(--t0); } .winner [data-team="1"] { color: var(--t1); } .winner [data-team="2"] { color: var(--t2); } .winner [data-team="3"] { color: var(--t3); }
.winner span { text-shadow: 0 5px 0 var(--deep), 0 0 30px currentColor; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; grid-template-columns: minmax(0, 420px); justify-content: center; align-content: center; padding: 20px; background: rgba(20, 8, 44, .7); animation: fade .2s both; }
.modal .sheet { animation: in .3s cubic-bezier(.2, .9, .3, 1.15) both; display: grid; gap: 14px; text-align: center; justify-items: center; background: var(--deep); }
.modal h2 { font-size: 26px; color: var(--gold); }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
/* the menu on a landscape phone or a desktop: decks in one wider grid */
@media (orientation: landscape) and (max-height: 560px) { .decks { grid-template-columns: repeat(9, 1fr); max-width: 980px; gap: 8px; } .deck .n { display: none; } .logo { flex-direction: row; gap: 14px; } .logo span { font-size: 44px; } }
/* short portrait phones: the whole menu (logo, 9 decks, pills, START) still fits on one screen */
@media (orientation: portrait) and (max-height: 760px) {
  .logo { flex-direction: row; gap: 12px; } .logo span { font-size: clamp(38px, 11vw, 52px); }
  .deck { aspect-ratio: 1; }
  .decks { max-width: min(460px, calc(100dvh - 300px)); gap: 8px; }
  .deck .n { display: none; }
}
