:root {
  --wood-1: #6b3f1f;
  --wood-2: #7d4b26;
  --wood-3: #5a3418;
  --chrome-1: #f4f4f4;
  --chrome-2: #9a9a9a;
  --plastic: #1d1a17;
  --panel: #2b2622;
  --label: #d9c7a7;
  --osd: #5dff6b;
  --claude: #d97757;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #2a1d14;
  font-family: 'VT323', monospace;
  user-select: none;
}

/* ---------- the room ---------- */
#room {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(to bottom, transparent 0 78%, #3b2414 78% 79%, #4a2e1a 79% 100%),
    repeating-linear-gradient(90deg, rgba(0,0,0,.06) 0 2px, transparent 2px 46px),
    radial-gradient(circle at 23px 23px, #b5733f 0 6px, transparent 7px) 0 0 / 46px 46px,
    radial-gradient(circle at 0 0, #8f5a33 0 9px, transparent 10px) 0 0 / 46px 46px,
    linear-gradient(#c88a52, #a96d3d);
  display: flex;
  align-items: center;
  justify-content: center;
}
#room::after { /* lamp glow */
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(255,210,150,.18), rgba(0,0,0,.55) 75%);
  pointer-events: none;
}

#stage {
  position: relative;
  width: 1000px;
  height: 900px;
  flex: none;
  transform-origin: center center;
  z-index: 1;
}

#set {
  position: absolute;
  left: 20px;
  top: 175px;
  width: 880px;
}

/* ---------- antenna ---------- */
#antenna {
  position: absolute;
  left: 50%;
  top: -18px;
  width: 0;
  height: 0;
  z-index: 0;
}
#antenna .dome {
  position: absolute;
  left: -46px;
  top: -10px;
  width: 92px;
  height: 34px;
  border-radius: 46px 46px 6px 6px;
  background: radial-gradient(ellipse at 40% 25%, #555, #151515 70%);
  box-shadow: 0 4px 6px rgba(0,0,0,.5);
}
#antenna .ear {
  position: absolute;
  left: -3px;
  top: 0;
  width: 6px;
  height: 165px;
  transform-origin: 3px 165px;
  margin-top: -165px;
  cursor: grab;
}
#antenna .ear .rod {
  position: absolute;
  inset: 0 1px;
  border-radius: 3px;
  background: linear-gradient(90deg, #777, #fff 40%, #888);
  box-shadow: 1px 0 2px rgba(0,0,0,.4);
}
#antenna .ear .tip {
  position: absolute;
  left: -3px;
  top: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #888 60%, #444);
}

/* ---------- cabinet ---------- */
#cabinet {
  position: relative;
  height: 560px;
  border-radius: 26px;
  background:
    repeating-linear-gradient(92deg, rgba(0,0,0,.0) 0 7px, rgba(0,0,0,.07) 7px 9px, rgba(255,255,255,.03) 9px 13px),
    repeating-radial-gradient(ellipse at 30% 140%, var(--wood-2) 0 9px, var(--wood-1) 9px 15px, var(--wood-3) 15px 19px),
    var(--wood-1);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.18),
    inset 0 -6px 12px rgba(0,0,0,.45),
    0 22px 40px rgba(0,0,0,.6);
  z-index: 1;
}

#bezel {
  position: absolute;
  left: 28px;
  top: 28px;
  width: 620px;
  height: 504px;
  border-radius: 34px;
  background: linear-gradient(145deg, #34302b, #141210);
  box-shadow:
    inset 0 0 0 4px #0c0b0a,
    inset 0 0 0 7px #8d8d8d,
    inset 0 0 0 9px #2a2723,
    0 1px 0 rgba(255,255,255,.2);
  padding: 30px;
}

/* ---------- the tube ---------- */
#crt {
  position: relative;
  width: 560px;
  height: 444px;
  border-radius: 46px / 38px;
  overflow: hidden;
  background: #0d1110;
  box-shadow: inset 0 0 40px rgba(0,0,0,.95), 0 0 0 3px #000;
}
#picture {
  position: absolute;
  inset: 0;
  transform-origin: center;
  filter: brightness(var(--bright, 1)) contrast(var(--contrast, 1)) saturate(1.25) blur(.35px);
  animation: flicker .12s infinite;
}
#crt.off #picture { visibility: hidden; }
#crt.off { background: radial-gradient(ellipse at 45% 40%, #2a302e, #0b0e0d 70%); }

@keyframes flicker { 0%, 100% { opacity: 1 } 50% { opacity: .975 } }

#yt-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: #000;
}
#yt-wrap iframe, #yt {
  position: absolute;
  top: -80px; /* overscan: YouTube's title bar and control bar sit outside the glass */
  left: 50%;
  width: 930px; /* 16:9 cropped to 4:3, pan & scan */
  height: 624px; /* taller than 16:9: YouTube pads it, so its bars land in the cropped strips */
  transform: translateX(-50%);
  border: 0;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
#game { display: none; background: #000; }

#bluescreen {
  position: absolute;
  inset: 0;
  display: none;
  background: #1530c9;
  color: #fff;
  font-family: 'VT323', monospace;
  text-shadow: 0 0 6px rgba(255,255,255,.6);
}
#bluescreen .blue-label { position: absolute; top: 34px; left: 44px; font-size: 54px; }
#bluescreen .blue-sub { position: absolute; bottom: 60px; width: 100%; text-align: center; font-size: 34px; opacity: .85; }

#crt[data-input="tv"] #game { display: none; }
#crt[data-input="av1"] #game, #crt[data-input="av2"] #game { display: block; }
#crt[data-input="av1"] #yt-wrap, #crt[data-input="av2"] #yt-wrap { visibility: hidden; }

/* ---------- on-screen display ---------- */
#osd {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--osd);
  font-family: 'VT323', monospace;
  text-shadow: 0 0 4px rgba(93,255,107,.9), 2px 2px 0 rgba(0,0,0,.6);
}
#osd > div { opacity: 0; transition: opacity .2s; }
#osd > div.show { opacity: 1; transition: none; }
#osd-ch { position: absolute; top: 26px; right: 46px; font-size: 64px; letter-spacing: 2px; }
#osd-input { position: absolute; top: 30px; left: 44px; right: 150px; font-size: 40px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#osd-vol { position: absolute; bottom: 44px; left: 0; right: 0; text-align: center; font-size: 30px; }
#osd-vol .bars { letter-spacing: -2px; margin: 0 10px; }
#osd-msg { position: absolute; top: 46%; left: 0; right: 0; text-align: center; font-size: 34px; }
#osd-bug { position: absolute; bottom: 18px; left: 40px; font-size: 18px; color: #fff; text-shadow: 0 0 3px #000, 1px 1px 0 #000; }
#osd-bug .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: #777; }
#osd-bug.working .dot { background: var(--claude); animation: blink 1s steps(2) infinite; }
#osd-bug.idle .dot { background: #4caf50; }
@keyframes blink { 50% { opacity: .2 } }

#bulletin {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 70px;
  display: flex;
  align-items: stretch;
  font-family: 'Press Start 2P', monospace;
  text-shadow: none;
  transform: translateY(20px);
}
#bulletin.show { transform: none; transition: transform .3s; }
#bulletin .flag { background: #c21d1d; color: #fff; padding: 10px 10px; font-size: 10px; line-height: 1.4; width: 110px; animation: blink 1s steps(2) infinite; }
#bulletin .body { flex: 1; background: rgba(10, 18, 60, .92); color: #fff; padding: 10px 12px; font-size: 10px; line-height: 1.6; }

/* ---------- glass, scanlines ---------- */
#crt .fx { position: absolute; inset: 0; pointer-events: none; }
.scanlines { background: repeating-linear-gradient(to bottom, rgba(0,0,0,.28) 0 1px, transparent 1px 3px); }
.mask { background: repeating-linear-gradient(90deg, rgba(255,0,0,.05) 0 1px, rgba(0,255,0,.035) 1px 2px, rgba(0,80,255,.05) 2px 3px); mix-blend-mode: screen; }
.vignette { background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,.65) 100%); box-shadow: inset 0 0 70px rgba(0,0,0,.8); border-radius: inherit; }
.glass { background: linear-gradient(125deg, rgba(255,255,255,.13) 0%, rgba(255,255,255,.04) 28%, transparent 42%), radial-gradient(ellipse at 28% 18%, rgba(255,255,255,.10), transparent 40%); }

#power-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
#power-fx::before {
  content: '';
  width: 100%;
  height: 100%;
  background: #fff;
  opacity: 0;
  border-radius: 50%;
}
#crt.turning-on #picture { animation: tubeOn .55s ease-out; }
#crt.turning-off #picture { visibility: visible; animation: tubeOff .45s ease-in forwards; }
#crt.turning-off #power-fx::before { animation: dotOff .9s ease-out forwards; }
@keyframes tubeOn {
  0% { transform: scale(1, .004); filter: brightness(6); }
  40% { transform: scale(1, .004); filter: brightness(4); }
  70% { transform: scale(1, 1.05); filter: brightness(1.8); }
  100% { transform: scale(1, 1); }
}
@keyframes tubeOff {
  0% { transform: scale(1, 1); }
  55% { transform: scale(1, .004); filter: brightness(5); }
  100% { transform: scale(0, .004); filter: brightness(8); opacity: 0; }
}
@keyframes dotOff {
  0%, 45% { opacity: 0; transform: scale(.02); }
  50% { opacity: 1; transform: scale(.025); }
  100% { opacity: 0; transform: scale(.004); }
}

#crt.degauss #picture { animation: degauss 1.4s ease-out; }
@keyframes degauss {
  0% { filter: hue-rotate(0) saturate(3); transform: skewX(0); }
  10% { filter: hue-rotate(160deg) saturate(4); transform: skewX(4deg) scale(1.03); }
  25% { filter: hue-rotate(-120deg) saturate(3); transform: skewX(-3deg); }
  45% { filter: hue-rotate(80deg) saturate(2); transform: skewX(2deg); }
  70% { filter: hue-rotate(-30deg) saturate(1.5); transform: skewX(-1deg); }
  100% { filter: hue-rotate(0) saturate(1.25); transform: none; }
}
#crt.wobble #picture { animation: wobble .25s linear; }
@keyframes wobble { 0%,100% { transform: none } 25% { transform: translateY(-3px) skewX(1deg) } 75% { transform: translateY(2px) skewX(-1deg) } }

/* ---------- control panel ---------- */
#panel {
  position: absolute;
  right: 26px;
  top: 28px;
  width: 190px;
  height: 504px;
  border-radius: 14px;
  background: linear-gradient(180deg, #34302b, var(--panel));
  box-shadow: inset 0 0 0 2px #0e0c0a, inset 0 0 0 4px #6d6d6d, inset 0 0 0 5px #1a1714;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}
.brand {
  font-family: 'Pacifico', cursive;
  font-size: 23px;
  color: #e8e8e8;
  background: linear-gradient(#fff, #a7a7a7 55%, #e9e9e9);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  line-height: 1;
  filter: drop-shadow(0 1px 0 #000);
}
.brand small {
  display: block;
  font-family: 'VT323', monospace;
  font-size: 12px;
  letter-spacing: 1px;
  -webkit-text-fill-color: var(--label);
  margin-top: 3px;
}
.label { font-size: 13px; color: var(--label); letter-spacing: 1px; }
.row { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }

.dial-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }
.dial-wrap > .label { position: absolute; top: -2px; left: -6px; }
.dial {
  position: relative;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: radial-gradient(circle, #1b1916 58%, #0d0c0a 60%, #2c2925 62%, #191714 100%);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.08), 0 2px 4px rgba(0,0,0,.6);
  cursor: pointer;
}
.dial-numbers span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  margin: -9px 0 0 -11px;
  text-align: center;
  color: var(--label);
  font-size: 15px;
  pointer-events: none;
}
.dial-numbers span.on { color: #fff; text-shadow: 0 0 6px #ffd27a; }
.dial-cap {
  position: absolute;
  inset: 23px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ddd, #8a8a8a, #f6f6f6, #8a8a8a, #e3e3e3, #888, #f0f0f0, #8a8a8a, #ddd);
  box-shadow: 0 4px 8px rgba(0,0,0,.7), inset 0 0 0 2px rgba(0,0,0,.25);
  transition: transform .14s cubic-bezier(.3, 1.6, .5, 1);
}
.dial-grip {
  position: absolute;
  left: 50%;
  top: 6px;
  bottom: 6px;
  width: 22px;
  margin-left: -11px;
  border-radius: 9px;
  background: linear-gradient(90deg, #5c5c5c, #cfcfcf 45%, #6a6a6a);
  box-shadow: 0 0 4px rgba(0,0,0,.6);
}
.dial-pointer {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 2px;
  background: #c21d1d;
}

.rocker, .chip-btn {
  font-family: 'VT323', monospace;
  cursor: pointer;
  border: 0;
  color: #eee;
  background: linear-gradient(#5a5550, #2b2825);
  box-shadow: 0 3px 0 #0d0c0a, inset 0 1px 0 rgba(255,255,255,.25);
  border-radius: 5px;
  transition: transform .05s, box-shadow .05s;
}
.rocker { width: 34px; height: 24px; font-size: 14px; }
.chip-btn { padding: 4px 9px; font-size: 15px; letter-spacing: 1px; }
.rocker:active, .chip-btn:active, .chip-btn.pressed { transform: translateY(3px); box-shadow: 0 0 0 #0d0c0a, inset 0 1px 0 rgba(255,255,255,.2); }
#muteBtn.on { color: #ff8a65; }

.knobs { align-items: flex-start; gap: 6px; }
.knob-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.knob-wrap .label { font-size: 11px; }
.knob {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, #2b2825 0 6deg, #47423d 6deg 12deg);
  box-shadow: 0 3px 6px rgba(0,0,0,.7), inset 0 0 0 6px #1d1b18, inset 0 0 0 7px #555;
  cursor: ns-resize;
}
.knob.small { width: 38px; height: 38px; margin-top: 6px; }
.knob::after {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6b655e, #24211e 70%);
}
.knob.small::after { inset: 8px; }
.knob-mark {
  position: absolute;
  left: 50%;
  top: 3px;
  width: 3px;
  height: 12px;
  margin-left: -1.5px;
  background: #f1e3c8;
  border-radius: 2px;
  z-index: 1;
}
.knob .knob-rot { position: absolute; inset: 0; }

.inputs { gap: 6px; }
.lamps { display: flex; gap: 4px; }
.lamps span {
  font-size: 13px;
  padding: 1px 4px;
  border-radius: 3px;
  color: #6b5d4a;
  background: #15120f;
  box-shadow: inset 0 0 0 1px #3c352d;
}
.lamps span.on { color: #ffe9a8; background: #6a3c0c; box-shadow: inset 0 0 0 1px #c47a1d, 0 0 8px #ffb347; }

.power-row { margin-top: 2px; }
#led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3a0d0d;
  box-shadow: inset 0 0 2px #000;
}
#led.on { background: #ff2a2a; box-shadow: 0 0 8px #ff2a2a, 0 0 2px #fff inset; }
.power-knob {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: radial-gradient(circle at 38% 32%, #fafafa, #a5a5a5 55%, #6b6b6b);
  box-shadow: 0 5px 0 #222, 0 6px 8px rgba(0,0,0,.6);
  transition: transform .08s, box-shadow .08s;
}
.power-knob.pushed { transform: translateY(4px); box-shadow: 0 1px 0 #222, 0 2px 4px rgba(0,0,0,.6); }
.power-knob.hint { animation: hint 1.4s ease-in-out infinite; }
@keyframes hint { 50% { box-shadow: 0 5px 0 #222, 0 0 16px 4px rgba(255,210,120,.8); } }

.grille {
  flex: 1;
  width: 100%;
  margin-top: 4px;
  border-radius: 8px;
  background: repeating-linear-gradient(to bottom, #0c0b09 0 4px, #3a342e 4px 7px);
  box-shadow: inset 0 0 0 2px #0c0b09;
}

/* ---------- program door + legs ---------- */
#door-row {
  position: relative;
  margin: -14px 40px 0;
  padding: 18px 16px 10px;
  background: linear-gradient(#4a2b14, #3b2210);
  border-radius: 0 0 14px 14px;
  box-shadow: 0 8px 16px rgba(0,0,0,.5);
  z-index: 0;
}
#doorBtn {
  font-family: 'VT323', monospace;
  font-size: 15px;
  letter-spacing: 1px;
  background: none;
  border: 0;
  color: var(--label);
  cursor: pointer;
}
#door { padding: 6px 4px 4px; color: var(--label); font-size: 17px; }
.door-form { display: flex; gap: 6px; margin: 6px 0; }
.door-form input {
  flex: 1;
  font-family: 'VT323', monospace;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #1a0f06;
  background: #f3ead7;
  color: #2a1d14;
  user-select: text;
}
.door-form button { font-family: 'VT323', monospace; font-size: 16px; padding: 3px 10px; cursor: pointer; border-radius: 4px; border: 1px solid #1a0f06; background: #d9c7a7; }
#door-list { font-size: 15px; columns: 2; opacity: .9; }
#door-list div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#legs { position: relative; height: 70px; margin: 0 90px; }
.leg {
  position: absolute;
  top: -4px;
  width: 22px;
  height: 74px;
  background: linear-gradient(90deg, #3b2210, #6b3f1f, #3b2210);
  border-radius: 4px 4px 8px 8px;
}
.leg.l { left: 30px; transform: skewX(10deg); }
.leg.r { right: 30px; transform: skewX(-10deg); }

#console { position: absolute; right: -40px; bottom: 60px; z-index: 2; filter: drop-shadow(0 8px 8px rgba(0,0,0,.6)); }

#help {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 6px;
  text-align: center;
  font-size: 15px;
  color: rgba(255, 240, 220, .75);
  z-index: 2;
  padding: 0 16px;
}
#help b { color: #ffd27a; font-weight: normal; }

/* ---------- VCR transport ---------- */
.vcr-row .rocker { width: 44px; font-size: 12px; letter-spacing: -1px; }
#vcrPlay.on { color: #ffd27a; }
#osd-seek { position: absolute; bottom: 44px; left: 0; right: 0; text-align: center; font-size: 28px; white-space: pre; }
#osd-seek .sym { margin-right: 12px; }
#osd-seek .bar { letter-spacing: -1px; margin-right: 12px; }

/* a video YouTube refuses to play here: hide its error card, the OSD explains */
#yt-wrap.dead iframe { visibility: hidden; }
