/* CRT TV web — tvOS CRT TV theme (bg #1C0A57, panel #201367, tile #35227D,
   gold #F5D547, pale #EDE5CB, muted #B0A5D0), spelunkr.tv-inspired browsing.
   VT323 font (c) 2011 The VT323 Project Authors, SIL OFL 1.1 — see assets/fonts/OFL.txt */

@font-face {
  font-family: 'VT323';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/VT323-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'VT323';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/VT323-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'VT323';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/VT323-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #1C0A57;
  --panel: #201367;
  --tile: #35227D;
  --gold: #F5D547;
  --pale: #EDE5CB;
  --muted: #B0A5D0;
  --green: #6FE87C;
  --danger: #FF6B6B;
  --hairline: rgba(255,255,255,0.16);
  --font-disp: "VT323", "Courier New", ui-monospace, monospace;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--pale); font-family: var(--font-mono); }
#app { min-height: 100vh; }
button { font-family: var(--font-mono); }

/* Focus: gold fill, dark label, gold glow (StationButtonStyle) */
.tbtn {
  background: var(--tile); color: var(--pale); border: 1px solid var(--hairline);
  padding: 10px 18px; font-size: 15px; font-weight: 700; cursor: pointer;
  letter-spacing: 0.02em; text-align: left;
}
.tbtn:hover { border-color: rgba(245,213,71,0.7); }
.tbtn:focus-visible, .tbtn.focused {
  background: var(--gold); color: var(--bg); border-color: var(--gold); outline: none;
  box-shadow: 0 0 18px rgba(245,213,71,0.5);
}

/* Boot */
#boot { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.boot-logo { font-family: var(--font-disp); font-size: 84px; color: var(--gold); letter-spacing: 0.04em; line-height: 1; }
.boot-status { color: var(--green); font-size: 16px; letter-spacing: 0.22em; font-weight: 700; }
.boot-error { color: var(--danger); max-width: 460px; text-align: center; line-height: 1.6; font-size: 15px; }

/* ---------- Guide ---------- */
#guide { padding: 22px clamp(12px, 3vw, 60px) 16px; max-width: 1780px; margin: 0 auto; }

.topbar { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.topbar .wordmark { font-family: var(--font-disp); font-size: 52px; line-height: 0.9; color: var(--gold); letter-spacing: 0.03em; }
.topbar .divider { width: 2px; height: 26px; background: rgba(245,213,71,0.6); align-self: center; }
.topbar .pagename { font-size: 19px; font-weight: 700; color: var(--pale); letter-spacing: 0.08em; }
.topbar .spacer { flex: 1; }
.topbar .clock { font-size: 21px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.topbar .tbtn { padding: 12px 14px; font-size: 14px; align-self: center; }

.statusline { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; margin: 10px 4px 16px; }
.statusline .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); flex: none; }

/* Hero: preview screen + channel detail (spelunkr guide hero, tvOS theme) */
.hero { display: grid; grid-template-columns: minmax(280px, 460px) 1fr; gap: 22px; margin-bottom: 22px; }
.hero-screen {
  position: relative; background: #000; border: 1px solid var(--hairline); aspect-ratio: 16 / 9;
  overflow: hidden;
}
.hero-screen video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.hero-screen .screen-tag {
  position: absolute; left: 10px; bottom: 8px; font-family: var(--font-disp); font-size: 18px;
  color: var(--muted); letter-spacing: 0.14em; pointer-events: none;
}
.hero-screen .screen-tuning {
  position: absolute; left: 10px; top: 8px; color: var(--green); font-weight: 700; font-size: 14px;
  letter-spacing: 0.18em; pointer-events: none; text-shadow: 0 1px 6px #000;
}
.hero-screen .screen-tuning .chnum { font-family: var(--font-disp); font-size: 26px; margin-right: 8px; letter-spacing: 0.06em; }
.hero-screen .screen-mute {
  position: absolute; right: 8px; bottom: 8px; background: rgba(32,19,103,0.85); color: var(--muted);
  border: 1px solid var(--hairline); font-size: 12px; padding: 4px 8px; cursor: pointer;
}
.hero-screen .screen-mute:hover { color: var(--pale); }
.hero-info { border: 1px solid var(--hairline); background: var(--panel); padding: 16px 20px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hero-chanline { display: flex; align-items: center; gap: 12px; }
.hero-chanline img { width: 44px; height: 44px; object-fit: contain; }
.hero-chanline .hname { font-family: var(--font-disp); font-size: 34px; color: var(--gold); letter-spacing: 0.04em; line-height: 1; }
.hero-chanline .hnum { color: var(--muted); font-size: 14px; font-weight: 700; letter-spacing: 0.1em; }
.hero-chanline .live { margin-left: auto; color: #fff; font-size: 13px; font-weight: 700; letter-spacing: 0.14em; }
.hero-chanline .live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #fff; margin-right: 7px; }
.hero-desc { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.hero-nowlabel { color: var(--gold); font-size: 13px; font-weight: 700; letter-spacing: 0.18em; margin-top: 4px; }
.hero-title { color: var(--pale); font-size: 19px; font-weight: 700; line-height: 1.35; }
.hero-progress { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hero-progress .bar { flex: 1; height: 5px; background: var(--tile); }
.hero-progress .bar > div { height: 100%; background: var(--gold); width: 0; }
.hero-next { color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.hero-next b { color: var(--pale); font-weight: 700; }
.hero-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.hero-actions .tbtn { font-size: 15px; padding: 12px 26px; }
.hero-chips { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.chip { border: 1px solid var(--hairline); background: var(--tile); padding: 7px 12px 5px; text-align: center; min-width: 104px; }
.chip .big { font-family: var(--font-disp); font-size: 26px; color: var(--gold); line-height: 1; display: block; }
.chip .small { color: var(--muted); font-size: 10.5px; letter-spacing: 0.1em; display: block; margin-top: 3px; }

/* EPG grid */
.epg { overflow-x: auto; border: 1px solid var(--hairline); background: var(--panel); }
.epg-inner { min-width: 900px; }
.epg-head { display: flex; border-bottom: 1px solid var(--hairline); }
.epg-head .chanlabel { width: 250px; flex: none; padding: 7px 0 6px 18px; font-size: 15px; font-weight: 700; color: var(--gold); letter-spacing: 0.1em; }
.epg-head .times { flex: 1; display: flex; position: relative; }
.epg-head .times span { flex: 1; font-size: 15px; font-weight: 700; color: var(--gold); padding: 7px 0 6px 8px; font-variant-numeric: tabular-nums; border-left: 1px solid rgba(255,255,255,0.07); }
.epg-row { display: flex; border-bottom: 1px solid rgba(255,255,255,0.06); }
.epg-row:last-child { border-bottom: 0; }
.chan-cell {
  width: 250px; flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 0;
  cursor: pointer; border: 1px solid transparent; background: transparent; color: var(--pale);
}
.chan-cell .stripe { width: 7px; align-self: stretch; flex: none; background: var(--chan, var(--gold)); }
.chan-cell .idcol { min-width: 0; }
.chan-cell .num { font-family: var(--font-disp); font-size: 34px; line-height: 1; color: var(--pale); }
.chan-cell .cname { font-size: 14px; font-weight: 700; color: var(--pale); line-height: 1.15; margin-top: 3px; }
.chan-cell img { width: 52px; height: 52px; object-fit: contain; margin-left: auto; flex: none; }
.epg-row.focused .chan-cell { background: var(--gold); }
.epg-row.focused .chan-cell .num, .epg-row.focused .chan-cell .cname { color: var(--bg); }
.epg-row .timeline { position: relative; flex: 1; min-height: 76px; background: var(--panel); overflow: hidden; }
.tile {
  position: absolute; top: 0; bottom: 0; background: var(--tile); border-right: 3px solid var(--panel);
  padding: 8px 10px; overflow: hidden; cursor: pointer; color: var(--pale); text-align: left; border-top: 0; border-left: 0; border-bottom: 0;
}
.tile .t { font-size: 14.5px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tile .s .onnow { color: var(--gold); font-weight: 700; margin-right: 8px; letter-spacing: 0.08em; }
.tile:hover { outline: 2px solid rgba(245,213,71,0.75); outline-offset: -2px; }
.epg-row.focused .tile { outline: 1px solid rgba(245,213,71,0.35); outline-offset: -1px; }
.nowline { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(245,213,71,0.8); pointer-events: none; z-index: 3; }

/* Detail line + footer */
.detail-line { margin: 14px 4px 0; min-height: 62px; }
.detail-line .dtitle { color: var(--gold); font-size: 17px; font-weight: 700; display: flex; gap: 14px; flex-wrap: wrap; }
.detail-line .dtitle .range { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 400; }
.detail-line .ddesc { color: var(--pale); font-size: 13.5px; margin-top: 6px; line-height: 1.5; }
.foot { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); letter-spacing: 0.06em; }
.foot .right { margin-left: auto; }
.foot a { color: var(--muted); }
.skew-warn { color: var(--danger); width: 100%; }
.skew-warn:empty { display: none; }

/* About overlay */
#about { position: fixed; inset: 0; background: rgba(14,5,46,0.9); display: none; z-index: 40; padding: 8vh clamp(16px, 8vw, 120px); overflow: auto; }
#about.on { display: block; }
#about .panel { background: var(--bg); border: 1px solid var(--hairline); padding: clamp(20px, 4vw, 60px); max-width: 860px; margin: 0 auto; }
#about h1 { font-family: var(--font-disp); color: var(--gold); font-size: 44px; margin: 0 0 18px; letter-spacing: 0.04em; }
#about p { color: var(--pale); font-size: 15px; line-height: 1.7; }

/* ---------- Player ---------- */
#player { position: fixed; inset: 0; background: #000; display: none; z-index: 30; }
#player.on { display: block; }
#video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.osd { position: absolute; inset: 0; pointer-events: none; transition: opacity 0.35s; display: flex; flex-direction: column; justify-content: flex-end; }
.osd.hidden { opacity: 0; }
.osd > * { pointer-events: auto; }

.osd-brand { position: absolute; top: 16px; left: 20px; font-family: var(--font-disp); font-size: 30px; color: var(--gold); letter-spacing: 0.05em; text-shadow: 0 2px 10px rgba(0,0,0,0.8); pointer-events: none; }
.osd-live { position: absolute; top: 22px; right: 22px; color: #fff; font-size: 14px; font-weight: 700; letter-spacing: 0.14em; text-shadow: 0 1px 6px #000; pointer-events: none; }
.osd-live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #fff; margin-right: 7px; }
.osd-tune { position: absolute; top: 60px; left: 20px; color: var(--green); font-weight: 700; letter-spacing: 0.18em; font-size: 16px; text-shadow: 0 1px 8px #000; pointer-events: none; display: none; }
.osd-tune.on { display: block; }
.osd-tune .chnum { font-family: var(--font-disp); font-size: 34px; letter-spacing: 0.06em; margin-right: 10px; }

.osd-status { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: clamp(17px, 2.6vw, 26px); font-weight: 700; letter-spacing: 0.2em; color: var(--pale); text-shadow: 0 2px 12px rgba(0,0,0,0.85); display: none; pointer-events: none; }
.osd-status.on { display: block; }
.osd-retry { position: absolute; top: calc(50% + 34px); left: 50%; transform: translateX(-50%); display: none; }
.osd-retry.on { display: block; }

.osd-stack {
  position: relative; width: 100%; padding: 40px 20px 16px;
  background: linear-gradient(transparent, rgba(10,4,35,0.75) 45%, rgba(10,4,35,0.94));
  display: flex; flex-direction: column; gap: 7px;
}
.osd-chan, .osd-desc, .osd-title, .osd-next, .osd-rows, .osd-foot { max-width: 900px; }
.osd-chan { display: flex; align-items: center; gap: 10px; }
.osd-chan img { width: 38px; height: 38px; object-fit: contain; }
.osd-chan .dial { font-family: var(--font-disp); font-size: 32px; color: var(--gold); line-height: 1; }
.osd-chan .cname { font-size: 17px; font-weight: 700; color: var(--pale); }
.osd-desc { color: var(--muted); font-size: 12.5px; }
.osd-title { color: #fff; font-size: clamp(17px, 2.4vw, 24px); font-weight: 700; text-shadow: 0 1px 8px rgba(0,0,0,0.7); }
.osd-next { color: var(--muted); font-size: 13px; letter-spacing: 0.04em; }
.osd-next .behind { color: var(--gold); margin-left: 12px; font-weight: 700; }
.osd-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.osd-row { display: flex; gap: 8px; flex-wrap: wrap; }
.osd-rows .tbtn { background: rgba(32,19,103,0.92); }
.osd-rows .tbtn:disabled { opacity: 0.45; cursor: default; }
.osd-foot { color: var(--muted); font-size: 11.5px; margin-top: 6px; letter-spacing: 0.04em; pointer-events: none; }

/* What's On strip: full-width band above the control stack, edge fade signals more */
#whatson {
  display: none; order: -1; gap: 8px; overflow-x: auto; margin: 0 20px 8px; padding: 6px 2px 8px;
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
  mask-image: linear-gradient(90deg, #000 88%, transparent);
}
#whatson.on { display: flex; }
.wo-card {
  flex: none; width: 190px; background: rgba(32,19,103,0.95); border: 1px solid var(--hairline);
  padding: 8px 10px; cursor: pointer; color: var(--pale); text-align: left;
}
.wo-card .wo-head { display: flex; align-items: center; gap: 8px; }
.wo-card img { width: 24px; height: 24px; object-fit: contain; }
.wo-card .wo-num { font-family: var(--font-disp); font-size: 22px; color: var(--gold); line-height: 1; }
.wo-card .wo-name { font-size: 12.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wo-card .wo-title { font-size: 12px; color: var(--pale); margin-top: 6px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.wo-card:hover { border-color: rgba(245,213,71,0.7); }
.wo-card.focused, .wo-card:focus-visible { background: var(--gold); color: var(--bg); border-color: var(--gold); outline: none; box-shadow: 0 0 18px rgba(245,213,71,0.5); }
.wo-card.focused .wo-num, .wo-card:focus-visible .wo-num,
.wo-card.focused .wo-title, .wo-card:focus-visible .wo-title { color: var(--bg); }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .topbar .wordmark { font-size: 40px; }
  .chan-cell { width: 190px; }
  .epg-head .chanlabel { width: 190px; }
  .osd-stack { padding: 30px 10px 12px; }
  #whatson { margin: 0 10px 6px; }
}
