:root {
  --accent: #3fa9f5;
  --panel: rgba(8, 14, 30, 0.88);
  --panel-solid: #0a1226;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f2f5fb;
  --muted: #9aa7c2;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--text); font-family: var(--font); overflow: hidden; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

#tv { position: fixed; inset: 0; cursor: none; }
#tv.show-cursor { cursor: default; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; object-fit: contain; }
#static { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; transition: opacity 0.25s; image-rendering: pixelated; }
#static.on { opacity: 1; transition: none; }

/* ---------- Power screen ---------- */
#power {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  background: radial-gradient(circle at 50% 45%, #13203f 0%, #000 70%); z-index: 50; cursor: default;
}
#powerBtn {
  width: 140px; height: 140px; border-radius: 50%; border: 3px solid #e2483d; background: #1a0d0d; color: #ff6b5e;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 0 40px rgba(226, 72, 61, 0.35); transition: transform 0.15s, box-shadow 0.15s;
}
#powerBtn:hover, #powerBtn:focus-visible { transform: scale(1.05); box-shadow: 0 0 70px rgba(226, 72, 61, 0.6); outline: none; }
.power-label { font-size: 22px; color: var(--muted); letter-spacing: 0.04em; }
.power-msg { max-width: 560px; text-align: center; color: #ffcf6b; line-height: 1.5; }
.power-msg a { color: var(--accent); }

/* ---------- Interstitial card ---------- */
#card {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 5;
  background: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--chan, #234) 55%, #000) 0%, #000 75%);
}
.card-inner { text-align: center; padding: 40px; max-width: 900px; }
.card-channel { display: inline-flex; gap: 14px; align-items: baseline; padding: 8px 20px; border-radius: 999px; background: rgba(0,0,0,0.35); border: 1px solid var(--line); margin-bottom: 36px; }
.card-channel .num { font-size: 28px; font-weight: 800; }
.card-channel .name { font-size: 20px; color: var(--muted); }
.card-kicker { text-transform: uppercase; letter-spacing: 0.3em; color: var(--muted); font-size: 18px; margin-bottom: 14px; }
.card-title { font-size: clamp(34px, 6vw, 72px); font-weight: 800; line-height: 1.05; text-shadow: 0 4px 30px rgba(0,0,0,0.6); }
.card-sub { font-size: clamp(18px, 2.4vw, 28px); color: #d6def0; margin-top: 12px; }
.card-time { font-size: clamp(20px, 3vw, 34px); margin-top: 34px; font-variant-numeric: tabular-nums; color: #ffd76b; }

/* ---------- Channel banner ---------- */
#banner {
  position: absolute; left: 4vw; right: 4vw; bottom: 5vh; z-index: 10; display: flex; align-items: stretch; gap: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55); backdrop-filter: blur(8px); animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.banner-chan { min-width: 150px; padding: 18px 22px; background: var(--chan, #234); display: flex; flex-direction: column; justify-content: center; text-align: center; }
.banner-chan .num { font-size: 46px; font-weight: 900; line-height: 1; text-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.banner-chan .name { font-size: 15px; margin-top: 6px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }
.banner-body { flex: 1; padding: 16px 24px; min-width: 0; }
.banner-top { display: flex; align-items: center; gap: 12px; }
.banner-top .title { font-size: 28px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rating { font-size: 12px; border: 1px solid var(--muted); color: var(--muted); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.rating:empty { display: none; }
.banner-body .sub { color: #cbd5ea; font-size: 18px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.2em; }
.progress { margin-top: 12px; height: 6px; background: rgba(255,255,255,0.15); border-radius: 3px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); }
.times { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 14px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.times .next { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-clock { padding: 16px 24px; font-size: 22px; font-weight: 600; display: flex; align-items: center; border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }

#numentry { position: absolute; top: 5vh; right: 5vw; z-index: 20; font-size: 64px; font-weight: 900; letter-spacing: 0.1em; color: #7dff9a; text-shadow: 0 0 12px rgba(0,255,90,0.6), 0 2px 0 #000; font-variant-numeric: tabular-nums; }
#mute { position: absolute; top: 5vh; left: 5vw; z-index: 20; font-size: 34px; font-weight: 900; color: #7dff9a; text-shadow: 0 0 12px rgba(0,255,90,0.6), 0 2px 0 #000; }

/* ---------- Guide ---------- */
#guide {
  position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(6,10,24,0.97), rgba(4,8,20,0.97)); cursor: default;
}
.guide-head { display: flex; justify-content: space-between; gap: 24px; padding: 22px 3vw 14px; min-height: 190px; }
.guide-detail { display: flex; gap: 20px; min-width: 0; }
.guide-detail .poster { width: 104px; height: 156px; object-fit: cover; border-radius: 8px; background: #111a33; flex: none; }
.guide-detail .poster[src=""] { visibility: hidden; }
.d-title { font-size: 30px; font-weight: 800; }
.d-sub { font-size: 18px; color: #cbd5ea; margin-top: 4px; }
.d-meta { font-size: 15px; color: var(--muted); margin-top: 6px; display: flex; gap: 10px; align-items: center; }
.d-summary { color: #c0c9dc; font-size: 15px; line-height: 1.45; max-width: 900px; margin: 10px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.guide-clock { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.guide-grid { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 3vw 10px; --chanw: 190px; }
.guide-times { position: relative; height: 34px; margin-left: var(--chanw); border-bottom: 1px solid var(--line); flex: none; }
.guide-times span { position: absolute; top: 6px; font-size: 15px; color: var(--muted); font-weight: 600; padding-left: 8px; border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.guide-rows { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; scrollbar-width: thin; position: relative; }
.g-row { display: flex; height: 64px; border-bottom: 1px solid var(--line); }
.g-chan { width: var(--chanw); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px; cursor: pointer; border-left: 5px solid var(--chan, #345); background: rgba(255,255,255,0.03); }
.g-chan .num { font-size: 22px; font-weight: 800; min-width: 42px; }
.g-chan .name { font-size: 14px; color: #cbd5ea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-row.current .g-chan { background: rgba(63,169,245,0.18); }
.g-progs { position: relative; flex: 1; overflow: hidden; }
.g-prog {
  position: absolute; top: 4px; bottom: 4px; padding: 7px 10px; border-radius: 6px; cursor: pointer; overflow: hidden;
  background: #16244a; border: 1px solid rgba(255,255,255,0.08); white-space: nowrap;
}
.g-prog:hover { background: #1f3264; }
.g-prog.on-now { background: #1b2f5e; }
.g-prog.selected { background: var(--accent); color: #031627; border-color: #fff; box-shadow: 0 0 0 2px #fff inset; }
.g-prog .t { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.g-prog .s { font-size: 12.5px; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.g-prog.selected .s { opacity: 0.9; }
.g-prog.cont::before { content: "◂ "; position: absolute; left: 3px; top: 7px; font-size: 11px; opacity: 0.6; }
.g-now { position: absolute; top: 0; bottom: 0; width: 2px; background: #ff5a4f; z-index: 2; pointer-events: none; box-shadow: 0 0 8px #ff5a4f; }
.guide-help { padding: 8px 3vw 14px; color: var(--muted); font-size: 14px; }

/* ---------- On-screen remote ---------- */
#remote {
  position: absolute; top: 3vh; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; gap: 6px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); cursor: default;
}
#remote button { background: #18223f; border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; font-weight: 700; font-size: 14px; cursor: pointer; min-width: 52px; }
#remote button:hover { background: #24345f; }
#remote button:active { transform: scale(0.96); }

@media (max-width: 760px) {
  .banner-chan { min-width: 90px; padding: 12px; }
  .banner-chan .num { font-size: 32px; }
  .banner-top .title { font-size: 20px; }
  .banner-body .sub { font-size: 14px; }
  .banner-clock { display: none; }
  .guide-grid { --chanw: 96px; }
  .g-chan .name { display: none; }
  .guide-head { min-height: 140px; }
  .guide-detail .poster { width: 70px; height: 105px; }
  .d-title { font-size: 22px; }
  .guide-clock { font-size: 18px; }
  #remote button { padding: 8px 9px; min-width: 0; font-size: 12px; }
}

/* While the guide is open, park the remote at the bottom so it doesn't cover the details. */
#guide:not(.hidden) ~ #remote { top: auto; bottom: 2vh; }
