/* trivvy — the answer board. theme.css owns colour; this file owns the
   board's material: panels, letter tabs, the bulb rail, segment digits,
   and how each surface (screen, controller, host) lays them out.

   Grammar, so a new screen can be built without guessing:
   .tv-panel       a cream card with a letter tab; face-up shows text,
                   face-down (.is-down) is a dark blank, lit (.is-lit)
                   is the amber reveal, dim (.is-dim) is a loser.
   .tv-rail        the incandescent bulb border; --lit bulbs of --bulbs
                   stay on, the rest are dark: it IS the timer.
   .tv-seg         seven-segment digits over ghost cells.
   .tv-marquee     the question, condensed caps on a lit strip.
   Display face is League Gothic; body is the theme's sans. */

:root {
  --tv-display: "League Gothic", "Arial Narrow", Impact, sans-serif;
  --tv-seg-font: "DSEG7", ui-monospace, monospace;
  --tv-ease: cubic-bezier(.2, .9, .2, 1);
}

/* ── Shell: the show has no chrome ─────────────────────────────────── */
.tv-mark { display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--tv-display); font-size: 1.6rem; letter-spacing: .04em; text-transform: uppercase; }
.tv-mark-bulb { color: var(--rst-accent); }
body.tv-show [rst-shell-bar], body.tv-show [rst-shell-foot] { display: none; }
body.tv-show [rst-page] { max-width: none; padding: 0; }
body.tv-show { background: var(--rst-bg); }

/* ── Panels ────────────────────────────────────────────────────────── */
.tv-panel { position: relative; display: grid; grid-template-columns: auto 1fr; align-items: stretch;
  min-height: 4.5rem; border-radius: var(--rst-radius); overflow: hidden;
  background: var(--tv-card); color: var(--tv-card-ink);
  border: 1px solid var(--tv-card-edge); box-shadow: var(--rst-shadow-lift);
  font-family: var(--tv-display); font-size: 1.6rem; line-height: 1.05; letter-spacing: .01em; text-align: left;
  transition: transform .18s var(--tv-ease), background .3s, color .3s, box-shadow .3s; }
.tv-panel-tab { display: grid; place-items: center; width: 3rem; color: #fff;
  font-size: 1.9rem; border-right: 1px solid rgba(0,0,0,.18); }
.tv-panel[data-l="A"] .tv-panel-tab { background: var(--tv-tab-a); }
.tv-panel[data-l="B"] .tv-panel-tab { background: var(--tv-tab-b); }
.tv-panel[data-l="C"] .tv-panel-tab { background: var(--tv-tab-c); color: var(--tv-card-ink); }
.tv-panel[data-l="D"] .tv-panel-tab { background: var(--tv-tab-d); }
.tv-panel-text { padding: .7rem .9rem; align-self: center; text-wrap: balance; }
.tv-panel .tv-seg::before { color: rgba(0, 0, 0, .12); }
.tv-panel-tally { margin-left: auto; padding: 0 .9rem; align-self: center;
  font-family: var(--tv-seg-font); font-size: 1.4rem; color: var(--tv-card-ink); opacity: .85; }
/* face-down: the blank a panel shows before the flip */
.tv-panel.is-down { background: var(--tv-card-down); color: transparent; border-color: transparent; box-shadow: none; }
.tv-panel.is-down .tv-panel-tab { color: rgba(255,255,255,.75); }
/* lit: the one panel the show is about right now */
.tv-panel.is-lit { background: var(--rst-accent); color: var(--rst-on-accent); border-color: var(--rst-accent-strong);
  box-shadow: var(--rst-shadow-pop); }
.tv-panel.is-lit .tv-panel-tally { color: var(--rst-on-accent); opacity: 1; }
/* dim: a loser after the reveal, still legible */
.tv-panel.is-dim { opacity: .5; box-shadow: none; }
/* mine: the panel this phone picked */
.tv-panel.is-mine { outline: 3px solid var(--rst-text); outline-offset: 2px; }
/* as a button (the controller) */
button.tv-panel { width: 100%; cursor: pointer; appearance: none; }
button.tv-panel:hover { transform: translateY(-2px); box-shadow: var(--rst-shadow-pop); }
button.tv-panel:active { transform: translateY(1px); box-shadow: var(--rst-shadow-knob); }
button.tv-panel:focus-visible { outline: 3px solid var(--rst-accent); outline-offset: 3px; }

/* ── Bulb rail ─────────────────────────────────────────────────────── */
.tv-rail { --bulbs: 48; --lit: 48; position: relative; padding: 1.1rem; border-radius: 14px;
  background: var(--rst-surface-2); box-shadow: inset 0 0 0 1px var(--rst-line); }
/* The bulbs ring the border: four runs (top, right, bottom, left) laid
   as flex rows/columns so the ring closes at any aspect ratio. Bulbs
   are numbered clockwise from top-left, so time runs round the frame. */
.tv-rail-bulbs { position: absolute; inset: .35rem; pointer-events: none; }
.tv-rail-run { position: absolute; display: flex; justify-content: space-between; align-items: center; }
.tv-rail-run.top { top: 0; left: 1.5rem; right: 1.5rem; height: .6rem; }
.tv-rail-run.right { top: 1.5rem; bottom: 1.5rem; right: 0; width: .6rem; flex-direction: column; }
.tv-rail-run.bottom { bottom: 0; left: 1.5rem; right: 1.5rem; height: .6rem; flex-direction: row-reverse; }
.tv-rail-run.left { top: 1.5rem; bottom: 1.5rem; left: 0; width: .6rem; flex-direction: column-reverse; }
.tv-bulb { width: .55rem; height: .55rem; border-radius: 50%; background: var(--tv-bulb-off); flex: none;
  transition: background .25s, box-shadow .25s; }
.tv-bulb.on { background: var(--tv-bulb); box-shadow: 0 0 0 2px rgba(255, 180, 40, .28); }
.tv-rail-inner { position: relative; z-index: 1; }

/* ── Segment digits ────────────────────────────────────────────────── */
.tv-seg { position: relative; display: inline-block; font-family: var(--tv-seg-font); font-weight: 700;
  color: var(--tv-led); font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: .04em; }
.tv-seg::before { content: attr(data-ghost); position: absolute; inset: 0; color: var(--tv-led-ghost); z-index: -1; }
.tv-seg-lg { font-size: 3rem; }
.tv-seg-xl { font-size: clamp(3rem, 7vw, 6rem); }

/* ── Marquee ───────────────────────────────────────────────────────── */
.tv-marquee { font-family: var(--tv-display); text-transform: uppercase; letter-spacing: .02em;
  line-height: .98; text-wrap: balance; margin: 0; }
.tv-marquee-sm { font-size: clamp(1.7rem, 6vw, 2.4rem); }
.tv-marquee-lg { font-size: clamp(2.4rem, 5.2vw, 5rem); }
.tv-label { font-family: var(--tv-display); text-transform: uppercase; letter-spacing: .12em;
  font-size: 1rem; color: var(--rst-text-muted); }

/* ── Big screen ────────────────────────────────────────────────────── */
.tv-stage { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; gap: 1rem;
  padding: clamp(.75rem, 2vw, 1.5rem); box-sizing: border-box; }
.tv-stagebar { display: flex; align-items: center; gap: 1.25rem; padding: 0 .5rem; }
.tv-stagebar .tv-code { font-family: var(--tv-display); font-size: 2.2rem; letter-spacing: .25em; color: var(--rst-accent); }
.tv-stagebar .tv-label { margin-right: auto; }
.tv-stage-body { display: grid; gap: 1.5rem; grid-template-rows: auto 1fr; align-content: start; }
.tv-board { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-content: start; }
.tv-board .tv-panel { min-height: clamp(6rem, 18vh, 11rem); font-size: clamp(1.6rem, 3.2vw, 3rem); }
.tv-board .tv-panel-tab { width: clamp(3rem, 6vw, 5rem); font-size: clamp(2rem, 4vw, 3.6rem); }
.tv-board .tv-panel-tally { font-size: clamp(1.4rem, 3vw, 2.6rem); }
.tv-count { display: flex; align-items: baseline; gap: .75rem; justify-content: center; margin-top: .5rem; }

.tv-lobby { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 2.5rem; align-items: center; }
.tv-qr { width: 100%; aspect-ratio: 1; background: #fff; padding: .75rem; box-sizing: border-box;
  border-radius: var(--rst-radius); border: 6px solid var(--tv-card); box-shadow: var(--rst-shadow-pop); image-rendering: pixelated; }
.tv-bigcode { font-family: var(--tv-display); font-size: clamp(4rem, 12vw, 10rem); letter-spacing: .22em; line-height: 1;
  color: var(--rst-accent); margin: .25rem 0; }
.tv-url { font-size: clamp(1.1rem, 2vw, 1.5rem); color: var(--rst-text-muted); word-break: break-all; }
.tv-chips { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.tv-chips li { padding: .35rem .8rem; border-radius: var(--rst-radius-sm); background: var(--tv-card); color: var(--tv-card-ink);
  font-family: var(--tv-display); font-size: 1.3rem; letter-spacing: .02em; box-shadow: var(--rst-shadow-lift); }
.tv-chips li.tv-idle { opacity: .4; }

/* ranked by billing weight: #1 largest, stepping down */
.tv-billing { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.tv-billing li { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 1rem;
  font-family: var(--tv-display); text-transform: uppercase; letter-spacing: .02em; padding: .35rem .75rem;
  border-radius: var(--rst-radius); background: var(--tv-card); color: var(--tv-card-ink); box-shadow: var(--rst-shadow-lift); }
.tv-billing li:nth-child(1) { font-size: clamp(2rem, 5vw, 4rem); background: var(--rst-accent); color: var(--rst-on-accent); }
.tv-billing li:nth-child(2) { font-size: clamp(1.7rem, 4vw, 3rem); }
.tv-billing li:nth-child(3) { font-size: clamp(1.5rem, 3.2vw, 2.4rem); }
.tv-billing li:nth-child(n+4) { font-size: clamp(1.2rem, 2.2vw, 1.7rem); }
.tv-billing .tv-rank { opacity: .6; }
.tv-billing .tv-seg { color: inherit; }
.tv-billing .tv-seg::before { color: rgba(0,0,0,.12); }
.tv-billing li.is-out { opacity: .55; text-decoration: line-through; }
.tv-billing li.is-mine { outline: 3px solid var(--rst-text); outline-offset: 2px; }

/* ── Controller (phone) ────────────────────────────────────────────── */
.tv-controller { max-width: 32rem; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; min-height: 100dvh; box-sizing: border-box;
  grid-template-rows: auto 1fr; }
.tv-me { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem;
  font-family: var(--tv-display); font-size: 1.4rem; letter-spacing: .02em; text-transform: uppercase; }
.tv-me .tv-seg { font-size: 1.5rem; }
.tv-me .tv-out { color: var(--rst-tone-negative-fg); }
.tv-choices { display: grid; gap: .75rem; align-content: start; }
.tv-hand { display: grid; gap: .75rem; align-content: start; }
.tv-wager { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; margin: 0; padding: 0; border: 0; }
.tv-wager legend { font-family: var(--tv-display); text-transform: uppercase; letter-spacing: .1em; color: var(--rst-text-muted); margin-bottom: .4rem; }
.tv-wager label { display: grid; place-items: center; gap: .1rem; padding: .55rem .2rem; border-radius: var(--rst-radius-sm);
  background: var(--rst-surface); border: 1px solid var(--rst-line-strong); cursor: pointer; text-align: center;
  font-family: var(--tv-display); font-size: 1.2rem; }
.tv-wager label small { font-family: var(--rst-font); font-size: .7rem; color: var(--rst-text-muted); }
.tv-wager input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tv-wager label:has(input:checked) { background: var(--rst-accent); color: var(--rst-on-accent); border-color: var(--rst-accent-strong); }
.tv-wager label:has(input:checked) small { color: inherit; }
.tv-wager label:has(input:focus-visible) { outline: 3px solid var(--rst-accent); outline-offset: 2px; }
.tv-waiting { text-align: center; padding: 2rem 1rem; color: var(--rst-text-muted); font-size: 1.1rem; }
.tv-waiting strong { color: var(--rst-text); }
.tv-result { text-align: center; font-family: var(--tv-display); text-transform: uppercase; font-size: 2rem; letter-spacing: .04em; margin: .5rem 0 0; }
.tv-result.is-good { color: var(--rst-accent); }

/* ── Front door / join ─────────────────────────────────────────────── */
.tv-door { display: grid; gap: 1.5rem; max-width: 34rem; margin: 0 auto; }
.tv-door h1 { font-family: var(--tv-display); text-transform: uppercase; letter-spacing: .02em; font-size: clamp(2.4rem, 8vw, 4rem); line-height: .95; margin: 0; text-wrap: balance; }
.tv-door .tv-panel { min-height: 3.5rem; }
.tv-join [rst-input] { font-size: 1.5rem; }
.tv-join #code { text-transform: uppercase; letter-spacing: .3em; font-family: var(--tv-display); font-size: 2.2rem; }

/* ── Host pages (house lights up): inherit the shell, add the board's type */
.tv-inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.tv-set-list li { padding: .5rem 0; border-bottom: 1px solid var(--rst-line); }
.tv-types { display: grid; gap: .5rem; }
.tv-types label { display: grid; grid-template-columns: auto 1fr; gap: .75rem; padding: .75rem; border-radius: var(--rst-radius);
  border: 1px solid var(--rst-line-strong); background: var(--rst-surface); cursor: pointer; align-items: start; }
.tv-types label:has(input:checked) { border-color: var(--rst-accent); background: var(--rst-accent-soft); }
.tv-types strong { font-family: var(--tv-display); text-transform: uppercase; font-size: 1.25rem; letter-spacing: .04em; display: block; }
.tv-host-q { font-family: var(--tv-display); font-size: 1.5rem; text-transform: uppercase; letter-spacing: .01em; margin: 0 0 .5rem; }

/* ── Motion: one authored moment, the flip ─────────────────────────── */
@keyframes tv-flip { from { transform: rotateX(90deg); opacity: .4; } to { transform: none; opacity: 1; } }
.tv-board .tv-panel.is-lit, .tv-hand .tv-panel.is-lit { animation: tv-flip .55s var(--tv-ease) both; transform-origin: 50% 100%; }
@media (prefers-reduced-motion: reduce) { .tv-panel, .tv-bulb { transition: none; animation: none !important; } }

@media (max-width: 720px) {
  .tv-board { grid-template-columns: 1fr; }
  .tv-lobby { grid-template-columns: 1fr; }
  .tv-qr { max-width: 240px; }
  .tv-stage { min-height: auto; }
}
