/* tv.css — Retro CRT Television Shell */

/* Two themes. Dark: moulded grainy plastic on a cabinet in a softly lit room, turned controls, a framed
   blackboard. Light: a 1970s hi-fi receiver, brushed aluminium in a walnut case (its own section further down).
   MENU › THEME sets data-theme on <html> (index.html does it before the first paint). Only the room and the
   cabinet change: the screen and its surround are dark glass in both, and everything on the picture stays
   phosphor on black. Kiosk and embed have no cabinet. */
:root {
  color-scheme:      dark;
  --room:            #141210;   /* the wall behind the TV */
  --room-glow:       #25211c;   /* the pool of light on it */
  --tv-bg:           #2a2520;   /* dark warm charcoal plastic body */
  --tv-highlight:    #3d3830;   /* lighter bevel edge */
  --tv-shadow:       #18140f;   /* darker bevel edge */
  --tv-sheen:        rgba(255,255,255,0.04);
  --tv-drop:         0 8px 40px rgba(0,0,0,0.85), 0 2px 8px rgba(0,0,0,0.6);
  --grain:           url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 .05 0 0 0 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --ink:             #b9b0a2;   /* lettering on the cabinet */
  --ink-shadow:      0 1px 0 rgba(0,0,0,0.6);
  --ink-off:         #6f685d;   /* lettering that waits for the power */
  --well:            #18140f;   /* what the power switch sits in */
  --well-edge:       #333;
  --switch-off:      #1c1c1c;
  --switch-edge:     #444;
  --switch-on:       #cc2200;
  --cap-hi:          #3a3530;   /* dials and buttons: lit side */
  --cap-lo:          #1a1510;   /* and shaded side */
  --cap-edge:        #222;
  --cap-seam:        #111;      /* between the rocker's two halves */
  --cap-ink:         #888;
  --cap-marker:      #aaa;
  --cap-lift:        0 2px 4px rgba(0,0,0,0.6), inset 0 1px 1px rgba(255,255,255,0.08);
  --cap-pressed:     0 1px 1px rgba(0,0,0,0.6), inset 0 1px 3px rgba(0,0,0,0.6);
  --btn-led-off:     #2a1a00;
  --focus:           #7a7;
  --badge-bg:        rgba(0,0,0,0.4);
  --badge-edge:      #222;
  --badge-ink:       #888;
  --badge-ink-off:   #444;
  --wood-a:          #6b4428;   /* the blackboard's frame: walnut */
  --wood-b:          #74492b;
  --wood-c:          #643f25;
  --tray-hi:         #7a4f30;
  --tray-lo:         #4e321d;
  --tv-screen-bg:    #050a05;   /* deep screen surround — slight green tint */
  --tv-screen-w:     min(72vw, 128vh);  /* screen width, respects both axes */
  --tv-aspect:       calc(9 / 16);      /* 16:9 screen */
  --led-off:         #1a0000;
  --led-on:          #ff2200;
  --lamp:            #ffaa00;   /* a lit button or key: HOLD, CHAT, TAPES */
  --lamp-glow:       0 0 6px rgba(255,170,0,0.9);
  --badge-glow:      none;
}

/* Light: a 1970s hi-fi receiver. A brushed-aluminium faceplate in a walnut case, knurled spun-metal knobs,
   aluminium piano keys, engraved black lettering, and a black glass display window lit blue. The cabinet's
   lamps (HOLD, CHAT, TAPES, the key that is down) glow blue as the dial does; the beat light keeps its colours. */
:root[data-theme="light"] {
  color-scheme:      light;
  --room:            #dcd9d2;
  --room-glow:       #f4f2ed;
  --tv-bg:           #d3d1cb;   /* the faceplate under its brushing */
  --tv-highlight:    #fbfaf7;
  --tv-shadow:       #8c8982;
  --tv-sheen:        rgba(255,255,255,0.4);
  --tv-drop:         0 14px 36px rgba(40,32,22,0.42), 0 3px 8px rgba(40,32,22,0.3);
  /* Brushed metal: noise stretched along the plate, so it reads as fine horizontal strokes */
  --brushed:         url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='240'%3E%3Cfilter id='b'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.0018 .9' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 .16'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23b)'/%3E%3C/svg%3E");
  --spun:            conic-gradient(from 20deg, #fbfbf9, #aeaca7 12.5%, #f1f0ed 25%, #a3a19c 37.5%, #fbfbf9 50%, #aeaca7 62.5%, #f1f0ed 75%, #a3a19c 87.5%, #fbfbf9);
  --metal-edge:      #5f5c56;
  --ink:             #1f1e1c;   /* engraved, filled black */
  --ink-shadow:      0 1px 0 rgba(255,255,255,0.75);
  --ink-off:         #4f4c47;
  --well:            #1e1d1b;   /* the slots the switch and the keys sit in */
  --well-edge:       #5f5c56;
  --switch-off:      linear-gradient(180deg, #fafaf8, #b9b7b1);
  --switch-edge:     #5f5c56;
  --switch-on:       linear-gradient(180deg, #ef5a3c, #b01f06);
  --cap-hi:          #f8f7f4;
  --cap-lo:          #bebcb6;
  --cap-edge:        #5f5c56;
  --cap-seam:        #6b6862;
  --cap-ink:         #1f1e1c;
  --cap-marker:      #1a1a1a;
  --cap-lift:        0 2px 3px rgba(40,32,22,0.5), 0 1px 1px rgba(0,0,0,0.3);
  --cap-pressed:     0 1px 1px rgba(40,32,22,0.5), inset 0 1px 3px rgba(0,0,0,0.4);
  --btn-led-off:     #2c3a44;
  --lamp:            #6fd2ff;
  --lamp-glow:       0 0 6px rgba(90,200,255,0.95), 0 0 2px #fff;
  --focus:           #0b5394;
  --badge-bg:        linear-gradient(180deg, #0b1a24, #050c12);  /* the dial glass */
  --badge-edge:      #2f4b5e;
  --badge-ink:       #8fdcff;
  --badge-ink-off:   #3f6a84;
  --badge-glow:      0 0 6px rgba(80,190,255,0.75);
  --wood-a:          #4a2a17;   /* the case, and the blackboard's frame to match: oiled walnut */
  --wood-b:          #56331d;
  --wood-c:          #3f2413;
  --tray-hi:         #5c3820;
  --tray-lo:         #331d0f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: radial-gradient(ellipse 90% 80% at 50% 38%, var(--room-glow), var(--room) 75%) var(--room);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  font-family: monospace;
}

/* --- TV Outer Wrapper --- */
#tv-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- TV Body --- */
#tv-body {
  background: var(--tv-bg);
  border-radius: 18px 18px 12px 12px;
  padding: 28px 28px 20px 28px;
  box-shadow:
    inset 0 2px 1px var(--tv-highlight),
    inset 0 -2px 1px var(--tv-shadow),
    inset 2px 0 1px var(--tv-highlight),
    inset -2px 0 1px var(--tv-shadow),
    var(--tv-drop);

  /* Moulded plastic: a fine grain, and the room's light across the top */
  background-image: var(--grain), radial-gradient(
    ellipse at 30% 20%,
    var(--tv-sheen) 0%,
    transparent 60%
  );
}

/* --- Screen Outer Border (thick inset surround) --- */
#tv-screen-border {
  width: var(--tv-screen-w);
  background: var(--tv-screen-bg);
  border-radius: 8px;
  padding: 14px;
  box-shadow:
    inset 0 0 20px rgba(0,0,0,0.9),
    inset 0 0 4px rgba(0,200,0,0.04),  /* faint green phosphor glow */
    0 0 0 2px var(--tv-shadow);
}

/* --- Screen Area (canvas container) --- */
#tv-screen-area {
  position: relative;
  width: 100%;
  padding-bottom: calc(var(--tv-aspect) * 100%);   /* aspect ratio trick */
  background: #000;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
}

#tv-screen-area canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Lite mode (lite.js): the Spaz collage over the (unused) canvas. Clicks go through to the canvas, which
   carries the picture's handlers. Static scanlines and a vignette stand in for the CRT shader. */
#lite-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: #000;
  opacity: 1;
  transition: opacity 0.8s ease;
}
#lite-layer .lite-lane {   /* sky, photos, logos: back to front */
  position: absolute;
  inset: 0;
  transition: opacity 0.5s ease;
}
#lite-layer .lite-lane.lite-off { opacity: 0; }   /* the logos with MENU › SPAZ LOGOS off */
#lite-layer img {
  position: absolute;
  max-width: none;
  will-change: transform, opacity;
}
/* Photos fade out towards their edges, so no hard border shows over the sky (prefixed for Safari 15 and
   Chrome before 120; the standard pair wins where both are known). */
#lite-layer .lite-photo img {
  -webkit-mask-image:
    linear-gradient(to right, transparent, #000 12%, #000 88%, transparent),
    linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent, #000 12%, #000 88%, transparent),
    linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  mask-composite: intersect;
}
#lite-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
}
#tv-body:not(.powered-on) #lite-layer { opacity: 0; }

/* Screen-off overlay — solid black shown when TV is off */
#screen-off-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 2;
}

/* When powered on or shutting down, fade out the black overlay to reveal canvas */
#tv-body.powered-on #screen-off-overlay,
#tv-body.shutting-down #screen-off-overlay {
  opacity: 0;
}

/* --- Controls Row --- */
#tv-controls {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 8px 4px 8px;
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.control-label {
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: var(--ink-shadow);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* --- Power Switch --- */
.power-switch {
  width: 32px;
  height: 48px;
  background: var(--well);
  border: 2px solid var(--well-edge);
  border-radius: 6px 6px 4px 4px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
  transition: background 0.2s;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.08), 0 2px 4px rgba(0,0,0,0.5);
}

.switch-knob {
  width: 18px;
  height: 22px;
  background: var(--switch-off);
  border-radius: 3px;
  border: 1px solid var(--switch-edge);
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.power-switch.active .switch-knob {
  background: var(--switch-on);
  transform: translateY(6px);
  box-shadow: 0 0 8px rgba(200,0,0,0.5);
}

/* --- Rotary Dial --- */
.rotary-dial {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, var(--cap-hi), var(--cap-lo));
  border: 2px solid var(--cap-edge);
  cursor: ns-resize;
  position: relative;
  box-shadow: var(--cap-lift);
  user-select: none;
  transition: transform 0s;  /* transform is set directly, no transition */
}

/* Marker line at top — shows rotation angle */
.dial-marker {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 10px;
  background: var(--cap-marker);
  border-radius: 1px;
}

/* --- The clusters: the main controls, the recessed scene panel, the radio face --- */
.control-cluster, #radio-face { display: flex; align-items: center; gap: 16px; }
.main-controls { gap: 18px; }
.scene-panel {
  gap: 14px;
  padding: 6px 12px 4px;
  border-radius: 8px;
  background: rgba(0,0,0,0.12);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.45), 0 1px 0 var(--tv-highlight);
}
.scene-panel .rotary-dial { width: 34px; height: 34px; }
.scene-panel .push-btn { width: 26px; height: 26px; }
.rotary-dial.big { width: 50px; height: 50px; }
.rotary-dial.big .dial-marker { height: 13px; }
.rocker.big .rocker-btn { width: 32px; height: 24px; font-size: 0.6rem; }

/* The radio face: the display window over the key bank, CHAT on the keys' right */
#radio-face {
  margin-left: auto;          /* sits against the right edge, and stays there when it wraps to a row of its own */
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas: "display ." "keys chat";
  gap: 6px 12px;
  align-items: center;
}
#radio-face > #station-block { grid-area: display; }
#radio-face > #key-bank { grid-area: keys; }
#radio-face > #chat-face { grid-area: chat; }
.face-btn { display: flex; align-items: center; gap: 6px; }
.face-btn .control-label { width: 3.2em; }
.face-btn .push-btn { width: 26px; height: 26px; }

/* --- The display window: source, station and channel, the beat, and who's tuned in --- */
#station-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 10px 2px;
  background: var(--badge-bg);
  border: 1px solid var(--badge-edge);
  border-radius: 4px;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.6);
  min-width: 0;
}

#listeners {
  min-height: 1.3em;   /* room kept while there is no count, so the row never shifts */
  color: var(--badge-ink);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
#tv-body:not(.powered-on) #listeners { visibility: hidden; }

#source-badge {
  padding: 0 5px;
  border: 1px solid var(--badge-edge);
  border-radius: 3px;
  color: var(--badge-ink);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
  user-select: none;
}
#tv-body:not(.powered-on) #source-badge { visibility: hidden; } /* off, nothing is playing */

#station-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

/* --- The key bank: piano keys like a car radio's. The key that is down sits lower, and its legend lights --- */
#key-bank {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 5px;
  background: var(--well);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.7), 0 1px 0 var(--tv-highlight);
}
.bank-key {
  position: relative;
  min-width: 42px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--cap-edge);
  border-radius: 3px 3px 4px 4px;
  background: linear-gradient(180deg, var(--cap-hi) 0%, var(--cap-lo) 100%);
  color: var(--cap-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 3px 0 var(--cap-seam), 0 4px 4px rgba(0,0,0,0.5);
  transform: translateY(-2px);
  transition: transform 0.06s, box-shadow 0.06s, color 0.15s, text-shadow 0.15s;
}
.bank-key:active { transform: translateY(0); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 1px 0 var(--cap-seam); }
.bank-key.down {
  transform: translateY(0);
  background: linear-gradient(180deg, var(--cap-lo) 0%, var(--cap-hi) 140%);
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.55), 0 1px 0 var(--cap-seam);
  color: #ffbb33;
  text-shadow: 0 0 6px rgba(255,170,0,0.8);
}
.bank-key:focus-visible { outline: 1px solid var(--focus); outline-offset: 2px; }
#keysBtn { min-width: 30px; font-size: 0.72rem; }
/* TAPES's light: a tape is in (or its list is open) */
.key-led {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--btn-led-off);
}
#tapesBtn[aria-pressed="true"] .key-led { background: var(--lamp); box-shadow: var(--lamp-glow); }

.led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--led-off);
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
  transition: background 0.3s, box-shadow 0.3s;
}


.station-text {
  color: var(--badge-ink-off);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums; /* the channel number keeps its width */
  user-select: none;
  transition: color 0.3s;
}

#tv-body.powered-on .station-text {
  color: var(--badge-ink);
}

/* --- Push buttons (FX, HOLD) and the channel rocker --- */
.push-btn, .rocker-btn {
  background: radial-gradient(circle at 35% 30%, var(--cap-hi), var(--cap-lo));
  border: 2px solid var(--cap-edge);
  color: var(--cap-ink);
  font: inherit;
  cursor: pointer;
  box-shadow: var(--cap-lift);
  transition: transform 0.06s, box-shadow 0.06s, opacity 0.2s;
}

.push-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.push-btn:active, .rocker-btn:active, .push-btn.pressed, .rocker-btn.pressed {
  transform: translateY(1px);
  box-shadow: var(--cap-pressed);
}

.rocker {
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--cap-edge);
}

.rocker-btn {
  width: 28px;
  height: 20px;
  border: 0;
  border-radius: 0;
  font-size: 0.55rem;
  line-height: 1;
}

.rocker-btn + .rocker-btn { border-top: 1px solid var(--cap-seam); }

.btn-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--btn-led-off);
  transition: background 0.2s, box-shadow 0.2s;
}

.push-btn[aria-pressed="true"] .btn-led {
  background: var(--lamp);
  box-shadow: var(--lamp-glow);
}

.push-btn:focus-visible, .rocker-btn:focus-visible, .rotary-dial:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 2px;
}

/* Live broadcast: the desktop drives the picture, viewer controls are locked */
#tv-body.live .push-btn, #tv-body.live .rocker-btn, #tv-body.live #timeDial, #tv-body.live #reactDial {
  opacity: 0.35;
  cursor: not-allowed;
}

/* iPhone/iPad Safari, live radio: only the device's buttons set the volume (ui.js volumeFixed) */
#volumeDial.fixed { opacity: 0.35; cursor: not-allowed; }

/* Beat LED: lit on each beat; green = locked to the music, amber = keeping time on its own */
/* The flash lasts 15% of a beat, shorter than the .led fade, so it lights at once and fades out */
.beat-led.on { background: #ffaa00; box-shadow: 0 0 6px rgba(255,170,0,0.8); transition: none; }
.beat-led.on.locked { background: #33ff55; box-shadow: 0 0 6px rgba(50,255,90,0.9); }
#tv-body:not(.powered-on) .beat-led { background: var(--led-off); box-shadow: none; }

/* --- On-screen display: phosphor-green text over the picture --- */
#osd {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  color: #8cff8c;
  font-family: "VT323", "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 0 6px rgba(80,255,80,0.8), 0 0 2px rgba(0,0,0,0.9), 1px 1px 0 rgba(0,0,0,0.8);
  font-size: clamp(11px, 1.9vw, 26px);
}

#osd > div, #osd-info > div, #osd-radio > div {
  opacity: 0;
  transition: opacity 0.4s;
}

#osd .show { opacity: 1 !important; transition: opacity 0.05s; }

#osd-ch {
  position: absolute;
  top: 5%;
  right: 5%;
  font-size: 2.2em;
}

#osd-radio {
  position: absolute;
  top: 5%;
  left: 5%;
  right: 30%;  /* clear of CH nn */
  opacity: 1 !important;
}
/* The show now and the next show: each wraps to two lines, then gives way (…) */
#osd-radio > div { overflow: hidden; }
#osd-track-text, #osd-next {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  line-height: 1.25;   /* room above each line, so no top of a hidden third line shows */
  max-height: 2.5em;   /* two lines */
  overflow: hidden;
  overflow-wrap: anywhere;
}
/* The track line is a row: the title gives way before SAVE does; SAVE sits by its last line */
#osd-radio > #osd-track { display: flex; align-items: baseline; align-items: last baseline; gap: 0.6em; }
#osd-track-text { flex: 0 1 auto; min-width: 0; }
#osd-save {
  flex: none;
  color: inherit;
  opacity: 0.6;
  text-decoration: none;
  pointer-events: auto;   /* the one thing on the OSD that takes a click */
  cursor: pointer;
}
#osd-save:hover, #osd-save:focus-visible { opacity: 1; text-decoration: underline; }
#osd-save[hidden] { display: none; }
#osd-track:not(.show) #osd-save { pointer-events: none; } /* a faded line has nothing to click */

#osd-msg {
  position: absolute;
  top: 50%;
  left: 5%;
  right: 5%;
  transform: translateY(-50%);
  text-align: center;
  font-size: 1.3em;
}

#osd-info {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 6%;
  opacity: 1 !important;
}

#osd-name, #osd-bg, #osd-chain { font-size: 1em; margin-top: 0.15em; }
#osd-track { font-size: 1em; }
#osd-next { margin-top: 0.2em; }
#osd-track { color: #c8ffc8; text-transform: none; }
#osd-next { font-size: 0.75em; color: #d9c2ff; text-shadow: 0 0 8px rgba(160,90,255,0.9), 1px 1px 0 rgba(0,0,0,0.8); }
#tv-body:not(.powered-on) #osd { display: none; }

/* --- Fullscreen: the screen (picture + OSD) fills the display --- */
#tv-screen-area:fullscreen {
  width: 100vw;
  height: 100vh;
  padding-bottom: 0;
  border-radius: 0;
}

#tv-screen-area:fullscreen #osd { font-size: clamp(14px, 2.4vw, 40px); }

/* --- Narrow screens: bigger picture, controls wrap onto two rows --- */
#tv-controls { flex-wrap: wrap; }

@media (max-width: 700px) {
  :root { --tv-screen-w: 92vw; }
  #tv-body { padding: 12px 10px 10px 10px; border-radius: 12px; }
  #tv-screen-border { padding: 6px; }
  #tv-controls { gap: 12px; justify-content: center; }
  .control-cluster { gap: 12px; }
  #radio-face { margin-left: 0; grid-template-columns: 1fr auto; width: 100%; }
  #key-bank { justify-content: space-between; }
  .bank-key { flex: 1 1 0; min-width: 0; padding: 0 2px; }
}

/* --- Light: the receiver. Same controls, same places; hi-fi materials (tokens in the light :root above) --- */
:root[data-theme="light"] #tv-body {
  border: 14px solid transparent;            /* the walnut case */
  border-radius: 12px;
  padding: 22px 16px 14px;                   /* with the case, as wide as the dark cabinet */
  background:
    var(--brushed) padding-box,
    linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0) 22%, rgba(0,0,0,0.04) 70%, rgba(255,255,255,0.2)) padding-box,
    linear-gradient(100deg, transparent 15%, rgba(255,255,255,0.28) 38%, transparent 58%) padding-box,
    linear-gradient(var(--tv-bg), var(--tv-bg)) padding-box,
    linear-gradient(180deg, rgba(255,225,190,0.16), transparent 18%, transparent 82%, rgba(0,0,0,0.3)) border-box,
    repeating-linear-gradient(91deg, var(--wood-a) 0 5px, var(--wood-b) 5px 8px, var(--wood-c) 8px 15px, var(--wood-b) 15px 17px) border-box;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),     /* the plate's machined edge */
    inset 0 -1px 0 rgba(0,0,0,0.3),
    inset 0 0 0 1px rgba(0,0,0,0.25),
    0 0 0 1px #24140a,
    var(--tv-drop);
}
@media (max-width: 700px) {
  :root[data-theme="light"] #tv-body { border-width: 8px; padding: 10px 8px 8px; }
}
/* The picture behind black glass, in a bright chrome bezel */
:root[data-theme="light"] #tv-screen-border {
  box-shadow:
    inset 0 0 20px rgba(0,0,0,0.9),
    0 0 0 1px #3c3a36,
    0 0 0 3px #eeedea,
    0 0 0 4px #7d7a73,
    0 2px 0 4px rgba(255,255,255,0.7);
}
/* Engraved lettering, spaced wide */
:root[data-theme="light"] .control-label { letter-spacing: 0.16em; font-weight: 700; font-size: 0.64rem; }
/* The scene panel: a printed rule round a group of controls, as on a faceplate */
:root[data-theme="light"] .scene-panel {
  background: none;
  border: 1px solid rgba(30,28,25,0.55);
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.75), inset 0 1px 0 rgba(255,255,255,0.75);
}

/* Knobs: a knurled skirt that turns with a spun-aluminium cap, and a black pointer line */
:root[data-theme="light"] .rotary-dial {
  border: 1px solid var(--metal-edge);
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,0.55), transparent 58%),
    radial-gradient(circle closest-side, transparent 80%, rgba(0,0,0,0.3) 100%),
    repeating-conic-gradient(#5a5852 0 4deg, #e6e4df 4deg 8deg);
  box-shadow: 0 3px 5px rgba(40,32,22,0.45), 0 1px 1px rgba(0,0,0,0.35);
}
:root[data-theme="light"] .rotary-dial::before {
  content: "";
  position: absolute;
  inset: 17%;
  border-radius: 50%;
  background: var(--spun);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.35), inset 0 1px 1px rgba(255,255,255,0.9);
}
:root[data-theme="light"] .rotary-dial .dial-marker { z-index: 1; top: 20%; height: 28%; width: 2px; }

/* Push buttons: round spun-metal caps; the rocker a brushed bar */
:root[data-theme="light"] .push-btn {
  background: var(--spun);
  border: 1px solid var(--metal-edge);
  box-shadow: var(--cap-lift), inset 0 0 0 2px rgba(255,255,255,0.35);
}
:root[data-theme="light"] .push-btn:active, :root[data-theme="light"] .push-btn.pressed { box-shadow: var(--cap-pressed); }
:root[data-theme="light"] .rocker { border: 1px solid var(--metal-edge); border-radius: 4px; box-shadow: var(--cap-lift); }
:root[data-theme="light"] .rocker-btn { background: var(--brushed), linear-gradient(180deg, #f8f7f4, #c6c4be); box-shadow: inset 0 1px 0 rgba(255,255,255,0.8); }
:root[data-theme="light"] .rocker-btn:active, :root[data-theme="light"] .rocker-btn.pressed { background: var(--brushed), linear-gradient(180deg, #c6c4be, #e8e7e3); box-shadow: inset 0 1px 3px rgba(0,0,0,0.4); }
:root[data-theme="light"] .btn-led { box-shadow: inset 0 1px 1px rgba(0,0,0,0.7); }

/* The power switch: a chrome lever in a black slot; red when it's on */
:root[data-theme="light"] .power-switch { box-shadow: inset 0 2px 3px rgba(0,0,0,0.8), 0 1px 0 rgba(255,255,255,0.75); }
:root[data-theme="light"] .switch-knob { box-shadow: 0 1px 2px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.9); }

/* The display window: black glass and a blue glow, like a tuning dial */
:root[data-theme="light"] #station-block {
  border-color: #000;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.9), 0 0 0 2px #e9e8e4, 0 0 0 3px #7d7a73, 0 2px 0 3px rgba(255,255,255,0.6);
}
/* with a tuning scale along the bottom of the glass, lit when the set is on */
:root[data-theme="light"] #station-block { position: relative; padding-bottom: 8px; }
:root[data-theme="light"] #station-block::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 5px;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 36px) bottom / 100% 5px no-repeat,
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 6px) bottom / 100% 2px no-repeat;
  color: var(--badge-ink-off);
  opacity: 0.6;
  transition: color 0.3s, opacity 0.3s;
}
:root[data-theme="light"] #tv-body.powered-on #station-block::after { color: var(--badge-ink); opacity: 0.55; filter: drop-shadow(0 0 2px rgba(80,190,255,0.8)); }
:root[data-theme="light"] #source-badge,
:root[data-theme="light"] #tv-body.powered-on .station-text,
:root[data-theme="light"] #listeners { text-shadow: var(--badge-glow); }

/* The key bank: aluminium keys in a black slot; the key that is down lights its legend blue */
:root[data-theme="light"] #key-bank { box-shadow: inset 0 1px 3px rgba(0,0,0,0.8), 0 1px 0 rgba(255,255,255,0.75); }
:root[data-theme="light"] .bank-key {
  background: var(--brushed), linear-gradient(180deg, #fbfaf8 0%, #dcdad5 55%, #c2c0ba 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 3px 0 var(--cap-seam), 0 4px 4px rgba(0,0,0,0.5);
}
:root[data-theme="light"] .bank-key.down {
  background: var(--brushed), linear-gradient(180deg, #c2c0ba 0%, #e4e3df 100%);
  color: #0b4f8f;
  text-shadow: 0 0 5px rgba(90,200,255,0.9);
}

/* --- Kiosk (?kiosk): no TV body, the picture fills the window; keyboard and swipe still work --- */
body.kiosk { background: #000; }
body.kiosk #tv-body { padding: 0; border-radius: 0; box-shadow: none; background: #000; }
body.kiosk #tv-screen-border { width: 100vw; padding: 0; border-radius: 0; box-shadow: none; background: #000; }
body.kiosk #tv-screen-area { padding-bottom: 0; width: 100vw; height: 100vh; border-radius: 0; }
body.kiosk #tv-controls { display: none; }
body.kiosk.idle, body.kiosk.idle #tv-screen-area canvas { cursor: none; }

/* --- AUTOPLAY's question (ui.js): a small green box low on the picture; the pages cover it --- */
#autoplay-ask {
  position: absolute;
  left: 50%;
  top: 70%;
  transform: translate(-50%, -50%);
  z-index: 3;
  max-width: 88%;
  box-sizing: border-box;
  padding: 0.5em 1.2em 0.45em;
  background: rgba(0, 8, 0, 0.78);
  border: 1px solid rgba(140,255,140,0.5);
  color: #8cff8c;
  font-family: "VT323", "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 0.06em;
  text-align: center;
  text-shadow: 0 0 6px rgba(80,255,80,0.8);
  font-size: clamp(11px, 1.7vw, 24px);
}
#autoplay-ask[hidden] { display: none; }
.menu-open #autoplay-ask, .card-up #autoplay-ask { visibility: hidden; }
#autoplay-ask .aa-buttons { display: flex; justify-content: center; gap: 1.2em; margin: 0.35em 0 0.3em; }
#autoplay-ask button { background: none; border: 1px solid #8cff8c; color: inherit; font: inherit; text-shadow: inherit; padding: 0.05em 1em; cursor: pointer; }
#autoplay-ask button:hover, #autoplay-ask button:focus-visible { background: #8cff8c; color: #021; text-shadow: none; }
#autoplay-ask .aa-note { font-size: 0.6em; opacity: 0.7; }

/* --- Service menu (menu.js): phosphor-green rows over a darkened picture --- */
#tv-menu {
  position: absolute;
  inset: 0;
  z-index: 4;
  padding: 3% 14% 2.5%;
  background: rgba(0, 8, 0, 0.72);
  color: #8cff8c;
  font-family: "VT323", "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 0.06em;
  text-shadow: 0 0 6px rgba(80,255,80,0.8);
  font-size: clamp(10px, 1.45vw, 21px);
  display: flex;
  flex-direction: column;
}
#tv-menu[hidden] { display: none; }
@media (max-width: 700px) { #tv-menu { padding-inline: 6%; } }
.menu-open #osd, .card-up #osd, .card-up #bumper { visibility: hidden; }
#tv-menu .menu-title { flex: none; font-size: 1.3em; margin-bottom: 0.3em; display: flex; align-items: center; gap: 0.6em; }
#tv-menu .menu-tabs { display: flex; gap: 0.3em; }
#tv-menu .menu-version { margin-left: auto; font-size: 0.55em; opacity: 0.6; }
/* The rows scroll on their own in a short window, so the help line under them always shows */
#tv-menu .menu-rows { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(140,255,140,0.4) transparent; }
#tv-menu .menu-row { display: flex; justify-content: space-between; align-items: center; padding: 0.16em 0.5em; cursor: pointer; }
/* Faint stripes, and a brighter one under the cursor, carry the eye from a label across to its value */
#tv-menu .menu-row:nth-child(even) { background: rgba(140,255,140,0.08); }
#tv-menu .menu-row:hover { background: rgba(140,255,140,0.22); }
#tv-menu .menu-row.sel { background: #8cff8c; color: #021; text-shadow: none; }
#tv-menu .menu-row.locked { opacity: 0.4; cursor: default; }
#tv-menu .menu-value { display: flex; align-items: center; gap: 0.6em; }
#tv-menu button { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0 0.2em; }
#tv-menu .menu-tab, #tv-menu .menu-close { font-size: 0.75em; padding: 0.05em 0.5em; border: 1px solid transparent; }
#tv-menu .menu-tab.on { border-color: #8cff8c; }
#tv-menu .menu-tab:hover, #tv-menu .menu-close:hover { background: rgba(140,255,140,0.22); }
#tv-menu .menu-tab.sel { background: #8cff8c; color: #021; text-shadow: none; }
#tv-menu .menu-hint { flex: none; box-sizing: border-box; margin-top: 0.3em; padding-top: 0.3em; min-height: 4.3em; border-top: 1px solid rgba(140,255,140,0.3); font-size: 0.8em; line-height: 1.3; opacity: 0.7; }

/* --- LIVE title card: a station ident that rolls in over the picture when the desktop goes on air --- */
#title-card {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.55), rgba(0,0,0,0.85));
  color: #ff5544;
  font-family: "VT323", "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 0.25em;
  text-shadow: 0 0 10px rgba(255,60,40,0.9), 0 0 2px rgba(0,0,0,0.9);
  font-size: clamp(14px, 3vw, 44px);
  opacity: 0;
  visibility: hidden;
}
#title-card .tc-live { font-size: 2.6em; }
#title-card .tc-name { color: #ffd6cc; letter-spacing: 0.12em; text-shadow: 0 0 8px rgba(255,120,100,0.8); }
#title-card.show { visibility: visible; animation: title-card 4.5s ease-out forwards; }
@keyframes title-card {
  0%   { opacity: 0; transform: scaleY(0.02); filter: brightness(3); }
  8%   { opacity: 1; transform: scaleY(1); filter: brightness(1.6); }
  80%  { opacity: 1; transform: scaleY(1); filter: brightness(1); }
  100% { opacity: 0; transform: scaleY(1); }
}
#tv-body:not(.powered-on) #title-card { display: none; }

/* The whole TV turns it on; once on, the cabinet (not the picture) turns it off. */
#tv-body:not(.powered-on) { cursor: pointer; }
#tv-body.powered-on { cursor: default; }
#tv-body.powered-on #tv-screen-area { cursor: crosshair; }

/* --- Branding --------------------------------------------------------------------------------- */
/* Power-on ident: logo and name fade in over the warm-up, once per visit */
#ident {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  background: radial-gradient(ellipse at center, rgba(10,0,20,0.7), rgba(0,0,0,0.95));
  font-family: "VT323", "Courier New", monospace;
  font-weight: bold;
  opacity: 0;
  visibility: hidden;
  font-size: clamp(12px, 2.4vw, 36px);
}
#ident img { width: 22%; max-width: 220px; filter: drop-shadow(0 0 18px rgba(150,80,255,0.7)); }
#ident .id-name { color: #d9c2ff; letter-spacing: 0.35em; font-size: 1.8em; text-shadow: 0 0 12px rgba(160,90,255,0.9); }
#ident .id-by { color: #8cff8c; letter-spacing: 0.25em; text-shadow: 0 0 8px rgba(80,255,80,0.8); }
#ident.show { visibility: visible; animation: ident 3.6s ease-in-out forwards; }
@keyframes ident {
  0% { opacity: 0; } 15% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; }
}
#tv-body:not(.powered-on) #ident { display: none; }

/* Bumper: a station ident line across the top of the picture */
#bumper {
  position: absolute;
  left: 0; right: 0; top: 18%;
  z-index: 3;
  pointer-events: none;
  text-align: center;
  padding: 0.5em 1em;
  background: rgba(0,0,0,0.55);
  color: #8cff8c;
  font-family: "VT323", "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 0.12em;
  text-shadow: 0 0 6px rgba(80,255,80,0.8);
  font-size: clamp(11px, 1.8vw, 26px);
  opacity: 0;
  transition: opacity 0.8s;
}
#bumper.show { opacity: 1; }
#bumper .bm-site { color: #d9c2ff; text-shadow: 0 0 8px rgba(160,90,255,0.9); }
#tv-body:not(.powered-on) #bumper { display: none; }

/* The ? page (also MENU › ABOUT): Liquid LSD on top; under the keys, the site with its QR code and the Spaz Radio app */
#keys .ab-head { display: flex; align-items: center; gap: 0.7em; margin-bottom: 0.3em; }
#keys .ab-head img { width: 2.4em; height: 2.4em; }
#keys .ab-name { font-size: 1.4em; letter-spacing: 0.3em; color: #d9c2ff; text-shadow: 0 0 10px rgba(160,90,255,0.9); }
#keys .ab-by { font-size: 0.8em; letter-spacing: 0.2em; }
#keys .ab-link { display: flex; align-items: center; gap: 0.8em; margin-top: 0.4em; }
#keys .ab-qr { flex: none; width: 5.2em; height: 5.2em; image-rendering: pixelated; border-radius: 3px; }
#keys .ab-text { display: flex; flex-direction: column; gap: 0.15em; }
#keys .ab-text p { margin: 0; line-height: 1.25; }
#keys .ab-text a { color: #d9c2ff; text-shadow: 0 0 8px rgba(160,90,255,0.8); }
body.kiosk #keys .ab-app { display: none; }
@media (max-width: 700px) { #keys .ab-text p { display: none; } #keys .ab-qr { width: 4em; height: 4em; } }
#osd-brand { font-size: 0.75em; margin-top: 0.3em; color: #d9c2ff; text-transform: none; }
#title-card .tc-from { font-size: 0.55em; letter-spacing: 0.3em; color: #d9c2ff; margin-top: 0.4em; }


/* SCHEDULE (schedule.js): the same page as ?, a list of the days and shows to come */
#schedule {
  position: absolute;
  inset: 0;
  z-index: 5;
  padding: 4% 8% 3%;
  background: rgba(0, 8, 0, 0.88);
  color: #8cff8c;
  font-family: "VT323", "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 0.04em;
  text-shadow: 0 0 6px rgba(80,255,80,0.7);
  font-size: clamp(10px, 1.45vw, 21px);
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  overflow: auto;
}
#schedule[hidden] { display: none; }
#schedule { scrollbar-width: thin; scrollbar-color: rgba(140,255,140,0.4) transparent; }
#schedule .sc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; flex-wrap: wrap; }
#schedule .sc-name { font-size: 1.4em; letter-spacing: 0.2em; color: #d9c2ff; text-shadow: 0 0 10px rgba(160,90,255,0.9); }
#schedule .sc-zone { font-size: 0.7em; opacity: 0.7; }
#schedule .sc-day { margin-top: 0.5em; color: #d9c2ff; letter-spacing: 0.15em; text-shadow: 0 0 8px rgba(160,90,255,0.8); }
#schedule .sc-show { display: flex; gap: 1em; padding: 0.05em 0.5em; }
#schedule .sc-time { flex: 0 0 auto; min-width: 13em; opacity: 0.85; }
#schedule .sc-show-name { flex: 1 1 auto; overflow-wrap: anywhere; }
#schedule .sc-show.on-air { background: #8cff8c; color: #021; text-shadow: none; }
#schedule .sc-on-air { margin-right: 0.6em; }
#schedule .sc-empty { margin-top: 1em; opacity: 0.8; }
#schedule .sc-hint { margin-top: auto; padding-top: 0.6em; font-size: 0.7em; opacity: 0.7; }
#tv-screen-area:has(#schedule:not([hidden])) #osd { visibility: hidden; }
@media (max-width: 700px) { #schedule .sc-time { min-width: 0; } #schedule .sc-show { flex-direction: column; gap: 0; } }

/* ? (and MENU › ABOUT): Liquid LSD and the keyboard shortcuts, and MENU › SKIPPED: the same page as SCHEDULE */
#keys, #skipped {
  position: absolute;
  inset: 0;
  z-index: 5;
  padding: 4% 8% 3%;
  background: rgba(0, 8, 0, 0.88);
  color: #8cff8c;
  font-family: "VT323", "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 0.04em;
  text-shadow: 0 0 6px rgba(80,255,80,0.7);
  font-size: clamp(10px, 1.45vw, 21px);
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(140,255,140,0.4) transparent;
}
#keys[hidden], #skipped[hidden] { display: none; }
#keys .ky-name, #skipped .ky-name { font-size: 1.4em; letter-spacing: 0.2em; color: #d9c2ff; text-shadow: 0 0 10px rgba(160,90,255,0.9); }
#keys .ky-groups { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1.5em; font-size: 0.8em; }
#keys .ky-group { break-inside: avoid; margin-bottom: 0.5em; }
#keys .ky-head { font-size: 0.8em; letter-spacing: 0.2em; opacity: 0.65; }
#keys .ky-list { display: grid; grid-template-columns: 6em 1fr; column-gap: 0.8em; margin: 0; }
#keys dd b { font-weight: inherit; color: #d9c2ff; text-shadow: 0 0 8px rgba(160,90,255,0.8); }
#keys dt { color: #d9c2ff; text-shadow: 0 0 8px rgba(160,90,255,0.8); white-space: nowrap; }
#keys dd { margin: 0; }
#keys .sc-hint, #skipped .sc-hint { margin-top: auto; padding-top: 0.6em; font-size: 0.7em; opacity: 0.7; }
body.kiosk #keys .ky-chat { display: none; }
#tv-screen-area:has(#keys:not([hidden])) #osd, #tv-screen-area:has(#skipped:not([hidden])) #osd { visibility: hidden; }
#skipped .sk-list { display: flex; flex-direction: column; margin: 0.4em 0 0; }
#skipped .sk-row { all: unset; display: flex; gap: 1.5em; padding: 0.05em 0.3em; cursor: pointer; }
#skipped .sk-row:hover, #skipped .sk-row:focus-visible, #skipped .sk-row.sel { background: rgba(140,255,140,0.18); }
#skipped .sk-ch { color: #d9c2ff; text-shadow: 0 0 8px rgba(160,90,255,0.8); white-space: nowrap; }
#skipped .sk-empty { opacity: 0.7; }
#skipped .sk-all { margin-top: 0.5em; color: #d9c2ff; text-shadow: 0 0 8px rgba(160,90,255,0.8); }

#tv-menu .menu-hint.help { opacity: 0.9; text-transform: none; letter-spacing: 0.02em; }

/* --- CHAT (chatboard.js): the Spaz Radio chat on a blackboard hung beside the TV ---------------------------
   Caveat (OFL, web/fonts/OFL.txt), served from here so it works offline. Name, line and time are styled apart:
   the line in bold chalk white, the name a size up in a pastel chalk (yellow is yours alone), the time small and
   faded without the chalk-dust blur. No letter-spacing anywhere: it breaks Caveat's joins. */
@font-face {
  font-family: "Caveat"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/caveat-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Caveat"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/caveat-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
:root {
  --slate: #21352e;
  --chalk: #eeebdd;
  --chalk-dim: #9ea79f;
  --chalk-yellow: #f4d06f;
  --chalk-font: "Caveat", "Comic Neue", "Comic Sans MS", cursive;
  --chalk-dust: 0 0 1px rgba(238, 235, 221, 0.6), 0 0 4px rgba(238, 235, 221, 0.2);
}

/* Side by side on a wide, landscape window: the TV gives up the board's width. */
#tv-wrapper { gap: 22px; align-items: stretch; }
@media (min-width: 1001px) and (orientation: landscape) {
  body.chat-open {
    --board-w: clamp(280px, 26vw, 400px);
    --tv-screen-w: min(calc(100vw - var(--board-w) - 140px), 128vh);
  }
}
#chalkboard { display: none; }
body.chat-open:not(.kiosk) #chalkboard {
  display: block;
  position: relative;          /* the slate is absolute: the board takes the TV's height, its lines never set it */
  flex: 0 0 var(--board-w, 320px);
  width: var(--board-w, 320px);
  border-radius: 12px;
  /* the wooden frame */
  background:
    linear-gradient(90deg, rgba(255,255,255,0.05), transparent 30%, rgba(0,0,0,0.12) 70%, rgba(255,255,255,0.04)),
    repeating-linear-gradient(88deg, var(--wood-a) 0 7px, var(--wood-b) 7px 11px, var(--wood-c) 11px 19px);
  box-shadow: inset 0 2px 1px rgba(255,220,180,0.25), inset 0 -2px 2px rgba(0,0,0,0.5),
    var(--tv-drop);
}
/* Narrow or portrait: the board hangs under the TV, and the page scrolls to it. */
@media (max-width: 1000px), (orientation: portrait) {
  #tv-wrapper { flex-direction: column; }
  body.chat-open:not(.kiosk) { overflow-y: auto; align-items: flex-start; padding-block: 12px; }
  body.chat-open:not(.kiosk) #chalkboard { width: 100%; flex: 0 0 auto; height: min(60vh, 520px); }
}

.cb-slate {
  position: absolute;
  inset: 14px 14px 30px 14px;
  display: flex;
  flex-direction: column;
  padding: 8px 14px 6px;
  border-radius: 3px;
  background-color: var(--slate);
  /* chalk dust: fine noise, plus a couple of faint eraser smears */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 .09 0 0 0 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 70% 22% at 32% 30%, rgba(238,235,221,0.045), transparent 70%),
    radial-gradient(ellipse 55% 18% at 70% 72%, rgba(238,235,221,0.035), transparent 70%);
  box-shadow: inset 0 0 18px rgba(0,0,0,0.55), 0 0 0 2px rgba(0,0,0,0.35);
  color: var(--chalk);
  font-family: var(--chalk-font);
  font-weight: 700;
  text-shadow: var(--chalk-dust);
  overflow: hidden;
}
.cb-slate button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-shadow: inherit; }

/* The X: obviously there, so the board is obviously optional */
.cb-close { position: absolute; top: 2px; right: 2px; width: 44px; height: 44px; display: grid; place-items: center; opacity: 0.85; }
.cb-close svg { width: 30px; height: 30px; fill: none; stroke: var(--chalk); stroke-width: 3.4; stroke-linecap: round;
  filter: drop-shadow(0 0 1px rgba(238,235,221,0.6)); }
.cb-close:hover, .cb-close:focus-visible { opacity: 1; }
.cb-close:hover svg, .cb-close:focus-visible svg { stroke: #fff; }
.cb-slate :focus-visible { outline: 2px dashed rgba(238,235,221,0.6); outline-offset: 2px; border-radius: 4px; }

.cb-title { margin: 0 44px 0 0; font-size: 30px; font-weight: 700; line-height: 1.3; color: var(--chalk-yellow);
  text-shadow: 0 0 1px rgba(244,208,111,0.6), 0 0 4px rgba(244,208,111,0.2);
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; text-decoration-color: rgba(244,208,111,0.5); }
.cb-roster { display: block; width: 100%; text-align: left; margin-top: 2px; font-size: 19px !important; font-weight: 500 !important;
  line-height: 1.35; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-roster.expanded { white-space: normal; }

.cb-log { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; margin: 6px -8px 0 0; padding-right: 8px;
  scrollbar-width: thin; scrollbar-color: rgba(238,235,221,0.3) transparent; }
.cb-msg { margin-top: 0.5em; }
.cb-msg.cont { margin-top: 0.1em; }
.cb-who { display: flex; align-items: baseline; gap: 0.5em; flex-wrap: wrap; }
.cb-name { font-size: 26px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.cb-time { font-size: 17px; font-weight: 500; color: var(--chalk-dim); text-shadow: none; white-space: nowrap; }
.cb-text { font-size: clamp(22px, 1.9vw, 26px); line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.cb-text a { color: inherit; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-color: rgba(238,235,221,0.55); }
.cb-text a:hover { text-decoration-color: var(--chalk); }
.cb-empty { margin-top: 1em; color: var(--chalk-dim); font-size: 22px; text-shadow: none; }
.cb-msg.new .cb-who, .cb-msg.new .cb-text { animation: cb-write 0.25s ease-out; }
@keyframes cb-write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* Pastel chalks for names, picked from the name; yellow is only ever your own (contrast on the slate 6.8-9:1) */
.cb-c0 { color: #f2a7b8; } .cb-c1 { color: #9fcbea; } .cb-c2 { color: #b5e3a1; } .cb-c3 { color: #f5b67a; } .cb-c4 { color: #c9b6f0; }
.cb-mine { color: var(--chalk-yellow); }
.cb-name[class*="cb-c"], .cb-mine { text-shadow: 0 0 1px currentColor, 0 0 4px rgba(255,255,255,0.08); }

.cb-newer { position: absolute; right: 18px; bottom: 74px; font-size: 22px !important; padding: 0 10px !important;
  border-radius: 14px; background: rgba(33,53,46,0.92) !important; box-shadow: 0 0 0 1.5px rgba(238,235,221,0.5); }
.cb-newer[hidden] { display: none; }

/* The bottom line: your name in yellow, then a chalk underline to write on */
.cb-form { display: flex; align-items: baseline; gap: 0.35em; margin-top: 6px; }
.cb-me { flex: 0 1 auto; max-width: 45%; font-size: 24px !important; color: var(--chalk-yellow) !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-me[hidden] { display: none; }
.cb-input { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 24px; font-weight: 700; color: var(--chalk); text-shadow: var(--chalk-dust);
  background: transparent; border: 0; border-bottom: 2px solid rgba(238,235,221,0.45); border-radius: 0; padding: 0 2px; caret-color: var(--chalk); }
.cb-input::placeholder { color: var(--chalk-dim); opacity: 0.8; font-weight: 500; text-shadow: none; }
.cb-input:focus { outline: none; border-bottom-color: rgba(238,235,221,0.8); }
.cb-status { min-height: 1.2em; font-size: 17px; font-weight: 500; color: var(--chalk-dim); text-shadow: none; line-height: 1.2; }

/* The chalk tray along the bottom of the frame: one stick of chalk and the eraser */
.cb-tray { position: absolute; left: 8px; right: 8px; bottom: 6px; height: 14px; border-radius: 2px;
  background: linear-gradient(var(--tray-hi), var(--tray-lo)); box-shadow: 0 2px 3px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,220,180,0.25); }
.cb-chalk { position: absolute; left: 22%; top: -3px; width: 34px; height: 7px; border-radius: 3px;
  background: linear-gradient(#fbf9f0, #d8d4c4); box-shadow: 0 1px 1px rgba(0,0,0,0.5); transform: rotate(-4deg); }
.cb-eraser { position: absolute; right: 16%; top: -9px; width: 54px; height: 13px; border-radius: 2px;
  background: linear-gradient(#4f4a44 0 55%, #d9d3c3 55% 100%); box-shadow: 0 1px 2px rgba(0,0,0,0.6); }

/* The CHAT button's LED: lit while the board is open, like HOLD's; blinks for new lines while it is closed */
#chatBtn.unread .btn-led { background: var(--lamp); box-shadow: var(--lamp-glow); }
body:not(.reduced-motion) #chatBtn.unread .btn-led { animation: cb-blink 1.6s ease-in-out infinite; }
@keyframes cb-blink { 50% { opacity: 0.45; } }

/* --- Embed (?embed): the picture only, inside a host app. Nothing on the page takes touches or shows chrome --- */
body.embed { overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; }
body.embed * { pointer-events: none; }
/* The picture fills the viewport by position, not by vh: Android's WebView can report 100vh as 0 (the canvas
   then had no height and the screen stayed black). */
body.embed #tv-screen-area { position: fixed; inset: 0; width: auto; height: auto; padding: 0; }
body.embed #osd, body.embed #title-card, body.embed #ident, body.embed #bumper,
body.embed #schedule, body.embed #keys, body.embed #tv-menu { display: none !important; }

/* --- TAPES (tapedeck.js): the archive list, the page SCHEDULE is, with a search and rows that pick --- */
#tapes {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  padding: 4% 6% 3%;
  background: rgba(0, 8, 0, 0.92);
  color: #8cff8c;
  font-family: "VT323", "Courier New", monospace;
  font-weight: bold;
  letter-spacing: 0.04em;
  text-shadow: 0 0 6px rgba(80,255,80,0.7);
  font-size: clamp(11px, 1.45vw, 21px);
}
#tapes[hidden] { display: none; }
#tv-screen-area:has(#tapes:not([hidden])) #osd { visibility: hidden; }
.tp-head { display: flex; justify-content: space-between; align-items: center; gap: 1em; }
.tp-name { font-size: 1.4em; letter-spacing: 0.2em; color: #d9c2ff; text-shadow: 0 0 10px rgba(160,90,255,0.9); }
.tp-close { flex: none; min-width: 2em; min-height: 2em; background: none; border: 1px solid rgba(140,255,140,0.45); color: inherit; font: inherit; cursor: pointer; }
.tp-close:hover, .tp-close:focus-visible { background: #8cff8c; color: #021; text-shadow: none; }
.tp-search {
  flex: none;
  width: 100%;
  box-sizing: border-box;
  padding: 0.2em 0.5em;
  background: rgba(0, 40, 0, 0.6);
  border: 1px solid rgba(140,255,140,0.45);
  border-radius: 0;
  color: inherit;
  font: inherit;
  text-shadow: inherit;
  outline: none;
}
.tp-search:focus { border-color: #8cff8c; box-shadow: 0 0 6px rgba(80,255,80,0.6); }
.tp-search::placeholder { color: rgba(140,255,140,0.55); }
.tp-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; position: relative; scrollbar-width: thin; scrollbar-color: rgba(140,255,140,0.4) transparent; }
.tp-sizer { position: relative; min-height: 100%; }
.tp-rows { position: absolute; top: 0; left: 0; right: 0; }
.tp-row {
  display: flex;
  width: 100%;
  gap: 1em;
  align-items: center;
  height: 1.6em;
  box-sizing: border-box;
  padding: 0 0.5em;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-shadow: inherit;
  text-align: left;
  cursor: pointer;
}
.tp-row:hover { background: rgba(140,255,140,0.15); }
.tp-row.sel { background: #8cff8c; color: #021; text-shadow: none; }
.tp-row.tp-action { color: #d9c2ff; text-shadow: 0 0 8px rgba(160,90,255,0.8); }
.tp-row.tp-action.sel { background: #d9c2ff; color: #102; text-shadow: none; }
.tp-date { flex: 0 0 7.5em; white-space: nowrap; overflow: hidden; }
.tp-dl { flex: 0 0 1.4em; align-self: stretch; display: flex; align-items: center; justify-content: center; margin: 0 -0.5em; color: inherit; text-decoration: none; opacity: 0.55; }
.tp-row:hover a.tp-dl, .tp-row.sel a.tp-dl { opacity: 0.85; }
a.tp-dl:hover, a.tp-dl:focus-visible { opacity: 1; background: rgba(140,255,140,0.3); }
.tp-title { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-len { flex: none; white-space: nowrap; opacity: 0.85; }
.tp-empty { margin-top: 1em; opacity: 0.8; }
.tp-hint { flex: none; padding-top: 0.3em; font-size: 0.7em; opacity: 0.7; }
.tp-app { flex: none; align-self: flex-start; margin-top: 0.3em; padding: 0.2em 0; font-size: 0.7em; color: #d9c2ff; text-decoration: none; opacity: 0.85; }
.tp-app:hover, .tp-app:focus-visible { opacity: 1; text-decoration: underline; }
@media (pointer: coarse) {
  #tapes { font-size: clamp(13px, 1.45vw, 21px); }
  .tp-row { height: 2.2em; }
  .tp-hint { display: none; }
}
@media (max-width: 700px) {
  .tp-date { flex-basis: 6.5em; font-size: 0.85em; }
}

/* The transport strip: along the bottom of the picture while the tape's info is up */
#tv-screen-area { --strip-h: clamp(34px, 5.5vw, 50px); }
#tape-strip {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 3%;
  z-index: 4;
  height: var(--strip-h);
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 3px;
  background: rgba(0, 8, 0, 0.72);
  border: 1px solid rgba(140,255,140,0.35);
  color: #8cff8c;
  font-family: "VT323", "Courier New", monospace;
  font-weight: bold;
  font-size: clamp(11px, 1.45vw, 20px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
#tape-strip.show { opacity: 1; visibility: visible; transition: opacity 0.1s; }
#tv-body:not(.powered-on) #tape-strip, .menu-open #tape-strip, .card-up #tape-strip { display: none; }
#tv-screen-area:has(#tapes:not([hidden])) #tape-strip, #tv-screen-area:has(#schedule:not([hidden])) #tape-strip,
#tv-screen-area:has(#keys:not([hidden])) #tape-strip,
#tv-screen-area:has(#skipped:not([hidden])) #tape-strip { display: none; }
#tv-screen-area:has(#tape-strip.show) #osd-info { bottom: calc(var(--strip-h) + 5%); }
.ts-btn { flex: none; min-width: 2.6em; padding: 0 0.3em; background: none; border: 1px solid rgba(140,255,140,0.35); color: inherit; font: inherit; cursor: pointer; }
.ts-btn:hover, .ts-btn:focus-visible { background: #8cff8c; color: #021; }
#tape-strip .ts-wave { position: static; display: block; flex: 1 1 0; min-width: 40px; width: 0; height: 100%; cursor: pointer; touch-action: none; }
.ts-clock { flex: none; align-self: center; padding: 0 0.3em; white-space: nowrap; }
@media (max-width: 700px) {
  .ts-eject, .ts-link { min-width: 0; }
  .ts-btn { min-width: 2.2em; }
  .ts-clock { font-size: 0.85em; }
}

/* On a tape, the source badge pulses red while a live show is on (eject or L to go back to it) */
#source-badge.on-air { border-color: #ff4d4d; color: #ff6b6b; animation: live-pulse 1.1s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
body.reduced-motion #source-badge.on-air { animation: none; }
/* A broadcast locks the viewer controls, but the archive is still there */
#tv-body.live #tapesBtn { opacity: 1; cursor: pointer; }
body.kiosk .kiosk-off { display: none; }

/* The chat's note that the viewer is hearing a tape */
.cb-tape { flex: none; margin: 0.1em 0 0.2em; font-size: 1.05rem; line-height: 1.1; opacity: 0.8; color: var(--chalk); }
.cb-tape[hidden] { display: none; }
