@import url('https://fonts.googleapis.com/css2?family=Onest:wght@100..900&display=swap');

:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --overlay-bg: rgba(0,0,0,0.55);
  --accent: #e50914;
}

html, body {
  height: 100%;
  margin: 0;
  background: #000;
  color: #fff;
  /* Change this line */
  font-family: 'Onest', 'Inter', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased; /* Makes text look sharper on TVs */
}

/* ================= VIDEO ================= */
#videoWrapper {
  position:fixed;
  inset:0;
  width:100vw;
  height:100dvh;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:0;
}

video {
  width:100vw;
  height:100dvh;
  object-fit:contain;
  transition:opacity .45s ease;
  opacity:0;
}

video.loaded { opacity:1; }

/* ================= FLOATING GLASS GUIDE ================= */
#guide {
  position: fixed;
  top: 24px;                  /* Detached from top */
  right: 24px;                /* Detached from right */
  bottom: 24px;               /* Detached from bottom */
  left: auto;
  width: 360px;               /* Wider for premium floating feel */
  max-width: calc(100vw - 48px); /* Responsive on small screens */
  height: auto;
  max-height: calc(100dvh - 32px);
  background: rgba(10, 10, 15, 0.35);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 32px;        /* Big soft rounded corners */
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 
    0 30px 60px rgba(0, 0, 0, 0.6),
    0 0 50px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 1.2rem;
  box-sizing: border-box;
  transform: translateX(120%);
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.2, 1);
  overflow: hidden;
  z-index: 60;
  display: flex;
  flex-direction: column;
}

#guide.visible { 
  transform: translateX(0); 
}

#guide > #channelBtn {
  display: none !important;
}


/* Search Input - Glass field with strong iOS-like glow */
#searchInput {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 10px 16px;
  margin: 2.8rem 0 1rem 0;
  color: #fff;
  font-size: 1rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.3s ease;
  box-sizing: border-box;
  width: 92%;
  flex-shrink: 0;
  outline: none;
}

#searchInput:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: #007aff;
  box-shadow:
    0 0 0 3px rgba(0, 122, 255, 0.3),
    0 0 20px rgba(0, 122, 255, 0.4);
  transform: scale(1.02);
}


/* ================= CAROUSEL STYLES (REPAIRED) ================= */
/* 1. SHIMMER ANIMATION */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.carousel-wrapper {
  width: 100%;
  height: 180px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  margin: 8px 0 20px 0;
  position: relative;
  background: #000;
  flex-shrink: 0;
  /* GPU acceleration hint */
  transform: translateZ(0);
}

.slider {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translateX(100%); 
  z-index: 1;
  visibility: hidden;
  will-change: transform;
  
  /* THE SHIMMER: Shows while image is downloading */
  background: linear-gradient(90deg, #0a0a0a 25%, #1a1a1a 50%, #0a0a0a 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite linear;
}

.slide.active {
  transform: translateX(0);
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 3;
  visibility: visible;
}

.slide.prev {
  transform: translateX(0);
  transition: none; 
  z-index: 2;
  visibility: visible;
}

/* IMAGE FIX: Starts invisible, fades in when .loaded is added by JS */
.slide img.slide-foreground {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: black;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
  position: relative;
  z-index: 2;
}

.slide img.loaded {
  opacity: 1;
}

/* CONTENT STYLING (Kept your exact design) */
.slide-content {
  position: absolute;
  bottom: 15px;
  left: 15px;
  color: #fff;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.9);
}

.slide-title { font-size: 1.2rem; font-weight: 800; margin: 0; }
.slide-description { font-size: 0.9rem; opacity: 0.9; margin: 0; }
.slide-badge {
  background: #e50914;
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  align-self: flex-start;
}

/* ================= CHANNEL LIST CONTAINER ================= */
#channelListContainer {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin-top: 8px;
  -webkit-overflow-scrolling: touch;    /* smooth + helps repaint */
  transform: translateZ(0);             /* force GPU layer */
  will-change: transform, scroll-position; /* hint browser to optimize */
  backface-visibility: hidden;          /* extra anti-flicker */
}


#channelListContainer::-webkit-scrollbar {
  width: 0px;
}

/* ================= CHANNEL LIST ITEMS ================= */
.channel {
  display: flex !important;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none !important;      /* ← force no border ever */
  outline: none !important;
}

.channel img {
  width: 50px;
  height: 50px;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  object-fit: contain;
  padding: 4px;
  flex-shrink: 0;
}

.channel .name {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.channel:hover,
.channel.selected {
  background: rgba(255, 255, 255, 0.08);
}

.channel.selected {
  background: rgba(96, 165, 250, 0.25) !important;
  transform: scale(1.03);
  box-shadow: inset 4px 0 0 #60a5fa;   /* left colored "border" using shadow – no repaint glitch */
  font-weight: bold;
}

/* ================= OVERLAYS ================= */
#overlay {
  position:fixed;
  left:24px;
  top:22px;
  background:var(--overlay-bg);
  border-radius:14px;
  padding:10px 16px;
  backdrop-filter:blur(5px);
  z-index:55;
  box-shadow:0 6px 18px rgba(0,0,0,0.6);
  display: none !important;
}

#overlay img {
  width:96px;
  height:72px;
  object-fit:contain;
  border-radius:10px;
}

#resolutionBadge {
  position:fixed;
  left:24px;
  top:20px;
  background:rgba(0,0,0,0.6);
  padding:6px 10px;
  border-radius:8px;
  font-weight:600;
  z-index:55;
  opacity:0;
  transition:opacity .3s;
}

#resolutionBadge.show { opacity:1; }

/* ================= PROGRESS BAR ================= */
#progressWrap {
    position: fixed;
    left: 24px;
    right: 24px;
    bottom: 18px;
    /* Increase height for better touch/click "hit area" */
    height: 30px; 
    z-index: 55;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer; /* Shows user it is interactive */
    background: transparent;
}

#progressBar {
    flex: 1;
    /* Keep the VISUAL bar thin at 6px */
    height: 6px; 
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    pointer-events: none; /* Let the click pass through to the Wrap */
}

#bufferBar {
  position:absolute;
  left:0;
  top:0;
  height:6px;
  background:rgba(255,255,255,0.35);
  width:0%;
}

#playedBar {
  position:absolute;
  left:0;
  top:0;
  height:6px;
  background:var(--accent);
  width:0%;
}

#liveIndicator {
  position: fixed;
  left: 24px;
  bottom: 60px; /* Positioned above the progress bar area */
  background: rgba(229, 9, 20, 0.85); /* Slightly transparent red */
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: 'Onest', sans-serif;
  font-weight: 900;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

/* The Blinking Status Dot */
#liveIndicator::before {
  content: "";
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px #fff;
  animation: live-pulse 1.5s infinite;
}

@keyframes live-pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

/* Auto-hide logic when any guide is open */
body.menu-open #liveIndicator {
  opacity: 0;
  transform: translateY(20px); /* Slides down out of view */
}

/* ================= SPINNER ================= */
#spinner {
  position:fixed;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  z-index:70;
  display:none;
}

.spinner-dot {
  width:12px;
  height:12px;
  background:rgba(255,255,255,0.95);
  border-radius:50%;
  display:inline-block;
  margin:6px;
  animation:spin .9s linear infinite;
}

.spinner-dot:nth-child(2){ animation-delay:.12s; }
.spinner-dot:nth-child(3){ animation-delay:.24s; }

@keyframes spin {
  0%,100%{ transform:translateY(0); }
  50%{ transform:translateY(-8px); }
}

/* ================= CHANNEL NUMBER ================= */
#channelNumber {
  position:fixed;
  left:50%;
  top:45%;
  transform:translate(-50%,-50%);
  background:rgba(0,0,0,0.65);
  padding:14px 22px;
  border-radius:12px;
  font-size:3.2rem;
  font-weight:700;
  z-index:80;
  opacity:0;
  transition:opacity .2s;
}

#channelNumber.show { opacity:1; }

/* ================= FULLSCREEN BTN ================= */
#fullscreenBtn {
    position: fixed;
    right: 24px;
    bottom: 60px;       /* Matches #liveIndicator bottom exactly */
    z-index: 90;
    padding: 8px 12px;
    background: transparent;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 20px;
    cursor: pointer;
    transition: opacity .2s;
}

#fullscreenBtn:hover {
  opacity: 0.6;
}


/* ================= EDGE ZONES ================= */
#edgeZone {
  position:fixed;
  top:0;
  right:0;
  width:60px;
  height:100vh;
  background:transparent;
  z-index:50;
  pointer-events:none;
}

@media (hover: none) and (pointer: coarse) {
  #edgeZone { pointer-events:auto; }
}

#focusEdge { pointer-events:auto; }

#rightEdgeTouchStrip {
  background: transparent;
}

/* ================= NOTIFY ================= */
#notify {
  position: fixed;
  top:20px;
  left:50%;
  transform: translateX(-50%);
  background: rgba(255,140,0,0.9);
  color:#fff;
  padding:10px 18px;
  border-radius:8px;
  font-weight:600;
  z-index:120;
  opacity:0;
  transition: opacity 0.4s ease, top 0.4s ease;
  will-change: top, opacity;
}

#notify.show {
  opacity:1;
  top:40px;
}

/* ================= RESPONSIVE ================= */
@media(max-width:900px){
  #guide {
    width: 320px;
    top: 16px;
    right: 16px;
    bottom: 16px;
    border-radius: 28px;
  }
}

@media(max-width:480px){
  #guide {
    width: calc(100vw - 32px);
    left: 16px;
    right: 16px;
    top: 16px;
    bottom: calc(16px + var(--safe-bottom));
    max-height: calc(100dvh - 32px - var(--safe-bottom));
  }
}

/* === CHANNEL BUTTON OVERRIDE === */
#channelBtn {
  background: linear-gradient(180deg, rgba(0,0,0,0.9), rgba(0,0,0,0.85)) !important;
  color: #ffffff !important;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6) !important;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}


#categoryGuide {
  position: fixed;
  top: 24px;
  right: 24px;
  bottom: 24px;
  left: auto;
  width: 360px;
  max-width: calc(100vw - 48px);
  background: rgba(10, 10, 15, 0.45);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  padding: 24px;
  box-sizing: border-box;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateX(120%);
  transition: all 0.45s cubic-bezier(0.2, 0.9, 0.2, 1);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

#categoryGuide.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto;
}

/* Title */
#categoryGuide .title {
  font-size: 1.6rem;          /* smaller than before */
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Category list container */
#categoryList {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
}

#categoryList::-webkit-scrollbar {
  width: 0;
}

/* Category items - shorter width, better text handling */
/* ================= CATEGORY ITEMS - FIXED & CENTERED ================= */
#categoryList > div {
  padding: 10px 16px;
  /* CHANGE: 8px top/bottom, 'auto' centers it horizontally */
  margin: 8px auto; 
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e0e0e0;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.2, 1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  
  /* THE FIX: Constraints to make buttons shorter and uniform */
  width: 80% !important;         /* Makes the button shorter than the panel */
  max-width: 250px;              /* Ensures it doesn't get too long on big TVs */
  text-align: center;            /* Centers the text inside the button */
  
  box-sizing: border-box;
  display: block;
}

/* Hover & Focus States */
#categoryList > div:hover,
#categoryList > div:focus {
  background: rgba(96, 165, 250, 0.25);
  color: #ffffff;
  /* Removed translateX to keep it centered while scaling */
  transform: scale(1.05); 
}

/* Selected State - The "Active" Button */
#categoryList > div.selected {
  background: #60a5fa !important;
  color: #000 !important;
  font-weight: 800;
  border: 3px solid #fff;
  width: 85% !important;        /* Slightly wider to show it's active */
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.5);
}




#categoriesBtn {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 95;
  padding: 10px 18px;
  background: rgba(10, 10, 15, 0.35);      /* same dark glass as guide */
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 16px;                     /* softer rounded corners */
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  color: #ffffff;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Hover & focus states - subtle glow like guide */
#categoriesBtn:hover,
#categoriesBtn:focus {
  background: rgba(10, 10, 15, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6),
              0 0 0 3px rgba(96, 165, 250, 0.3);
}

/* Optional: slight scale on active press */
#categoriesBtn:active {
  transform: scale(0.97);
}

/* Auto-hide when guide is open  */
#guide.visible ~ #categoriesBtn {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

/* Hide Categories button when category guide is open */
#categoryGuide.open ~ #categoriesBtn {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);  /* optional subtle slide down */
  transition: all 0.3s ease;
}

#titleOverlay {
  font-weight: 900 !important;          /* maximum boldness */
  letter-spacing: 1.2px;
  text-shadow: 0 4px 12px rgba(0,0,0,0.7);
  margin-bottom: 12px !important;    /* pushes title up a bit, creates space below */
  line-height: 1.1;                  /* tightens vertical spacing inside the text itself */
}

@media (min-width: 768px) {
  #titleOverlay {
    margin-bottom: 16px !important;  /* more space on desktop */
  }
}


#categoryGuide .title {
  font-weight: 800 !important;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* ================= SMART TV DEEP SMOKE REPLACEMENT ================= */
.is-tv #guide,
.is-tv #categoryGuide,
.is-tv #categoriesBtn,
.is-tv #categoryMenu,
.is-tv .settings-bar {
  /* 1. Kill the Blur for Performance */
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  
  /* 2. Deepen the Transparency (Moved from 0.65 to 0.88 for readability) */
  background: rgba(10, 10, 15, 0.88) !important;
  
  /* 3. Defined edges for TV clarity */
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.9) !important;
}

/* Specific Search Input Tweak */
.is-tv #searchInput {
  background: rgba(255, 255, 255, 0.12) !important;
  backdrop-filter: none !important;
}

/* Specific Overlay Tweak */
.is-tv #overlay {
  background: rgba(0, 0, 0, 0.9) !important; /* Almost solid for logos */
}

videoWrapper.radio-logo {
  background: #000;
}

/* Fixed-size container for radio logos – all logos same size/shape */
#videoWrapper.radio-logo::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;                /* fixed width – change if too big/small */
  height: 200px;               /* fixed height – square keeps it consistent */
  background-image: var(--radio-logo, none);  /* logo from JS */
  background-size: contain;    /* fit without stretching or distortion */
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 24px;         /* soft rounded corners */
  box-shadow: 0 16px 48px rgba(0,0,0,0.7); /* nice depth/elevation */
  z-index: 10;                 /* above video but below any controls */
}

#leftEdgeTouchStrip, #rightEdgeTouchStrip {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* ================= QUICK SETTINGS BAR ================= */
.settings-bar {
  position: fixed;
  bottom: 60px; /* Sits comfortably above the progress bar */
  left: 50%;
  transform: translateX(-50%) translateY(150px); /* Hidden below screen */
  display: flex;
  gap: 16px;
  background: rgba(10, 10, 15, 0.35);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 12px 24px;
  border-radius: 100px; /* Capsule shape */
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  z-index: 9999;
  opacity: 0;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.settings-bar.open {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.setting-item {
  padding: 10px 20px;
  border-radius: 50px;
  color: #e0e0e0;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

/* Focused state for TV Navigation */
.setting-item.focused {
  background: #60a5fa; /* Matching your blue selection color */
  color: #000;
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(96, 165, 250, 0.4);
}

/* TV Performance Optimization */
.is-tv .settings-bar {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: rgba(10, 10, 15, 0.85) !important;
}

@media (max-width: 480px) {
  .settings-bar {
    width: 90%;
    bottom: 80px;
    gap: 8px;
    padding: 8px 16px;
  }
  .setting-item {
    font-size: 0.85rem;
    padding: 8px 12px;
  }
}

#splashScreen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #1a1a1a 0%, #000 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000; /* Above everything */
  transition: opacity 0.6s ease, visibility 0.6s;
}

#splashScreen.hidden {
  opacity: 0;
  visibility: hidden;
}

.start-btn {
  background: #e50914;
  color: white;
  border: none;
  padding: 16px 40px;
  font-size: 1.5rem;
  font-weight: 800;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(229, 9, 20, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: pulse 2s infinite;
}

.start-btn:focus, .start-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 40px rgba(229, 9, 20, 0.6);
  outline: none;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(229, 9, 20, 0.7); }
  70% { box-shadow: 0 0 0 20px rgba(229, 9, 20, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 9, 20, 0); }
}

#splashScreen h1 {
  font-family: 'Onest', sans-serif;
  font-weight: 900;
  font-size: 3rem;
  background: linear-gradient(to bottom, #fff 0%, #aaa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

/* Carousel Titles */
.slide-title { 
  font-family: 'Onest', sans-serif;
  font-size: 1.4rem; 
  font-weight: 800; /* Extra Bold */
  letter-spacing: -0.5px;
  margin: 0; 
}

/* Channel Names in the list */
.channel .name {
  font-family: 'Onest', sans-serif;
  font-size: 1.05rem;
  font-weight: 500; /* Medium weight for readability */
  letter-spacing: -0.2px;
}

/* Category Guide Title */
#categoryGuide .title {
  font-family: 'Onest', sans-serif;
  font-weight: 900; /* Maximum thickness */
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ================= LOADING SHIMMER ================= */
.loading-placeholder {
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  opacity: 0.6;
}

.shimmer-logo {
  width: 50px;
  height: 50px;
  background: linear-gradient(90deg, #222 25%, #333 50%, #222 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 12px;
}

.shimmer-text {
  height: 15px;
  flex: 1;
  background: linear-gradient(90deg, #222 25%, #333 50%, #222 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Focus state for the Refresh Button on TV */
.refresh-btn-tv:focus {
  outline: none;
  transform: scale(1.15);
  background: #ff0000 !important; /* Brighter red on focus */
  border-color: #fff !important;   /* White border to show focus */
  box-shadow: 0 0 30px rgba(229, 9, 20, 0.8);
}

/* Settings Overlay (Left Side) */
#settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px; /* Slightly narrower than the channel guide */
    height: 100%;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    z-index: 2005; /* Higher than video, equal to guide */
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    color: white;
}

#settings-overlay.visible {
    transform: translateX(0);
}

.settings-header {
    font-size: 1.6rem;
    font-weight: 900;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.setting-row {
    padding: 16px;
    margin-bottom: 8px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.03);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.setting-row.focused {
    background: rgba(255,255,255,0.15);
    border-color: white;
    transform: scale(1.02);
}

.setting-row .label {
    font-weight: 500;
    font-size: 0.95rem;
}

.setting-row .value {
    color: #00d4ff; /* Accent color for current status */
    font-weight: 700;
    font-size: 0.85rem;
}

/* ================= PLAYBACK SETTINGS GUIDE (LEFT PANEL) ================= */
#settingsGuide {
    position: fixed;
    left: -400px;               /* Slide-out start position */
    top: 24px;                  /* Detached from top */
    bottom: 24px;               /* Detached from bottom */
    width: 320px;
    height: auto;               /* Allow top/bottom to define height */
    background: rgba(10, 10, 15, 0.35);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-radius: 32px;        /* Matches Channel Guide */
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
    padding: 1.5rem;
    box-sizing: border-box;
    transition: left 0.45s cubic-bezier(0.2, 0.9, 0.2, 1);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    color: white;
}

/* When visible, slide to a detached left position */
#settingsGuide.visible {
    left: 24px;                 /* Detached from left wall */
}

/* Settings List container - scrollable area */
#settingsListContainer .channel {
    display: flex !important;
    align-items: center;
    justify-content: center; /* Center text inside the button */
    
    /* THE FIX: Constraints */
    width: 90% !important;        /* Shorter than the panel */
    max-width: 260px;             /* Prevents it from getting too wide */
    margin: 6px auto !important;  /* Vertical spacing + horizontal centering */
    
    padding: 12px 16px !important;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s cubic-bezier(0.2, 0.9, 0.2, 1);
    box-sizing: border-box;
}

/* Header style inside the settings list */
.setting-header {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.4);
    margin: 20px 0 8px 12px;
    font-weight: 800;
}

/* Specific styling for the Settings Menu items */
#settingsListContainer .channel {
    padding: 14px !important;
    margin: 4px 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.2s ease;
}

#settingsListContainer .channel.selected {
    background: #60a5fa !important;
    color: #000 !important;
    font-weight: 800;
    transform: scale(1.05); /* Pop out slightly */
    
    /* Glow now has room to breathe because of the 15px container padding */
    box-shadow: 0 0 15px rgba(96, 165, 250, 0.5);
    border: 2px solid #fff; /* Added a white border for that "active" look */
    z-index: 5;
}

.setting-header {
    width: 90%;
    max-width: 260px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.4);
    margin: 18px 0 6px 0;
    font-weight: 800;
    text-align: left; 
}

#settingsGuide::after {
    content: "";
    position: absolute;
    bottom: 0; /* Changed from 32px to 0 */
    left: 0;
    right: 0;
    height: 60px;
    /* This makes it fade to the same transparency as your guide background */
    background: linear-gradient(to top, rgba(10, 10, 15, 0.35), transparent); 
    pointer-events: none;
    border-radius: 0 0 32px 32px;
}

/* Hide scrollbar for the Settings Guide specifically */
#settingsListContainer {
    overflow-y: auto;
    flex: 1;
    /* Hide scrollbar for Firefox */
    scrollbar-width: none; 
    /* Hide scrollbar for IE/Edge */
    -ms-overflow-style: none; 
}

/* Hide scrollbar for Chrome, Safari, and Opera */
#settingsListContainer::-webkit-scrollbar {
    display: none;
    width: 0 !important;
}

/* ================= TV OPTIMIZATION FOR SETTINGS ================= */
.is-tv #settingsGuide {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(10, 10, 15, 0.92) !important; /* Solid dark for TV */
    border-right: 2px solid rgba(255, 255, 255, 0.1);
}

/* Responsive tweak for mobile settings */
@media (max-width: 480px) {
    #settingsGuide {
        width: 280px;
        left: -300px;
    }
}

/* settings button */
#settingsBtn {
    position: fixed;
    right: 75px;        
    bottom: 60px;       
    z-index: 90;
    padding: 8px;
    background: transparent;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

#settingsBtn:hover, #settingsBtn:focus {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(30deg); /* Subtle spin animation */
}

/* Hide gear when guides are open to avoid clutter */
#guide.visible ~ #settingsBtn,
#categoryGuide.open ~ #settingsBtn {
    opacity: 0;
    pointer-events: none;
}

/* Container for the dots */
.carousel-dots {
    position: absolute;
    bottom: 12px;
    left: 20px; /* Positioned to the side for a premium look */
    display: flex;
    gap: 10px;
    z-index: 10;
}

.dot {
    width: 12px;
    height: 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    transition: width 0.3s ease;
}

/* The Stretching Animation */
.dot.active {
    width: 45px; /* The "Stretched" final width */
    background: rgba(255, 255, 255, 0.3);
}

.dot.active::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: #fff; /* The bright white progress color */
    border-radius: 10px;
    animation: stretchProgress 5s linear forwards;
}

@keyframes stretchProgress {
    from { width: 0%; }
    to { width: 100%; }
}


/* 2. Add the professional "Press" effect */
button:active, 
.channel:active,
.category-item:active {
    transform: scale(0.95) !important;
    transition: transform 0.1s ease;
}

/* ================= PREMIUM FOCUS ENGINE ================= */

/* 1. Global Reset: Kill browser default outlines */
button:focus, 
input:focus, 
div:focus,
.channel:focus,
.category-item:focus {
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
}

/* 2. Unified Selection Style (The Glow) */
button:focus,           /* Targets your ☰ and ⚙ buttons */
#searchInput:focus,
.channel.selected,      /* Channel list items */
.category-item.selected, /* Selected item in category list */
.category-item:focus,    /* Focused item in category list */
.setting-item.focused,
.setting-row.focused,
.start-btn:focus,
#categoriesBtn:focus,   /* Explicitly target Categories Button */
#settingsBtn:focus,     /* Explicitly target Settings Button */
#fullscreenBtn:focus {
    box-shadow: 0 0 20px rgba(96, 165, 250, 0.6), 
                0 0 0 2px rgba(96, 165, 250, 0.9) !important;
    transform: scale(1.05) !important; /* Slightly more lift for buttons */
    z-index: 999;
    transition: all 0.2s cubic-bezier(0.2, 0.9, 0.2, 1);
}

/* 3. Button Specific Tweaks */
#categoriesBtn, #settingsBtn {
    transition: all 0.2s ease;
}

/* 4. The "Tactile Press" for Categories */
.category-item:active {
    transform: scale(0.96) !important;
    opacity: 0.8;
}


/* 1. The Container Fix */
#channelListContainer {
    display: block;
    width: 100% !important;
    /* Create a 'Safe Zone' for the scaling/glow effect */
    padding: 10px 15px !important; 
    box-sizing: border-box !important;
    overflow-x: hidden !important; /* Prevents horizontal 'jitter' during selection */
}

/* 2. The Channel Row Fix */
.channel {
    display: flex !important;
    align-items: center;
    /* calc(100% - 4px) leaves a tiny gap so it never touches the guide walls */
    width: calc(100% - 4px) !important; 
    margin: 6px auto !important; /* Centers the channel in the guide */
    box-sizing: border-box !important;
    position: relative; /* Keeps the glow relative to the row */
    transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.2, 1), box-shadow 0.2s ease;
}

/* 3. The 'Premium Glow' without the cutoff */
.channel.selected {
    /* Scale down slightly from 1.03 to 1.02 for safety on older TV browsers */
    transform: scale(1.02) !important; 
    background: rgba(96, 165, 250, 0.25) !important;
    /* Use a spread radius that fits within our 15px container padding */
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.5), 
                inset 4px 0 0 #60a5fa !important;
    z-index: 10;
}

/* 4. Text Safety */
.channel .name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px; /* Prevents text from hitting the right edge */
}