header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2vh;
  width: 100%;
}

.search-container {
  width: 90%;
  max-width: 500px;
  margin: 0 auto 4vh;
  display: flex;
  gap: 1vw;
  justify-content: center;
  padding: 0 2vw;
  box-sizing: border-box;
}

.media-section {
  margin-bottom: 4vh;
  width: 100%;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2vw;
  padding: 2vh 0;
  width: 100%;
}

.similar-media-section {
  margin: 2vh 0 0 0;
  padding: 0;
  width: 100%;
}

.similar-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2vw;
  width: 100%;
}

/* --- SIDEBAR & GENRE LIST (from base.css) --- */
.sidebar {
  position: fixed;
  /* Desktop / tablet: floating panel that slides in from the side,
     with fixed card-like width independent of screen side width */
  left: -420px;             /* off-screen by panel width (updated for wider panel) */
  top: 4vh;
  bottom: 4vh;
  height: auto;
  width: min(400px, 95vw);  /* widened so three buttons per row are clearly visible */
  min-width: 260px;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.3s ease, left 0.3s ease;
  z-index: 5000;
  padding-top: 8vh;
  padding-left: 20px;
  padding-right: 14px;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
  overflow-y: auto; /* Enable vertical scrolling */
  border-radius: 0 16px 16px 0; /* rounded "card" edge on the inside */
  transform: translateX(0);     /* base transform (used by open state) */

  /* NEW: hide sidebar scrollbars across browsers */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.sidebar::-webkit-scrollbar {
  display: none; /* WebKit (Chrome/Safari) */
}

/* Desktop / tablet open state */
@media (min-width: 481px) {
  .sidebar.open {
    /* Slide the panel in slightly away from the hard edge on larger screens */
    left: 2vw;
    transform: translateX(0);
  }
}

/* Sidebar title removed per design – keep selector hidden for safety */
.sidebar-title {
  display: none !important;
}

.sidebar-close {
  position: absolute;
  top: 10px;
  right: 10px;
  /* NEW: circular ball-style close button */
  width: 42px;               /* ~20% larger than typical icon size */
  height: 42px;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  color: #ffffff;
  font-size: 2.16rem;        /* 20% larger than previous 1.8rem */
  cursor: pointer;
  display: flex;             /* center the “×” inside the ball */
  align-items: center;
  justify-content: center;
  z-index: 5001;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.sidebar-close:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  opacity: 0.9;
}

.genre-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr)); /* three categories per line */
  gap: 1.2vh 1.2vw;
  padding: 0;
  margin: 0;
  list-style: none;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* --- COLOR BALL UI (from styles.css/base.css) --- */
.color-ball-container {
  position: fixed;
  top: 2vh;
  right: 2vw;
  z-index: 500; 
  display: flex;
  flex-direction: row; /* align balls in a row */
  gap: 10px;          /* even spacing */
  align-items: center;
}

/* Base style for all top action balls to match theme ball */
.action-ball {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
  background: var(--primary-color);
  border: 2px solid transparent;
  opacity: 0.85;
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  user-select: none;
}

/* Ensure the standalone color ball is circular and visually consistent */
.color-ball {
  width: 50px;
  height: 50px;
  min-width: 35px;
  min-height: 35px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 2px solid transparent;
  box-shadow: none;
  opacity: 0.85;
  display: inline-block;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

/* Keep mobile sizing but preserve circular shape */
@media (max-width: 768px) {
  .color-ball {
    width: 35px !important;
    height: 35px !important;
    min-width: 35px !important;
    min-height: 35px !important;
    border-radius: 50% !important;
    display: inline-block;
  }

  .action-ball {
    width: 35px;
    height: 35px;
    font-size: 1.1rem;
  }
}

.action-ball-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

[data-theme]:not([data-theme^="light"]) .action-ball-icon {
  filter: invert(1);
}

.action-ball:hover {
  background: var(--background-color);
  border: 2px solid var(--lighter-primary-color);
  transform: scale(1.1);
}

/* Light theme contrast tweaks */
[data-theme^="light"] .action-ball {
  border-color: var(--text-color);
  color: #000000;
}
[data-theme^="light"] .action-ball:hover {
  background: var(--background-color);
  border-color: var(--primary-color);
  color: #000000;
}

/* Mobile sizing to match theme ball */
@media (max-width: 768px) {
  .action-ball {
    width: 35px;
    height: 35px;
    font-size: 1.1rem;
  }

  .action-ball-icon {
    width: 20px;
    height: 20px;
  }
}

.color-tooltip {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
  display: none !important;
  z-index: 1001;
}

.color-tooltip::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 5px 5px 5px;
  border-style: solid;
  border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
}

/* --- SCROLL TO TOP UI (from base.css) --- */
.scroll-to-top-container {
    position: fixed;
    bottom: 2vh; 
    right: 2vw; 
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* Reposition tooltip for the bottom element */
.scroll-to-top-container .color-tooltip {
    top: auto; 
    bottom: 60px; 
    transform: translateX(-50%);
}

.scroll-to-top-container .color-tooltip::before {
    top: auto;
    bottom: -5px; 
    border-width: 5px 5px 0 5px;
    border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
}

/* Styles for the Scroll Top Ball (Up Arrow) */
.scroll-top-ball {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.2rem; 
  font-weight: 900; 
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.5s ease, visibility 0.5s ease, transform 0.3s ease, box-shadow 0.3s ease;
}
/* New: caret icon styling inside scroll-to-top ball */
.scroll-top-ball .scroll-top-caret {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.scroll-top-ball.visible {
  opacity: 0.8;
  visibility: visible;
  pointer-events: auto; 
  transform: translateY(-5px); 
}

.scroll-top-ball:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* Ensure text color is black for light themes where primary color is light */
[data-theme^="light"] .scroll-top-ball {
    color: #000000;
}

/* --- MODAL PLAYER UI ELEMENTS (from layout.css) --- */
#seasonSelect,
#episodeSelect {
  padding: 1.2vh 2vh;
  margin: 1vh;
  min-width: 20vw;
  background-color: rgba(0, 0, 0, 0.8);
  color: var(--text-color);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

#seasonSelect option,
#episodeSelect option {
  padding: 0.8vh;
  background-color: rgba(0, 0, 0, 0.8);
  color: var(--text-color);
}

#seasonEpisodeSelector {
  margin: 2.5vh 0;
  display: flex;
  gap: 1.5vh;
  flex-wrap: wrap;
  align-items: center;
}

#seasonEpisodeSelector button {
  padding: 1.2vh 2.4vh;
  background-color: var(--primary-color);
  color: var(--text-color);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#seasonEpisodeSelector button:hover {
  background-color: #f40612;
}

.media-server-selector {
  margin: 1vh 0;
  width: 100%;
  padding: 0.8vh 1.2vh;
  background: rgba(0, 0, 0, 0.8);
  color: var(--text-color);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.episode-navigation {
  display: flex;
  gap: 1vw;
  margin: 2vh 0;
  justify-content: center;
  align-items: center;
}

.episode-info {
  font-size: 1.1rem;
  color: var(--text-color);
  margin: 0 2vw;
}

.nav-button {
  padding: 1.2vh 2.4vh;
  background-color: var(--primary-color);
  color: var(--text-color);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.nav-button:hover {
  background-color: #f40612;
}

.nav-button:disabled {
  background-color: #666;
  cursor: not-allowed;
}

/* Media queries related to sidebar/genre list sizing */
@media (max-width: 600px) {
  .genre-item {
    font-size: calc(1rem - 4px);
    padding: 0.5vh 0.9vh;
  }

  .genre-header {
    font-size: calc(0.9rem - 4px);
    padding: 0.5vh 1.5vh;
  }
}

@media (max-width: 480px) {
  .genre-list {
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }

  .sidebar {
    /* On small mobile, let the categories drawer behave like a full-height sheet
       that still slides from the side but feels integrated with the screen edges */
    width: 85vw;               /* 85% of screen width */
    left: -100vw;              /* move completely off-screen so no edge peeks through */
    /* Make the window only as tall as its content on mobile */
    top: 4vh;
    bottom: auto;
    height: auto;
    border-radius: 0;
    /* Show more of the page background by reducing sidebar opacity to ~20% on mobile */
    background-color: rgba(0, 0, 0, 0.2);
    /* Equal horizontal padding on mobile plus 30px extra space below the last category row */
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: 30px; /* 30px spacing after the last category */
  }

  /* NEW: Center the mobile category window when open */
  .sidebar.open {
    left: 50%;
    transform: translateX(-50%);
  }
}

.home-ball,
.settings-ball {
  border: none !important;
}

/* Ensure no border appears on hover */
.home-ball:hover,
.settings-ball:hover {
  border: none !important;
}

.search-ball {
  border: none !important;
}

.search-ball:hover {
  border: none !important;
}

/* NEW: Info button (small round I button in lower-left) */
.info-ball {
  position: fixed;
  left: 2vw;
  bottom: 2vh;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 2px solid transparent;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 500;
  opacity: 0.88;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.info-ball:hover {
  transform: scale(1.08);
  box-shadow: 0 5px 16px rgba(0,0,0,0.6);
  opacity: 0.96;
}

.info-ball-letter {
  font-family: "Abril Fatface", cursive;
  font-size: 1.5rem;
  font-style: italic;
  color: #ffffff;
  line-height: 1;
}

/* Light theme tweak: keep strong outline on info ball */
[data-theme^="light"] .info-ball {
  border-color: rgba(0,0,0,0.25);
}

/* Ensure it stays visible above scroll-to-top ball on small screens */
@media (max-width: 768px) {
  .info-ball {
    left: 3vw;
    bottom: 3vh;
    width: 38px;
    height: 38px;
  }
  .info-ball-letter {
    font-size: 1.3rem;
  }
}