/* ══════════════════════════════════════════════════════════════
   Grumpy's Movies — Live TV  (Pluto TV-inspired layout)
   ══════════════════════════════════════════════════════════════ */
@import url('party.css');

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --tv-bg:          #080d18;
  --tv-surface:     #0e1625;
  --tv-surface2:    #141e30;
  --tv-border:      rgba(255,255,255,0.07);
  --tv-border2:     rgba(255,255,255,0.12);
  --tv-text:        #e8edf5;
  --tv-muted:       #7a8fae;
  --tv-accent:      #f5c518;
  --tv-live:        #ef4444;
  --tv-live-bg:     rgba(239,68,68,0.15);
  --tv-row-hover:   rgba(255,255,255,0.05);
  --tv-row-active:  rgba(245,197,24,0.10);
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --topbar-h:       56px;
  --topbar-h-live:  0px;
  --transition:     0.15s ease;
}

/* ── Reset / base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

.tv-body {
  margin: 0;
  background: var(--tv-bg);
  color: var(--tv-text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  height: 100dvh;
  overflow: hidden;
}

.tv-no-topbar {
  --topbar-h: var(--topbar-h-live);
}

.tv-no-topbar .tv-topbar {
  display: none;
}

/* ── App shell ──────────────────────────────────────────────── */
.tv-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── Top bar ────────────────────────────────────────────────── */
.tv-topbar {
  min-height: var(--topbar-h);
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 16px;
  padding: env(safe-area-inset-top, 0px) 20px 0;
  background: rgba(8,13,24,0.96);
  border-bottom: 1px solid var(--tv-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}

.brand .logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e11d48, #9f1239);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}

.tv-nav {
  display: flex;
  gap: 4px;
  margin-right: auto;
}

.tv-nav a {
  color: var(--tv-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.tv-nav a:hover { color: var(--tv-text); background: var(--tv-row-hover); }
.tv-nav a.active { color: var(--tv-text); }

.tv-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.tv-clock {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--tv-accent);
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* Region pill in topbar */
.region-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--tv-surface2);
  border: 1px solid var(--tv-border2);
  border-radius: 99px;
  padding: 3px 6px 3px 10px;
}

.region-select {
  background: none;
  border: none;
  color: var(--tv-text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  padding: 0;
  max-width: 120px;
}

.region-select option { background: var(--tv-surface); }

.region-detect-btn {
  background: none;
  border: none;
  color: var(--tv-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--transition);
  line-height: 1;
}
.region-detect-btn:hover { color: var(--tv-accent); }

/* ── Main stage ─────────────────────────────────────────────── */
.tv-stage {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  --player-stack-h: calc(min(52vh, 620px) + 49px);
}

/* ── Player column — pinned above the scrolling guide ── */
.tv-player-col {
  position: relative;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #000;
  border-bottom: 2px solid var(--tv-border);
  flex-shrink: 0;
  box-shadow: 0 4px 24px rgba(0,0,0,0.55);
}

/* ── Screen & overlays ──────────────────────────────────────── */
.tv-screen-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  width: 100%;
  /* Cap height so player doesn't dominate on tall screens */
  max-height: min(52vh, 620px);
  overflow: hidden;
}

.tv-screen {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

.tv-youtube-embed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.tv-youtube-embed[hidden] { display: none; }

/* Overlay states (buffer / unmute / error) */
.tv-overlay-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0,0,0,0.75);
  text-align: center;
  font-size: 14px;
  color: var(--tv-text);
}

.tv-overlay-state[hidden] { display: none; }

.btn-unmute {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-unmute:hover { background: rgba(255,255,255,0.25); }

.unmute-icon { font-size: 20px; }

.tv-overlay-error { background: rgba(0,0,0,0.85); }
.overlay-error-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 28ch;
}
.overlay-error-icon {
  font-size: 28px;
  color: var(--tv-live);
}
.overlay-error-inner p {
  margin: 0;
  font-size: 13px;
  color: var(--tv-muted);
}
.btn-ghost-sm {
  background: none;
  border: 1px solid var(--tv-border2);
  color: var(--tv-text);
  font: inherit;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.btn-ghost-sm:hover {
  background: var(--tv-row-hover);
  border-color: rgba(255,255,255,0.2);
}

/* Buffer spinner */
.tv-overlay-buffer {
  flex-direction: row;
  gap: 10px;
  font-size: 13px;
  color: var(--tv-muted);
}
.buffer-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--tv-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Invisible tap target for touch devices to surface the overlay */
.tv-tap-target {
  position: absolute;
  inset: 0;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  z-index: 4;
}
.tv-tap-target:focus-visible {
  outline: 2px solid var(--tv-accent);
  outline-offset: -3px;
}

/* Bottom player info overlay (gradient) — auto-hides */
.tv-player-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 16px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.78) 55%, rgba(0,0,0,0.96));
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 5;
}
.tv-player-overlay.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.tv-player-overlay[hidden] { display: none; }

/* Always-visible LIVE pulse at the top-left of the player.
   Hidden when the YouTube iframe is active (YouTube has its own UI). */
.tv-screen-wrap:has(.tv-youtube-embed:not([hidden]))::before { display: none; }
.tv-screen-wrap::before {
  content: '● LIVE';
  position: absolute;
  top: 10px;
  left: 12px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--tv-live);
  padding: 3px 8px;
  border-radius: 3px;
  z-index: 3;
  animation: live-pulse 2s ease-in-out infinite;
  pointer-events: none;
  opacity: 0.9;
}

.tv-overlay-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Overlay control row */
.tv-overlay-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.overlay-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 99px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  color: #fff;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.overlay-btn:hover,
.overlay-btn:focus-visible {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.22);
  outline: none;
}
.overlay-btn:active { transform: scale(0.94); }
.overlay-btn.active {
  background: var(--tv-accent);
  border-color: var(--tv-accent);
  color: #000;
}
.overlay-btn svg { display: block; }
.overlay-btn[hidden] { display: none; }

/* Channel surf pop-up indicator */
.tv-zap {
  position: absolute;
  top: 18px;
  right: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(8,13,24,0.85);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  z-index: 6;
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: 60%;
}
.tv-zap.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.tv-zap[hidden] { display: none; }

.tv-zap-num {
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 800;
  color: var(--tv-accent);
  letter-spacing: 0.03em;
}
.tv-zap-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.tv-overlay-badge {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.2);
}

.tv-overlay-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tv-overlay-name {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tv-overlay-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}

.tv-live-dot {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--tv-live);
  letter-spacing: 0.06em;
  animation: live-pulse 2s ease-in-out infinite;
  white-space: nowrap;
}

/* ── Below-player info bar ──────────────────────────────────── */
.tv-info-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--tv-surface);
  border-top: 1px solid var(--tv-border);
  flex-shrink: 0;
}

.tv-info-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.tv-live-badge {
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  background: var(--tv-live);
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  animation: live-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

.tv-ch-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tv-info-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tv-ch-group-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--tv-surface2);
  border: 1px solid var(--tv-border2);
  color: var(--tv-muted);
  white-space: nowrap;
}

.tv-ch-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--tv-muted);
  font-variant-numeric: tabular-nums;
  min-width: 2em;
  text-align: right;
}

.tv-info-hint {
  font-size: 11px;
  color: var(--tv-muted);
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--tv-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  transition: color var(--transition), background var(--transition);
}
.icon-btn:hover { color: var(--tv-text); background: var(--tv-row-hover); }

/* ── Theater mode — collapse the guide, expand the player ──── */
body.theater-mode .tv-guide-col { display: none; }
body.theater-mode .tv-screen-wrap {
  max-height: calc(100dvh - var(--topbar-h) - 49px);
}
body.theater-mode .tv-player-col {
  border-bottom: none;
  flex: 1;
}


/* ── Guide column — Pluto-style sidebar + EPG grid ─────────── */
.tv-guide-col {
  background: var(--tv-bg);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.guide-layout {
  display: flex;
  align-items: stretch;
  height: 100%;
  min-height: 0;
}

/* ── Left category sidebar — fixed while EPG scrolls ───────── */
.guide-sidebar {
  width: 196px;
  flex-shrink: 0;
  background: #000;
  border-right: 1px solid var(--tv-border);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.guide-cat-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px 24px;
  position: sticky;
  top: 0;
}

.guide-cat-nav .chip {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border-radius: 99px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.72);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-cat-nav .chip:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.guide-cat-nav .chip.active {
  background: var(--tv-accent);
  color: #000;
}

/* ── Main guide area ───────────────────────────────────────── */
.guide-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--tv-surface);
  overflow: hidden;
}

.guide-toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-surface);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.guide-home-link {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--tv-border2);
  background: var(--tv-surface2);
  color: var(--tv-muted);
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
  transition: color var(--transition), background var(--transition);
}

.guide-home-link:hover {
  color: var(--tv-text);
  background: var(--tv-row-hover);
}

.guide-toolbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}

.guide-search-wrap {
  position: relative;
  flex: 1;
  min-width: 120px;
}

.guide-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
  opacity: 0.4;
}

.guide-search {
  width: 100%;
  padding: 7px 10px 7px 30px;
  background: var(--tv-surface2);
  border: 1px solid var(--tv-border2);
  border-radius: 99px;
  color: var(--tv-text);
  font: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition);
}
.guide-search:focus { border-color: rgba(255,255,255,0.25); }
.guide-search::placeholder { color: var(--tv-muted); }

/* ── EPG grid ──────────────────────────────────────────────── */
.guide-epg {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.guide-epg-header {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-surface);
  flex-shrink: 0;
}

.guide-epg-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--tv-text);
}

.guide-epg-col-now {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.guide-epg-label { line-height: 1.2; }

.guide-epg-time {
  font-size: 11px;
  font-weight: 500;
  color: var(--tv-muted);
  font-variant-numeric: tabular-nums;
}

.guide-epg-col-later {
  justify-content: space-between;
}

.guide-epg-more {
  font-size: 16px;
  color: var(--tv-muted);
  line-height: 1;
}

.guide-epg-body-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.guide-epg-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 32px;
}

/* ── EPG channel row ─────────────────────────────────────────── */
.guide-epg-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
  min-height: 56px;
}

.guide-epg-row.guide-epg-has-data .guide-epg-sub {
  color: var(--tv-accent);
  opacity: 0.85;
}

.guide-epg-row.active .guide-epg-cell-now {
  outline: 2px solid var(--tv-accent);
  outline-offset: -1px;
}

.guide-epg-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--tv-border);
  border-radius: var(--radius);
  background: var(--tv-surface2);
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background var(--transition), border-color var(--transition);
}

.guide-epg-cell:hover {
  background: rgba(255,255,255,0.07);
  border-color: var(--tv-border2);
}

.guide-epg-cell-now {
  padding: 10px 12px;
}

.guide-epg-ch {
  font-size: 14px;
  font-weight: 700;
  color: var(--tv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-epg-program {
  font-size: 13px;
  font-weight: 500;
  color: var(--tv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-epg-logo {
  display: none;
}

.guide-epg-cell-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guide-epg-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-epg-sub {
  font-size: 11px;
  color: var(--tv-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-epg-remain {
  font-size: 11px;
  color: var(--tv-muted);
  font-variant-numeric: tabular-nums;
}

.guide-epg-remain-live {
  color: var(--tv-live);
  font-weight: 600;
}

.guide-epg-progress {
  display: block;
  height: 3px;
  border-radius: 99px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
}

.guide-epg-progress > span {
  display: block;
  height: 100%;
  background: #fff;
  border-radius: 99px;
  transition: width 0.4s ease;
}

.guide-epg-menu {
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  font-size: 16px;
  line-height: 1;
  color: var(--tv-muted);
  opacity: 0.5;
  pointer-events: none;
}

.guide-epg-slot-time {
  font-size: 11px;
  color: var(--tv-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.guide-epg-cell-next {
  background: rgba(255, 255, 255, 0.02);
}

.guide-epg-cell-next.is-empty {
  opacity: 0.45;
}

.guide-epg-next-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--tv-text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guide-epg-next-sub {
  display: block;
  font-size: 11px;
  color: var(--tv-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .guide-epg-col-later {
    display: none;
  }

  .guide-epg-header,
  .guide-epg-row {
    grid-template-columns: 1fr;
  }

  .guide-epg-cell-next {
    display: none;
  }
}

/* Status messages */
.guide-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 24px;
  color: var(--tv-muted);
  font-size: 13px;
  grid-column: 1 / -1;
}

.loading-dots::after {
  content: '…';
  animation: dots 1.4s steps(4,end) infinite;
}
@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

.guide-empty {
  padding: 20px 24px;
  color: var(--tv-muted);
  font-size: 13px;
}

.guide-status {
  margin: 0;
  padding: 4px 16px 6px;
  font-size: 11px;
  color: var(--tv-accent);
  flex-shrink: 0;
}
.guide-status.error { color: #fca5a5; }
.guide-status[hidden] { display: none; }

.guide-region-hint {
  margin: 0;
  padding: 4px 16px 12px;
  font-size: 11px;
  color: var(--tv-muted);
  opacity: 0.6;
  flex-shrink: 0;
}


/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .tv-body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .tv-no-topbar.tv-body {
    height: 100dvh;
    overflow: hidden;
  }

  .tv-app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .tv-no-topbar .tv-app {
    height: 100dvh;
    overflow: hidden;
  }

  .tv-stage {
    min-height: auto;
    overflow: visible;
    --player-stack-h: calc(56vw + 49px);
  }

  .tv-no-topbar .tv-stage {
    min-height: 0;
    flex: 1;
    overflow: hidden;
  }

  .tv-player-col {
    position: sticky;
    top: var(--topbar-h);
  }

  .tv-no-topbar .tv-player-col {
    top: 0;
  }

  .tv-guide-col {
    min-height: 50vh;
    overflow: visible;
  }

  .guide-layout {
    flex-direction: column;
    height: auto;
    min-height: 50vh;
  }

  .guide-sidebar {
    width: 100%;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--tv-border);
    overflow-x: auto;
    overflow-y: hidden;
    position: sticky;
    top: calc(var(--topbar-h) + var(--player-stack-h));
    z-index: 40;
    background: #000;
  }

  .guide-cat-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    padding: 10px 12px;
    gap: 6px;
    position: static;
  }

  .guide-cat-nav .chip {
    width: auto;
    flex-shrink: 0;
    padding: 8px 14px;
  }

  .guide-main {
    height: auto;
    overflow: visible;
  }

  .guide-epg-body-wrap {
    overflow: visible;
    max-height: none;
  }

  .guide-epg-header,
  .guide-epg-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .guide-epg-cell-now {
    padding: 10px 12px;
    min-height: 0;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  .tv-topbar {
    min-height: var(--topbar-h);
    height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 10px 0;
    gap: 8px;
  }

  .tv-body {
    --topbar-h: 48px;
  }

  .brand-name { display: none; }
  .tv-nav a { padding: 5px 8px; font-size: 12px; }
  .tv-nav { gap: 2px; }
  .tv-clock { font-size: 12px; }
  .region-select { max-width: 88px; font-size: 11px; }

  .tv-screen-wrap { max-height: none; }
  .tv-info-hint { display: none; }

  /* Single on-now column */
  .guide-epg-header,
  .guide-epg-row {
    grid-template-columns: 1fr;
  }

  /* Bigger touch targets on EPG channel rows */
  .guide-epg-cell-now {
    padding: 12px;
    min-height: 52px;
  }

  /* Compact + larger overlay buttons */
  .tv-player-overlay { padding: 24px 12px 12px; }
  .overlay-btn { width: 44px; height: 44px; }
  .tv-overlay-controls { gap: 6px; }

  /* Category chips horizontal scroll: bigger tap targets */
  .guide-cat-nav .chip {
    padding: 10px 16px;
    font-size: 13px;
    min-height: 38px;
  }

  .guide-toolbar-meta .region-select {
    max-width: 96px;
  }
}

/* Phone landscape & short viewports — side-by-side player + scrollable guide */
@media (max-height: 520px), (orientation: landscape) and (max-height: 700px) {
  .tv-body {
    height: 100dvh;
    overflow: hidden;
  }

  .tv-app {
    height: 100dvh;
    overflow: hidden;
  }

  .tv-stage {
    flex-direction: row;
    min-height: 0;
    overflow: hidden;
    --player-stack-h: 0px;
  }

  .tv-player-col {
    width: min(42vw, 420px);
    max-width: 45%;
    flex-shrink: 0;
    position: relative;
    top: auto;
    border-bottom: none;
    border-right: 2px solid var(--tv-border);
    box-shadow: none;
  }

  .tv-screen-wrap {
    max-height: none;
    aspect-ratio: 16 / 9;
    height: auto;
  }

  .tv-info-bar {
    padding: 6px 10px;
  }

  .tv-ch-name {
    font-size: 13px;
  }

  .tv-guide-col {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .guide-layout {
    flex: 1;
    min-height: 0;
    height: auto;
    flex-direction: row;
    overflow: hidden;
  }

  .guide-sidebar {
    width: 88px;
    max-height: none;
    border-bottom: none;
    position: static;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .guide-cat-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    padding: 8px 6px;
  }

  .guide-cat-nav .chip {
    width: 100%;
    padding: 8px 6px;
    font-size: 11px;
    min-height: 0;
    text-align: center;
  }

  .guide-main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .guide-epg {
    flex: 1;
    min-height: 0;
  }

  .guide-epg-body-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    max-height: none;
  }

  .guide-epg-header,
  .guide-epg-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .guide-epg-cell {
    padding: 8px 10px;
    gap: 6px;
  }

  .guide-epg-ch { font-size: 13px; }
  .guide-epg-program { font-size: 12px; }

  .guide-epg-sub,
  .guide-epg-remain,
  .guide-epg-slot-time {
    font-size: 10px;
  }

  .guide-toolbar-row {
    padding: 6px 10px;
  }

  .guide-home-link {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  /* Hide theater button on phones — it's a desktop convenience */
  #tv-theater  { display: none; }
}

/* Hide the LIVE pulse top-left chip when in fullscreen (HTML5 native player
   shows its own) and on YouTube channels (different overlay). */
.tv-screen-wrap:fullscreen::before,
.tv-screen-wrap:-webkit-full-screen::before {
  display: none;
}
