:root {
  --bg: #050505;
  --panel: #0d0d0f;
  --panel-2: #151518;
  --screen: #0a0a0c;
  --text: #ffffff;
  --muted: #9b9b9f;
  --red: #ff2638;
  --red-dark: #b80e1c;
  --line: rgba(255,255,255,.10);
  --tile: #151518;
  --tile-hover: #1c1c21;
  --radius: clamp(14px, 1.8vw, 30px);
  --pad: clamp(10px, 1.45vw, 22px);
  --gap: clamp(10px, 1.25vw, 20px);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
html { overflow: hidden; }
body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 10%, rgba(255,38,56,.16), transparent 26%),
    linear-gradient(135deg, #020202, #070707 45%, #030303);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}
button, select, video { font: inherit; }
button { color: inherit; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.tv-app {
  width: 100vw;
  height: 100dvh;
  padding: var(--pad);
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(240px, 1fr);
  gap: var(--gap);
  overflow: hidden;
}

.screen-panel,
.control-panel {
  min-width: 0;
  min-height: 0;
}

.screen-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(8px, .85vw, 14px);
}

.player-frame {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--screen);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0,0,0,.56);
}

#videoPlayer {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #050505;
}

.player-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  gap: 12px;
  align-content: center;
  padding: 20px;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(255,38,56,.16), transparent 34%),
    #09090a;
}
.player-overlay.hidden { display: none; }
.big-play {
  width: clamp(64px, 7vw, 116px);
  height: clamp(64px, 7vw, 116px);
  border: 2px solid rgba(255,255,255,.14);
  border-radius: 28%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: grid;
  place-items: center;
  padding-left: .14em;
  font-size: clamp(30px, 4vw, 58px);
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 18px 48px rgba(255,38,56,.25);
}
.overlay-copy h1 {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 36px);
  line-height: 1.1;
}
.overlay-copy p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: clamp(12px, 1.1vw, 16px);
}

.now-row {
  min-height: clamp(38px, 4.2vh, 54px);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.live-tag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  font-size: clamp(11px, .9vw, 14px);
  font-weight: 900;
  letter-spacing: .08em;
}
.live-tag span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(255,38,56,.12), 0 0 20px rgba(255,38,56,.55);
}
.now-text { min-width: 0; }
.now-text strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(16px, 1.8vw, 26px);
  line-height: 1.1;
}
.now-text small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(11px, .95vw, 14px);
}

.control-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: clamp(8px, 1vw, 15px);
  padding: clamp(8px, 1vw, 16px);
  border-radius: var(--radius);
  background: rgba(13,13,15,.78);
  border: 1px solid var(--line);
  box-shadow: 0 18px 56px rgba(0,0,0,.42);
  overflow: hidden;
}

.brand-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand-copy { min-width: 0; }
.brand-copy h2 {
  margin: 0;
  white-space: nowrap;
  font-size: clamp(22px, 2.15vw, 40px);
  line-height: .95;
  font-weight: 950;
  letter-spacing: -.035em;
}
.brand-copy small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: clamp(10px, .85vw, 13px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-dot {
  flex: 0 0 auto;
  width: clamp(16px, 1.7vw, 30px);
  height: clamp(16px, 1.7vw, 30px);
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 7px rgba(255,38,56,.08), 0 0 22px rgba(255,38,56,.45);
}

.dropdown-box {
  position: relative;
  min-width: 0;
}
.dropdown-box::after {
  content: "";
  position: absolute;
  right: clamp(12px, 1.2vw, 18px);
  top: 50%;
  transform: translateY(-30%);
  width: 0;
  height: 0;
  pointer-events: none;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid #fff;
}
#groupSelect {
  width: 100%;
  height: clamp(38px, 4.6vh, 50px);
  min-width: 0;
  appearance: none;
  border: 1px solid rgba(255,255,255,.12);
  outline: 0;
  border-radius: clamp(10px, 1vw, 15px);
  padding: 0 38px 0 13px;
  background: #18181c;
  color: #fff;
  font-weight: 800;
  font-size: clamp(12px, 1vw, 15px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-grid {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, .75vw, 10px);
  overflow: hidden;
}
.channel-tile {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: clamp(10px, 1vw, 16px);
  background: linear-gradient(180deg, var(--tile), #0f0f12);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  gap: 5px;
  padding: clamp(5px, .6vw, 8px);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.channel-tile:hover {
  background: var(--tile-hover);
  border-color: rgba(255,38,56,.48);
  transform: translateY(-1px);
}
.channel-tile.active {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px rgba(255,38,56,.65), 0 0 24px rgba(255,38,56,.14);
}
.logo-wrap {
  width: min(70%, 54px);
  aspect-ratio: 1 / 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: clamp(8px, .8vw, 12px);
  background: rgba(255,255,255,.06);
  overflow: hidden;
}
.logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.logo-fallback {
  font-size: clamp(15px, 1.3vw, 22px);
  font-weight: 950;
  color: #fff;
}
.channel-name {
  width: 100%;
  min-height: 2.2em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
  line-height: 1.12;
  font-size: clamp(9px, .72vw, 12px);
  font-weight: 800;
  color: #f5f5f5;
  word-break: break-word;
}

.pager {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}
.arrow-btn {
  width: clamp(38px, 4.5vw, 56px);
  height: clamp(30px, 4vh, 44px);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 999px;
  background: #17171b;
  color: var(--red);
  font-size: clamp(28px, 3vw, 44px);
  line-height: .6;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.arrow-btn:last-child { justify-self: end; }
.arrow-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.page-status {
  color: var(--muted);
  font-size: clamp(10px, .8vw, 12px);
  font-weight: 900;
  white-space: nowrap;
}

/* Tablet and narrow landscape: still one fixed page, player on top and control below. */
@media (max-width: 900px) {
  .tv-app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 58fr) minmax(0, 42fr);
  }
  .screen-panel {
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .control-panel {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }
  .brand-copy h2 { font-size: clamp(20px, 6vw, 34px); }
  .brand-dot { width: 20px; height: 20px; }
  .logo-wrap { width: min(60%, 44px); }
  .channel-name { font-size: clamp(8px, 2vw, 11px); }
}

@media (max-width: 520px) {
  :root { --pad: 8px; --gap: 8px; }
  .tv-app {
    grid-template-rows: minmax(0, 54fr) minmax(0, 46fr);
  }
  .control-panel { padding: 8px; gap: 7px; }
  .now-row { min-height: 34px; gap: 8px; }
  .live-tag { font-size: 10px; }
  .now-text strong { font-size: 14px; }
  .now-text small { display: none; }
  #groupSelect { height: 34px; font-size: 12px; }
  .channel-grid { gap: 5px; }
  .channel-tile { border-radius: 9px; padding: 4px; }
  .logo-wrap { width: min(55%, 34px); border-radius: 7px; }
  .channel-name { font-size: 8px; min-height: 2.1em; }
  .arrow-btn { width: 36px; height: 28px; font-size: 28px; }
}

@media (max-height: 560px) and (min-width: 901px) {
  .brand-copy small { display: none; }
  .control-panel { gap: 7px; padding: 8px; }
  #groupSelect { height: 34px; }
  .logo-wrap { width: min(58%, 40px); }
  .channel-name { font-size: 9px; }
  .now-row { min-height: 34px; }
}
