:root {
  --room: #140d08;
  --wood-1: #5a3a22;
  --wood-2: #3b2414;
  --plastic: #2a2622;
  --epg-1: #0b2a7a;
  --epg-2: #04123f;
  --panel: rgba(8, 26, 90, 0.78);
  --panel-line: #2f5bd8;
  --ink: #e9f1ff;
  --dim: #8ea6de;
  --cyan: #5ff2ff;
  --yellow: #ffd83a;
  --green: #3dff8b;
  --red: #ff3b3b;
  --blue: #3b7bff;
  --live: #ff2d55;
  --pixel: "VT323", ui-monospace, monospace;
  --block: "Press Start 2P", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, #3a2616 0%, transparent 60%),
    radial-gradient(ellipse at 50% 110%, #24160c 0%, transparent 60%),
    var(--room);
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 20px;
  line-height: 1.15;
  padding: 28px 16px 40px;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px dashed var(--yellow); outline-offset: 2px; }

/* ---------- The TV set ---------- */
.tv {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 26px 0;
  border-radius: 34px;
  background:
    repeating-linear-gradient(92deg, rgba(0,0,0,.08) 0 3px, transparent 3px 9px),
    linear-gradient(180deg, var(--wood-1), var(--wood-2));
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.12),
    inset 0 -6px 16px rgba(0,0,0,.5),
    0 30px 60px rgba(0,0,0,.6),
    0 0 0 6px #1b110a;
}
.screen {
  position: relative;
  overflow: hidden;
  border-radius: 38px / 30px;
  padding: 22px 26px 0;
  min-height: 70vh;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(80,130,255,.25), transparent 70%),
    linear-gradient(180deg, var(--epg-1), var(--epg-2));
  box-shadow:
    0 0 0 10px #111, 0 0 0 14px #2c2c2c,
    inset 0 0 80px rgba(0,0,0,.85),
    inset 0 0 18px rgba(120,170,255,.35);
  animation: flicker 6s infinite steps(1);
  text-shadow: 0 0 6px rgba(120,190,255,.45);
}
/* scanlines + curved-glass vignette */
.screen::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: repeating-linear-gradient(180deg, rgba(0,0,0,.22) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.glass {
  position: absolute; inset: 0; pointer-events: none; z-index: 6;
  background:
    radial-gradient(ellipse at 30% 8%, rgba(255,255,255,.10), transparent 35%),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%);
}
@keyframes flicker { 0%, 100% { filter: none; } 47% { filter: brightness(1.04); } 48% { filter: brightness(.97); } }

.static {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 7; pointer-events: none; opacity: 0; transition: opacity .12s;
}
.static.on { opacity: .9; }

/* ---------- EPG header ---------- */
.epg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 12px; border-bottom: 2px solid var(--panel-line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dish { font-size: 34px; filter: drop-shadow(0 0 6px rgba(255,216,58,.5)); }
h1 {
  margin: 0; font-family: var(--block); font-size: 20px; color: var(--yellow);
  letter-spacing: 1px; text-shadow: 3px 3px 0 #b3261e, 0 0 10px rgba(255,216,58,.5);
}
.tvtag {
  font-size: 10px; margin-left: 8px; padding: 3px 5px; vertical-align: middle;
  background: var(--red); color: #fff; text-shadow: none; border-radius: 3px;
}
.sub { margin: 6px 0 0; color: var(--cyan); letter-spacing: 2px; font-size: 18px; }
.clock { text-align: right; font-size: 34px; color: var(--green); line-height: 1; text-shadow: 0 0 8px rgba(61,255,139,.6); }
.clock-date { display: block; font-size: 18px; color: var(--dim); text-shadow: none; }

/* ---------- Day tabs (remote colour keys) ---------- */
.days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 10px; }
.day {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 10px 8px 30px; position: relative; text-align: left;
  background: var(--panel); border: 2px solid var(--panel-line); border-radius: 6px;
}
.day::before {
  content: ""; position: absolute; left: 10px; top: 13px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--k); box-shadow: 0 0 8px var(--k);
}
.day .dname { font-size: 24px; letter-spacing: 1px; }
.day .ddate { font-size: 16px; color: var(--dim); }
.day .dn { position: absolute; right: 8px; top: 6px; font-size: 16px; color: var(--dim); }
.day[aria-selected="true"] { background: var(--yellow); border-color: #fff4b0; color: #111; text-shadow: none; }
.day[aria-selected="true"] .ddate, .day[aria-selected="true"] .dn { color: #3a3000; }
.day:nth-child(1) { --k: var(--red); }
.day:nth-child(2) { --k: var(--green); }
.day:nth-child(3) { --k: var(--yellow); }
.day:nth-child(4) { --k: var(--blue); }

/* ---------- Controls ---------- */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 0; }
.chip {
  background: rgba(0,0,0,.35); border: 2px solid var(--panel-line); padding: 4px 10px;
  font-size: 18px; letter-spacing: 1px; border-radius: 0;
}
.seg .chip:first-child { border-radius: 6px 0 0 6px; }
.seg .chip:last-child { border-radius: 0 6px 6px 0; }
.seg .chip + .chip { border-left: 0; }
.chip.toggle { border-radius: 6px; }
.chip.ghost { border-radius: 6px; border-style: dashed; margin-left: auto; }
.chip[aria-pressed="true"] { background: var(--cyan); color: #00202a; text-shadow: none; border-color: #bff9ff; }
.chip:hover { border-color: var(--yellow); }
.count { color: var(--dim); font-size: 18px; }

/* ---------- Programme list ---------- */
.list { display: flex; flex-direction: column; gap: 6px; padding-bottom: 60px; min-height: 40vh; }
.prog {
  display: grid; grid-template-columns: 92px 1fr auto; gap: 14px; align-items: center;
  background: var(--panel); border: 2px solid transparent; border-left: 6px solid var(--sport);
  padding: 10px 12px; border-radius: 4px;
}
.prog.football { --sport: var(--green); }
.prog.cricket { --sport: var(--yellow); }
.prog.f1 { --sport: #ff5a36; }
.prog.tennis { --sport: #c8ff3d; }
.lines { list-style: none; margin: 2px 0 4px; padding: 0; font-size: 19px; color: var(--ink); }
.lines li::before { content: "› "; color: var(--sport); }
.prog:hover, .prog:focus-within { border-color: var(--yellow); border-left-color: var(--sport); background: rgba(20, 50, 150, .85); }
.prog.post { opacity: .6; }
.time { text-align: center; }
.time .t { font-size: 34px; color: var(--yellow); line-height: 1; display: block; }
.time .z { font-size: 14px; color: var(--dim); letter-spacing: 2px; }
.live-tag {
  display: inline-block; margin-top: 4px; padding: 0 6px; background: var(--live); color: #fff;
  font-size: 16px; text-shadow: none; animation: blink 1s steps(2) infinite;
}
.ft-tag { display: inline-block; margin-top: 4px; padding: 0 6px; border: 1px solid var(--dim); color: var(--dim); font-size: 15px; }
@keyframes blink { 50% { opacity: .35; } }

.meta { font-size: 16px; color: var(--cyan); letter-spacing: 1px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.meta .ch { background: var(--sport); color: #041030; padding: 0 5px; text-shadow: none; }
.teams { font-size: 26px; margin: 3px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.team { display: inline-flex; align-items: center; gap: 6px; }
.team img { width: 22px; height: 22px; object-fit: contain; filter: drop-shadow(0 0 2px rgba(255,255,255,.4)); }
.score { color: var(--green); margin-left: 4px; }
.vs { color: var(--dim); font-size: 18px; }
.venue { font-size: 16px; color: var(--dim); }
.result { font-size: 17px; color: var(--green); }

.watch { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill {
  font-size: 16px; padding: 1px 7px; border: 1px solid; border-radius: 3px; white-space: nowrap; text-shadow: none;
}
.pill.p-tv { background: #f2f2f2; color: #0b1a4a; border-color: #fff; }
.pill.p-ott { background: #1b0b3a; color: #e5d6ff; border-color: #9b7bff; }
.pill.p-free { background: var(--green); color: #002a12; border-color: #b6ffd3; font-weight: bold; }
.pill.p-unknown { background: transparent; color: var(--dim); border-style: dashed; }
.pill .q, .q { color: #ff9f1c; font-weight: bold; }

.cal { position: relative; display: flex; gap: 6px; align-items: center; }
.bell-btn {
  background: rgba(0,0,0,.35); border: 2px solid var(--yellow); color: var(--yellow); padding: 6px 9px; font-size: 18px;
  border-radius: 6px; white-space: nowrap; box-shadow: 0 3px 0 #6b5a00;
}
.bell-btn[aria-pressed="true"] { background: var(--yellow); color: #111; text-shadow: none; animation: ring 2.4s ease-in-out infinite; }
.bell-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #6b5a00; }
@keyframes ring { 0%, 88%, 100% { transform: rotate(0); } 91% { transform: rotate(-8deg); } 95% { transform: rotate(8deg); } }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 50; max-width: min(calc(100% - 32px), 560px);
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
  background: #020a26; border: 2px solid var(--yellow); color: var(--ink); padding: 8px 14px; font-size: 19px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.cal-btn {
  background: var(--red); border: 2px solid #ff9a9a; color: #fff; padding: 6px 10px; font-size: 18px;
  border-radius: 6px; text-shadow: none; white-space: nowrap; box-shadow: 0 3px 0 #7a0f0f;
}
.cal-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a0f0f; }
.cal-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 4; min-width: 200px;
  background: #020a26; border: 2px solid var(--yellow); display: none; flex-direction: column;
}
.cal.open .cal-menu { display: flex; }
.cal-menu a, .cal-menu button {
  background: none; border: 0; text-align: left; padding: 8px 12px; color: var(--ink); text-decoration: none; font-size: 18px;
}
.cal-menu a:hover, .cal-menu button:hover { background: var(--yellow); color: #111; text-shadow: none; }

/* ---------- States ---------- */
.state { text-align: center; padding: 30px 10px; }
.state h2 { font-family: var(--block); font-size: 16px; color: var(--yellow); margin: 18px 0 10px; }
.state p { color: var(--dim); margin: 0; }
.bars { display: inline-flex; gap: 5px; align-items: flex-end; height: 40px; }
.bars span { width: 10px; background: var(--green); animation: sig 1s infinite ease-in-out; }
.bars span:nth-child(1) { height: 25%; } .bars span:nth-child(2) { height: 50%; animation-delay: .15s; }
.bars span:nth-child(3) { height: 75%; animation-delay: .3s; } .bars span:nth-child(4) { height: 100%; animation-delay: .45s; }
@keyframes sig { 50% { opacity: .2; } }
.testcard { display: grid; grid-template-columns: repeat(7, 1fr); height: 110px; max-width: 420px; margin: 0 auto; border: 3px solid #000; }
.testcard span:nth-child(1) { background: #c0c0c0; } .testcard span:nth-child(2) { background: #c0c000; }
.testcard span:nth-child(3) { background: #00c0c0; } .testcard span:nth-child(4) { background: #00c000; }
.testcard span:nth-child(5) { background: #c000c0; } .testcard span:nth-child(6) { background: #c00000; }
.testcard span:nth-child(7) { background: #0000c0; }
.section-h { font-size: 16px; color: var(--dim); letter-spacing: 3px; margin: 10px 0 2px; border-bottom: 1px dashed var(--panel-line); }

/* ---------- Ticker ---------- */
.ticker {
  position: absolute; left: 0; right: 0; bottom: 0; height: 34px; overflow: hidden; z-index: 3;
  background: linear-gradient(180deg, #b3261e, #7a120d); border-top: 2px solid var(--yellow);
  display: flex; align-items: center;
}
.ticker-inner { white-space: nowrap; padding-left: 100%; animation: tick 60s linear infinite; font-size: 20px; color: #fff; }
@keyframes tick { to { transform: translateX(-100%); } }

/* ---------- Cabinet ---------- */
.cabinet { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 10px 18px; }
.badge {
  font-family: var(--block); font-size: 10px; color: #d9c7a5; letter-spacing: 2px;
  padding: 6px 10px; background: linear-gradient(#c9b27f, #8a7446); color: #2a1e0c; border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
}
.badge b { color: #7a120d; }
.remote { display: flex; gap: 10px; }
.key { width: 26px; height: 12px; border-radius: 6px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.35), 0 2px 0 #000; }
.key.red { background: var(--red); } .key.green { background: #1fcf5d; } .key.yellow { background: var(--yellow); } .key.blue { background: var(--blue); }
.knobs { display: flex; align-items: center; gap: 12px; }
.knob {
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #777, #222 70%);
  box-shadow: 0 3px 6px rgba(0,0,0,.6), inset 0 0 0 3px #111;
  position: relative;
}
.knob::after { content: ""; position: absolute; left: 50%; top: 4px; width: 3px; height: 10px; background: #ddd; transform: translateX(-50%) rotate(30deg); transform-origin: 50% 13px; }
.led { width: 8px; height: 8px; border-radius: 50%; background: #3dff8b; box-shadow: 0 0 8px #3dff8b; }
.led.busy { background: #ff9f1c; box-shadow: 0 0 8px #ff9f1c; animation: blink .5s steps(2) infinite; }

.foot { max-width: 1080px; margin: 18px auto 0; color: #a58b6b; font-size: 17px; text-align: center; }
.foot p { margin: 6px 0; }
.linkish { background: none; border: 0; padding: 0; color: var(--yellow); text-decoration: underline; font: inherit; }
kbd { border: 1px solid #a58b6b; border-radius: 3px; padding: 0 4px; font-family: inherit; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  body { padding: 10px 8px 24px; font-size: 18px; }
  .tv { padding: 10px 10px 0; border-radius: 20px; }
  .screen { padding: 14px 12px 0; border-radius: 22px / 18px; box-shadow: 0 0 0 6px #111, inset 0 0 50px rgba(0,0,0,.8); }
  h1 { font-size: 13px; }
  .dish { font-size: 24px; }
  .sub { font-size: 14px; letter-spacing: 1px; }
  .clock { font-size: 24px; }
  .clock-date { font-size: 14px; }
  .days { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .day { padding: 22px 4px 6px; align-items: center; text-align: center; }
  .day::before { left: 50%; top: 6px; transform: translateX(-50%); width: 10px; height: 10px; }
  .day .dname { font-size: 18px; }
  .day .ddate { font-size: 13px; }
  .day .dn { display: none; }
  .chip { font-size: 16px; padding: 4px 7px; }
  .chip.ghost { margin-left: 0; }
  .seg .lbl { display: none; }
  .seg .chip { padding: 4px 10px; }
  .prog { grid-template-columns: 64px 1fr; gap: 10px; }
  .time .t { font-size: 26px; }
  .cal { grid-column: 2; justify-self: start; margin-top: -4px; }
  .cal-btn, .bell-btn { font-size: 16px; padding: 4px 10px; }
  .cal-menu { left: 0; right: auto; }
  .sub { display: none; }
  .clock-date { max-width: 110px; margin-left: auto; }
  .teams { font-size: 21px; }
  .knobs { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .screen, .ticker-inner, .live-tag, .bars span, .bell-btn { animation: none; }
  .ticker-inner { padding-left: 12px; }
}
