/* ─────────────────────────────────────────────────────────────
   JD PRODUCTIONS — palette
   Black is the base. Each colour has one job so it never turns
   into a rainbow:
     green  → the TV / signal / on-screen UI (phosphor)
     red    → cinema, power, recording
     yellow → light: sun, highlights, focus
     purple → night, and the "info" / story layer
   ───────────────────────────────────────────────────────────── */
:root {
  --ink: #0b0b0c;
  --ink-2: #141416;
  --ink-3: #1d1d21;
  --paper: #f4f1ea;
  --paper-2: #d9d4c8;
  --mute: #8f8a80;
  --green: #3ee06d;
  --green-dim: #1b7a3b;
  --red: #e3342b;
  --red-dk: #8f1a14;
  --yellow: #f3c23a;
  --purple: #7b54e0;

  --f-display: "Archivo", system-ui, sans-serif;
  --f-serif: "Instrument Serif", Georgia, serif;
  --f-osd: "VT323", ui-monospace, monospace;

  --ease: cubic-bezier(.22, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-display);
  font-variation-settings: "wdth" 100;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }

/* ───────── stages (16:9 renders scaled to cover the viewport) ───────── */
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage-img, .room-imgs img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; }

#frame { position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 2; overflow: hidden; transform-origin: 0 0; }
#world { position: absolute; left: 0; top: 0; width: 100vw; height: 100vh; }
#room, #gallery { position: absolute; inset: 0; overflow: hidden; }
#theater { position: fixed; inset: 0; z-index: 1; visibility: hidden; background: #000; overflow: hidden; }
#theater .theater-stage { visibility: hidden; }
#theater.on-A #theaterA, #theater.on-B #theaterB { visibility: visible; }
.screen-glow { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; opacity: .55;
  background: radial-gradient(60% 50% at var(--gx, 50%) var(--gy, 40%), rgba(255, 238, 220, .22), transparent 70%); }

/* ───────── room ───────── */
.room-imgs { position: absolute; inset: 0; z-index: 2; }
#roomStage { animation: breathe 5.5s ease-in-out infinite; transform-origin: 50% 70%; }
@keyframes breathe { 50% { transform: translateY(-0.25%) scale(1.004); } }
.room-imgs img { opacity: 0; transition: opacity 2.2s ease; }
.room-imgs img.on { opacity: 1; }
.tv-screen { position: absolute; z-index: 1; background: #000; overflow: hidden; }
.tv-screen canvas, #introVid, #ytWrap { position: absolute; inset: 0; width: 100%; height: 100%; }
#introVid { object-fit: contain; background: #000; opacity: 0; }
/* YouTube shown whole (16:9 inside the 4:3 tube) */
#ytWrap { overflow: hidden; visibility: hidden; }
#ytWrap.live { visibility: visible; }
#ytWrap iframe { position: absolute; left: 0; top: 50%; width: 100%; height: calc(100% * (4 / 3) / (16 / 9)); transform: translateY(-50%); pointer-events: none; border: 0; }
.yt-scan, .tv-glass { position: absolute; inset: 0; pointer-events: none; }
.yt-scan { background: repeating-linear-gradient(0deg, rgba(0,0,0,.28) 0 1px, transparent 1px 3px);
  box-shadow: inset 0 0 40px 12px rgba(0,0,0,.75); }
.tv-glass { background:
    radial-gradient(120% 90% at 30% 15%, rgba(255,255,255,.10), transparent 40%),
    radial-gradient(80% 60% at 75% 95%, rgba(255,255,255,.04), transparent 60%);
  box-shadow: inset 0 0 30px 8px rgba(0,0,0,.55); }

.tv-spill { position: absolute; inset: 0; z-index: 3; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(var(--spw, 17%) var(--sph, 26%) at var(--sx, 49.3%) var(--sy, 40%), var(--spill, rgba(120,150,255,.35)), transparent 70%);
  opacity: var(--spill-o, .5); transition: background .25s linear; }
#dust { position: absolute; inset: 0; z-index: 4; pointer-events: none; width: 100%; height: 100%; }

/* on-screen display (inside the tube) */
.osd { position: absolute; inset: 13% 14% 11%; z-index: 3; pointer-events: none; font-family: var(--f-osd); color: var(--green);
  text-shadow: 0 0 6px rgba(62,224,109,.8), 2px 2px 0 rgba(0,0,0,.6); font-size: clamp(12px, 1.35vw, 26px); line-height: 1; }
.osd-ch { position: absolute; right: 0; top: 0; font-size: 1.9em; opacity: 0; }
.osd-vol { position: absolute; left: 0; right: 0; bottom: 4%; opacity: 0; }
.osd-vol span { display: block; margin-bottom: .2em; }
.osd-vol i { display: block; height: .7em; background: repeating-linear-gradient(90deg, var(--green) 0 7%, transparent 7% 10%);
  width: calc(var(--v, .4) * 100%); box-shadow: 0 0 8px rgba(62,224,109,.6); }
.osd-msg { position: absolute; left: 0; top: 0; font-size: 1.2em; opacity: 0; max-width: 70%; }
.osd .show { opacity: 1; }


/* ───────── top bar ───────── */
.topbar { position: fixed; z-index: 20; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 24px;
  padding: max(18px, env(safe-area-inset-top)) clamp(16px, 3vw, 40px) 18px;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent); pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-rec { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); animation: pulse 2s infinite; }
.brand-text { font-weight: 800; font-size: 14px; letter-spacing: .14em; font-variation-settings: "wdth" 115; line-height: 1.15; }
.brand-text small { display: block; font-weight: 400; letter-spacing: .02em; font-size: 12px; color: var(--paper-2); font-variation-settings: "wdth" 100; }
.clock { margin-left: auto; }
.clock-btn { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 8px; border-radius: 99px; border: 1px solid rgba(255,255,255,.14);
  background: rgba(10,10,12,.35); backdrop-filter: blur(8px); transition: border-color .3s; }
.clock-btn:hover { border-color: var(--yellow); }
.clock-icon { width: 22px; height: 22px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 12px var(--yellow); transition: all .6s var(--ease); }
.clock-icon.night { background: transparent; box-shadow: inset -6px -3px 0 0 #d9ccff; filter: drop-shadow(0 0 6px var(--purple)); }
.clock-icon.golden { background: #ff9a2e; box-shadow: 0 0 14px #ff7a1a; }
.clock-icon.morning { background: #ffc7a8; box-shadow: 0 0 12px #ffb38a; }
.clock-text { text-align: left; line-height: 1.05; }
.clock-text b { font-family: var(--f-osd); font-weight: 400; font-size: 20px; letter-spacing: .04em; }
.clock-text small { display: block; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--paper-2); }
.toplinks { display: flex; gap: 4px; }
.toplinks > * { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; padding: 8px 12px; border-radius: 99px; text-decoration: none; transition: background .2s, color .2s; }
.toplinks > *:hover { background: var(--paper); color: var(--ink); }

/* ───────── now playing ───────── */
.now { position: fixed; z-index: 15; left: clamp(16px, 3vw, 40px); bottom: clamp(16px, 3vw, 36px); display: flex; gap: 16px; align-items: flex-start;
  max-width: min(460px, calc(100vw - 32px)); padding: 16px 18px; border-radius: 14px; background: rgba(8,8,10,.62); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.08); transition: opacity .5s, transform .5s var(--ease); }
.now.hide { opacity: 0; transform: translateY(20px); pointer-events: none; }
.now-ch { font-family: var(--f-osd); font-size: 28px; color: var(--green); text-shadow: 0 0 10px rgba(62,224,109,.6); line-height: .9; white-space: nowrap; }
.now-body { flex: 1; min-width: 0; }
.now-artist { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--paper-2); }
.now-title { font-family: var(--f-serif); font-size: 30px; line-height: 1; margin: 4px 0 6px; }
.now-meta { font-size: 12px; color: var(--mute); }
.now-actions { display: flex; flex-direction: column; gap: 6px; }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 99px; font-size: 12px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; text-decoration: none; background: var(--paper); color: var(--ink); white-space: nowrap; transition: transform .2s, background .2s; }
.chip:hover { transform: translateY(-1px); background: var(--yellow); }
.chip.ghost { background: transparent; color: var(--paper); border: 1px solid rgba(255,255,255,.25); }
.chip.ghost:hover { border-color: var(--yellow); color: var(--yellow); background: transparent; }

/* ───────── remote ─────────
   Resting on the armrest (glowing outline). Click it or the "Remote" button → Blender-rendered grab
   animation plays on a canvas that sits exactly over the render → it ends up in your hand, keys live.
   Nothing in the room moves, so nothing ever uncovers black. */
#roomLift { position: absolute; inset: 0; }
.arm-patch { position: absolute; z-index: 5; pointer-events: none; visibility: hidden; }
.arm-patch.on { visibility: visible; }
.remote-hint { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; overflow: visible; }
.remote-hint polygon { fill: rgba(243,194,58,.001); stroke: var(--yellow); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round;
  pointer-events: auto; cursor: pointer; filter: drop-shadow(0 0 6px rgba(243,194,58,.9)); animation: hint-pulse 2.4s ease-in-out infinite; transition: fill .2s; }
.remote-hint polygon:hover { fill: rgba(243,194,58,.12); animation-play-state: paused; stroke-opacity: 1; }
@keyframes hint-pulse { 0%, 100% { stroke-opacity: .15; } 50% { stroke-opacity: .85; } }
body.remote-up .remote-hint, body.remote-up .pickup { display: none; }
.pickup { position: absolute; z-index: 7; transform: translate(-100%, -120%); padding: 8px 14px 8px 12px; border-radius: 99px; background: rgba(8,8,10,.72);
  backdrop-filter: blur(6px); border: 1px solid rgba(243,194,58,.5); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap;
  display: flex; align-items: center; gap: 8px; opacity: 0; transition: opacity .4s; }
.pickup::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.pickup.show, .pickup:hover { opacity: 1; }
.remote-anim { position: absolute; z-index: 8; pointer-events: none; visibility: hidden; }
.remote-anim.on { visibility: visible; }
.remote-anim canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.remote-keys { position: absolute; inset: 0; pointer-events: none; }
body.remote-ready .remote-keys .rk { pointer-events: auto; }
.remote-float { position: fixed; z-index: 46; pointer-events: none; }

/* keys */
.rk { position: absolute; transform: translate(-50%, -50%); aspect-ratio: 1; border-radius: 50%; pointer-events: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: box-shadow .15s, background .15s; }
.rk:hover, .rk:focus-visible { box-shadow: 0 0 0 1.5px rgba(243,194,58,.85), 0 0 14px 2px rgba(243,194,58,.35); outline: none; }
.rk.press { background: radial-gradient(circle, rgba(0,0,0,.5), rgba(0,0,0,.18) 60%, transparent 72%); box-shadow: 0 0 0 1.5px rgba(255,255,255,.5); }
.rk-led { position: absolute; transform: translate(-50%, -50%); aspect-ratio: 1; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, #ff3b2a 0 30%, rgba(255,40,20,.45) 45%, transparent 70%); mix-blend-mode: screen; transition: opacity .05s; }
.rk-led.on { opacity: 1; }
.key-tip { position: fixed; z-index: 60; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: rgba(8,8,10,.85); backdrop-filter: blur(6px);
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; opacity: 0; transform: translate(-50%, calc(-100% - 14px)); transition: opacity .15s; }
.key-tip.show { opacity: 1; }
.key-tip kbd { font-family: var(--f-osd); font-size: 14px; color: var(--green); margin-left: 8px; letter-spacing: 0; }

/* "Remote" button */
.remote-toggle { position: fixed; z-index: 44; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  padding: 11px 20px 11px 14px; border-radius: 99px; background: rgba(12,12,14,.72); backdrop-filter: blur(10px); color: var(--paper);
  border: 1px solid rgba(243,194,58,.45); font-weight: 700; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; box-shadow: 0 10px 30px rgba(0,0,0,.45);
  transition: opacity .3s, border-color .3s; animation: toggle-glow 2.4s ease-in-out infinite; }
.remote-toggle:hover { border-color: var(--yellow); }
@keyframes toggle-glow { 50% { box-shadow: 0 10px 30px rgba(0,0,0,.45), 0 0 18px rgba(243,194,58,.35); } }
.remote-toggle i { width: 9px; height: 24px; border-radius: 4px; background: linear-gradient(#2a2a2e, #111); border: 1px solid #444; position: relative; }
.remote-toggle i::before { content: ""; position: absolute; left: 50%; top: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--red); box-shadow: 0 0 6px var(--red); }
body.remote-up .remote-toggle { animation: none; }
body.mode-player .remote-toggle { display: none; }
@media (max-width: 760px) {
  body.remote-up .now { opacity: 0; pointer-events: none; }
  body.remote-up .remote-toggle { left: 14px; transform: none; }
}

/* ───────── overlays ───────── */
.overlay { position: fixed; inset: 0; z-index: 40; }
.x { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border-radius: 50%; font-size: 15px; background: rgba(255,255,255,.08); transition: background .2s, transform .3s; }
.x:hover { background: var(--red); transform: rotate(90deg); }

/* program guide — a 90s cable guide, but readable */
.guide { background: rgba(4,8,6,.86); backdrop-filter: blur(10px); display: grid; place-items: center; padding: 20px; }
.guide-inner { position: relative; width: min(1100px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  border: 1px solid rgba(62,224,109,.3); border-radius: 18px; background: linear-gradient(180deg, #07130c, #050806); overflow: hidden;
  box-shadow: 0 0 80px rgba(62,224,109,.12); }
.guide-head { display: flex; justify-content: space-between; padding: 26px 28px 10px; }
.guide-kicker { font-family: var(--f-osd); color: var(--green); font-size: 20px; letter-spacing: .08em; }
.guide-head h2 { font-family: var(--f-serif); font-weight: 400; font-size: clamp(30px, 4vw, 48px); line-height: 1; margin-top: 4px; }
.guide-head .x { position: static; }
.guide-tabs { display: flex; gap: 6px; padding: 8px 28px 16px; flex-wrap: wrap; }
.guide-tabs button { padding: 7px 14px; border-radius: 99px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; border: 1px solid rgba(62,224,109,.3); color: #bfe9cc; }
.guide-tabs button.on, .guide-tabs button:hover { background: var(--green); color: #031008; border-color: var(--green); }
.guide-list { overflow: auto; padding: 0 16px 16px; scrollbar-color: var(--green-dim) transparent; }
.g-row { display: grid; grid-template-columns: 64px 120px 1fr 150px 30px; gap: 16px; align-items: center; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px; border-top: 1px solid rgba(62,224,109,.08); transition: background .15s; }
.g-row:hover, .g-row:focus-visible { background: rgba(62,224,109,.1); }
.g-row.live { background: rgba(62,224,109,.16); }
.g-ch { font-family: var(--f-osd); font-size: 30px; color: var(--green); }
.g-thumb { width: 120px; aspect-ratio: 16/9; border-radius: 6px; background: #0e1a12 center/cover no-repeat; filter: saturate(.85); }
.g-main small { display: block; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #8fb79b; }
.g-main b { font-family: var(--f-serif); font-weight: 400; font-size: 24px; }
.g-main em { font-style: normal; font-size: 12px; color: #7d8f82; display: block; }
.g-kind { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #bfe9cc; }
.g-live { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); opacity: 0; }
.g-row.live .g-live { opacity: 1; animation: pulse 1.2s infinite; }
.guide-foot { padding: 12px 28px; font-family: var(--f-osd); font-size: 17px; color: #5f9d72; border-top: 1px solid rgba(62,224,109,.15); }
@keyframes pulse { 50% { opacity: .3; } }

/* about — VHS sleeve */
.info { background: rgba(10,6,20,.78); backdrop-filter: blur(10px); display: grid; place-items: center; padding: 20px; overflow: auto; }
.vhs { display: grid; grid-template-columns: minmax(260px, 380px) minmax(0, 620px); max-height: calc(100vh - 40px); border-radius: 8px; overflow: hidden;
  box-shadow: 0 40px 100px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.06); }
.vhs-front { position: relative; background: #0e0e10; min-height: 560px; overflow: hidden; }
.vhs-cover { position: absolute; inset: 0; background-size: cover; background-position: center; filter: saturate(1.1) contrast(1.05); }
.vhs-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.2), rgba(0,0,0,.1) 40%, rgba(0,0,0,.9)); }
.vhs-stripe { position: absolute; z-index: 2; top: 0; bottom: 0; left: 18px; width: 22px;
  background: linear-gradient(90deg, var(--red) 0 70%, transparent 70% 80%, var(--yellow) 80%); opacity: .95; }
.vhs-title { position: absolute; z-index: 2; left: 60px; right: 22px; bottom: 70px; }
.vhs-title small { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--yellow); }
.vhs-title h2 { font-size: clamp(54px, 7vw, 86px); line-height: .86; font-weight: 900; font-variation-settings: "wdth" 70; text-transform: uppercase; margin: 8px 0 12px; }
.vhs-title p { font-size: 13px; color: var(--paper-2); }
.vhs-badges { position: absolute; z-index: 2; left: 60px; bottom: 24px; display: flex; gap: 6px; }
.vhs-badges span { font-size: 9px; letter-spacing: .14em; font-weight: 700; padding: 4px 7px; border: 1px solid rgba(255,255,255,.5); border-radius: 3px; }
.vhs-back { position: relative; background: var(--paper); color: var(--ink); padding: 44px 44px 30px; overflow: auto; font-size: 15px; line-height: 1.6; }
.vhs-back .x { background: rgba(0,0,0,.06); }
.vhs-back p { margin-bottom: 14px; max-width: 60ch; }
.vhs-quote { font-family: var(--f-serif); font-size: 30px; line-height: 1.1; font-style: italic; color: var(--red-dk); }
.vhs-with { font-size: 13px; color: #4a463f; }
.vhs-with b { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--ink); margin-right: 6px; }
.vhs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; margin: 22px 0; padding: 20px 0; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.vhs-grid h4, .vhs-contact h4 { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; margin-bottom: 4px; }
.vhs-grid p { font-size: 13px; margin: 0; line-height: 1.45; color: #3a3731; }
.vhs-contact .chip { background: var(--ink); color: var(--paper); }
.vhs-contact .chip.ghost { background: transparent; color: var(--ink); border-color: rgba(0,0,0,.3); }
.vhs-contact .chip:hover { background: var(--red); color: #fff; }
.vhs-links { display: flex; gap: 8px; flex-wrap: wrap; }
.vhs-barcode { display: flex; align-items: center; gap: 12px; margin-top: 26px; font-family: var(--f-osd); font-size: 16px; color: #6b665d; }
.vhs-barcode i { flex: 0 0 90px; height: 26px; background: repeating-linear-gradient(90deg, #111 0 2px, transparent 2px 4px, #111 4px 5px, transparent 5px 8px); }

/* clean player */
.player { background: #000; display: grid; grid-template-rows: 1fr auto; }
.player-frame { position: relative; display: grid; place-items: center; min-height: 0; }
.player-frame video, .player-frame iframe { width: 100%; height: 100%; max-height: calc(100vh - 70px); object-fit: contain; border: 0; background: #000; }
.player-actions { display: flex; gap: 8px; }
.player-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px clamp(16px, 3vw, 40px); }
.player-title { font-family: var(--f-serif); font-size: 24px; }
.player-title small { font-family: var(--f-display); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); margin-right: 10px; }

/* lightbox */
.lightbox { background: rgba(244,241,234,.97); display: grid; place-items: center; color: var(--ink); }
.lightbox img { max-width: 88vw; max-height: 80vh; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.lb-cap { position: absolute; left: 0; right: 0; bottom: 22px; text-align: center; font-family: var(--f-serif); font-size: 20px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 54px; width: 64px; height: 64px; color: var(--ink); }
.lb-nav.prev { left: 12px; } .lb-nav.next { right: 12px; }
.lightbox .x { background: rgba(0,0,0,.06); color: var(--ink); }

/* ───────── cinematic layer ───────── */
#cine { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.cine-title { position: absolute; left: 0; right: 0; bottom: 3vh; text-align: center; opacity: 0; }
.cine-title small { display: block; font-size: 10px; letter-spacing: .4em; text-transform: uppercase; color: var(--yellow); }
.cine-title span { display: block; font-family: var(--f-serif); font-size: clamp(28px, 4vw, 54px); font-style: italic; line-height: 1.1; }
.cine-title em { font-style: normal; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--paper-2); }
.flash { position: absolute; inset: 0; background: #000; opacity: 0; }

/* audience */
.audience { position: absolute; inset: 0; pointer-events: none; }
.seat-person { position: absolute; transform: translate(-50%, -14%); animation: bob var(--bob) ease-in-out var(--delay) infinite; transform-origin: 50% 100%; }
.seat-person svg { display: block; width: 100%; height: auto; overflow: visible; }
#audienceB .seat-person svg { filter: url(#boil); }
.seat-person.react-lean { animation: none; transform: translate(-50%, -14%) rotate(var(--lean)) translateX(4%); transition: transform .5s var(--ease); }
.seat-person.react-laugh { animation: laugh .18s ease-in-out 6; }
@keyframes bob { 50% { transform: translate(-50%, -15.5%) rotate(calc(var(--lean) * .2)); } }
@keyframes laugh { 50% { transform: translate(-50%, -17%); } }

/* ───────── gallery (the white room inside the movie) ───────── */
#gallery { background: #f3f1ec; color: var(--ink); }
.gal-track { position: absolute; inset: 0; display: flex; align-items: stretch; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior: contain; }
.gal-track::-webkit-scrollbar { display: none; }
.gal-floor { position: absolute; left: 0; right: 0; bottom: 0; height: 17vh; pointer-events: none;
  background: linear-gradient(180deg, #d8d4cb 0, #e6e2da 8%, #eeebe4 100%); box-shadow: 0 -1px 0 #c9c4b8; }
.gal-wall { position: relative; flex: 0 0 auto; height: 100%; display: flex; align-items: center; gap: clamp(40px, 6vw, 110px); padding: 0 clamp(60px, 8vw, 140px) 17vh; }
.gal-wall::before { content: ""; position: absolute; inset: 0 0 17vh; background: radial-gradient(70% 55% at 50% 0%, var(--wash, transparent), transparent 70%); pointer-events: none; }
.gal-wall + .gal-wall { border-left: 1px solid rgba(0,0,0,.05); }
.gal-intro { width: min(520px, 80vw); }
.gal-intro .kicker { font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--mute); }
.gal-intro h1 { font-family: var(--f-serif); font-weight: 400; font-size: clamp(56px, 8vw, 120px); line-height: .88; margin: 12px 0 18px; }
.gal-intro h1 em { color: var(--red); }
.gal-intro p { font-size: 15px; line-height: 1.6; color: #4a463f; max-width: 42ch; }
.gal-intro .hint { margin-top: 24px; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--mute); display: flex; align-items: center; gap: 10px; }
.gal-intro .hint i { width: 40px; height: 1px; background: currentColor; animation: hint 1.6s ease-in-out infinite; transform-origin: left; }
@keyframes hint { 50% { transform: scaleX(1.6); } }
.room-sign { width: 280px; flex: 0 0 auto; }
.room-sign .num { font-family: var(--f-serif); font-size: 96px; line-height: .8; color: var(--accent); }
.room-sign h2 { font-size: 13px; letter-spacing: .3em; text-transform: uppercase; margin: 14px 0 10px; font-weight: 700; }
.room-sign p { font-family: var(--f-serif); font-size: 22px; line-height: 1.2; color: #3a3731; }
.room-sign .swatch { width: 44px; height: 6px; background: var(--accent); margin-top: 18px; }
.frame { position: relative; flex: 0 0 auto; background: #fff; padding: clamp(10px, 1.4vw, 22px); box-shadow: 0 1px 0 #111, 0 0 0 2px #151515, 0 22px 30px -12px rgba(0,0,0,.35), 0 50px 70px -40px rgba(0,0,0,.35);
  cursor: zoom-in; transition: transform .6s var(--ease), box-shadow .6s var(--ease); }
.frame:hover { transform: translateY(-6px); box-shadow: 0 1px 0 #111, 0 0 0 2px #151515, 0 34px 40px -14px rgba(0,0,0,.4), 0 60px 90px -40px rgba(0,0,0,.35); }
.frame img { display: block; height: 100%; width: auto; }
.frame.land { height: clamp(180px, 34vh, 380px); }
.frame.port { height: clamp(240px, 48vh, 520px); }
.frame.sq { height: clamp(220px, 42vh, 460px); }
.frame .plate { position: absolute; left: 0; top: calc(100% + 26px); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #6b665d; white-space: nowrap; }
.frame .plate b { color: var(--accent); margin-right: 6px; }
.gal-exit { width: min(460px, 80vw); }
.gal-exit h2 { font-family: var(--f-serif); font-weight: 400; font-size: clamp(44px, 6vw, 80px); line-height: .95; margin-bottom: 18px; }
.gal-exit p { font-size: 15px; line-height: 1.6; color: #4a463f; margin-bottom: 20px; }
.gal-exit .chip { background: var(--ink); color: var(--paper); }
.gal-exit .chip.ghost { background: transparent; color: var(--ink); border-color: rgba(0,0,0,.25); }
.gal-bar { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 20px; padding: 18px clamp(16px, 3vw, 40px); }
.gal-back { display: flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 99px; background: var(--ink); color: var(--paper); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.gal-back:hover { background: var(--red); }
.gal-progress { flex: 1; height: 2px; background: rgba(0,0,0,.1); }
.gal-progress i { display: block; height: 100%; width: 0; background: var(--ink); }
.gal-room { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; min-width: 120px; text-align: right; }

/* ───────── gate ───────── */
#gate { position: fixed; inset: 0; z-index: 60; background: #000; display: grid; place-items: center; transition: opacity .8s; }
#gate.gone { opacity: 0; pointer-events: none; }
.gate-inner { text-align: center; }
.gate-kicker { font-size: 11px; letter-spacing: .5em; color: #6f6b64; margin-bottom: 34px; }
.gate-power { position: relative; width: 108px; height: 108px; border-radius: 50%; display: grid; place-items: center; color: var(--red); font-size: 34px;
  background: radial-gradient(circle at 40% 35%, #1d1d21, #0a0a0b); box-shadow: 0 0 0 1px #242428, 0 10px 30px rgba(0,0,0,.8); transition: transform .3s var(--ease), color .3s; }
.gate-power:hover { transform: scale(1.05); color: #fff; }
.gate-ring { position: absolute; inset: -10px; border-radius: 50%; border: 1px solid rgba(227,52,43,.45); animation: ring 2.2s ease-out infinite; }
@keyframes ring { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
.gate-sym { filter: drop-shadow(0 0 10px rgba(227,52,43,.8)); }
.gate-cta { margin-top: 30px; font-family: var(--f-serif); font-size: 30px; font-style: italic; }
.gate-note { margin-top: 6px; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: #6f6b64; }
.gate-skip { margin-top: 40px; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: #6f6b64; border-bottom: 1px solid #333; padding-bottom: 3px; }
.gate-skip:hover { color: var(--paper); }
.gate-led { width: 6px; height: 6px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); margin: 0 auto 18px; animation: pulse 1.6s infinite; }
.gate-loading { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; }
.gate-loading i { display: block; height: 100%; width: 0; background: var(--red); transition: width .3s; }

/* film grain over everything */
.grain { position: fixed; inset: -50%; z-index: 55; pointer-events: none; opacity: .07; mix-blend-mode: overlay; animation: grain .5s steps(4) infinite; }
@keyframes grain { 25% { transform: translate(-3%, 2%); } 50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -1%); } }

body.is-booting .topbar, body.is-booting .now, body.is-booting .remote-toggle { opacity: 0; pointer-events: none; }
.topbar, .now { transition: opacity .8s, transform .6s var(--ease); }
body.mode-cinema .topbar, body.mode-cinema .now, body.mode-cinema .remote-toggle { opacity: 0; pointer-events: none; }
body.mode-gallery .topbar, body.mode-gallery .now, body.mode-gallery .remote-toggle { opacity: 0; pointer-events: none; }
body.mode-gallery .topbar *, body.mode-cinema .topbar * { pointer-events: none !important; }

/* ───────── small screens ───────── */
@media (max-width: 760px) {
  .toplinks { display: none; }
  .brand-text small { display: none; }
  .now { left: 12px; right: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 58px); bottom: auto; max-width: none; padding: 10px 14px; }
  .now-title { font-size: 24px; }
  .now-meta { display: none; }
  .vhs { grid-template-columns: 1fr; max-height: none; }
  .vhs-front { min-height: 380px; }
  .vhs-back { padding: 30px 22px; }
  .g-row { grid-template-columns: 44px 1fr 24px; }
  .g-thumb, .g-kind { display: none; }
  .room-sign { width: 220px; }
  .clock-text small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .grain, .seat-person, .gate-ring { animation: none !important; }
}


/* desktop: the Remote button lives in the now-playing card; phones keep the floating pill */
@media (min-width: 761px) { .remote-toggle { display: none; } }
@media (max-width: 760px) { .now-remote { display: none; } }
@media (max-width: 1100px) { .brand-text small { display: none; } .toplinks > * { padding: 8px 9px; } }

/* the TV's two playback decks: rendered (iPhones need that for WebGL) but invisible */
.tv-deck { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: .01; pointer-events: none; z-index: -1; }

/* ───────── cinema: cheap letterbox bars (GPU transforms, no per-frame clip repaint) ───────── */
.cine-bar { position: fixed; left: 0; right: 0; height: var(--bar, 0px); background: #000; will-change: transform; visibility: hidden; }
.cine-bar.top { top: 0; transform: translateY(-100%); }
.cine-bar.bot { bottom: 0; transform: translateY(100%); }
#theater { will-change: transform; }

/* keep phones smooth while the sequence runs: pause what nobody is looking at */
body.mode-cinema .grain, body.mode-cinema #dust { display: none; }
body.mode-cinema #roomStage { animation: none; }
@media (pointer: coarse), (max-width: 760px) {
  .seat-person { animation: none !important; }
  #audienceB .seat-person svg { filter: none; }
  .grain { display: none; }
}

/* ───────── the room as a projected film on the theater screen ───────── */
.proj-fx { position: absolute; inset: 0; z-index: 20; pointer-events: none; opacity: 0; transition: opacity .8s ease; overflow: hidden; }
.proj-fx::before { /* projector hot-spot + lamp falloff toward the edges */
  content: ""; position: absolute; inset: 0; mix-blend-mode: screen;
  background: radial-gradient(ellipse 55% 60% at 50% 46%, rgba(255,244,222,.20), rgba(255,244,222,.06) 45%, transparent 70%); }
.proj-fx::after { /* vignette + film grain */
  content: ""; position: absolute; inset: -20%;
  background:
    radial-gradient(ellipse at center, transparent 48%, rgba(0,0,0,.62) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  background-size: 100% 100%, 160px 160px; mix-blend-mode: overlay; opacity: .55; animation: proj-grain .3s steps(3) infinite; }
.proj-fx .scratch { position: absolute; top: -5%; bottom: -5%; width: 1.5px; background: rgba(255,250,240,.35); left: 22%; opacity: 0; animation: scratch 2.3s steps(1) infinite; }
.proj-fx .scratch.s2 { left: 71%; width: 1px; animation-duration: 3.1s; animation-delay: -1.2s; }
body.projecting .proj-fx { opacity: 1; animation: proj-flicker .16s steps(2) infinite; }
@keyframes proj-flicker { 50% { opacity: .9; } }
@keyframes proj-grain { 33% { transform: translate(-3%, 2%); } 66% { transform: translate(2%, -2%); } }
@keyframes scratch { 0% { opacity: 0; } 12% { opacity: .8; transform: translateX(0); } 18% { opacity: 0; transform: translateX(6px); } 55% { opacity: .5; transform: translateX(-30px); } 60% { opacity: 0; } }
@media (pointer: fine) {
  /* on desktop also grade the picture like a print on a screen and add a gentle gate weave */
  body.projecting #room { filter: sepia(.16) saturate(.86) contrast(.92) brightness(1.06); animation: weave .24s steps(1) infinite; }
  @keyframes weave { 25% { transform: translate(.6px, -.4px); } 50% { transform: translate(-.4px, .5px); } 75% { transform: translate(.3px, .2px); } }
}
/* projector beam through the haze over the audience */
.proj-beam { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; opacity: 0; transition: opacity 1s;
  background: linear-gradient(to bottom, rgba(255,240,215,.13), rgba(255,240,215,.05) 70%, rgba(255,240,215,.02));
  clip-path: polygon(14% 0%, 86% 0%, var(--sx1) var(--sy1), var(--sx0) var(--sy1)); }
body.projecting .proj-beam { opacity: 1; animation: proj-flicker .16s steps(2) infinite; }
body.projecting .screen-glow { animation: proj-flicker .16s steps(2) infinite; opacity: .75; }

/* ═════════ performance pass ═════════
   Full-screen blend layers, backdrop blurs over the live TV canvas and always-on layer hints were exhausting
   the GPU (black unpainted strips, panels cut in half, flicker on hover). Same look, far cheaper. */
.grain { display: none !important; }
.now, .clock-btn, .guide, .info, .pickup, .key-tip, .remote-toggle { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
.now { background: rgba(10,10,12,.9); }
.clock-btn { background: rgba(10,10,12,.72); }
.guide { background: rgba(3,8,5,.95); }
.info { background: rgba(8,5,16,.93); }
.pickup, .key-tip, .remote-toggle { background: rgba(10,10,12,.9); }
.chip:hover { transform: none; }
#roomStage { animation: none !important; }
#frame, #theater { will-change: auto; }
body.mode-cinema #frame, body.mode-cinema #theater { will-change: transform; }
.remote-hint polygon { filter: none; stroke-width: 2.5; }
.seat-person, #audienceB .seat-person svg, .seat-person svg { animation: none !important; filter: none !important; }
/* projector look without blend modes or big moving layers */
body.projecting #room { filter: none !important; animation: none !important; }
.proj-fx::before { mix-blend-mode: normal; background: radial-gradient(ellipse 55% 60% at 50% 46%, rgba(255,244,222,.09), transparent 70%); }
.proj-fx::after { mix-blend-mode: normal; inset: 0; opacity: .18; animation: none; }
.proj-beam, .screen-glow { mix-blend-mode: normal; }
.screen-glow { opacity: .35; }
.rk-led { mix-blend-mode: normal; }
.tv-spill { mix-blend-mode: normal; transition: none; }

/* audience painted once into a bitmap (brush-stroke look baked in); two "boil" frames alternate */
.audience img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; }
.audience img + img { visibility: hidden; }
.audience.boil-b img:first-child { visibility: hidden; }
.audience.boil-b img + img { visibility: visible; }

/* ═════════ round 6 ═════════ */
/* on-screen display: channel number top-right, programme name as a two-line lower third, sized to the tube */
.osd { font-size: calc(var(--tvw, 300px) * .05); inset: 12% 13% 12%; }
.osd-ch { top: 0; right: 0; font-size: 1.7em; }
.osd-msg { top: auto; bottom: 0; left: 0; right: 0; max-width: none; font-size: 1em; line-height: 1.05; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.osd-vol { bottom: 0; }
.osd-vol.show + .osd-msg { opacity: 0; }

/* layering: the room is its own group, the gallery always sits above it (it used to show only through the TV hole) */
#room { z-index: 0; isolation: isolate; }
#gallery { z-index: 1; }

/* animated overlays get their own GPU layers so they never force the zooming scene to repaint */
.proj-fx, .proj-beam, .screen-glow, #flash { will-change: opacity; }
.proj-fx .scratch { will-change: transform, opacity; }
body.mode-cinema #gallery { will-change: opacity; }
/* audience = one still, pre-drawn brush-stroke image per shot (inherits the theater's visibility) */
.audience img + img { display: none !important; }

/* ═════════ round 7: theater back to the simple first-version look — no projector overlays ═════════ */
.proj-fx, .proj-beam { display: none !important; }
body.projecting .screen-glow, .screen-glow { animation: none !important; }

/* the tube sits above the room JPEG, cut to the exact screen shape by a mask */
.tv-screen { z-index: 3; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
