/* Social games: the party page, the shared stage (also used by the TV page), phone controls and the drawing pad.
   Builds on site.css, table.css and game-shell.css. Each game tints things with --game. */
:root { --game: #e0457b; --accent: var(--game); }
.party-page { --title-ink: linear-gradient(100deg, var(--ink), var(--game) 70%, var(--yellow)); }

/* ---------- Home ---------- */
.pg-hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 36px; align-items: center; padding: 20px 0 10px; }
.pg-hero h1 { margin: 0; font: 800 clamp(3.2rem, 8.5vw, 6.2rem)/.9 var(--display); letter-spacing: -.05em; background: linear-gradient(100deg, #e0457b, #f08a24 45%, #7a4be0); -webkit-background-clip: text; background-clip: text; color: transparent; padding-bottom: .06em; }
.pg-hero .lede { margin: 14px 0 0; font-size: 1.2rem; color: var(--ink-soft); }
.pg-join { margin-top: 22px; }
.pg-join input { font-size: 1.2rem; }
.pg-hero-art { position: relative; height: 300px; border-radius: 34px; background: radial-gradient(circle at 30% 30%, color-mix(in srgb, #e0457b 30%, var(--card)), transparent 60%), radial-gradient(circle at 80% 70%, color-mix(in srgb, #7a4be0 30%, var(--card)), transparent 60%), var(--card); box-shadow: var(--shadow); overflow: hidden; }
.pg-bubble { position: absolute; display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 1.9rem; animation: pgFloat 5s ease-in-out infinite; }
.pg-bubble.b1 { left: 8%; top: 12%; } .pg-bubble.b2 { left: 32%; top: 6%; animation-delay: -1s; } .pg-bubble.b3 { right: 10%; top: 10%; animation-delay: -2s; }
.pg-bubble.b4 { left: 5%; bottom: 14%; animation-delay: -3s; } .pg-bubble.b5 { right: 30%; bottom: 8%; animation-delay: -1.5s; } .pg-bubble.b6 { right: 6%; bottom: 30%; animation-delay: -2.5s; } .pg-bubble.b7 { left: 26%; bottom: 38%; animation-delay: -.5s; }
@keyframes pgFloat { 50% { transform: translateY(-12px) rotate(6deg); } }
.pg-phone { position: absolute; left: 44%; top: 30%; width: 92px; height: 160px; padding: 10px 8px; border-radius: 18px; background: var(--ink); color: var(--on-ink); box-shadow: 0 16px 30px -12px rgba(0,0,0,.5); transform: rotate(-8deg); display: grid; align-content: end; gap: 8px; }
.pg-phone span { height: 60px; border-radius: 10px; background: linear-gradient(135deg, #e0457b, #f6c431); }
.pg-phone b { font-size: .7rem; text-align: center; padding: 6px; border-radius: 8px; background: #22a75d; color: #fff; }
.pg-tv { position: absolute; right: 12%; top: 34%; width: 150px; padding: 12px; border-radius: 12px; border: 6px solid var(--ink); background: var(--paper); display: grid; place-items: center; gap: 4px; transform: rotate(4deg); }
.pg-tv span { font-size: 2rem; } .pg-tv small { font-size: .62rem; font-weight: 700; color: var(--ink-soft); }
.pg-howto { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.pg-howto div { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; padding: 14px 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.pg-howto span { grid-row: span 2; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: var(--on-ink); font: 800 1.1rem var(--display); }
.pg-howto b { font: 700 1.1rem/1.2 var(--display); }
.pg-howto small { color: var(--muted); }
.pg-section { margin: 34px 0 14px; font: 800 1.9rem/1 var(--display); }
.pg-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.pg-card { display: grid; grid-template-rows: auto 1fr; border-radius: 26px; background: var(--card); box-shadow: var(--shadow); overflow: hidden; transition: transform .2s; }
.pg-card:hover { transform: translateY(-4px) rotate(-.4deg); }
.pg-card-art { display: grid; place-items: center; height: 120px; background: radial-gradient(circle at 50% 120%, color-mix(in srgb, var(--game) 60%, #fff), var(--game)); }
.pg-card-art span { font-size: 3.6rem; filter: drop-shadow(0 6px 10px rgba(0,0,0,.25)); transition: transform .3s; }
.pg-card:hover .pg-card-art span { transform: scale(1.15) rotate(-8deg); }
.pg-card-body { display: grid; gap: 8px; align-content: start; padding: 16px 18px 18px; }
.pg-card h3 { margin: 0; font: 800 1.45rem/1.1 var(--display); }
.pg-card-tag { margin: 0; color: var(--ink-soft); }
.pg-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 4px; }
.pg-card-meta span { padding: 3px 9px; border-radius: 999px; background: var(--paper); font-size: .78rem; font-weight: 700; color: var(--ink-soft); }
.pg-rating.adult { background: #2a1f33; color: #ffb3c7; }
.pg-rating.family { background: color-mix(in srgb, #22a75d 22%, var(--card)); color: var(--ink); }
.pg-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pg-card-actions .primary-button { background: var(--game); box-shadow: 0 4px 0 color-mix(in srgb, var(--game) 60%, #000); }
.pg-footnote { margin: 22px 0 0; color: var(--muted); font-size: .9rem; }

/* ---------- Settings dialog ---------- */
.pg-setup { width: min(560px, calc(100% - 24px)); --accent: var(--game); }
.pg-setup-head { display: flex; align-items: center; gap: 14px; }
.pg-setup-head h2 { margin: 0; }
.pg-setup-head .kicker { margin: 0; }
.pg-setup-emoji { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 18px; background: var(--game); font-size: 2rem; }
.pg-setup-tag { margin: 8px 0 16px; color: var(--ink-soft); }
.pg-field { display: grid; gap: 6px; }
.pg-field + .pg-field { margin-top: 6px; }
.pg-label { font-weight: 700; font-size: .92rem; }
.pg-field select { padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; font-weight: 600; }
.pg-field .gs-seg span { font-size: .9rem; text-align: center; }
.pg-note { color: var(--ink-soft); font-size: .8rem; }
.pg-subhead { margin: 14px 0 2px; color: var(--ink-soft); font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.pg-play { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.pg-play legend { grid-column: 1 / -1; }
.pg-play-option { position: relative; display: grid; justify-items: center; gap: 2px; padding: 14px 8px; border: 2px solid var(--line); border-radius: 16px; background: var(--paper); cursor: pointer; text-align: center; transition: transform .15s, border-color .15s; }
.pg-play-option input { position: absolute; opacity: 0; pointer-events: none; }
.pg-play-option:hover { transform: translateY(-2px); }
.pg-play-option:has(input:checked) { border-color: var(--game); background: var(--card); box-shadow: 0 0 0 3px color-mix(in srgb, var(--game) 25%, transparent); }
.pg-play-option:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.pg-play-emoji { font-size: 1.9rem; transition: transform .2s; }
.pg-play-option:has(input:checked) .pg-play-emoji { transform: scale(1.15) rotate(-6deg); }
.pg-play-option small { color: var(--ink-soft); font-size: .8rem; }
.pg-play.shake { animation: pgShake .4s 1; }
@keyframes pgShake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.pc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pg-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-bottom: 16px; }
.pg-pick { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border: 2px solid transparent; border-radius: 14px; background: var(--paper); }
.pg-pick span { font-size: 1.5rem; } .pg-pick small { font-weight: 700; font-size: .72rem; line-height: 1.15; text-align: center; }
.pg-pick.on { border-color: var(--game); background: color-mix(in srgb, var(--game) 14%, var(--card)); }

/* ---------- Room layout ---------- */
.pg-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.pg-main { display: grid; gap: 14px; min-width: 0; }
.pg-stage { padding: 18px 20px 22px; border-radius: 28px; background: var(--card); box-shadow: var(--shadow); border-top: 6px solid var(--game); min-height: 180px; }
.pg-control { display: grid; gap: 12px; }
.pg-control:empty { display: none; }
.pg-hostbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 18px; background: var(--paper-deep); }
.pg-host-label { font-weight: 800; font-size: .85rem; margin-right: auto; }
.pg-people { display: grid; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.pg-people li { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 14px; background: var(--paper); }
.pg-people li.me { box-shadow: inset 0 0 0 2px var(--game); }
.pg-person b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-person small { color: var(--muted); font-size: .78rem; }
.pg-score { font: 800 1.1rem var(--display); }
.pg-mini { width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--card); font-size: .8rem; }
.pg-mini.danger:hover { background: var(--red); color: #fff; }
.pg-extra { margin: 0 0 10px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.pg-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.pg-inline { display: flex; gap: 8px; }
.pg-inline input { flex: 1; }

/* ---------- Stage (shared screen) ---------- */
.ps-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 14px; }
.ps-title { display: flex; align-items: center; gap: 8px; font: 800 1.2rem var(--display); }
.ps-emoji { font-size: 1.4rem; }
.ps-status { padding: 4px 12px; border-radius: 999px; background: var(--paper); font-size: .78rem; font-weight: 800; letter-spacing: .06em; color: var(--ink-soft); }
.ps-timer { margin-left: auto; min-width: 54px; padding: 6px 12px; border-radius: 999px; background: var(--ink); color: var(--on-ink); font: 800 1.2rem var(--body); font-variant-numeric: tabular-nums; text-align: center; }
.ps-timer.low { background: var(--red); color: #fff; animation: gsPop .5s ease-in-out infinite; }
.ps-body { display: grid; gap: 14px; animation: psIn .45s ease-out; }
.ps-body.still, .ps-body.still .sp-clue { animation: none; }
@keyframes psIn { from { opacity: 0; transform: translateY(10px); } }
.ps-big { margin: 0; font: 800 clamp(1.3rem, 3.6vw, 2.1rem)/1.15 var(--display); letter-spacing: -.01em; }
.ps-big.ps-turn { color: var(--game); }
.ps-note { margin: 0; color: var(--ink-soft); font-size: 1.05rem; }
.ps-kicker { margin: 0; font-weight: 800; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--game); }
.ps-prompt { margin: 0; padding: 18px 20px; border-radius: 20px; background: var(--ink); color: var(--on-ink); font: 700 clamp(1.25rem, 3.4vw, 2rem)/1.25 var(--display); animation: psCard .5s cubic-bezier(.2,1.4,.4,1); }
.ps-prompt.question { background: color-mix(in srgb, var(--game) 16%, var(--card)); color: var(--ink); }
@keyframes psCard { from { transform: scale(.9) rotate(-2deg); opacity: 0; } }
.ps-blank { display: inline-block; width: 4.5em; height: .95em; margin: 0 .15em; border-bottom: 4px solid var(--game); vertical-align: baseline; }
.ps-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; font-weight: 700; }
.ps-chip b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-chip.big { font-size: 1.3rem; }
.ps-chip.win b { color: var(--green); }
.ps-dot { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; color: #fff; font: 800 .8rem var(--body); font-style: normal; }
.ps-chip.big .ps-dot { width: 38px; height: 38px; font-size: 1.1rem; }
.ps-roster { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; padding: 0; list-style: none; }
.ps-roster li { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--paper); transition: background .3s, opacity .3s; }
.ps-roster li.waiting { opacity: .55; }
.ps-roster li.waiting::after { content: '…'; font-weight: 800; }
.ps-roster li.done { background: color-mix(in srgb, var(--green) 20%, var(--card)); animation: gsPop .4s ease-out; }
.ps-roster li.done::after { content: '✓'; color: var(--green); font-weight: 800; }
.ps-roster li.away { opacity: .4; }
.ps-roster li.away::before { content: '📴'; }
.ps-roster li.turn { box-shadow: 0 0 0 3px var(--game); background: var(--card); }
.ps-roster small { font-size: .72rem; font-weight: 800; }
.ps-ready { color: var(--green); }
.ps-score { padding: 1px 7px; border-radius: 999px; background: var(--ink); color: var(--on-ink); }
.ps-wait { color: var(--ink-soft); font-size: 1.15rem; }

/* Lobby */
.ps-lobby { display: grid; justify-items: center; gap: 6px; padding: 22px; border-radius: 24px; background: radial-gradient(circle at 50% 0, color-mix(in srgb, var(--game) 30%, var(--card)), var(--card) 70%); text-align: center; }
.ps-lobby-emoji { font-size: 3.4rem; animation: pgFloat 3s ease-in-out infinite; }
.ps-lobby h2 { margin: 0; font: 800 clamp(1.8rem, 5vw, 2.8rem)/1 var(--display); }
.ps-tagline { margin: 0; color: var(--ink-soft); font-size: 1.1rem; }
.ps-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 6px 0 0; }
.ps-tags span { padding: 3px 10px; border-radius: 999px; background: var(--card); font-size: .8rem; font-weight: 700; }
.ps-join { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 14px; border-radius: 22px; background: var(--paper); }
.ps-qr { width: 132px; flex: none; border-radius: 12px; overflow: hidden; background: #fff; }
.ps-qr svg { display: block; width: 100%; height: auto; }
.ps-join-text { display: grid; gap: 2px; }
.ps-join-text small { color: var(--muted); font-weight: 600; }
.ps-join-text b { font-size: 1.15rem; }
.ps-code { font: 800 2.4rem/1 var(--display); letter-spacing: .14em; color: var(--game); }

/* Scores */
.ps-scores { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ps-scores li { display: grid; grid-template-columns: 28px minmax(90px, 180px) 1fr auto auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 16px; background: var(--paper); animation: psSlide .5s both cubic-bezier(.2,1.2,.4,1); }
.ps-scores li.gone { opacity: .45; }
@keyframes psSlide { from { opacity: 0; transform: translateX(-30px); } }
.ps-rank { font: 800 1.1rem var(--display); color: var(--muted); }
.ps-bar { height: 12px; border-radius: 999px; background: var(--card); overflow: hidden; }
.ps-bar i { display: block; height: 100%; border-radius: 999px; animation: psGrow 1s .3s both ease-out; transform-origin: left; }
@keyframes psGrow { from { transform: scaleX(0); } }
.ps-points { font: 800 1.3rem var(--display); }
.ps-delta { padding: 2px 8px; border-radius: 999px; background: var(--green); color: #fff; font-style: normal; font-weight: 800; font-size: .85rem; animation: psDelta 1.2s .6s both cubic-bezier(.2,1.6,.4,1); }
@keyframes psDelta { from { transform: translateY(12px) scale(.4); opacity: 0; } }
.ps-trophy { justify-self: center; font-size: 4rem; animation: gsTrophy 1s cubic-bezier(.2, 1.6, .4, 1); }
.ps-winner { text-align: center; }

/* Clues, answers, options */
.ps-clues, .ps-answers, .ps-said, .ps-options, .ps-guesses, .ps-rules, .ps-chain { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ps-clues { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.ps-clues li { display: grid; gap: 4px; padding: 10px 14px; border-radius: 16px; background: var(--paper); animation: psPop .4s both cubic-bezier(.2,1.5,.4,1); }
.ps-clues li b { font: 800 1.35rem/1.15 var(--display); overflow-wrap: anywhere; }
.ps-clues li.passed b { color: var(--muted); font-style: italic; font-weight: 600; }
.ps-clues li.impostor { box-shadow: inset 0 0 0 3px var(--red); background: color-mix(in srgb, var(--red) 12%, var(--card)); }
@keyframes psPop { from { transform: scale(.6); opacity: 0; } }
.ps-votes { color: var(--game); font-weight: 800; }
.ps-reveal-head { text-align: center; font-size: clamp(1.6rem, 5vw, 2.6rem); animation: gsStamp 1.2s cubic-bezier(.2,1.6,.4,1) both; animation-name: psStampIn; }
@keyframes psStampIn { from { transform: scale(2) rotate(-6deg); opacity: 0; } }
.ps-reveal-card { display: grid; justify-items: center; gap: 4px; padding: 18px; border-radius: 22px; background: #1f2233; color: #f5efe4; text-align: center; animation: psFlip .8s .2s both ease-out; }
.ps-reveal-card strong { font: 800 clamp(2rem, 6vw, 3.4rem)/1 var(--display); color: var(--yellow); letter-spacing: -.02em; }
.ps-reveal-card small { opacity: .75; font-weight: 700; }
.ps-reveal-card .ps-chip b { color: #f5efe4; }
.ps-role-emoji { font-size: 3rem; }
@keyframes psFlip { from { transform: perspective(600px) rotateX(80deg); opacity: 0; } }
.ps-answers { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.ps-answers li, .ps-said li, .ps-options li { display: grid; gap: 8px; align-content: space-between; padding: 14px 16px; border-radius: 18px; background: var(--paper); animation: psPop .45s both cubic-bezier(.2,1.4,.4,1); }
.ps-answers li p, .ps-said li p, .ps-options li p { margin: 0; font: 700 1.2rem/1.25 var(--display); overflow-wrap: anywhere; }
.ps-answers li.win { background: color-mix(in srgb, var(--yellow) 40%, var(--card)); box-shadow: 0 0 0 3px var(--yellow); }
.ps-answers li.win::before { content: '🏆 WINNER'; font-weight: 800; font-size: .75rem; letter-spacing: .1em; }
.ps-answer-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: .9rem; }
.ps-answer-foot small { color: var(--muted); font-weight: 600; }
.ps-said.reveal li, .ps-options.reveal li { animation: psReveal .7s both cubic-bezier(.2,1.3,.4,1); }
@keyframes psReveal { from { opacity: 0; transform: translateY(24px) scale(.92); } }
.ps-options li.real { background: color-mix(in srgb, var(--green) 25%, var(--card)); box-shadow: 0 0 0 3px var(--green); }
.ps-options li.fake p { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 3px; }
.ps-verdict { font-size: .85rem; }
.ps-pickers { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; }
.ps-fact { padding: 12px 16px; border-radius: 16px; background: var(--paper); animation: psReveal .7s both; }
.ps-solved { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-weight: 700; }
.ps-guesses li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 14px; background: var(--paper); }
.ps-guesses li.win { background: color-mix(in srgb, var(--green) 18%, var(--card)); }
.ps-rules li { padding: 8px 12px; border-radius: 12px; background: var(--paper); font-weight: 600; }
.ps-rules small { color: var(--muted); }
.ps-recap { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.ps-recap-q { padding: 12px; border-radius: 16px; background: var(--paper); }
.ps-recap-q ul { margin: 6px 0 0; padding-left: 18px; }
.ps-recap-q em { font-style: normal; font-weight: 700; }

/* Alien letters */
.ps-letters { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.ps-letter { display: grid; justify-items: center; gap: 6px; min-width: 80px; padding: 12px 10px; border-radius: 18px; background: #16122b; color: #b9f5c8; box-shadow: inset 0 0 0 2px #3c2f6e, 0 0 22px -6px #7a4be0; animation: psBeam .6s both ease-out; }
.ps-letter b { font: 800 2.4rem/1 var(--display); text-shadow: 0 0 12px #5cff9d; }
.ps-letter.wild b { color: #f6c431; text-shadow: 0 0 12px #f6c431; }
.ps-letter span { font: 700 1.05rem var(--body); color: #fff; overflow-wrap: anywhere; text-align: center; }
@keyframes psBeam { from { opacity: 0; transform: translateY(-20px) scaleY(1.6); filter: blur(4px); } }
.ps-letter.skipped { opacity: .35; }
/* Alien Transmission: one card per alien (a team each in the race) */
.ps-aliens { display: grid; gap: 12px; margin: 14px 0 0; padding: 0; list-style: none; }
.ps-aliens.many { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.ps-aliens > li { display: grid; gap: 10px; align-content: start; padding: 14px; border-radius: 20px; background: var(--paper); border: 2px solid transparent; animation: psIn .4s both ease-out; }
.ps-aliens > li.win { border-color: var(--green); background: color-mix(in srgb, var(--green) 14%, var(--card)); animation: psIn .4s both ease-out, psPop .5s .2s both; }
.ps-aliens > li.out { opacity: .6; }
.ps-alien-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ps-team { padding: 2px 8px; border-radius: 999px; background: var(--game); color: #fff; font-size: .7rem; font-weight: 800; letter-spacing: .08em; }
.ps-arrow { color: var(--muted); font-weight: 800; }
.ps-chip.alien b::before { content: '👽 '; }
.ps-alien-hint, .ps-alien-status { margin: 0; color: var(--ink-soft); font-size: .85rem; font-weight: 700; }
.ps-alien-status { animation: psShimmer 2s 3; }
.ps-alien-secret { display: grid; gap: 2px; padding: 10px 14px; border-radius: 14px; background: #1f2233; color: #f5efe4; animation: psFlip .7s .1s both ease-out; }
.ps-alien-secret small { opacity: .7; font-weight: 700; font-size: .75rem; }
.ps-alien-secret strong { font: 800 clamp(1.4rem, 4vw, 2.2rem)/1.05 var(--display); color: var(--yellow); }
.ps-aliens .ps-letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.ps-aliens .ps-letter { min-width: 0; padding: 8px 6px; border-radius: 12px; }
.ps-aliens .ps-letter b { font-size: 1.4rem; }
.ps-aliens .ps-letter span { font-size: .9rem; }
.ps-words { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.ps-words span { padding: 6px 12px; border-radius: 12px; background: #16122b; color: #fff; font-weight: 700; animation: psBeam .5s both ease-out; }

/* Telephone */
.ps-chain-dots { display: flex; flex-wrap: wrap; gap: 6px; }
.ps-chain-dots i { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--paper); font-style: normal; font-weight: 800; font-size: .85rem; opacity: .5; }
.ps-chain-dots i.done { opacity: 1; background: color-mix(in srgb, var(--green) 25%, var(--card)); }
.ps-chain-dots i.now { opacity: 1; background: var(--game); color: #fff; animation: gsPop 1s ease-in-out infinite; }
.ps-chain { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.ps-chain li { position: relative; display: grid; gap: 8px; align-content: start; padding: 12px; border-radius: 18px; background: var(--paper); }
.ps-chain li.latest { animation: psReveal .7s both cubic-bezier(.2,1.3,.4,1); box-shadow: 0 0 0 3px var(--game); }
.ps-entry-by { display: flex; align-items: center; gap: 6px; }
.ps-entry-by small { color: var(--muted); font-weight: 700; }
.ps-entry-text { margin: 0; font: 700 1.3rem/1.25 var(--display); }
.ps-skipped { margin: 0; color: var(--muted); font-style: italic; }
.ps-art { width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; background: #fffdf7; box-shadow: inset 0 0 0 1px var(--line); }
.ps-art.loading { animation: psShimmer 1.2s ease-in-out infinite; }
@keyframes psShimmer { 50% { opacity: .5; } }
.ps-like { justify-self: start; padding: 4px 10px; border: 0; border-radius: 999px; background: var(--card); font-weight: 700; }
.ps-like.liked { background: #ffd6e0; transform: scale(1.1); }
.ps-like:disabled { cursor: default; }

/* ---------- Phone controls ---------- */
.pc-card { display: grid; justify-items: center; gap: 4px; padding: 18px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow); text-align: center; }
.pc-card.done { background: color-mix(in srgb, var(--green) 14%, var(--card)); }
.pc-card p { margin: 0; color: var(--ink-soft); }
.pc-icon { font-size: 2rem; }
.pc-prompt { margin: 4px 2px 0; font-weight: 800; }
.pc-note { margin: 0; color: var(--muted); font-size: .9rem; text-align: center; }
.pc-compose { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.pc-compose input, .pc-compose textarea { width: 100%; min-height: 54px; padding: 14px 16px; border: 2px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); font: 600 1.1rem var(--body); resize: none; }
.pc-compose input:focus, .pc-compose textarea:focus { border-color: var(--game); outline: none; }
.pc-compose .primary-button { min-height: 54px; background: var(--game); }
.pc-count { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; min-height: 0; }
.pc-count:empty { display: none; }
.pc-secret { position: relative; display: grid; min-height: 132px; padding: 0; border: 0; border-radius: 24px; background: #1f2233; color: #f5efe4; overflow: hidden; text-align: center; box-shadow: var(--shadow); }
.pc-secret-cover, .pc-secret-inner { grid-area: 1 / 1; display: grid; place-content: center; gap: 4px; padding: 16px; transition: opacity .25s, transform .35s; }
.pc-secret-cover { font-weight: 800; font-size: 1.1rem; background: repeating-linear-gradient(45deg, transparent 0 12px, rgba(255,255,255,.05) 12px 24px); }
.pc-secret-inner { opacity: 0; transform: scale(.9); }
.pc-secret.open .pc-secret-cover { opacity: 0; transform: scale(1.1); }
.pc-secret.open .pc-secret-inner { opacity: 1; transform: none; }
.pc-secret small { opacity: .75; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .75rem; }
.pc-secret strong { font: 800 clamp(1.8rem, 8vw, 2.6rem)/1.05 var(--display); color: var(--yellow); overflow-wrap: anywhere; }
.pc-secret em { font-style: normal; opacity: .85; }
.pc-secret i { font-style: normal; font-size: .75rem; opacity: .5; }
.pc-secret.bad { background: linear-gradient(135deg, #8a1c1a, #e8423f); }
.pc-secret.bad strong { color: #fff; }
.pc-secret.rule { min-height: 96px; background: linear-gradient(135deg, #0f5e5f, #0f8b8d); }
.pc-secret.rule strong { font-size: 1.25rem; font-family: var(--body); }
.pc-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pc-pick { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 10px 12px; border: 2px solid transparent; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); text-align: left; transition: transform .15s; }
.pc-pick:active { transform: scale(.97); }
.pc-pick b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-pick.on { border-color: var(--game); background: color-mix(in srgb, var(--game) 14%, var(--card)); }
.pc-lobby { display: grid; gap: 10px; }
.pc-start { min-height: 60px; font-size: 1.15rem; background: var(--game); }
.pc-ready { min-height: 56px; }
.pc-ready.on { box-shadow: inset 0 0 0 2px var(--green); }
.pc-transmit { display: grid; gap: 8px; }
.pc-letter-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; align-items: center; }
.pc-letter { display: grid; place-items: center; height: 52px; border-radius: 14px; background: #16122b; color: #b9f5c8; font: 800 1.6rem var(--display); }
.pc-letter-row.wild .pc-letter { color: #f6c431; }
.pc-letter-row input { min-height: 52px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); font: 600 1.1rem var(--body); }
.pc-reroll { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--paper-deep); font-size: 1.2rem; }
.pc-tries { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pc-tries li { padding: 8px 12px; border-radius: 12px; background: var(--paper); font-weight: 600; }
.pc-tries li.close { background: color-mix(in srgb, #f08a24 22%, var(--card)); }
.pc-tries li.correct { background: color-mix(in srgb, var(--green) 22%, var(--card)); }
.pc-hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.pc-card-choice { min-height: 104px; padding: 12px; border: 0; border-radius: 16px; background: var(--card); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); font: 700 1rem/1.25 var(--display); text-align: left; transition: transform .15s, box-shadow .15s; animation: psPop .35s both; }
.pc-card-choice.on { transform: translateY(-4px) rotate(-1deg); box-shadow: 0 0 0 3px var(--game), var(--shadow); background: color-mix(in srgb, var(--game) 10%, var(--card)); }
.pc-hand-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.pc-hand-bar .primary-button { flex: 1; background: var(--game); }
.pc-answers { display: grid; gap: 8px; }
.pc-answer { position: relative; min-height: 58px; padding: 12px 16px; border: 2px solid transparent; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); font: 700 1.05rem/1.3 var(--display); text-align: left; }
.pc-answer.on { border-color: var(--game); background: color-mix(in srgb, var(--game) 14%, var(--card)); }
.pc-answer.own { opacity: .55; }
.pc-answer small { display: block; font: 700 .75rem var(--body); color: var(--muted); }
.pc-match { display: grid; gap: 8px; }
.pc-match-row { display: grid; gap: 8px; padding: 12px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.pc-match-row p { margin: 0; font: 700 1.05rem/1.3 var(--display); }
.pc-match-row select { padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: 600 1rem var(--body); }
.pc-match-row.own { opacity: .6; }
.pc-idea { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--yellow) 25%, var(--card)); font-weight: 600; }
.pc-from { margin: 0; }
.pc-from.text { padding: 14px 16px; border-radius: 16px; background: var(--ink); color: var(--on-ink); font: 700 1.3rem/1.25 var(--display); }
.pc-from.art { width: 100%; aspect-ratio: 4 / 3; border-radius: 14px; background: #fffdf7; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Drawing pad ---------- */
.dp-pad { display: grid; gap: 8px; }
.dp-canvas { width: 100%; aspect-ratio: 4 / 3; border-radius: 16px; background: #fffdf7; box-shadow: inset 0 0 0 2px var(--line); touch-action: none; cursor: crosshair; }
.dp-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dp-tool { display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px; border: 2px solid transparent; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-size: 1.1rem; }
.dp-tool.on { border-color: var(--game); }
.dp-swatch i { display: block; width: 20px; height: 20px; border-radius: 50%; }
.dp-size i { display: block; border-radius: 50%; background: var(--ink); }
.dp-eraser { margin-left: auto; }

/* ---------- Confetti ---------- */
.pg-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.pg-confetti i { position: absolute; top: -14px; width: 10px; height: 16px; border-radius: 2px; animation: pgConfetti 2.8s ease-in forwards; }
@keyframes pgConfetti { to { transform: translate(var(--dx), 105vh) rotate(var(--r)); opacity: .3; } }

@media (max-width: 960px) {
  .pg-hero { grid-template-columns: 1fr; gap: 16px; }
  .pg-hero-art { order: -1; height: 200px; }
  .pg-layout { grid-template-columns: 1fr; }
  .pg-side { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .pg-howto { grid-template-columns: 1fr; }
  .pg-stage { padding: 14px 14px 18px; border-radius: 22px; }
  .ps-scores li { grid-template-columns: 24px minmax(70px, 1fr) 70px auto auto; gap: 8px; }
  .ps-join { flex-direction: column; text-align: center; }
  .ps-letter { min-width: 64px; }
  .ps-letter b { font-size: 1.8rem; }
  .pg-bubble { width: 48px; height: 48px; font-size: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  .pg-bubble, .ps-lobby-emoji, .ps-body, .ps-clues li, .ps-answers li, .ps-said li, .ps-options li, .ps-letter, .ps-scores li, .ps-delta, .ps-bar i { animation: none !important; }
}

/* ---------- TV page ---------- */
.tv-page { min-height: 100vh; overflow-x: hidden; }
.tv-shell { width: min(1600px, 100%); margin: 0 auto; padding: 2.5vh 3vw; min-height: 100vh; display: flex; flex-direction: column; gap: 2vh; }
.tv-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.tv-brand { display: flex; align-items: center; gap: 12px; font: 800 clamp(1.2rem, 2vw, 1.8rem) var(--display); }
.tv-room { display: flex; align-items: center; gap: 14px; padding: 8px 10px 8px 18px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-weight: 700; }
.tv-room b { font: 800 clamp(1.4rem, 2.4vw, 2.2rem) var(--display); letter-spacing: .14em; color: var(--game); }
.tv-room .ps-qr { width: 64px; }
.tv-start { flex: 1; display: grid; align-content: center; gap: 4vh; padding: 4vh 4vw; border-radius: 40px; background: var(--card); box-shadow: var(--shadow); text-align: center; }
.tv-start h1 { margin: 0; font: 800 clamp(2.4rem, 5vw, 4.6rem)/1 var(--display); letter-spacing: -.04em; background: linear-gradient(100deg, #e0457b, #f08a24 45%, #7a4be0); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tv-start .tv-lede { margin: 0; color: var(--ink-soft); font-size: clamp(1.1rem, 2vw, 1.7rem); }
.tv-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3vw; }
.tv-choice { display: grid; gap: 1.8vh; align-content: start; padding: 3vh 2.5vw; border-radius: 28px; background: var(--paper); text-align: left; animation: psIn .5s both ease-out; }
.tv-choice + .tv-choice { animation-delay: .1s; }
.tv-choice h2 { margin: 0; font: 800 clamp(1.6rem, 2.6vw, 2.6rem) var(--display); }
.tv-choice p { margin: 0; color: var(--ink-soft); font-size: clamp(1rem, 1.5vw, 1.4rem); }
.tv-choice .primary-button, .tv-join input { min-height: 64px; font-size: clamp(1.1rem, 1.8vw, 1.7rem); }
.tv-choice button:focus-visible, .tv-join input:focus-visible { outline: 4px solid #7a4be0; outline-offset: 3px; }
.tv-join { display: flex; gap: 12px; }
.tv-join input { flex: 1; min-width: 0; padding: 0 18px; border: 3px solid var(--line); border-radius: 18px; background: var(--card); color: var(--ink); font-weight: 800; letter-spacing: .3em; text-transform: uppercase; }
.tv-join input::placeholder { letter-spacing: normal; text-transform: none; }
.tv-start small { color: var(--muted); font-size: clamp(.9rem, 1.3vw, 1.1rem); }
.tv-stage { flex: 1; padding: 3vh 3vw; border-radius: 40px; background: var(--card); box-shadow: var(--shadow); border-top: 10px solid var(--game); font-size: clamp(16px, 1.45vw, 30px); }
.tv-stage .ps-big { font-size: clamp(1.8rem, 3.4vw, 4rem); }
.tv-stage .ps-prompt { font-size: clamp(1.8rem, 3.2vw, 3.6rem); }
.tv-stage .ps-answers li p, .tv-stage .ps-said li p, .tv-stage .ps-options li p { font-size: clamp(1.3rem, 2vw, 2.4rem); }
.tv-stage .ps-clues li b { font-size: clamp(1.5rem, 2.4vw, 2.8rem); }
.tv-stage .ps-title { font-size: clamp(1.3rem, 2vw, 2.4rem); }
.tv-stage .ps-status { font-size: clamp(.9rem, 1.2vw, 1.4rem); }
.tv-stage .ps-timer { font-size: clamp(1.4rem, 2.4vw, 3rem); }
.tv-stage .ps-qr { width: min(26vh, 22vw); }
.tv-stage .ps-code { font-size: clamp(2.6rem, 5vw, 5.4rem); }
.tv-stage .ps-chip { font-size: 1.1em; }
.tv-stage .ps-dot { width: 1.6em; height: 1.6em; }
.tv-stage .ps-letter { min-width: 8vw; }
.tv-stage .ps-letter b { font-size: clamp(2.4rem, 5vw, 5rem); }
.tv-stage .ps-aliens .ps-letter { min-width: 0; }
.tv-stage .ps-aliens .ps-letter b { font-size: clamp(1.6rem, 2.6vw, 3rem); }
.tv-stage .ps-alien-secret strong { font-size: clamp(1.8rem, 3vw, 3.4rem); }
.tv-stage .ps-reveal-card strong { font-size: clamp(2.6rem, 6vw, 6rem); }
.tv-msg { margin: 0; text-align: center; color: var(--muted); font-weight: 600; }
.tv-foot { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .9rem; }
.tv-foot button { border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; }
@media (max-width: 800px) { .tv-choices { grid-template-columns: 1fr; } }
.tv-room span b { font: inherit; letter-spacing: 0; color: inherit; }
.pg-tv-modal { width: min(480px, calc(100% - 24px)); }
.pg-tv-steps { display: grid; gap: 8px; margin: 0 0 12px; padding-left: 1.2em; }
.pg-tv-code { padding: 1px 10px; border-radius: 10px; background: var(--ink); color: var(--on-ink); letter-spacing: .16em; }
.pg-or { margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
.pg-setup { overflow-x: hidden; }
.pg-field .gs-seg { grid-template-columns: repeat(var(--count, 3), minmax(0, 1fr)); }
.pg-field .gs-seg span { min-height: 100%; padding: 10px 4px; line-height: 1.2; }
@media (max-width: 520px) {
  .pc-compose { grid-template-columns: 1fr; }
  .pc-compose .primary-button { width: 100%; }
  .pg-field .gs-seg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.pc-result { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; padding: 14px 18px; border-radius: 18px; background: var(--paper-deep); animation: psPop .4s both; }
.pc-result b { font: 800 1.3rem var(--display); }
.pc-result span { color: var(--ink-soft); font-weight: 700; }
.pc-result.up { background: color-mix(in srgb, var(--green) 20%, var(--card)); }
.pc-result.up b { color: var(--green); }
.pc-result { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; padding: 14px 18px; border-radius: 18px; background: var(--paper-deep); animation: psPop .4s both; }
.pc-result b { font: 800 1.3rem var(--display); }
.pc-result span { color: var(--ink-soft); font-weight: 700; }
.pc-result.up { background: color-mix(in srgb, var(--green) 20%, var(--card)); }
.pc-result.up b { color: var(--green); }

/* ---------- Reading out loud (in-person play) ---------- */
.pc-read-list { display: grid; gap: 8px; margin: 0 0 12px; padding-left: 1.6em; }
.pc-read-list li { padding: 10px 12px; border-radius: 14px; background: var(--paper); font-weight: 700; font-size: 1.05rem; animation: psIn .3s both; }
.pc-letters { display: grid; grid-template-columns: repeat(auto-fit, minmax(30px, 1fr)); gap: 5px; margin: 4px 0 10px; }
.pc-letters b { display: grid; place-items: center; height: 46px; border-radius: 12px; background: #16122b; color: #b9f5c8; font: 800 1.5rem var(--display); box-shadow: inset 0 0 0 2px #3c2f6e; }
.pc-letters b.wild { color: #f6c431; }
.pc-message { margin: 0 0 10px; padding: 12px 16px; border-radius: 16px; background: #16122b; color: #fff; font: 700 1.25rem/1.35 var(--body); animation: psBeam .5s both ease-out; }
.pg-tucked { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; }
.pg-stage:has(.pg-tucked) { min-height: 0; padding-block: 12px; }
.pg-stage-hide { display: block; margin: 12px auto 0; font-size: .85rem; }
@keyframes pgPop { 50% { transform: scale(1.08); } }

.pc-share { width: 100%; min-height: 46px; margin-bottom: 10px; }


/* Phones: title and timer on one row, the round/phase line on its own row underneath (it used to push the timer onto a third). */
@media (max-width: 560px) {
  .ps-head .ps-status { order: 3; flex: 1 1 100%; text-align: center; font-size: .7rem; letter-spacing: .04em; }
  .ps-head .ps-timer { font-size: 1rem; padding: 4px 10px; }
}

/* Phones: the drawing tools as two neat rows (all eight colours, then sizes · eraser · undo · clear)
   instead of wrapping into three with the bin on its own. */
@media (max-width: 560px) {
  .dp-tools { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px 4px; justify-items: center; }
  .dp-tools .dp-tool { width: 100%; min-width: 0; max-width: 42px; height: auto; aspect-ratio: 1; padding: 0; }
  .dp-tools .dp-eraser { grid-column: 6; margin-left: 0; }
  .dp-tools .dp-undo { grid-column: 7; }
  .dp-tools .dp-clear { grid-column: 8; }
}

/* ---------- Code Masters ---------- */
.sp-wrap { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 3.6fr) minmax(150px, 1fr); gap: 14px; align-items: start; }
.sp-centre { display: grid; gap: 12px; min-width: 0; }
.sp-teams-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sp-team { display: grid; gap: 8px; align-content: start; min-width: 0; padding: 12px; border-radius: 18px; background: var(--paper); border-top: 6px solid var(--sp); transition: box-shadow .3s; }
.sp-team-red { --sp: var(--red); } .sp-team-blue { --sp: var(--blue); }
.sp-team.turn { background: color-mix(in srgb, var(--sp) 14%, var(--card)); box-shadow: 0 0 0 3px var(--sp); }
.sp-team.won { background: color-mix(in srgb, var(--sp) 22%, var(--card)); box-shadow: 0 0 0 3px var(--sp), 0 10px 30px -10px var(--sp); animation: gsPop .6s 2; }
.sp-team-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 8px; }
.sp-team-head b { font: 800 1.2em var(--display); color: var(--sp); }
.sp-left { font-weight: 800; font-size: .85em; }
.sp-members { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.sp-members li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; }
.sp-members small { color: var(--muted); font-weight: 700; font-size: .75em; }
.sp-members li.done .ps-chip b::after { content: ' ✓'; color: var(--green); }
.sp-log { display: grid; gap: 4px; margin: 0; padding: 8px 0 0; border-top: 1px solid var(--line); list-style: none; font-size: .85em; }
.sp-log li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.sp-hit { padding: 1px 6px; border-radius: 6px; font-size: .78em; font-weight: 800; background: var(--sp-tile, var(--card)); color: var(--sp-ink, var(--ink)); }
.sp-say-red { color: var(--red) !important; } .sp-say-blue { color: var(--blue) !important; }
.sp-clue { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 14px; padding: 10px 18px; border-radius: 20px; background: var(--ink); color: var(--on-ink); border-left: 10px solid var(--sp); animation: psCard .5s cubic-bezier(.2,1.4,.4,1); }
.sp-clue-red { --sp: var(--red); } .sp-clue-blue { --sp: var(--blue); }
.sp-clue strong { font: 800 clamp(1.5rem, 4vw, 2.4rem)/1.1 var(--display); letter-spacing: .02em; }
.sp-clue small { font-weight: 700; opacity: .75; }
.sp-count { display: grid; place-items: center; min-width: 1.8em; height: 1.8em; padding: 0 .3em; border-radius: 999px; background: var(--sp); color: #fff; font: 800 clamp(1.3rem, 3vw, 1.9rem) var(--display); }
.sp-result { display: grid; gap: 4px; justify-items: center; }

/* The grid. Font sizes follow the grid's width (cqi), with a vw fallback for older TV browsers. */
.sp-grid { --cols: 5; --fs: 1; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 6px; container-type: inline-size; }
.sp-tile { position: relative; display: grid; place-items: center; min-width: 0; aspect-ratio: 1.3; padding: 2px; border: 0; border-radius: 10px; background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line), 0 3px 0 var(--line); font: 800 1.6vw/1.05 var(--body); text-transform: uppercase; letter-spacing: .01em; overflow: hidden; transition: transform .15s, box-shadow .15s; }
/* --fs is 5 / columns, so a word gets the same share of its tile on every grid size. */
.sp-grid .sp-s { font-size: calc(3.6cqi * var(--fs)); } .sp-grid .sp-m { font-size: calc(3.1cqi * var(--fs)); } .sp-grid .sp-l { font-size: calc(2.6cqi * var(--fs)); } .sp-grid .sp-xl { font-size: calc(2.2cqi * var(--fs)); } .sp-grid .sp-xxl { font-size: calc(1.8cqi * var(--fs)); }
.sp-word { max-width: 100%; overflow-wrap: break-word; text-align: center; letter-spacing: -.01em; }
button.sp-tile { cursor: pointer; }
button.sp-tile:hover { transform: translateY(-2px); }
button.sp-tile:active { transform: scale(.96); }
.sp-tile.selected { box-shadow: inset 0 0 0 3px var(--game), 0 0 0 3px color-mix(in srgb, var(--game) 35%, transparent); transform: translateY(-3px); }
.sp-c-red { --sp-tile: var(--red); --sp-ink: #fff; }
.sp-c-blue { --sp-tile: var(--blue); --sp-ink: #fff; }
.sp-c-bystander { --sp-tile: #eadfc4; --sp-ink: #1f2233; }
.sp-c-assassin { --sp-tile: #16171f; --sp-ink: #f5efe4; }
.sp-c-lucky { --sp-tile: #22a75d; --sp-ink: #fff; }
.sp-tile.open { background: var(--sp-tile); color: var(--sp-ink); box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); }
.sp-tile.open .sp-word { opacity: .8; }
.sp-tile.open.sp-c-assassin { box-shadow: inset 0 0 0 2px var(--red); }
.sp-tile.fresh { animation: spFlip .7s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes spFlip { from { transform: perspective(500px) rotateY(180deg) scale(.9); } 50% { transform: perspective(500px) rotateY(90deg); } }
/* The spymaster's key (and the full board once it's over): colour on every tile, faded once found. */
.sp-tile.keyed, .sp-tile.shown { background: color-mix(in srgb, var(--sp-tile) 30%, var(--card)); box-shadow: inset 0 0 0 3px var(--sp-tile); }
.sp-tile.keyed.sp-c-assassin, .sp-tile.shown.sp-c-assassin { background: #16171f; color: #f5efe4; }
.sp-tile.shown { opacity: .78; }
.sp-keyed .sp-tile.open { opacity: .35; }
.sp-icon { position: absolute; top: 2px; left: 4px; font-style: normal; font-size: max(10px, 2.6cqi); }
.sp-marks { position: absolute; right: 3px; bottom: 3px; display: flex; gap: 1px; }
.sp-dot { width: max(14px, 3.4cqi); height: max(14px, 3.4cqi); font-size: max(8px, 1.8cqi); box-shadow: 0 0 0 2px var(--card); animation: psPop .3s both; }
.sp-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; }
.sp-legend span { padding: 2px 9px; border-radius: 999px; background: var(--sp-tile); color: var(--sp-ink); font-size: .78rem; font-weight: 800; }
.sp-bar { position: sticky; bottom: 8px; z-index: 2; display: grid; grid-template-columns: 1.6fr 1fr; gap: 8px; padding: 8px; border-radius: 18px; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(6px); box-shadow: var(--shadow); }
.sp-bar .primary-button { min-height: 54px; background: var(--game); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-me-red { box-shadow: inset 0 6px 0 var(--red), var(--shadow); } .sp-me-blue { box-shadow: inset 0 6px 0 var(--blue), var(--shadow); }
.sp-clue-form { display: grid; gap: 10px; padding: 14px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.sp-clue-form input { min-height: 54px; padding: 12px 16px; border: 2px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); font: 800 1.2rem var(--body); text-transform: uppercase; }
.sp-clue-form input:focus { border-color: var(--game); outline: none; }
.sp-counts { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.sp-count-btn { min-height: 46px; border: 2px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); font: 800 1.15rem var(--display); }
.sp-count-btn.on { border-color: var(--game); background: var(--game); color: #fff; animation: pgPop .25s 1; }
.sp-clue-form .primary-button { min-height: 54px; background: var(--game); }
@media (max-width: 900px) {
  .sp-wrap { grid-template-columns: 1fr 1fr; }
  .sp-wrap .sp-centre { grid-column: 1 / -1; grid-row: 1; }
}
@media (max-width: 560px) {
  .sp-grid { gap: 4px; }
  .sp-tile { aspect-ratio: 1.05; border-radius: 8px; font-size: 2.6vw; }
  .sp-grid .sp-s { font-size: calc(4.2cqi * var(--fs)); } .sp-grid .sp-m { font-size: calc(3.35cqi * var(--fs)); } .sp-grid .sp-l { font-size: calc(2.65cqi * var(--fs)); } .sp-grid .sp-xl { font-size: calc(2.2cqi * var(--fs)); } .sp-grid .sp-xxl { font-size: calc(1.8cqi * var(--fs)); }
  .sp-team { padding: 10px; font-size: .9rem; }
}
/* TV: the board as big as the screen allows. */
@media (min-width: 901px) { .tv-stage .sp-wrap { grid-template-columns: minmax(180px, 1fr) minmax(0, 4fr) minmax(180px, 1fr); } }
.tv-stage .sp-grid { --ratio: 1.5; width: min(100%, calc((100vh - 330px) * var(--ratio))); margin: 0 auto; gap: .6vw; }
.tv-stage .sp-tile { aspect-ratio: 1.5; border-radius: .8vw; }
.tv-stage .sp-clue strong { font-size: clamp(2rem, 3.6vw, 4rem); }
.tv-stage .sp-count { font-size: clamp(1.6rem, 2.8vw, 3.2rem); }
.tv-stage .sp-result .ps-note { font-size: clamp(1.1rem, 1.5vw, 1.8rem); }
@media (prefers-reduced-motion: reduce) { .sp-tile.fresh, .sp-team.won, .sp-clue { animation: none !important; } }

/* Code Masters: funny tiles, spy reveal, notes */
.sp-c-gift { --sp-tile: #e0457b; --sp-ink: #fff; }
.sp-c-freeze { --sp-tile: #5bc0eb; --sp-ink: #0b2a3a; }
.sp-tile.exposed { box-shadow: inset 0 0 0 3px var(--sp-tile), 0 3px 0 var(--line); background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--sp-tile) 22%, var(--card)) 0 8px, var(--card) 8px 16px); }
.sp-keyed .sp-tile.exposed { outline: 3px dashed var(--ink); outline-offset: -6px; }
.sp-flags { margin: 0; font-size: .8em; font-weight: 800; color: var(--ink-soft); }
.sp-tip { margin: 0; padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--yellow) 22%, var(--card)); font-weight: 700; }
.sp-hidden { margin: 0; text-align: center; color: var(--muted); font-weight: 700; font-size: .9em; }
.tv-stage .sp-hidden { font-size: clamp(.9rem, 1.1vw, 1.4rem); }
.sp-expose { display: grid; gap: 10px; padding: 14px; border-radius: 22px; background: var(--card); box-shadow: inset 0 0 0 2px var(--game), var(--shadow); }
.sp-expose p { margin: 0; color: var(--ink-soft); font-weight: 600; }
.sp-expose .primary-button { background: var(--game); }
.pg-words { width: 100%; min-height: 76px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: 600 .95rem/1.35 var(--body); resize: vertical; }
.pg-words:focus { border-color: var(--game); outline: none; }
/* TV: keep the win banner to one line so the whole board still fits a 1080p screen. */
.tv-stage .sp-result { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 4px 18px; }
.tv-stage .sp-result .ps-big { font-size: clamp(1.8rem, 3vw, 3.4rem); }
.tv-stage .sp-centre > .ps-big { font-size: clamp(1.6rem, 2.6vw, 3rem); }
/* The black tile needs a light edge to stand out on dark cards. */
.sp-tile.keyed.sp-c-assassin, .sp-tile.shown.sp-c-assassin, .sp-tile.open.sp-c-assassin { box-shadow: inset 0 0 0 3px var(--red), 0 0 0 1px rgba(255,255,255,.35); }
.sp-legend .sp-c-assassin, .sp-hit.sp-c-assassin { box-shadow: inset 0 0 0 2px var(--red); }
.sp-tile.selected { outline: 4px solid var(--game); outline-offset: 1px; z-index: 1; }

/* TV: fit 720p screens without scrolling, scale text with the smaller of width and height, and fill the screen */
.tv-shell { height: 100vh; min-height: 0; padding: 2vh 3vw; gap: 1.6vh; }
.tv-start, .tv-stage { min-height: 0; overflow: auto; }
.tv-stage { display: flex; flex-direction: column; justify-content: center; padding: 2.5vh 3vw; font-size: clamp(16px, min(1.7vw, 3vh), 36px); }
.tv-stage > * { width: 100%; }
.tv-stage .ps-big { font-size: clamp(1.6rem, min(3.8vw, 6.5vh), 4.6rem); }
.tv-stage .ps-prompt { font-size: clamp(1.6rem, min(3.4vw, 6vh), 4rem); }
.tv-stage .ps-title { font-size: clamp(1.3rem, min(2.2vw, 4vh), 2.6rem); }
.tv-stage .ps-qr { width: min(24vh, 20vw); }
.tv-stage .ps-code { font-size: clamp(2.2rem, min(5vw, 9vh), 5.6rem); }
.tv-stage .ps-chip b { overflow: visible; text-overflow: clip; }
.tv-start { gap: 3vh; padding: 3vh 4vw; }
.tv-start h1 { font-size: clamp(2.2rem, min(5vw, 9vh), 4.6rem); }
.tv-choice { padding: 2.5vh 2.5vw; }
#screenView:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1.6vh; }
.tv-stage { justify-content: safe center; }
.tv-stage .ps-waiting { gap: 1.6vh; }
.tv-stage .ps-lobby { padding-block: 1.5vh; }
.tv-stage .ps-lobby-emoji { font-size: min(3.4rem, 7vh); }
.tv-stage .ps-lobby h2 { font-size: clamp(1.8rem, min(3.6vw, 6.5vh), 4rem); }
.tv-stage .ps-wait, .tv-stage .ps-waiting > .ps-note { text-align: center; }
.tv-stage:has(.ps-waiting) > .ps-head { display: none; } /* the lobby card already shows the game's name */
.tv-stage .ps-waiting .ps-qr { width: min(22vh, 18vw); }
@media (max-height: 800px) { .tv-stage .ps-waiting .ps-lobby-emoji, .tv-stage .ps-waiting .ps-tags { display: none; } }
/* TV showing a room: the room code sits in the header row and the footer shrinks, so the game gets the height. */
.tv-shell { position: relative; }
#screenView > .tv-top { position: absolute; top: 1.2vh; right: 3vw; z-index: 2; }
#screenView .tv-room { padding: 4px 6px 4px 14px; }
#screenView .tv-room .ps-qr { width: 46px; }
.tv-page:has(#screenView:not([hidden])) .tv-foot { margin-top: 0; padding-top: 6px; font-size: .75rem; opacity: .7; }
.tv-page:has(#screenView:not([hidden])) .tv-shell { padding-top: 1.6vh; padding-bottom: 1vh; }
