:root {
  --plastic: #26282b;
  --plastic-hi: #44474c;
  --plastic-lo: #0f1012;
  --guide-blue-1: #0a0a72;
  --guide-blue-2: #1a1ab4;
  --guide-cell: #1414a0;
  --guide-grid: #4a4ad8;
  --guide-yellow: #ffe000;
  --guide-cyan: #28e0ff;
  --osd-green: #3dff66;
  --osd-green-dk: #0c5a22;
  --led: #2bd44a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(ellipse at 50% -10%, #2c2c34 0%, #16161b 55%, #08080b 100%) fixed;
  color: #ddd;
  display: flex; align-items: center; justify-content: center;
  padding: max(22px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
}

.room { width: 100%; max-width: 760px; display: flex; flex-direction: column; align-items: center; }
.tv { width: 100%; }

/* ===== realistic plastic cabinet ===== */
.cabinet {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0) 9%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.018) 0 2px, rgba(0,0,0,0.05) 2px 4px),
    linear-gradient(180deg, var(--plastic-hi) 0%, var(--plastic) 14%, #1c1d20 78%, var(--plastic-lo) 100%);
  border-radius: 26px 26px 16px 16px;
  padding: 24px 26px 18px;
  border: 1px solid #000;
  box-shadow:
    inset 0 2px 1px rgba(255,255,255,0.18),
    inset 0 -10px 26px rgba(0,0,0,0.65),
    inset 0 0 0 2px rgba(0,0,0,0.4),
    0 30px 70px rgba(0,0,0,0.8),
    0 6px 14px rgba(0,0,0,0.6);
}

/* recessed screen surround */
.bezel {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 36%, #202125 0%, #0c0d0f 72%),
    linear-gradient(180deg, #2a2b2f, #0a0b0d);
  border-radius: 34px / 42px;
  padding: 22px;
  box-shadow:
    inset 0 0 0 2px #000,
    inset 0 8px 14px rgba(0,0,0,0.85),
    inset 0 -4px 10px rgba(255,255,255,0.05),
    0 2px 4px rgba(255,255,255,0.06);
}
/* glass screw corners */
.bezel::before, .bezel::after {
  content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #6a6d72, #16171a 70%);
  box-shadow: inset 0 0 2px #000, 0 1px 1px rgba(255,255,255,0.1);
  top: 9px;
}
.bezel::before { left: 9px; }
.bezel::after { right: 9px; }

.screen {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  background: #000; border-radius: 22px / 30px; overflow: hidden;
  box-shadow: inset 0 0 70px rgba(0,0,0,0.95), inset 0 0 0 2px rgba(0,0,0,0.9);
}
.screen::after {
  content: ""; position: absolute; inset: 0; border-radius: 22px / 30px;
  box-shadow: inset 0 0 90px 26px rgba(0,0,0,0.6); pointer-events: none; z-index: 9;
}

/* ===== YouTube player positioning ===== */
#player, #player iframe { position: absolute; border: 0; }
#player {
  top: 4.5%; left: 3.5%; width: 53%; height: 33%;
  transition: top .35s ease, left .35s ease, width .35s ease, height .35s ease;
  background: #000; z-index: 1;
}
#player iframe { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.screen.tuned #player { top: 0; left: 0; width: 100%; height: 100%; }

/* ===== NO SIGNAL fallback ===== */
.no-signal {
  position: absolute; top: 4.5%; left: 3.5%; width: 53%; height: 33%;
  z-index: 2; display: none; flex-direction: column;
  align-items: center; justify-content: center; background: #101012; overflow: hidden;
}
.screen.tuned .no-signal { top: 0; left: 0; width: 100%; height: 100%; }
.no-signal.show { display: flex; }
.ns-bars {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, #fff 0 14%, #ff0 14% 28%, #0ff 28% 42%, #0f0 42% 56%, #f0f 56% 70%, #f00 70% 84%, #00f 84% 100%);
  opacity: 0.22;
}
.ns-text { position: relative; z-index: 1; color: #fff; font-weight: 900; font-size: clamp(13px,4vw,26px); letter-spacing: 2px; text-align: center; text-shadow: 2px 2px 0 #000; }
.ns-text span { display: block; font-size: 0.5em; color: #ffd; letter-spacing: 1px; margin-top: 4px; }

/* ===== Guide overlay ===== */
.guide { position: absolute; inset: 0; z-index: 2; font-weight: bold; opacity: 1; transition: opacity 0.25s ease; }
.screen.tuned .guide, .screen.off .guide { opacity: 0; pointer-events: none; }

.preview-window { position: absolute; top: 4.5%; left: 3.5%; width: 53%; height: 33%; padding: 0; border: 0; background: transparent; cursor: pointer; font: inherit; }
.preview-frame { position: absolute; inset: 0; border: 3px solid var(--guide-cyan); box-shadow: 0 0 0 2px #000, 0 0 12px rgba(40,224,255,0.5); border-radius: 3px; }
.preview-tag { position: absolute; top: -2px; left: 6px; background: var(--guide-cyan); color: #002; font-size: 10px; padding: 2px 6px; letter-spacing: 1px; }
.preview-watch { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,0.6); color: var(--guide-cyan); border: 1px solid var(--guide-cyan); font-size: clamp(8px,2vw,12px); padding: 2px 7px; border-radius: 3px; opacity: 0; transition: opacity 0.15s ease; }
.preview-window:hover .preview-watch, .preview-window:focus-visible .preview-watch { opacity: 1; }

.promo { position: absolute; top: 4.5%; right: 3.5%; width: 38%; height: 33%; background: linear-gradient(160deg, var(--guide-blue-2), var(--guide-blue-1)); border: 2px solid var(--guide-grid); border-radius: 4px; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; color: #fff; overflow: hidden; }
.promo-logo { line-height: 0.9; }
.promo-logo-top { display: block; font-size: clamp(11px,3.2vw,22px); color: var(--guide-yellow); letter-spacing: 2px; text-shadow: 2px 2px 0 #000; font-style: italic; }
.promo-logo-bot { display: block; font-size: clamp(9px,2.4vw,16px); color: #fff; letter-spacing: 1px; text-shadow: 1px 1px 0 #000; }
.promo-logo-bot b { color: var(--guide-cyan); }
.promo-now { margin-top: auto; font-size: clamp(9px,2.3vw,14px); color: var(--guide-yellow); text-shadow: 1px 1px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.promo-msg { font-size: clamp(7px,1.8vw,11px); font-weight: normal; color: #cfe; line-height: 1.2; }
.promo-clock { font-size: clamp(9px,2.2vw,13px); color: #fff; }

.listings { position: absolute; left: 3.5%; right: 3.5%; top: 41%; bottom: 4%; background: var(--guide-blue-1); border: 2px solid var(--guide-grid); border-radius: 4px; display: flex; flex-direction: column; overflow: hidden; }
.listings-head, .row { display: grid; grid-template-columns: 34% 22% 22% 22%; }
.listings-head { background: linear-gradient(180deg, #3a2a8a, #241468); border-bottom: 2px solid var(--guide-grid); flex: 0 0 auto; }
.lh-channel, .lh-time { padding: 3px 6px; font-size: clamp(8px,2vw,12px); color: var(--guide-yellow); letter-spacing: 1px; border-right: 1px solid var(--guide-grid); }
.lh-channel { color: var(--guide-cyan); }
.listings-viewport { position: relative; flex: 1 1 auto; overflow: hidden; }
.listings-rows { position: absolute; left: 0; right: 0; top: 0; animation: scrollUp 44s linear infinite; }
.listings-rows.paused, .screen.tuned .listings-rows, .screen.off .listings-rows { animation-play-state: paused; }
@keyframes scrollUp { from { transform: translateY(0); } to { transform: translateY(-50%); } }
.row { border-bottom: 1px solid var(--guide-grid); cursor: pointer; }
.row:hover, .row.hot { background: rgba(40,224,255,0.14); }
.row.current .cell-ch { background: var(--guide-yellow); color: #001; }
.row.current .cell-ch::after { content: " \25B6"; color: #001; }
.cell { padding: 4px 6px; font-size: clamp(8px,2vw,12px); border-right: 1px solid var(--guide-grid); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-ch { background: var(--guide-cell); color: var(--guide-yellow); }
.cell-ch b { color: #fff; margin-right: 4px; }

/* ===== channel bug + back chip ===== */
.chan-bug { position: absolute; right: 4%; bottom: 6%; z-index: 6; pointer-events: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; max-width: 64%; opacity: 0; transition: opacity 0.3s ease; background: rgba(0,0,0,0.4); padding: 4px 10px; border-radius: 5px; }
.bug-line { display: flex; align-items: baseline; gap: 6px; }
.chan-bug b { color: var(--guide-yellow); font-size: clamp(13px,3.4vw,20px); text-shadow: 1px 1px 0 #000; }
.chan-bug .bug-line span { color: #fff; font-size: clamp(9px,2.4vw,13px); letter-spacing: 1px; text-shadow: 1px 1px 0 #000; }
.bug-title { color: #cfe; font-weight: normal; font-size: clamp(8px,2.1vw,12px); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; text-shadow: 1px 1px 0 #000; }
.bug-title:empty { display: none; }
.screen.tuned .chan-bug { opacity: 0.92; }
.guide-chip { position: absolute; left: 4%; top: 5%; z-index: 6; font: inherit; font-weight: bold; font-size: clamp(10px,2.6vw,14px); letter-spacing: 1px; color: #fff; background: rgba(10,10,114,0.7); border: 1px solid var(--guide-cyan); border-radius: 4px; padding: 5px 10px; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.screen.tuned .guide-chip { opacity: 0.92; pointer-events: auto; }

/* ===== 90s green OSD ===== */
.osd { position: absolute; z-index: 8; pointer-events: none; font-family: "Courier New", Courier, monospace; font-weight: bold; color: var(--osd-green); text-shadow: 2px 2px 0 #001b08, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 0 0 12px rgba(61,255,102,0.65); opacity: 0; transition: opacity 0.12s linear; }
.osd.show { opacity: 1; }
.osd-ch { top: 5%; left: 5%; font-size: clamp(20px,6.2vw,42px); letter-spacing: 2px; line-height: 1; }
.osd-ch .nm { display: block; font-size: 0.42em; color: #c7ffd4; letter-spacing: 2px; margin-top: 5px; }
.screen.tuned .osd-ch { left: auto; right: 5%; text-align: right; }
.osd-vol { bottom: 7%; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; }
.osd-vol .spk { font-size: clamp(14px,4vw,24px); }
.osd-vol .lbl { font-size: clamp(12px,3.6vw,22px); letter-spacing: 2px; }
.vol-bar { display: flex; gap: 3px; }
.seg { width: clamp(7px,2.4vw,16px); height: clamp(16px,5vw,30px); background: rgba(6,40,18,0.55); border: 2px solid var(--osd-green-dk); }
.seg.on { background: var(--osd-green); border-color: #b9ffc8; box-shadow: 0 0 6px var(--osd-green); }

/* ===== tap to unmute ===== */
.unmute { position: absolute; left: 50%; bottom: 20%; transform: translateX(-50%); z-index: 8; font: inherit; font-weight: bold; font-size: clamp(11px,3vw,16px); letter-spacing: 1px; color: #001; background: var(--guide-yellow); border: 2px solid #000; border-radius: 20px; padding: 7px 16px; cursor: pointer; box-shadow: 0 3px 10px rgba(0,0,0,0.5); opacity: 0; pointer-events: none; transition: opacity 0.25s ease; animation: pulse 1.6s ease-in-out infinite; }
.screen.show-unmute .unmute { opacity: 1; pointer-events: auto; }
@keyframes pulse { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.06); } }

/* ===== distortion ===== */
.rollbar { position: absolute; left: 0; right: 0; top: -16%; height: 16%; z-index: 3; pointer-events: none; opacity: 0; background: linear-gradient(180deg, transparent, rgba(255,255,255,0.28) 40%, rgba(0,0,0,0.45) 60%, transparent); mix-blend-mode: screen; }
.screen.glitching .rollbar { animation: roll 0.45s linear; }
@keyframes roll { 0% { opacity: 1; top: -16%; } 100% { opacity: 1; top: 100%; } }
.screen.glitching #player { animation: jitter 0.45s steps(4); }
@keyframes jitter { 0% { transform: translateX(0); } 25% { transform: translateX(-1.6%); } 50% { transform: translateX(1.1%); } 75% { transform: translateX(-0.6%); } 100% { transform: translateX(0); } }
.static { position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.9'/></svg>"); background-size: 220px 220px; transition: opacity 0.1s linear; }
.static.on { opacity: 0.95; animation: noise 0.18s steps(3) infinite; }
@keyframes noise { 0% { background-position: 0 0; } 33% { background-position: -45px 22px; } 66% { background-position: 34px -28px; } 100% { background-position: 0 0; } }

/* ===== CRT effects ===== */
.scanlines { position: absolute; inset: 0; z-index: 4; pointer-events: none; background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px, rgba(0,0,0,0.16) 3px, rgba(0,0,0,0.16) 4px); mix-blend-mode: multiply; opacity: 0.5; }
.glare { position: absolute; inset: 0; z-index: 4; pointer-events: none; background: linear-gradient(115deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0) 38%); }
.power-off { position: absolute; inset: 0; z-index: 10; background: #000; transition: opacity 0.4s ease; }
.power-off.hidden { opacity: 0; pointer-events: none; }
.screen.turning-off .guide, .screen.turning-off #player { animation: crtOff 0.45s forwards; }
@keyframes crtOff { 0% { transform: scale(1,1); filter: brightness(1); } 55% { transform: scale(1.05, 0.02); filter: brightness(2.5); } 100% { transform: scale(0, 0.02); filter: brightness(6); opacity: 0; } }

/* ===== Front panel ===== */
.front {
  display: flex; align-items: center; gap: 16px; margin-top: 18px;
  padding: 12px 16px; flex-wrap: wrap; border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.25));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -2px 6px rgba(0,0,0,0.5);
}

/* perforated speaker grille */
.speaker {
  flex: 1 1 130px; height: 86px; border-radius: 8px; overflow: hidden;
  background: #0c0d0f; border: 1px solid #000;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.85), inset 0 0 0 1px rgba(255,255,255,0.03);
}
.grille {
  width: 100%; height: 100%;
  background-image: radial-gradient(circle at center, #2b2d31 28%, transparent 32%);
  background-size: 9px 9px; background-position: center;
  box-shadow: inset 0 0 26px rgba(0,0,0,0.7);
}

/* metallic brand plate */
.badge {
  text-align: center; min-width: 96px; padding: 6px 12px; border-radius: 6px;
  background: linear-gradient(180deg, #6c6f74, #303236 48%, #1b1c1f 52%, #34363a);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), inset 0 -1px 1px rgba(0,0,0,0.6), 0 1px 2px rgba(0,0,0,0.6);
}
.brand { font-weight: 900; font-style: italic; letter-spacing: 1px; font-size: 20px; color: #e9ebee;
  background: linear-gradient(180deg, #fff, #9aa 60%, #f0f0f0); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 1px 1px rgba(0,0,0,0.4); }
.sub { font-size: 8px; letter-spacing: 3px; color: #aab; margin-top: 1px; }

/* tactile buttons */
.buttons { display: flex; flex-direction: column; gap: 8px; min-width: 178px; }
.btn-row { display: flex; gap: 8px; }
.btn {
  position: relative; font-family: inherit; font-weight: bold; font-size: 12px; letter-spacing: 1px;
  color: #eceff2; cursor: pointer; flex: 1; min-height: 42px; padding: 10px 12px;
  border: 1px solid #050505; border-radius: 8px;
  background: linear-gradient(180deg, #54585e 0%, #393d42 46%, #2a2d31 54%, #1a1c1f 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.30),
    inset 0 -2px 3px rgba(0,0,0,0.55),
    0 3px 5px rgba(0,0,0,0.55),
    0 1px 0 rgba(255,255,255,0.04);
  text-shadow: 0 -1px 1px rgba(0,0,0,0.6);
  transition: transform 0.05s ease, box-shadow 0.05s ease, filter 0.1s ease;
}
.btn:hover { filter: brightness(1.15); }
.btn:active {
  transform: translateY(2px);
  background: linear-gradient(180deg, #2a2d31, #3a3e43);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.7), 0 1px 0 rgba(255,255,255,0.05);
}
.btn.full { width: 100%; color: var(--guide-cyan); }
.btn.power {
  display: flex; align-items: center; gap: 9px; justify-content: center; width: 100%;
  background: linear-gradient(180deg, #8a3030 0%, #5a1c1c 48%, #441414 54%, #2c0d0d 100%);
  color: #ffe6e6;
}
.led {
  width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #663, #220);
  box-shadow: inset 0 0 2px #000; transition: background 0.25s, box-shadow 0.25s;
}
.led.on { background: radial-gradient(circle at 35% 30%, #aaffb0, var(--led)); box-shadow: 0 0 10px var(--led), 0 0 3px #fff inset; }

:focus-visible { outline: 3px solid var(--guide-cyan); outline-offset: 2px; border-radius: 6px; }

/* ===== Legs + hint ===== */
.legs { display: flex; justify-content: space-between; padding: 0 80px; }
.leg { width: 18px; height: 28px; background: linear-gradient(180deg, #1a1a1d, #050506); border-radius: 0 0 6px 6px; box-shadow: 0 6px 8px rgba(0,0,0,0.6); }
.hint { margin-top: 18px; font-size: 13px; color: #9aa; text-align: center; line-height: 1.5; }
.hint b { color: #cfe; }

/* ===== Cinema / full-screen mode ===== */
body.cinema { padding: 0; height: 100vh; height: 100dvh; overflow: hidden; }
body.cinema .room { max-width: none; height: 100%; }
body.cinema .tv { position: fixed; inset: 0; display: flex; flex-direction: column; }
body.cinema .cabinet { flex: 1; display: flex; flex-direction: column; border-radius: 0; padding: 8px; gap: 6px; border: 0; }
body.cinema .bezel { flex: 1; display: flex; padding: 10px; border-radius: 16px; }
body.cinema .bezel::before, body.cinema .bezel::after { display: none; }
body.cinema .screen { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 10px; }
body.cinema .front { margin-top: 0; padding: 6px 8px; gap: 8px; border-radius: 8px; }
body.cinema .speaker, body.cinema .badge { display: none; }
body.cinema .buttons { flex-direction: row; flex-wrap: wrap; min-width: 0; width: 100%; gap: 6px; align-items: stretch; }
body.cinema .btn-row { flex: 1 1 30%; }
body.cinema .btn.power, body.cinema .btn.full { width: auto; flex: 1 1 30%; }
body.cinema .legs, body.cinema .hint { display: none; }

@media (max-width: 560px) {
  .badge { order: -1; width: 100%; }
  .speaker { display: none; }
  .buttons { min-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .listings-rows { animation: none; }
  .static.on { animation: none; }
  .screen.glitching .rollbar, .screen.glitching #player { animation: none; }
  .unmute { animation: none; }
  .screen.turning-off .guide, .screen.turning-off #player { animation: none; }
  #player { transition: none; }
}
