:root {
  --room: #1d130d;
  --cream: #f3e3c3;
  --orange: #e2772b;
  --mustard: #d9a52e;
  --wood-1: #7a4423;
  --wood-2: #5a2f17;
  --wood-3: #3c1e0e;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

[hidden] { display: none !important; }

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 90% 60% at 50% 30%, #4a2c18 0%, transparent 70%),
    var(--room);
  color: var(--cream);
  font-family: Georgia, 'Times New Roman', serif;
  -webkit-tap-highlight-color: transparent;
}

.room {
  max-width: 1160px;
  margin: 0 auto;
  padding: 22px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- heading ---------- */

.masthead { text-align: center; margin-bottom: 26px; }
.masthead h1 {
  margin: 0;
  font: 400 clamp(34px, 7vw, 60px)/1 'Righteous', 'Cooper Black', Georgia, serif;
  letter-spacing: .02em;
  color: var(--cream);
  text-shadow: 3px 3px 0 var(--orange), 6px 6px 0 #8f3d1c;
}

/* ---------- the TV ---------- */

/* The set is sized from the height of the window as well as its width, so the whole TV,
   the title plate and the buttons under it fit on screen without scrolling.
   --rest is the room the heading and those controls need; 1.69 is the set's width for each unit of height. */
.tv-wrap {
  --rest: 318px;
  width: min(100%, 1100px, max(530px, (100vh - var(--rest)) * 1.69));
  container-type: inline-size;
}

/* on a short, wide window the heading gives up room to the TV */
@media (max-height: 800px) and (min-aspect-ratio: 1 / 1) {
  .room { padding-top: 12px; }
  .masthead { margin-bottom: 14px; }
  .masthead h1 { font-size: clamp(28px, 6vh, 44px); text-shadow: 2px 2px 0 var(--orange), 4px 4px 0 #8f3d1c; }
  .masthead .home { margin-top: 10px; min-height: 36px; }
  .tv-wrap { --rest: 250px; }
}

.tv { position: relative; }

.cabinet {
  position: relative;
  padding: 3.4cqw 3.4cqw 3.8cqw;
  border-radius: 5cqw / 6cqw;
  background:
    /* grain */
    repeating-linear-gradient(92deg, rgba(0,0,0,.16) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(88deg, rgba(255,210,160,.06) 0 2px, transparent 2px 19px),
    linear-gradient(180deg, #8a4f2a 0%, var(--wood-1) 18%, var(--wood-2) 70%, var(--wood-3) 100%);
  box-shadow:
    inset 0 .5cqw .6cqw rgba(255,214,170,.28),
    inset 0 -1cqw 1.4cqw rgba(0,0,0,.5),
    inset 1cqw 0 1.2cqw rgba(0,0,0,.25),
    inset -1cqw 0 1.2cqw rgba(0,0,0,.25),
    0 4cqw 6cqw rgba(0,0,0,.55);
}

.face {
  display: grid;
  grid-template-columns: 1fr 20%;
  gap: 2.2cqw;
  padding: 2.4cqw;
  border-radius: 3cqw / 3.6cqw;
  background: linear-gradient(160deg, #2b2a28, #121110 60%);
  box-shadow:
    inset 0 0 0 .35cqw #050505,
    inset 0 .9cqw 1.4cqw rgba(255,255,255,.07),
    0 .3cqw .2cqw rgba(255,220,180,.25);
}

.tube {
  padding: 2cqw;
  border-radius: 7cqw / 8cqw;
  background: linear-gradient(150deg, #cfcac0 0%, #8f8a80 35%, #5d5952 100%);
  box-shadow:
    inset 0 0 0 .3cqw rgba(0,0,0,.45),
    inset 0 .5cqw .8cqw rgba(255,255,255,.5),
    0 .4cqw 1cqw rgba(0,0,0,.7);
}

.screen {
  position: relative;
  aspect-ratio: 16 / 9; /* same shape as the videos */
  overflow: hidden;
  border-radius: 4% / 7%;
  background: #05070a;
  box-shadow: 0 0 0 .5cqw #0a0a0a;
  cursor: pointer;
  isolation: isolate;
}

.screen video,
.screen canvas,
.screen .glass {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The picture sits slightly inside the glass so the rounded corners
   never cut into it. */
.screen video { inset: 2.2%; width: 95.6%; height: 95.6%; object-fit: contain; background: #000; }

#snow {
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity .12s;
  pointer-events: none;
}
.screen.snowy #snow { opacity: 1; }

.no-signal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 700 5cqw/1 'Courier New', monospace;
  letter-spacing: .25em;
  color: #fff;
  text-shadow: 0 0 1.2cqw #000, 0 0 .4cqw #000;
  pointer-events: none;
}

.big-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 15cqw;
  height: 15cqw;
  min-width: 56px;
  min-height: 56px;
  border: 0;
  border-radius: 50%;
  background: rgba(20,14,10,.62);
  box-shadow: 0 0 0 .4cqw rgba(243,227,195,.85);
  cursor: pointer;
}
.big-play::after {
  content: '';
  position: absolute;
  left: 54%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 2.6cqw 0 2.6cqw 4.4cqw;
  border-color: transparent transparent transparent var(--cream);
}

/* curved glass: glare up top, dark edges, faint scan lines */
.glass {
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 45% at 28% 8%, rgba(255,255,255,.10), transparent 60%),
    radial-gradient(ellipse 120% 120% at 50% 50%, transparent 70%, rgba(0,0,0,.22) 100%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.025) 0 1px, transparent 1px 4px);
  box-shadow: inset 0 0 2.2cqw rgba(0,0,0,.5);
}

/* ---------- control panel ---------- */

.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6cqw;
  padding: 2cqw 1.6cqw 1.8cqw;
  border-radius: 2cqw;
  background: linear-gradient(180deg, #24211e, #0e0d0c);
  box-shadow: inset 0 0 0 .25cqw #000, inset 0 .4cqw .5cqw rgba(255,255,255,.08);
}

.dial {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .9cqw;
}
.dial span {
  font: 400 max(1.35cqw, 9px)/1 'Righteous', Georgia, serif;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #c9b48a;
}

.knob {
  --turn: 0deg;
  position: relative;
  width: 11cqw;
  height: 11cqw;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  /* silver ring with tick marks */
  background:
    radial-gradient(circle, transparent 0 56%, rgba(0,0,0,.35) 57% 58%, transparent 59%),
    repeating-conic-gradient(from -1.5deg, #2a2724 0 3deg, transparent 3deg 30deg),
    linear-gradient(145deg, #f1eee6, #9d988c 55%, #6e6a61);
  box-shadow: 0 .5cqw .9cqw rgba(0,0,0,.8), inset 0 .2cqw .2cqw rgba(255,255,255,.7);
}
.knob.small { width: 9cqw; height: 9cqw; }

.knob i {
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #5c5650, #1b1917 60%, #070707);
  box-shadow: 0 .4cqw .7cqw rgba(0,0,0,.75), inset 0 0 0 .2cqw rgba(255,255,255,.06);
  transform: rotate(var(--turn));
  transition: transform .28s cubic-bezier(.3,1.5,.5,1);
}
.knob i::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 7%;
  width: 9%;
  height: 34%;
  transform: translateX(-50%);
  border-radius: 99px;
  background: var(--cream);
}
.knob:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }

.grille {
  flex: 1;
  width: 100%;
  min-height: 5cqw;
  margin-top: .4cqw;
  border-radius: 1.2cqw;
  background:
    repeating-linear-gradient(0deg, #060606 0 .55cqw, #3c3832 .55cqw 1.1cqw);
  box-shadow: inset 0 0 0 .25cqw #000, inset 0 0 1.2cqw rgba(0,0,0,.8);
}

/* ---------- legs ---------- */

.legs {
  display: flex;
  justify-content: space-between;
  padding: 0 13cqw;
  height: 7cqw;
  margin-top: -.4cqw;
}
.legs b {
  width: 3cqw;
  height: 100%;
  background: linear-gradient(90deg, #6b3a1d, #3a1c0c);
  clip-path: polygon(0 0, 100% 0, 78% 100%, 42% 100%);
  transform: skewX(14deg);
  transform-origin: top;
}
.legs b:last-child { transform: skewX(-14deg) scaleX(-1); }

/* phones: move the controls under the screen so the picture stays big */
@container (max-width: 520px) {
  .cabinet { padding: 4cqw 4cqw 4.4cqw; border-radius: 7cqw / 6cqw; }
  .face { grid-template-columns: 1fr; gap: 3cqw; padding: 3cqw; }
  .tube { padding: 2.6cqw; }
  .panel {
    flex-direction: row;
    justify-content: flex-start;
    gap: 5cqw;
    padding: 3cqw 4cqw;
  }
  .knob { width: 17cqw; height: 17cqw; }
  .knob.small { width: 14cqw; height: 14cqw; }
  .dial { gap: 1.6cqw; }
  .dial span { font-size: 2.7cqw; }
  .grille { align-self: stretch; margin-top: 0; min-height: 0; }
  .legs { height: 9cqw; }
  .legs b { width: 4cqw; }
}

/* ---------- name plate + buttons ---------- */

.plate {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 620px);
  margin-top: 18px;
  padding: 10px 16px;
  border-radius: 8px;
  background: linear-gradient(180deg, #e9c46a, #b98a2c);
  color: #2a1a08;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 3px 10px rgba(0,0,0,.5);
}
.plate .ch { font: 400 15px/1 'Righteous', Georgia, serif; letter-spacing: .08em; white-space: nowrap; }
.plate .title { flex: 1; min-width: 0; font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* HOME: opens the walkable house in house/ */
.home {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 104px; margin-top: 18px; padding: 0 22px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ea8a3c, #c2591b);
  color: #1d0f05;
  font: 400 15px/1 'Righteous', Georgia, serif;
  letter-spacing: .12em;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255,220,180,.25), 0 2px 6px rgba(0,0,0,.5);
}
.home:active { transform: translateY(1px); }
.home:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; }

.buttons { display: flex; gap: 10px; margin-top: 14px; }
.buttons button {
  min-height: 44px;
  min-width: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #4a2c18, #2c190d);
  color: var(--cream);
  font: 400 15px/1 'Righteous', Georgia, serif;
  letter-spacing: .06em;
  box-shadow: inset 0 1px 0 rgba(255,220,180,.25), 0 2px 6px rgba(0,0,0,.5);
  cursor: pointer;
}
.buttons button.wide { min-width: 104px; background: linear-gradient(180deg, #ea8a3c, #c2591b); color: #1d0f05; }
.buttons button:active { transform: translateY(1px); }
.buttons button:focus-visible, .listing button:focus-visible {
  outline: 3px solid var(--mustard); outline-offset: 2px;
}

/* ---------- channel guide ---------- */

.guide { width: min(100%, 620px); margin-top: 30px; }

.listing { list-style: none; margin: 0; padding: 0; border-top: 1px solid rgba(243,227,195,.18); }
.listing li { border-bottom: 1px solid rgba(243,227,195,.18); }
.listing button {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 8px 6px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.listing .n { font: 400 18px/1 'Righteous', Georgia, serif; color: var(--mustard); width: 2.2em; }
.listing .t { flex: 1; min-width: 0; font-size: 16px; }
.listing button[aria-current="true"] { background: rgba(226,119,43,.18); }
.listing button[aria-current="true"] .t { color: #ffd9a8; font-weight: 700; }
.listing .empty { padding: 18px 6px; color: #c9b48a; font-style: italic; }

footer { margin-top: 34px; font-size: 12px; letter-spacing: .12em; color: #8d7556; }

@media (prefers-reduced-motion: reduce) {
  .knob i { transition: none; }
}

/* ---------- interactive version: button, list tag ---------- */

.explore {
  min-height: 48px;
  margin-top: 14px;
  padding: 0 26px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #e9c46a, #b98a2c);
  color: #2a1a08;
  font: 400 16px/1 'Righteous', Georgia, serif;
  letter-spacing: .06em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 3px 10px rgba(0,0,0,.5);
  cursor: pointer;
}
.explore:active { transform: translateY(1px); }
.explore:focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }

.listing .x {
  padding: 4px 8px;
  border: 1px solid rgba(217,165,46,.6);
  border-radius: 99px;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--mustard);
  white-space: nowrap;
}

/* ---------- flat-screen viewer ---------- */

body.viewing { overflow: hidden; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(ellipse 100% 80% at 50% 45%, #3a3d46 0%, #15161a 90%);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #e9eaee;
}

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
}
.viewer-bar button {
  flex: none;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid #4a4d57;
  border-radius: 8px;
  background: #1b1d22;
  color: #fff;
  font: 600 15px/1 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  cursor: pointer;
}
.viewer-bar button:hover { background: #2a2d35; }
.viewer-bar button:focus-visible { outline: 3px solid #8ab4ff; outline-offset: 2px; }
.viewer-bar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; color: #c6c8d0; }

.viewer-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px 10px;
  container-type: size;
}

.flat-set { display: flex; flex-direction: column; align-items: center; }

/* thin black frame, like a modern flat screen */
.flat {
  position: relative;
  width: min(100cqw, (100cqh - 30px) * 16 / 9);
  aspect-ratio: 16 / 9;
  border: 6px solid #08080a;
  border-bottom-width: 9px;
  border-radius: 6px;
  background: #000;
  box-shadow: 0 0 0 1px #4a4d57, 0 24px 60px rgba(0,0,0,.7);
  overflow: hidden;
}
.flat iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.flat-loading { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; z-index: 1; background: #000; color: #9a9ca6; font-size: 15px; letter-spacing: .08em; }

.flat-feet { display: flex; justify-content: space-between; width: 66%; height: 22px; }
.flat-feet b {
  width: 58px;
  height: 100%;
  background: linear-gradient(180deg, #2a2c33, #4a4d57);
  clip-path: polygon(44% 0, 56% 0, 100% 100%, 88% 100%, 50% 34%, 12% 100%, 0 100%);
}

/* tall windows (phones held upright): let the screen use the whole height */
@container (max-aspect-ratio: 1 / 1) {
  .flat { width: 100cqw; height: calc(100cqh - 30px); aspect-ratio: auto; }
}
