:root {
  --wall: #2a1c15;
  --wall-2: #33231a;
  --walnut: #6b4325;
  --walnut-dark: #3d2414;
  --alu: #c9c3b6;
  --alu-dark: #8f897d;
  --tube: #0b0f0d;
  --phosphor: #8dffa8;
  --tt-yellow: #ffe14d;
  --tt-cyan: #5ce8ff;
  --tt-red: #ff5a4a;
  --ink: #2a221b;
  --paper: #efe6d2;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "PT Sans", system-ui, sans-serif;
  color: var(--paper);
  background-color: var(--wall);
  /* 90s wallpaper: small damask dots on a warm brown wall */
  background-image:
    radial-gradient(circle at 50% 50%, rgba(255, 220, 170, .045) 0 3px, transparent 4px),
    radial-gradient(circle at 0 0, rgba(255, 220, 170, .03) 0 2px, transparent 3px),
    linear-gradient(180deg, var(--wall-2), var(--wall) 70%, #1c130e);
  background-size: 28px 28px, 28px 28px, 100% 100%;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.room {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

/* ---------- TV body ---------- */
.tv { position: relative; }
.tv-face {
  display: grid;
  grid-template-columns: 1fr 250px;
  grid-template-areas: "screen panel" "dial panel";
  gap: 18px 22px;
  padding: 26px;
  border-radius: 22px;
  background:
    repeating-linear-gradient(97deg, rgba(0,0,0,.0) 0 7px, rgba(0,0,0,.09) 8px 9px, rgba(255,255,255,.03) 10px 13px),
    repeating-linear-gradient(91deg, rgba(0,0,0,.06) 0 31px, rgba(255,220,180,.05) 32px 46px),
    linear-gradient(170deg, #8a5a33, var(--walnut) 40%, var(--walnut-dark));
  box-shadow:
    inset 0 2px 0 rgba(255,230,200,.25),
    inset 0 -6px 14px rgba(0,0,0,.45),
    0 30px 60px rgba(0,0,0,.55),
    0 4px 0 #24150b;
}
.feet { display: flex; justify-content: space-between; padding: 0 12%; }
.feet span { width: 70px; height: 14px; background: linear-gradient(#2a1a10, #120b06); border-radius: 0 0 8px 8px; }

.bezel {
  grid-area: screen;
  padding: 18px;
  border-radius: 28px;
  background: linear-gradient(145deg, #2b2620, #121010 60%, #252019);
  box-shadow: inset 0 0 0 2px #0a0807, inset 0 3px 8px rgba(255,255,255,.08), 0 1px 0 rgba(255,230,200,.2);
}

.screen {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 9% / 12%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #1a201d, var(--tube) 70%);
  box-shadow: inset 0 0 40px 12px rgba(0,0,0,.9);
  cursor: pointer;
}
.picture {
  position: absolute; inset: 0;
  transform-origin: 50% 50%;
  opacity: 0;
}
.screen[data-state="on"] .picture { opacity: 1; animation: crt-on .55s cubic-bezier(.2,.8,.2,1) both; }
.screen[data-state="turning-off"] .picture { opacity: 1; animation: crt-off .45s ease-in both; }

@keyframes crt-on {
  0% { transform: scale(0, .004); filter: brightness(6); }
  35% { transform: scale(1, .004); filter: brightness(5); }
  70% { transform: scale(1, 1.03); filter: brightness(1.6); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}
@keyframes crt-off {
  0% { transform: scale(1, 1); filter: brightness(1); }
  45% { transform: scale(1, .006); filter: brightness(4); }
  80% { transform: scale(.02, .006); filter: brightness(8); }
  100% { transform: scale(0, 0); filter: brightness(8); }
}
.dot {
  position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px; margin: -3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 18px 6px rgba(200,255,230,.7);
  opacity: 0;
  pointer-events: none;
}
.screen[data-state="turning-off"] .dot { animation: dot-fade .9s .35s ease-out both; }
@keyframes dot-fade { 0% { opacity: 1; } 100% { opacity: 0; transform: scale(.3); } }

/* YouTube rules (required minimum functionality): nothing in front of the player, no cropping or filters,
   player stays clickable and at least 200x200. So the player is a plain rectangle on top of everything inside
   the tube; scanlines, glass and the vignette live only on the tube rim and on our own static layer. */
.glass { z-index: 1; }
.picture { z-index: 2; }
.dot { z-index: 2; }
.video-wrap {
  position: absolute; z-index: 3;
  inset: 5% 6%;
  background: #000;
  min-width: 200px; min-height: 200px;
  visibility: hidden;
}
.screen[data-state="on"][data-video="show"] .video-wrap { visibility: visible; }
.video-wrap iframe, .video-wrap #player {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0;
}
.picture::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.25) 0 1px, transparent 1px 3px);
}
#noise {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity .12s;
}
#noise.show { opacity: 1; }

.osd {
  position: absolute; top: 8%; right: 9%;
  font-family: "Press Start 2P", monospace;
  color: var(--phosphor);
  text-shadow: 0 0 6px rgba(120,255,160,.8), 2px 2px 0 rgba(0,0,0,.6);
  text-align: right;
  line-height: .9;
  opacity: 0;
  transition: opacity .2s;
}
.osd.show { opacity: 1; }
.osd-ch { display: block; font-size: clamp(16px, 3.6vw, 34px); }
.osd-year { display: block; margin-top: .5em; font-size: clamp(11px, 2vw, 18px); }
.osd-msg {
  position: absolute; left: 0; right: 0; bottom: 12%;
  text-align: center;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(10px, 1.8vw, 16px);
  line-height: 1.6;
  color: var(--phosphor);
  text-shadow: 0 0 6px rgba(120,255,160,.8);
  padding: 0 10%;
}
.osd-msg:empty { display: none; }

.glass {
  position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0,0,0,.55) 100%),
    linear-gradient(155deg, rgba(255,255,255,.14), rgba(255,255,255,0) 32%),
    radial-gradient(ellipse 60% 30% at 30% 12%, rgba(255,255,255,.10), transparent 70%);
  box-shadow: inset 0 0 22px rgba(160,255,200,.05);
}
.screen[data-state="on"] .glass { box-shadow: inset 0 0 50px rgba(160,255,200,.08); }

/* ---------- Control panel ---------- */
.panel {
  grid-area: panel;
  display: flex; flex-direction: column; gap: 18px;
  padding: 18px 16px;
  border-radius: 14px;
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.06) 0 1px, rgba(0,0,0,.04) 1px 2px),
    linear-gradient(180deg, #ddd8cc, var(--alu) 50%, #aea89b);
  box-shadow: inset 0 1px 0 #fff, inset 0 -2px 4px rgba(0,0,0,.25), 0 2px 3px rgba(0,0,0,.4);
}
.display {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #0d1a10;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.8), 0 1px 0 rgba(255,255,255,.6);
  font-family: "Press Start 2P", monospace;
  color: var(--phosphor);
  text-shadow: 0 0 6px rgba(120,255,160,.7);
}
.disp-main { font-size: 14px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.disp-msg { font-size: 9px; line-height: 1.6; color: #b8ffc8; }
.disp-msg:empty { display: none; }
.source { border: 0; margin: 0; padding: 0; min-width: 0; }
.source legend { font-size: 13px; color: #5d574e; margin-bottom: 8px; padding: 0; }
.source-row { display: flex; gap: 8px; }
.source-row .small-btn { margin-left: 0; flex: 1; }
.plate { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid rgba(0,0,0,.25); padding-bottom: 10px; }
.brand {
  font-family: "PT Sans Narrow", sans-serif;
  font-size: 28px; letter-spacing: .02em;
  color: #3a3631;
  text-shadow: 0 1px 0 rgba(255,255,255,.8), 0 -1px 0 rgba(0,0,0,.35);
}
.model { font-family: "PT Sans Narrow", sans-serif; font-size: 16px; color: #8a2a1f; }

.row-power { display: flex; align-items: center; gap: 14px; }
.power {
  width: 64px; height: 64px; border-radius: 50%;
  border: 0; padding: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #4a4540, #1d1a17 70%);
  box-shadow: 0 4px 0 #0c0a09, 0 6px 10px rgba(0,0,0,.4), inset 0 1px 1px rgba(255,255,255,.25);
  display: grid; place-items: center;
  transition: transform .08s, box-shadow .08s;
}
.power-cap { width: 22px; height: 22px; border: 3px solid #d8d2c4; border-top-color: transparent; border-radius: 50%; position: relative; }
.power-cap::after { content: ""; position: absolute; left: 50%; top: -8px; width: 3px; height: 13px; margin-left: -1.5px; background: #d8d2c4; border-radius: 2px; }
.power[aria-pressed="true"] { transform: translateY(3px); box-shadow: 0 1px 0 #0c0a09, 0 2px 4px rgba(0,0,0,.4), inset 0 1px 1px rgba(255,255,255,.2); }
.led { width: 10px; height: 10px; border-radius: 50%; background: #4a1410; box-shadow: inset 0 1px 2px rgba(0,0,0,.6); }
.led.on { background: #ff3b2a; box-shadow: 0 0 8px 2px rgba(255,60,40,.7); }

.small-btn {
  margin-left: auto;
  min-height: 44px; min-width: 64px; padding: 0 12px;
  font: 700 15px "PT Sans", sans-serif; color: var(--ink);
  border: 0; border-radius: 6px; cursor: pointer;
  background: linear-gradient(#f2eee4, #bdb7aa);
  box-shadow: 0 3px 0 #7d776b, inset 0 1px 0 #fff;
}
.small-btn[aria-pressed="true"] { transform: translateY(2px); box-shadow: 0 1px 0 #7d776b; background: linear-gradient(#cfc9bc, #e6e1d6); }
.small-btn:disabled { opacity: .5; cursor: default; }

.keys { border: 0; margin: 0; padding: 0; min-width: 0; }
.keys legend { font-size: 13px; color: #5d574e; margin-bottom: 8px; padding: 0; }
.keys-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.key {
  position: relative;
  min-height: 46px;
  display: flex; align-items: center; gap: 4px;
  padding: 0 6px;
  font: 700 14px "PT Sans Narrow", "PT Sans", sans-serif; color: #f4efe4;
  text-align: left;
  border: 0; border-radius: 4px 4px 7px 7px; cursor: pointer;
  background: linear-gradient(#4b4640, #2a2622);
  box-shadow: 0 5px 0 #14110f, 0 6px 8px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform .06s, box-shadow .06s;
}
.key-num { font-family: "VT323", monospace; font-size: 17px; color: #ffcf6b; width: 1ch; }
.key[aria-pressed="true"] { transform: translateY(4px); box-shadow: 0 1px 0 #14110f, inset 0 2px 4px rgba(0,0,0,.5); background: linear-gradient(#36322d, #221f1c); }
.key[aria-pressed="true"]::after { content: ""; position: absolute; right: 5px; top: 6px; width: 6px; height: 6px; border-radius: 50%; background: #ffcf6b; box-shadow: 0 0 6px #ffb02e; }
.key:disabled { opacity: .35; cursor: default; }

.grille {
  flex: 1; min-height: 0;
  border-radius: 8px;
  background:
    repeating-linear-gradient(0deg, #2a2622 0 3px, #9d978b 3px 7px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.5);
  opacity: .8;
}

/* ---------- Year dial, like a radio tuning scale ---------- */
.dial { grid-area: dial; display: flex; align-items: center; gap: 14px; }
.dial-label { font-family: "PT Sans Narrow", sans-serif; font-size: 18px; color: #f1d9b8; text-shadow: 0 1px 0 rgba(0,0,0,.6); }
.dial-window {
  position: relative; flex: 1;
  height: 64px;
  border-radius: 8px;
  background: linear-gradient(180deg, #1b140d, #2c2016);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.8), 0 1px 0 rgba(255,230,200,.2);
  overflow: hidden;
}
.dial-scale {
  position: absolute; inset: 0 14px;
  display: grid; grid-template-columns: repeat(21, 1fr);
  background: linear-gradient(180deg, rgba(255,214,140,.10), rgba(255,214,140,.02));
}
.tick { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 8px; font: 18px/1 "VT323", monospace; color: #ffd68c; }
.tick::before { content: ""; position: absolute; top: 8px; width: 1px; height: 12px; background: #ffd68c; }
.tick.major::before { height: 20px; width: 2px; }
.tick.empty { color: rgba(255,214,140,.28); }
.tick.empty::before { background: rgba(255,214,140,.28); }
.tick span { visibility: hidden; }
.tick.major span { visibility: visible; }
#year {
  position: absolute; inset: 0 14px; width: calc(100% - 28px); height: 100%;
  margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
#year::-webkit-slider-runnable-track { height: 100%; background: transparent; }
#year::-moz-range-track { height: 100%; background: transparent; }
#year::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 44px; height: 64px; background:
    linear-gradient(90deg, transparent 20px, #ff3b2a 20px 24px, transparent 24px);
  filter: drop-shadow(0 0 4px rgba(255,60,40,.8));
  border: 0;
}
#year::-moz-range-thumb {
  width: 44px; height: 64px; border: 0; border-radius: 0;
  background: linear-gradient(90deg, transparent 20px, #ff3b2a 20px 24px, transparent 24px);
}

/* ---------- Teletext guide ---------- */
.guide {
  margin: 34px auto 0;
  max-width: 760px;
  background: #000;
  font-family: "PT Mono", monospace;
  font-size: 17px;
  line-height: 1.35;
  padding: 14px 16px 12px;
  border: 2px solid #1a1a1a;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.tt-head { font-family: "Press Start 2P", monospace; font-size: 12px; line-height: 1.6; display: flex; justify-content: space-between; gap: 12px; color: #fff; }
.tt-head #tt-title { color: var(--tt-yellow); flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-head span:first-child { color: var(--tt-cyan); }
.tt-list { list-style: none; margin: 10px 0 6px; padding: 0; }
.tt-list li { display: grid; grid-template-columns: 5ch 1fr; gap: 8px; color: var(--tt-cyan); padding: 1px 0; }
.tt-list li .t { color: var(--tt-yellow); }
.tt-list li.now { background: #0033cc; color: #fff; }
.tt-list li.now .t { color: #fff; }
.tt-list li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-credit { margin: 6px 0 0; color: #b6b6b6; font-size: 15px; }
.tt-credit a { color: var(--tt-cyan); }

/* ---------- Footer links ---------- */
.links { max-width: 760px; margin: 28px auto 0; font-size: 15px; line-height: 1.7; color: #d9c7ad; }
.links span { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
.links a { color: #ffd68c; text-underline-offset: 3px; display: inline-block; min-height: 28px; }
.links .fine { color: #a8957c; font-size: 14px; }

:focus-visible { outline: 3px solid #ffcf6b; outline-offset: 3px; }

/* ---------- Phone: TV fills the width, panel sits under the screen ---------- */
@media (max-width: 760px) {
  .room { padding: 16px 10px 40px; }
  .tv-face {
    grid-template-columns: 1fr;
    grid-template-areas: "screen" "dial" "panel";
    padding: 12px; gap: 12px; border-radius: 16px;
  }
  .bezel { padding: 9px; border-radius: 18px; }
  .panel { padding: 12px; gap: 12px; }
  .plate { display: none; }
  .row-power { gap: 12px; }
  .power { width: 52px; height: 52px; }
  .keys-grid { grid-template-columns: repeat(4, 1fr); gap: 7px; }
  .key { padding: 0 6px; font-size: 14px; gap: 4px; justify-content: center; }
  .key-num { display: none; }
  .key[aria-pressed="true"]::after { right: 4px; top: 6px; margin: 0; width: 5px; height: 5px; }
  .dial-label { display: none; }
  .dial-window { height: 52px; }
  .tick { font-size: 15px; padding-bottom: 6px; }
  .tick::before { top: 6px; }
  .tick.major span { visibility: hidden; }
  .tick.mobile-major span { visibility: visible; }
  #year::-webkit-slider-thumb { height: 52px; }
  .guide { font-size: 15px; margin-top: 22px; }
  .tt-head { font-size: 10px; }
  .grille { display: none; }
  .display { min-height: 0; flex-direction: row; align-items: baseline; justify-content: space-between; gap: 10px; }
  .disp-main { font-size: 12px; }
  .disp-msg { font-size: 8px; text-align: right; }
  .feet span { width: 50px; height: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .screen[data-state="on"] .picture { animation: none; }
  .screen[data-state="turning-off"] .picture { animation: none; opacity: 0; transition: opacity .2s; }
  .screen[data-state="turning-off"] .dot { animation: none; }
  .key, .power, .small-btn { transition: none; }
}
