/* TV mode (?tv=1, CONTRACTS §9.4): a watch-only big screen. The whole HUD scales with the screen width (rem-based
   type grows from 16 px on a laptop to ~24 px on a 1080p TV); the TV's own code form, broadcast lobby and the corner
   QR bug live here. */

html.is-tv, html.is-tv body { font-size: clamp(16px, 1.25vw, 30px); }
html.is-tv {
  --sidebar-w: clamp(340px, 30vw, 620px);
  --topbar-h: clamp(56px, 3.6vw, 76px);
}

/* ── Code form ─────────────────────────────────────────────────────── */

.tv-logo { font-size: clamp(1.7rem, 3.2vw, 3.6rem); text-align: center; }
.tv-kicker {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
  color: var(--c-pink);
}
.tv-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
}
.tv-code-input { min-height: 3.4rem; font-size: 2rem; text-align: center; letter-spacing: 0.4em; }
.tv-code-input::placeholder { font-size: 1.4rem; letter-spacing: 0.4em; }
.tv-hint { font-size: 0.85rem; color: var(--c-dim); text-align: center; text-wrap: balance; }

/* ── Broadcast lobby ───────────────────────────────────────────────── */

/* Sized by the sidebar, not the window: four Unbounded glyphs must fit its width at every screen size. */
.tv-room-code {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: calc(var(--sidebar-w) * 0.19);
  line-height: 1;
  letter-spacing: 0.12em;
  /* The trailing letter-spacing would push the code off-centre. */
  padding-left: 0.12em;
  text-align: center;
  color: var(--c-cyan);
  text-shadow: 0 0 34px rgba(0, 240, 255, 0.7), 0 4px 0 rgba(0, 0, 0, 0.6);
}
.tv-join { display: flex; align-items: center; gap: 1rem; }
.tv-qr { flex: none; width: min(46%, 300px); }
.tv-scan { min-width: 0; font-size: 0.82rem; line-height: 1.4; color: var(--c-dim); overflow-wrap: anywhere; }
.tv-scan b { color: var(--c-text); }

.tv-cast { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tv-cast-chip {
  --seat: var(--c-cyan);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  border: 1.5px solid var(--seat);
  background: color-mix(in srgb, var(--seat) 14%, rgba(9, 11, 28, 0.9));
  animation: chip-pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.5) both;
}
.tv-cast-chip.is-offline { opacity: 0.45; }
.tv-cast-avatar {
  flex: none;
  width: 2rem; height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  font-size: 1.2rem;
}
.tv-cast-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 0.9rem; }
.tv-cast-crown { flex: none; }
.tv-empty { font-size: 0.85rem; color: var(--c-dim); }
.tv-empty[hidden] + .lobby-screens { margin-top: 0; }
.tv-lobby .lobby-screens { align-self: flex-start; }
.tv-lobby .lobby-wait { justify-content: center; }

/* ── Corner bug during the show: latecomers can still scan in ──────── */

.tv-corner {
  position: absolute;
  left: max(14px, var(--safe-l));
  bottom: calc(14px + var(--safe-b));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border-radius: 16px;
  background: rgba(9, 11, 28, 0.82);
  border: 1px solid var(--glass-line);
  pointer-events: none;
  z-index: 2;
}
.tv-corner-qr { width: clamp(84px, 6.2vw, 150px); padding: 5px; border-radius: 10px; box-shadow: none; }
.tv-corner-text { display: flex; flex-direction: column; gap: 2px; }
.tv-corner-label { font-family: var(--font-display); font-size: 0.55rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--c-dim); }
.tv-corner-code { font-family: var(--font-display); font-size: 1.4rem; font-weight: 900; letter-spacing: 0.12em; color: var(--c-cyan); }

/* The reveal lower third is centred on a TV: the corner bug sits to its left, never under it. */
@media (orientation: landscape) and (min-width: 700px) {
  html.is-tv .reveal-inner { width: min(100%, 62vw); }
}
/* A portrait "TV" (a tablet on a stand): the bug moves to the top-left, clear of the bottom docks. */
@media (orientation: portrait) {
  .tv-corner { top: calc(var(--topbar-h) + var(--safe-t) + 8px); bottom: auto; }
}
