/* TV display: sized in vw/vh so it reads from across a room on any screen. */
body.tv { overflow: hidden; height: 100vh; }
/* Keeps words crisp when fireworks burst behind them. */
.tv #screen { text-shadow: 0 2px 10px rgba(20, 0, 40, 0.75), 0 0 2px rgba(20, 0, 40, 0.6); }
/* Gold gradient text can't take a text-shadow (it paints over the letters); glow it instead. */
.tv-brand span, .tv .gold-text { text-shadow: none; filter: drop-shadow(0 2px 8px rgba(20, 0, 40, 0.8)); }
.tv-brand, .tv-title { font-family: "Cinzel", Georgia, serif; }
.tv #screen { height: 100vh; padding: 3vh 3.5vw 12vh; display: flex; flex-direction: column; gap: 2.5vh; }
/* Some TV browsers give the page less height than the screen (their own toolbar),
   so the screen may scroll; the remote's focus brings tiles into view. */
.tv #screen { overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.tv #screen::-webkit-scrollbar { display: none; }
.tv .card { border-radius: 2vw; padding: 2.5vh 2vw; margin: 0; }

.tv-head { display: flex; align-items: center; justify-content: space-between; gap: 2vw; }
.tv-brand { font-size: 3.4vw; font-weight: 800; line-height: 1; }
.tv-brand span { background: linear-gradient(180deg, #fff1b8 0%, var(--gold) 45%, var(--gold-deep) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tv-link { font-size: 1.9vw; font-weight: 700; color: var(--muted); text-align: right; line-height: 1.1; }
.tv-link b { color: var(--gold); display: block; font-size: 2.3vw; }

.tv-title { font-size: 4.2vw; font-weight: 800; line-height: 1.05; }
.tv-sub { font-size: 2vw; color: var(--muted); }
.tv-grow { flex: 1; min-height: 0; }

/* Pairing */
.pair { flex: 1; display: grid; place-items: center; text-align: center; }
.pair-code { font-size: 12vw; font-weight: 800; letter-spacing: 1.5vw; color: var(--gold); line-height: 1; margin: 2vh 0; text-shadow: 0 0 4vw rgba(255, 201, 74, 0.35); }
.pair-steps { display: flex; gap: 2vw; justify-content: center; margin-top: 3vh; }
.pair-steps div { background: var(--card); border-radius: 1.5vw; padding: 2vh 1.6vw; font-size: 1.7vw; width: 24vw; text-align: left; }
.pair-steps b { display: block; color: var(--gold); font-size: 2.6vw; }

/* Lobby */
/* The QR block never shrinks; the guest panel takes whatever height is left. */
.lobby { flex: 1 0 auto; display: grid; grid-template-columns: 46vh 1fr; gap: 3vw; min-height: 0; align-items: center; }
.lobby .qr-big { background: #fff; border-radius: 2vw; padding: 1.6vh; width: 46vh; height: 46vh; }
.lobby .qr-big img { width: 100%; height: 100%; display: block; }
.join-words { font-size: 4.6vw; font-weight: 800; color: var(--gold); line-height: 1.05; word-break: break-word; }
.join-host { font-size: 2vw; color: var(--muted); }
.guests-card { flex: 0 1 auto; min-height: 0; overflow: hidden; }
.avatars-wall { display: flex; flex-wrap: wrap; gap: 1.2vw; align-content: flex-start; overflow: hidden; }
.guest { background: var(--card); border-radius: 999px; padding: 1vh 1.6vw 1vh 1vw; font-size: 2.2vw; font-weight: 700; display: flex; align-items: center; gap: 0.6vw; animation: pop 0.45s cubic-bezier(.2, 1.6, .4, 1) both; }
.guest .face { font-size: 3vw; }
.guest.off { opacity: 0.35; }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Corner join reminder during games */
.corner-join { display: flex; align-items: center; gap: 1vw; background: var(--card); border-radius: 1.4vw; padding: 1vh 1vw; }
.corner-join img { width: 10vh; height: 10vh; background: #fff; border-radius: 0.8vw; padding: 0.5vh; }
.corner-join div { font-size: 1.4vw; color: var(--muted); line-height: 1.15; }
.corner-join b { color: var(--gold); display: block; font-size: 1.7vw; }

/* Games */
.game-grid { flex: 1; display: grid; grid-template-columns: 1fr 26vw; gap: 2vw; min-height: 0; }
.bombs-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(17vw, 1fr)); gap: 1.6vw; align-content: start; }
.bomb-card { background: var(--card-2); border-radius: 2vw; padding: 2vh 1vw; text-align: center; }
.bomb-card .bomb { font-size: 7vw; }
.bomb-card .who { font-size: 2.4vw; font-weight: 800; }
.side-list { display: flex; flex-direction: column; gap: 1vh; overflow: hidden; }
.side-list h3 { font-size: 2vw; margin: 0; }
.row-item { display: flex; align-items: center; gap: 0.8vw; font-size: 1.8vw; font-weight: 700; padding: 0.6vh 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.row-item .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .pts { color: var(--gold); font-weight: 800; }
.medal { width: 2.6vw; text-align: center; }

.race { display: flex; flex-direction: column; gap: 2vh; justify-content: space-evenly; }
.race-row { display: grid; grid-template-columns: 26vw 1fr 12vw; gap: 1.5vw; align-items: center; }
.race-row .team { font-size: 3vw; font-weight: 800; line-height: 1.05; }
.race-row .team small { display: block; font-size: 1.6vw; color: var(--muted); font-weight: 600; }
.race-track { height: 7vh; background: var(--bg-2); border-radius: 999px; overflow: hidden; position: relative; }
.race-track > div { height: 100%; border-radius: 999px; transition: width 0.4s ease; display: flex; justify-content: flex-end; align-items: center; padding-right: 1vw; font-size: 3vh; }
.race-time { font-size: 3vw; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.big-count { position: fixed; inset: 0; display: grid; place-items: center; font-size: 30vw; font-weight: 800; color: var(--gold); text-shadow: 0 0 6vw rgba(255, 201, 74, 0.5); pointer-events: none; z-index: 30; }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 2vw; margin-top: auto; }
.podium > div { background: var(--card-2); border-radius: 1.5vw 1.5vw 0 0; width: 18vw; text-align: center; padding: 2vh 1vw; }
.podium .face { font-size: 5vw; }
.podium .nm { font-size: 2vw; font-weight: 800; }
.podium .pts { font-size: 2.4vw; color: var(--gold); font-weight: 800; }
.podium .rank { font-size: 4vw; line-height: 1; }
.podium > div { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 0.4vh; }
.podium .p1 { min-height: 40vh; background: linear-gradient(#b8860b, #6b4a00); }
.podium .p2 { min-height: 32vh; }
.podium .p3 { min-height: 26vh; }

/* Side padding keeps the remote buttons clear of the corner diyas. */
.tv-ctrl { position: fixed; left: 0; right: 0; bottom: 2vh; display: flex; justify-content: center; gap: 0.8vw; z-index: 40; padding: 0 8.5vw; }
.tv-ctrl.two { flex-direction: column; align-items: center; gap: 1.2vh; }
.tv-row { display: flex; justify-content: center; gap: 0.8vw; flex-wrap: wrap; }
/* Two rows of buttons need more room at the bottom of the screen. */
body.tv-two-rows #screen { padding-bottom: 20vh; }
.tv-btn { width: auto; font-size: 1.7vw; padding: 1.4vh 2vw; border-radius: 1.2vw; background: var(--card-2); color: var(--text); border: 0.25vw solid transparent; transition: transform 0.12s; }
.tv-btn:focus, .tv-btn:hover { outline: none; background: var(--gold); color: #1b0f2e; border-color: #fff; transform: scale(1.08); box-shadow: 0 0 2.5vw rgba(255, 201, 74, 0.6); }
.asleep { border: 0.2vw dashed rgba(255, 255, 255, 0.25); }
.tv .toast { font-size: 2vw; top: 3vh; padding: 1.4vh 2.4vw; }
.tv .flash { font-size: 9vw; }

.tv #screen { position: relative; z-index: 1; }

@media (max-aspect-ratio: 4/3) {
  /* Portrait or square screens (tablets): stack instead of side by side. */
  .lobby { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .game-grid { grid-template-columns: 1fr; }
  .tv-brand { font-size: 6vw; }
  .join-words { font-size: 7vw; }
}

/* Last one standing and finale */
.big-next { font-size: 5vw; font-weight: 800; color: var(--gold); text-align: center; }
.winner { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1vh; }
.winner-face { font-size: 18vw; line-height: 1; animation: pop 0.6s cubic-bezier(.2, 1.6, .4, 1) both; filter: drop-shadow(0 0 4vw rgba(255, 201, 74, 0.6)); }
.tv-btn { font-size: 1.35vw; padding: 1.3vh 1.2vw; white-space: nowrap; }

.bomb-secs { font-size: 2.6vw; font-weight: 800; color: var(--gold); margin-top: 0.6vh; font-variant-numeric: tabular-nums; }
.bomb-secs.hot { color: #ff5a5a; animation: fuse-pulse 0.35s ease-in-out infinite alternate; }
.bomb-secs.throwing { color: #7dffb0; font-size: 2vw; }

/* Tambola */
.tb-grid { grid-template-columns: 30vw 1fr; }
.tb-left { display: flex; flex-direction: column; gap: 2vh; min-height: 0; }
.tb-now { text-align: center; flex: none; padding: 1.6vh 1.5vw; }
.tb-now .tv-sub { font-size: 1.6vw; }
.tb-prizes { flex: 1; gap: 0.2vh; }
.tb-prizes h3 { font-size: 1.7vw; }
.tb-prizes .row-item { font-size: 1.45vw; padding: 0.2vh 0; }
.tb-num { font-size: 7.5vw; font-weight: 800; color: var(--gold); line-height: 1; text-shadow: 0 0 4vw rgba(255, 201, 74, 0.5); }
.tb-recent { display: flex; flex-wrap: wrap; gap: 0.6vw; justify-content: center; align-items: center; margin-top: 1vh; }
.tb-recent b { font-size: 1.4vw; color: var(--muted); margin-right: 0.4vw; }
.tb-recent span { background: var(--bg-2); border-radius: 999px; padding: 0.2vh 0.8vw; font-size: 1.5vw; font-weight: 800; color: var(--muted); }
.tb-board { display: grid; grid-template-columns: repeat(10, 1fr); gap: 0.5vw; height: 100%; }
.tb-n { display: grid; place-items: center; border-radius: 0.8vw; background: rgba(0, 0, 0, 0.25); color: rgba(255, 255, 255, 0.35); font-size: 2vw; font-weight: 800; }
.tb-n.on { background: linear-gradient(#ffb347, #ff7a1a); color: #2b1340; text-shadow: none; }
.tb-n.now { background: var(--gold); color: #1b0f2e; transform: scale(1.18); box-shadow: 0 0 2vw rgba(255, 201, 74, 0.8); }

/* Diwali Decode */
.dc-title { font-size: 3.4vw; }
.dc-board { display: grid; grid-template-columns: repeat(5, 1fr); grid-auto-rows: 1fr; gap: 0.8vw; min-height: 0; }
.dc-word { display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 1vw; background: #fff3dc; color: #2b1340; font-size: 2.1vw; font-weight: 800; text-shadow: none; letter-spacing: 0.05vw; }
.dc-word.k-red { background: #e63946; color: #fff; }
.dc-word.k-blue { background: #3a86ff; color: #fff; }
.dc-word.k-neutral { background: #8a7a5c; color: #fff; }
.dc-word.k-bomb { background: #111; color: #fff; }
.dc-word.late { opacity: 0.45; }
.dc-ic { font-size: 1.6vw; line-height: 1; }
.dc-side { min-height: 0; overflow: hidden; }
.dc-team { display: grid; grid-template-columns: 6vw 1fr; gap: 1vw; align-items: center; border: 0.3vw solid transparent; font-size: 1.8vw; }
.dc-team.on { box-shadow: 0 0 2.5vw rgba(255, 255, 255, 0.35); }
.dc-left { font-size: 5vw; font-weight: 800; text-align: center; line-height: 1; }
.dc-members { font-size: 1.4vw; color: var(--muted); }

/* Finale: places 4 and below, two tidy columns. */
.finale-rest { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6vh 3vw; font-size: 1.9vw; max-width: 70vw; }
.finale-rest .row-item { display: flex; gap: 0.8vw; align-items: center; }
.finale-rest .rk { color: var(--muted); min-width: 2.6vw; }
.finale-rest .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finale-rest .pts { color: var(--gold); font-weight: 800; }
/* Decode side panel: cards shrink, the tip line always shows. */
.dc-side { display: flex; flex-direction: column; }
.dc-side > .tv-sub { flex: none; font-size: 1.6vw; }
.dc-members { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.side-list.asleep .tv-sub { font-size: 1.6vw; }
/* Two rows of buttons: a slightly smaller QR leaves the guest wall room. */
body.tv-two-rows .lobby { grid-template-columns: 38vh 1fr; }
body.tv-two-rows .lobby .qr-big { width: 38vh; height: 38vh; }
.guest.more { color: var(--gold); }
/* Decode team picking */
.dc-pick-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 2vw; min-height: 0; }
.dc-pick { border: 0.35vw solid transparent; display: flex; flex-direction: column; gap: 1.2vh; min-height: 0; overflow: hidden; }
.dc-pick-h { font-size: 3.2vw; font-weight: 800; }
.dc-pick-list { display: flex; flex-wrap: wrap; gap: 0.8vw; }
.tv-sub.fair { color: var(--gold); font-size: 1.7vw; }

/* Lobby: four game tiles under the join info. */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.4vw; flex: none; }
.tv-btn.tile { display: flex; flex-direction: column; align-items: flex-start; text-align: left; white-space: normal; gap: 0.5vh; padding: 1.8vh 1.3vw; border-radius: 1.6vw; background: var(--card); min-height: 20vh; }
.tile .t-icon { font-size: 3.4vw; line-height: 1; }
.tile .t-name { font-size: 2.1vw; font-weight: 800; }
.tile .t-blurb { font-size: 1.3vw; color: var(--muted); line-height: 1.25; flex: 1; }
.tile .t-min { font-size: 1.2vw; color: var(--gold); font-weight: 700; }
.tile:focus .t-blurb, .tile:hover .t-blurb, .tile:focus .t-min, .tile:hover .t-min { color: #3b2400; }
.tv-btn.tile:focus, .tv-btn.tile:hover { transform: scale(1.04); background: var(--gold); color: #1b0f2e; text-shadow: none; }
.tv-btn.opt-btn:focus, .tv-btn.opt-btn:hover { text-shadow: none; }
/* With tiles below, the QR block is smaller. */
.lobby { grid-template-columns: 30vh 1fr; flex: 0 0 auto; }
.lobby .qr-big { width: 30vh; height: 30vh; }
.lobby .join-words { font-size: 4.6vw; }
.guests-card { max-height: 16vh; padding-top: 1.2vh; padding-bottom: 1.2vh; flex: 0 0 auto; }
.guests-card .guest { font-size: 1.6vw; padding: 0.6vh 1.2vw 0.6vh 0.8vw; }
.guests-card .avatars-wall { gap: 0.8vh 0.8vw; }

/* "Next up" screen */
.ready-grid { flex: 1; display: grid; grid-template-columns: 1.25fr 1fr; gap: 2vw; min-height: 0; }
.ready-rules ol { margin: 1vh 0 0; padding-left: 2.4vw; display: flex; flex-direction: column; gap: 1.4vh; font-size: 2vw; line-height: 1.3; }
.ready-rules h3, .ready-opts h3 { font-size: 2vw; margin: 0; }
.ready-opts { display: flex; flex-direction: column; gap: 1.4vh; }
.tv-btn.opt-btn { display: flex; justify-content: space-between; align-items: center; gap: 1vw; font-size: 1.9vw; padding: 1.6vh 1.6vw; white-space: normal; text-align: left; }
.opt-btn .opt-k { opacity: 0.8; }
.opt-btn .opt-v { font-weight: 800; }
.tv-sub.warn { color: #ff9f9f; }
.guests-card .avatars-wall { max-height: 12vh; }
.guest.hidden { display: none; }

/* Judged games */
.jg-who { font-size: 2.4vw; color: var(--gold); font-weight: 800; }
.jg-task { background: var(--card); border-radius: 2vw; padding: 3vh 2.5vw; text-align: center; display: flex; flex-direction: column; gap: 1.5vh; }
.jg-line { font-size: 4.4vw; font-weight: 800; line-height: 1.2; }
.jg-letter { font-size: 12vw; font-weight: 900; color: var(--gold); line-height: 1; }
.jg-twist { font-size: 3.2vw; font-weight: 800; }
.jg-secs { font-size: 6vw; font-weight: 900; text-align: center; color: var(--gold); font-variant-numeric: tabular-nums; }
.jg-secs.hot { color: #ff5a5a; animation: fuse-pulse 0.35s ease-in-out infinite alternate; }
.jg-reveal { text-align: center; }
.jg-answer { font-size: 5vw; font-weight: 900; color: #7dffb0; animation: pop 0.5s cubic-bezier(.2, 1.6, .4, 1) both; }
.jg-result { font-size: 6vw; font-weight: 900; text-align: center; animation: pop 0.5s cubic-bezier(.2, 1.6, .4, 1) both; }
.jg-result.ok { color: #7dffb0; }
.jg-result.no { color: #ff8a8a; }
.jg-scores { display: grid; gap: 1.5vh; }
.jg-team { border: 0.35vw solid transparent; display: grid; grid-template-columns: 7vw 1fr; align-items: center; column-gap: 1vw; font-size: 2vw; font-weight: 800; }
.jg-team .dc-members { grid-column: 2; }
.jg-team.on { box-shadow: 0 0 2.5vw rgba(255, 255, 255, 0.35); }
.jg-score { font-size: 5.5vw; font-weight: 900; text-align: center; grid-row: span 2; }
.jg-levels { display: flex; justify-content: center; gap: 1.5vw; }
.jg-level { font-size: 2.6vw; font-weight: 900; padding: 2vh 2vw; border-radius: 1.4vw; background: var(--card-2); }
.jg-step { font-size: 2.1vw; line-height: 1.3; background: rgba(125, 255, 176, 0.12); border: 0.2vw solid rgba(125, 255, 176, 0.45); border-radius: 1.4vw; padding: 1.6vh 1.6vw; text-align: left; animation: pop 0.5s cubic-bezier(.2, 1.6, .4, 1) both; }
.jg-step b { color: #7dffb0; }
.jg-task { padding: 2.2vh 2vw; gap: 1vh; }

/* ---- Animations (TV) ---- */
@keyframes tv-shake { 10%, 90% { transform: translate(-0.4vw, 0.2vh); } 20%, 80% { transform: translate(0.6vw, -0.3vh); } 30%, 50%, 70% { transform: translate(-0.9vw, 0.4vh); } 40%, 60% { transform: translate(0.9vw, -0.4vh); } }
body.shake #screen { animation: tv-shake 0.45s both; }
body.shake-strong #screen { animation: tv-shake 0.6s both; }
@keyframes flip-in { from { transform: rotateY(90deg) scale(0.9); } to { transform: rotateY(0) scale(1); } }
.dc-word.just { animation: flip-in 0.5s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes ball-drop { 0% { transform: translateY(-40vh) scale(0.6); opacity: 0; } 60% { transform: translateY(2vh) scale(1.1); opacity: 1; } 80% { transform: translateY(-1vh); } 100% { transform: none; } }
.tb-num.just { animation: ball-drop 0.7s cubic-bezier(.3, 1.3, .5, 1) both; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.45); color: #fff; } 100% { transform: scale(1); } }
.bump { animation: bump 0.6s ease-out both; display: inline-block; }
@media (prefers-reduced-motion: reduce) { body.shake #screen, body.shake-strong #screen, .dc-word.just, .tb-num.just, .bump { animation: none; } }
.tv .feedback { padding: 1.4vh 1.6vw; }
.tv .feedback h3 { font-size: 2vw; margin: 0 0 0.6vh; }
.tv .feedback .star { font-size: 3.4vw; padding: 0.6vh 1vw; }
.tv .feedback p { font-size: 1.6vw; }
