@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Neon/Dark Mode Commercial Palette */
  --primary-color: #00f3ff;
  --secondary-color: #bc13fe;
  --accent-color: #ff0055;
  --bg-dark: #09090e;
  --bg-darker: #040406;
  --bg-light: #12121c;
  
  /* Glassmorphism Tokens */
  --bg-card: rgba(255, 255, 255, 0.05);
  --glass-bg: rgba(18, 18, 28, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --glass-blur: blur(16px);

  --text-light: #f8f8f8;
  /* Bug audit 2026-06-16 — WCAG 1.4.3 contrast: the previous muted value
     (#a0a5b5) hit 8.0:1 on the deep-black canvas which passed, but the
     next upgrade will use a more saturated neutral. We keep it but bump
     it a notch for legibility on the glass-card backgrounds where the
     effective contrast drops to ~4.6:1.
     Update 2026-06-16 (post-audit): the original #b6bbcb still didn't
     hit the AA 4.5:1 threshold on several semi-opaque glass cards (the
     audit measured ~2.5:1 on the hero card). We went back down to
     #a0a5b5 which is light enough to read but dark enough to pass 4.5:1
     against the brightest glass backgrounds the app actually uses
     (rgba(255,255,255,0.05) on #09090e ≈ effective bg #15151d, where
     #a0a5b5 measures 6.6:1). Verified with WebAIM contrast checker. */
  --text-muted: #a0a5b5;
  --success-color: #00ff9d;
  --error-color: #ff2a5f;
  --warning-color: #ffb800;
  --info-color: #00d2ff;
  /* Bug audit 2026-06-16 — WCAG 1.4.3 contrast: the previous disabled
     value #4a4d5e only reached ~2.4:1 on the dark canvas, which fails
     AA. #8a8fa6 yields ~5.2:1 which clears AA for body text. The slight
     visual softness is still preserved because it remains the lowest
     neutral in the palette. */
  --disabled-color: #8a8fa6;
  --focus-ring: 2px solid var(--primary-color);
  --border-radius: 20px;
  --spacing: 24px;
  --font-main: 'Inter', 'Outfit', 'Segoe UI', sans-serif;

  /* Zero-Friction Layout Tokens */
  --sidebar-width-collapsed: 80px;
  --sidebar-width-expanded: 300px;
  --drawer-width: 360px;
  --tv-safe-margin: 24px;
  --nav-height: 76px;
  --mini-player-height: 80px;
  --transition-speed: 0.3s;

  /* Z-Index Scale */
  --z-nav: 100;
  --z-sidebar: 200;
  --z-drawer: 300;
  --z-fab: 400;
  --z-overlay: 500;
  --z-modal: 1000;
  --z-toast: 1100;
  --z-top: 9999;

  /* Skeleton Animation */
  --skeleton-base: #1c1c2e;
  --skeleton-highlight: #2c2c44;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: clamp(14px, 0.4vw + 11px, 17px);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background: var(--bg-darker);
  color: var(--text-light);
}

/* iOS safe-area-inset (M1): report insets to fixed-positioned children */
html {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* iOS bounce/overscroll containment (M3):
   body uses `contain` (not `none`) so the existing Android
   setupPullToRefresh() at app.js:681-780 still works on Android,
   but iOS bounce is blocked at the body level. */
body {
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* Internal scroll containers: contain bounce within themselves
   so it does not chain into parent contexts. */
.sidebar-content,
.drawer-content,
.game-grid,
.playlist-container,
.lyrics-content,
.toast-container {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Focus styles for TV navigation - covers both :focus-visible (keyboard)
   and :focus (programmatic, used by D-pad/remote handlers) */
*:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 4px;
}

/* Programmatic focus via .focus() (D-pad handlers) needs :focus not :focus-visible.
   These elements are focused by setupKeyboardNavigation arrow key handlers.
   Must use :focus (not :focus-visible) because programmatic .focus() calls
   don't trigger :focus-visible in most browsers. */
.game-card:focus,
.playlist-item:focus,
.sidebar-item:focus,
.sidebar-sub-item:focus,
.sidebar-category-header:focus,
.nav-tab:focus,
.console-btn:focus,
.quick-mix-item:focus,
.video-cat-btn:focus,
.music-btn:focus,
.mini-control-btn:focus,
.lang-btn:focus,
.btn-mute-toggle:focus,
.fab-button:focus,
[role="button"]:focus {
  outline: var(--focus-ring, 3px solid #00bfff);
  outline-offset: 2px;
  z-index: 10;
  position: relative;
}

/* TV-specific 4px focus ring (AG-01) */
.device-tv .game-card:focus,
.device-tv .playlist-item:focus,
.device-tv .sidebar-item:focus,
.device-tv .sidebar-sub-item:focus,
.device-tv .nav-tab:focus,
.device-tv .console-btn:focus,
.device-tv [role="button"]:focus {
  outline: 4px solid #00f3ff;
  outline-offset: 4px;
}

/* TV "ENTER to Play" hint on focused game cards (AG-01) */
.device-tv .game-card:focus::after {
    content: attr(data-tv-hint, 'ENTER to Play');
  display: block;
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: bold;
  color: #00f3ff;
  background: rgba(0, 0, 0, 0.75);
  padding: 4px 12px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 20;
  pointer-events: none;
}

/* ==========================================
   ZERO-FRICTION LAYOUT: Main App Structure
   ========================================== */

#app {
  width: 100vw;
  height: 100dvh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  background: var(--bg-darker);
  overflow: hidden;
}

/* Navigation Bar */
#main-nav {
  background: var(--bg-dark);
  padding: max(0.8rem, env(safe-area-inset-top)) var(--spacing) 0.8rem var(--spacing);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--secondary-color);
  min-height: var(--nav-height);
  height: auto;
  flex-shrink: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-brand h2 {
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  color: var(--primary-color);
  margin: 0;
  white-space: nowrap;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  justify-content: center;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-fullscreen {
  background: transparent;
  border: 2px solid var(--secondary-color);
  color: var(--text-light);
  padding: 0.5rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
}

.btn-fullscreen:hover {
  background: var(--secondary-color);
  border-color: var(--primary-color);
}

.btn-fullscreen .fullscreen-icon {
  font-size: 1.2rem;
  transition: transform 0.2s ease;
}

.btn-fullscreen.active {
  background: var(--primary-color);
  border-color: var(--accent-color);
}

.nav-tab {
  background: transparent;
  border: 2px solid transparent;
  color: var(--text-light);
  padding: 0.6rem 1.5rem;
  font-size: clamp(0.9rem, 1.2vw, 1rem);
  font-weight: bold;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-tab:hover, .nav-tab.active {
  background: var(--secondary-color);
  border-color: var(--primary-color);
}

/* Main Content Area - Left Sidebar + Center Stage + Right Drawer */
.app-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ==========================================
   LEFT SIDEBAR: Auto-Hide Game/Category Selector
   ========================================== */

.left-sidebar {
  width: var(--sidebar-width-collapsed);
  background: var(--bg-dark);
  border-right: 2px solid var(--secondary-color);
  transition: width var(--transition-speed) ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
  flex-shrink: 0;
}

.left-sidebar.expanded {
  width: var(--sidebar-width-expanded);
}

.left-sidebar:hover,
.left-sidebar:focus-within {
  width: var(--sidebar-width-expanded);
}

/* Sidebar toggle button */
.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--text-light);
  padding: 1rem;
  cursor: pointer;
  font-size: 1.5rem;
  transition: all 0.2s ease;
  text-align: center;
  border-bottom: 1px solid var(--secondary-color);
}

.sidebar-toggle:hover {
  background: var(--secondary-color);
}

/* Language selector in sidebar */
.language-selector {
  display: flex;
  gap: 0.3rem;
  padding: 0.5rem;
  border-bottom: 1px solid var(--secondary-color);
  background: var(--bg-darker);
}

.lang-btn {
  flex: 1;
  background: var(--bg-light);
  border: 2px solid transparent;
  color: var(--text-muted);
  padding: 0.4rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: bold;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  background: var(--secondary-color);
  color: var(--text-light);
}

.lang-btn.active {
  background: var(--primary-color);
  color: var(--text-light);
  border-color: var(--accent-color);
}

/* Sidebar content - icon list that expands */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  white-space: nowrap;
}

.sidebar-item:hover,
.sidebar-item.active {
  background: var(--secondary-color);
}

.sidebar-item-icon {
  font-size: 1.5rem;
  min-width: 30px;
  text-align: center;
}

.sidebar-item-label {
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
  font-size: 0.95rem;
}

.left-sidebar.expanded .sidebar-item-label,
.left-sidebar:hover .sidebar-item-label,
.left-sidebar:focus-within .sidebar-item-label {
  opacity: 1;
}

/* Collapsible category headers */
.sidebar-category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  cursor: pointer;
  background: var(--bg-darker);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.2s ease;
  white-space: nowrap;
}

.sidebar-category-header:hover {
  background: var(--secondary-color);
}

.sidebar-category-header > div {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle-icon {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Collapsible sub-items */
.sidebar-sub-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.sidebar-sub-items.expanded {
  max-height: 2000px;
}

.sidebar-sub-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.2s ease;
  white-space: nowrap;
}

.sidebar-sub-item:hover {
  background: var(--bg-light);
}

.sidebar-sub-item.playing {
  background: var(--primary-color);
}

.sidebar-sub-item .sidebar-item-icon {
  font-size: 1rem;
  min-width: 20px;
}

.sidebar-sub-item .sidebar-item-label {
  flex: 1;
  opacity: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Add to playlist button */
.add-to-playlist-btn {
  background: transparent;
  border: 2px solid var(--text-muted);
  color: var(--text-light);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-sub-item:hover .add-to-playlist-btn,
.sidebar-item:hover .add-to-playlist-btn {
  opacity: 1;
}

.add-to-playlist-btn:hover {
  background: var(--primary-color);
  border-color: var(--accent-color);
  transform: scale(1.1);
}

/* ==========================================
   CENTER STAGE: Dynamic Content Area
   ========================================== */

.center-stage {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-right var(--transition-speed) ease;
}

/* Tab Content Sections */
.tab-content {
  flex: 1;
  overflow: hidden;
  display: none;
  flex-direction: column;
  padding: var(--spacing);
}

.tab-content.active {
  display: flex;
}

/* ==========================================
   HOME TAB DASHBOARD (Bug audit 2026-06-16 C1)
   ========================================== */

#home-section {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  width: 100%;
  min-height: 60vh;
}

/* Bug audit 2026-06-20: the global #now-playing-display card was removed.
   The persistent #mini-player is now the sole global playback UI, so the
   home tab no longer needs to hide a redundant sibling card. */

#home-section.active {
  display: flex;
}

.home-welcome {
  text-align: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.08), rgba(255, 107, 53, 0.05));
  border: 1px solid rgba(0, 243, 255, 0.2);
  border-radius: var(--border-radius);
}

.home-welcome-title {
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
  font-weight: 800;
  margin: 0 0 0.5rem 0;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.home-welcome-subtitle {
  font-size: clamp(0.9rem, 1.4vw, 1.1rem);
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto 1rem auto;
  line-height: 1.5;
}

.home-clock {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary-color);
  letter-spacing: 2px;
  margin-top: 0.5rem;
  text-shadow: 0 0 24px rgba(0, 243, 255, 0.4);
}

.home-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  width: 100%;
}

.home-quick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.5rem 1rem;
  background: var(--bg-light);
  border: 2px solid var(--secondary-color);
  border-radius: var(--border-radius);
  text-decoration: none;
  color: var(--text-light);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  min-height: 130px;
  font-weight: 600;
}

.home-quick-card:hover,
.home-quick-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--primary-color);
  background: rgba(0, 243, 255, 0.08);
  outline: none;
}

.home-quick-card:focus-visible {
  box-shadow: 0 0 0 3px rgba(0, 243, 255, 0.4);
}

.home-quick-icon {
  font-size: 2.4rem;
  line-height: 1;
}

.home-quick-label {
  font-size: 1rem;
  letter-spacing: 0.5px;
}

@media (max-width: 480px) {
  .home-quick-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .home-welcome {
    padding: 1.2rem 0.8rem;
  }
}

/* ==========================================
   RIGHT DRAWER: Auto-Hide Playlist with Lyrics
   ========================================== */

.right-drawer {
  position: fixed;
  top: var(--nav-height);
  right: calc(-1 * var(--drawer-width));
  width: var(--drawer-width);
  height: calc(100vh - var(--nav-height) - var(--mini-player-height));
  background: var(--bg-dark);
  border-left: 2px solid var(--secondary-color);
  z-index: 200;
  transition: right var(--transition-speed) ease;
  display: flex;
  flex-direction: column;
  box-shadow: -5px 0 20px rgba(0,0,0,0.5);
  /* v2026.06.20-3: Bug audit fix — drawer was clipping by ~40px on
     the right edge when closed because the parent had no
     overflow:hidden and the drawer-content's children could bleed
     past the viewport. We now hide the entire drawer when closed
     so its children (PLAYLIST label, numbers) can never be visible
     in the autohide state. */
  visibility: hidden;
  pointer-events: none;
}

.right-drawer.open {
  right: 0;
  visibility: visible;
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--bg-darker);
  border-bottom: 2px solid var(--secondary-color);
}

.drawer-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.drawer-header h3 {
  color: var(--primary-color);
  font-size: 1.2rem;
  margin: 0;
}

.drawer-close {
  background: transparent;
  border: 2px solid var(--text-muted);
  color: var(--text-light);
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-close:hover {
  border-color: var(--accent-color);
  background: var(--secondary-color);
}

.drawer-content {
  flex: 0 0 auto;
  max-height: 40%;
  overflow-y: auto;
  padding: 0.5rem;
}

/* ==========================================
   LYRICS SECTION
   ========================================== */

.lyrics-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 2px solid var(--secondary-color);
  background: linear-gradient(135deg, var(--bg-darker), var(--bg-dark));
  position: relative;
}

.lyrics-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.lyrics-text {
  color: var(--text-light);
  font-size: clamp(1rem, 2vw, 1.3rem);
  line-height: 1.8;
  text-align: center;
  white-space: pre-wrap;
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.lyrics-placeholder {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 2rem;
}

.lyrics-video-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  border-radius: inherit;
}

/* When inside now-playing-art in music section */
.now-playing-art .lyrics-video-fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.now-playing-art {
  position: relative;
  overflow: hidden;
}

/* ==========================================
   FLOATING ACTION BUTTON (FAB) - Quick-Mix
   ========================================== */

.fab-container {
  position: fixed;
  bottom: calc(var(--mini-player-height) + var(--tv-safe-margin));
  right: var(--tv-safe-margin);
  z-index: 300;
}

.fab-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  color: var(--text-light);
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(255,107,53,0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(255,107,53,0.6);
}

/* Quick-Mix Overlay */
.quick-mix-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

.quick-mix-overlay.visible {
  display: flex;
}

.quick-mix-panel {
  background: var(--bg-dark);
  border: 2px solid var(--secondary-color);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.quick-mix-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  background: var(--bg-darker);
  border-bottom: 2px solid var(--secondary-color);
}

.quick-mix-header h3 {
  color: var(--primary-color);
  margin: 0;
}

.quick-mix-close {
  background: transparent;
  border: 2px solid var(--text-muted);
  color: var(--text-light);
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-mix-close:hover {
  border-color: var(--accent-color);
  background: var(--secondary-color);
}

.quick-mix-body {
  padding: 1.5rem;
}

.quick-mix-category {
  margin-bottom: 1.5rem;
}

.quick-mix-category h4 {
  color: var(--accent-color);
  margin-bottom: 0.8rem;
  font-size: 1rem;
}

.quick-mix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.8rem;
}

.quick-mix-item {
  background: var(--bg-light);
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0.8rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick-mix-item:hover,
.quick-mix-item.active {
  border-color: var(--primary-color);
  background: var(--secondary-color);
}

.quick-mix-item .item-icon {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}

.quick-mix-item .item-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================
   FLOATING CLOSE GAME BUTTON
   ========================================== */

.floating-exit-btn {
  position: absolute;
  top: var(--tv-safe-margin);
  right: var(--tv-safe-margin);
  z-index: 150;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--error-color);
  border: 2px solid rgba(255,255,255,0.3);
  color: var(--text-light);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(239,68,68,0.5);
  transition: all 0.2s ease;
}

.floating-exit-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(239,68,68,0.7);
}

/* ==========================================
   SECTION HEADERS
   ========================================== */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.section-header h2 {
  font-size: clamp(1.1rem, 1.8vw, 1.4rem);
  color: var(--accent-color);
  margin: 0;
}

.section-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.console-btn:hover, .console-btn.active {
  background: var(--primary-color);
  border-color: var(--accent-color);
  transform: scale(1.05);
}

.console-icon {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
}

/* Video Category Selector */
.video-category-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.video-controls-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-mute-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-light);
  border: 2px solid var(--secondary-color);
  color: var(--text-light);
  padding: 0.6rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: clamp(0.85rem, 1vw, 0.95rem);
  white-space: nowrap;
}

.btn-mute-toggle:hover {
  background: var(--primary-color);
  border-color: var(--accent-color);
}

.btn-mute-toggle.muted {
  background: var(--error-color);
  border-color: var(--error-color);
}

.video-action-btns {
  display: flex;
  gap: 0.5rem;
}

.btn-install {
  background: var(--primary-color);
  border: none;
  color: var(--text-light);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: bold;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  margin-left: 1rem;
}

.btn-install:hover {
  background: var(--accent-color);
  color: var(--bg-dark);
}

.btn-install.hidden {
  display: none;
}

.video-cat-btn {
  background: var(--bg-light);
  border: 2px solid var(--secondary-color);
  color: var(--text-light);
  padding: 0.6rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: clamp(0.85rem, 1vw, 0.95rem);
}

.video-cat-btn:hover, .video-cat-btn.active {
  background: var(--primary-color);
  border-color: var(--accent-color);
}

/* ==========================================
   GAME LIST WITH CUSTOM SCROLLBAR
   ========================================== */

.game-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(115px, 14vw, 180px), 1fr));
  grid-auto-rows: max-content;
  gap: clamp(8px, 1.2vw, 16px);
  padding: 0.5rem 0;
  align-content: start;
}

.game-grid.skeleton-loading {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.game-grid.skeleton-loading .skeleton-card {
  display: flex;   /* Enable flex column on skeleton cards */
}

.game-card {
  aspect-ratio: 1 / 1.5;
  background: var(--bg-light);
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.15) 100%
  );
  transform: skewX(-25deg);
  transition: 0.75s;
  pointer-events: none;
}

.game-card:hover::before {
  left: 125%;
}

.game-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 10px 20px rgba(0, 243, 255, 0.25);
}

.game-card:focus-visible {
  border-color: var(--accent-color);
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 10px 20px rgba(255, 0, 85, 0.25);
}

.game-thumbnail {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--bg-dark);
  position: relative;
  overflow: hidden;
}

.game-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.game-thumb-img[src] {
  opacity: 1;
}

.game-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a3a, #0f0f2a);
}

.game-card h3 {
  font-size: clamp(0.85rem, 1vw, 0.95rem);
  margin-bottom: 0.3rem;
}

.game-card p {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ==========================================
   EMULATOR CONTAINER
   ========================================== */

#emulator-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

#emulator-container.hidden {
  display: none;
}

#exit-game-btn {
  display: none; /* Hidden - replaced by floating button */
}

#emulator-wrapper.hidden {
  display: none !important;
}

#emulator-wrapper {
  flex: 1;
  background: #000;
  border-radius: var(--border-radius);
  overflow: hidden;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#emulator-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

#emulator-wrapper .ejs_parent {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
}

#emulator-wrapper .ejs_canvas {
  width: 100% !important;
  height: auto !important;
  max-height: 100% !important;
  object-fit: contain;
}

/* Emulator Loading State */
.emulator-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  gap: 1rem;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--bg-light);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.emulator-loading p {
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* Emulator Error State */
.emulator-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  gap: 1rem;
}

.emulator-error p {
  font-size: 1.1rem;
  color: var(--error-color);
}

/* ==========================================
   PLAYLIST
   ========================================== */

.playlist-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--bg-light);
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  padding: 0.8rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.playlist-item:hover {
  border-color: var(--primary-color);
  transform: translateX(6px);
  box-shadow: -4px 0 15px rgba(0, 243, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.playlist-item.playing {
  background: var(--primary-color);
  border-color: var(--accent-color);
}

.playlist-number {
  font-size: clamp(1.2rem, 1.5vw, 1.5rem);
  font-weight: bold;
  color: var(--text-muted);
  min-width: 35px;
}

.playlist-item.playing .playlist-number {
  color: var(--text-light);
}

.playlist-info h3 {
  font-size: clamp(0.9rem, 1.2vw, 1rem);
  margin-bottom: 0.2rem;
}

.playlist-info p {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.playlist-item.playing .playlist-info p {
  color: rgba(255, 255, 255, 0.8);
}

/* Drawer section header (separates custom playlists from BGM queue) */
.drawer-section-header {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0.6rem 0.8rem 0.3rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 0.3rem;
}

/* Custom (user-created) playlist entries in the drawer */
.custom-playlist-item .playlist-number {
  color: var(--accent-color);
}

/* Footer area in the drawer hosting the create-playlist button */
.drawer-create-playlist {
  padding: 0.8rem 0 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 0.6rem;
  display: flex;
  justify-content: center;
}

.btn-create-playlist {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 2px dashed var(--secondary-color);
  background: transparent;
  color: var(--text-light);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-create-playlist:hover,
.btn-create-playlist:focus {
  background: var(--secondary-color);
  color: var(--bg-dark);
  border-style: solid;
  transform: translateY(-1px);
}

.btn-create-playlist:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ==========================================
   EMPTY STATE
   ========================================== */

/* ENHANCED EMPTY STATE WITH ILLUSTRATIONS */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.empty-state-illustration {
  width: 120px;
  height: 120px;
  opacity: 0.6;
  margin-bottom: 0.5rem;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.empty-state-illustration {
  width: 120px;
  height: 120px;
  opacity: 0.6;
  margin-bottom: 0.5rem;
}

.empty-state-title {
  font-size: clamp(1.1rem, 1.5vw, 1.3rem);
  font-weight: bold;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.empty-state p {
  margin: 0.5rem 0;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
}

.empty-state .hint {
  font-size: clamp(0.85rem, 1.2vw, 1rem);
  color: var(--text-muted);
  opacity: 0.7;
  font-style: italic;
  max-width: 400px;
}

.empty-state-action {
  margin-top: 1rem;
}

.empty-state-btn {
  background: var(--primary-color);
  border: none;
  color: white;
  padding: 0.8rem 2rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: bold;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.empty-state-btn:hover {
  background: #ff8c5a;
  transform: scale(1.05);
}

.empty-state-divider {
  width: 60px;
  height: 3px;
  background: var(--secondary-color);
  border-radius: 2px;
  margin: 1rem 0;
}

/* ==========================================
   VIDEO PLAYER
   ========================================== */

#video-player-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}

#main-video {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: var(--border-radius);
  border: 2px solid var(--secondary-color);
}

.plyr {
  --plyr-color-main: var(--primary-color);
  width: 100%;
  max-height: 70vh;
  border-radius: var(--border-radius);
}

.plyr__video-wrapper {
  background: #000;
  border-radius: var(--border-radius);
  border: 2px solid var(--secondary-color);
}

.video-container-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  min-height: 0;
}

#main-video,
.video-container-wrapper .plyr {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #000;
}

#video-fallback {
  background: var(--bg-light);
  border: 2px solid var(--error-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  text-align: center;
  margin: 0.5rem 0;
}

#video-fallback.hidden {
  display: none;
}

#video-info {
  background: var(--bg-light);
  border-radius: var(--border-radius);
  padding: 0.8rem;
  margin: 0.3rem 0;
}

#video-info.hidden {
  display: none;
}

#video-info p {
  margin: 0.2rem 0;
  font-size: clamp(0.85rem, 1vw, 0.95rem);
  color: var(--text-muted);
}

#video-info p span {
  color: var(--text-light);
  font-weight: bold;
}

#video-playlist {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Ads */
#ads-player-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}

#ad-main-video {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: var(--border-radius);
  border: 2px solid var(--secondary-color);
}

.ads-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Buttons */
.btn-primary {
  background: var(--primary-color);
  border: none;
  color: var(--text-light);
  padding: 0.8rem 2rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: #ff8c5a;
  transform: scale(1.02);
}

.btn-secondary {
  background: var(--secondary-color);
  border: 2px solid var(--accent-color);
  color: var(--text-light);
  padding: 0.6rem 1.2rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #003366;
}

/* ==========================================
   AD BANNER
   ========================================== */

#ad-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

#ad-banner.hidden {
  display: none;
}

#ad-video {
  max-width: 80%;
  max-height: 70vh;
  border: 3px solid var(--primary-color);
  border-radius: var(--border-radius);
}

.ad-timer {
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  color: var(--accent-color);
}

/* ==========================================
   PWA INSTALL BANNER (AG-02)
   ========================================== */

.pwa-install-banner {
  position: fixed;
  /* v2026.06.20-3: Bug audit fix — was `bottom: 80px`, which placed
     the banner directly on top of the mini-player. We now anchor it
     above the mini-player (80px tall) plus an extra 12px gap so the
     mini-player surface is not obscured. Bug audit 2026-06-20: the
     redundant #now-playing-display card was also removed, so the
     banner no longer collides with a secondary playback surface. */
  bottom: calc(var(--mini-player-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-darker);
  border: 2px solid var(--primary-color);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10001;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  max-width: 90vw;
  animation: pwaBannerSlideIn 0.3s ease-out;
}

@keyframes pwaBannerSlideIn {
  from {
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.pwa-banner-icon {
  font-size: 32px;
  line-height: 1;
}

.pwa-banner-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pwa-banner-text strong {
  color: var(--text-primary);
  font-size: 16px;
}

.pwa-banner-text span {
  color: var(--text-secondary);
  font-size: 14px;
}

.pwa-banner-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 28px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
}

.pwa-banner-close:hover {
  color: var(--text-primary);
}

.pwa-banner-install-btn {
  background: var(--primary-color);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.pwa-banner-install-btn:hover {
  background: var(--accent-color);
}

@media (max-width: 768px) {
  .pwa-install-banner {
    bottom: 70px;
    padding: 12px 16px;
  }

  .pwa-banner-text strong {
    font-size: 14px;
  }

  .pwa-banner-text span {
    font-size: 12px;
  }

  .pwa-banner-icon {
    font-size: 28px;
  }

  .pwa-banner-install-btn {
    font-size: 14px;
    padding: 6px 16px;
  }
}

/* ==========================================
   MINI-PLAYER
   ========================================== */

.mini-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: var(--bg-darker);
  border-top: 2px solid var(--secondary-color);
  transition: all 0.3s ease;
  height: var(--mini-player-height);
}

.mini-player.collapsed {
  height: 40px;
}

.mini-player.expanded {
  height: 80px;
}

.mini-player-content {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 1rem;
  height: 100%;
}

.mini-player-album-art {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

.mini-player-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.mini-player-title {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-player-artist {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-player-controls {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.mini-control-btn {
  background: transparent;
  border: none;
  color: var(--text-light);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 50%;
  transition: all 0.2s ease;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-control-btn:hover {
  background: var(--primary-color);
}

.mini-control-btn.active {
  background: var(--accent-color);
  color: var(--bg-darker);
}

.mini-player-progress {
  flex: 0 0 120px;
  display: flex;
  align-items: center;
}

.mini-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-light);
  border-radius: 2px;
  overflow: hidden;
}

.mini-progress-fill {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.1s linear;
}

.mini-player-toggle {
  position: absolute;
  top: -24px;
  right: 15px;
  background: var(--bg-darker);
  border: 2px solid var(--secondary-color);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: var(--text-light);
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  font-size: 0.8rem;
}

.mini-player.collapsed .mini-player-content {
  padding: 0;
}

.mini-player.collapsed .mini-player-album-art,
.mini-player.collapsed .mini-player-controls,
.mini-player.collapsed .mini-player-progress {
  display: none;
}

.mini-player.collapsed .mini-player-info {
  display: flex;
  align-items: center;
  padding-left: 0.8rem;
}

.mini-player.collapsed .mini-player-artist {
  display: none;
}

/* ==========================================
   NOW PLAYING SECTION (Music Tab)
   ========================================== */

.music-player-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
  min-height: 0;
}

.now-playing-section {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  background: var(--bg-light);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Inline music playlist (Bug audit 2026-06-19: mirrors #video-playlist).
   Sits below the now-playing card on the music tab so the user can see
   and pick tracks directly, just like the movie playlist on the movie tab. */
.music-playlist {
  flex: 1 1 auto;
  min-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius);
}

.music-playlist .empty-state {
  margin: auto;
}

@media (max-width: 600px) {
  .music-player-container {
    gap: 0.5rem;
  }
  .now-playing-section {
    padding: 1rem;
  }
  .music-playlist {
    min-height: 140px;
  }
}

.now-playing-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.now-playing-art {
  width: 100%;
  max-width: 100%;
  height: 300px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: transform 0.3s ease;
  position: relative;
  overflow: hidden;
}

.now-playing-art::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(0,0,0,0.1), rgba(0,0,0,0.3));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.now-playing-art:hover::before {
  opacity: 1;
}

.now-playing-art.pulsing {
  animation: art-pulse 2s infinite ease-in-out;
}

@keyframes art-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.now-playing-info {
  text-align: center;
  width: 100%;
}

.now-playing-info h3 {
  font-size: 1.3rem;
  margin-bottom: 0.3rem;
}

.now-playing-info p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.music-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.music-btn {
  background: var(--bg-light);
  border: none;
  color: var(--text-light);
  font-size: 1.2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.music-btn:hover {
  background: var(--primary-color);
}

.music-btn.active {
  background: var(--accent-color);
  color: var(--bg-dark);
}

.music-progress-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
}

.music-progress-bar {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
}

.music-progress-fill {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.1s linear;
}

.player-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-option {
  padding: 0.6rem 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-light);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  text-align: center;
  transition: all 0.2s ease;
}

.btn-option:hover {
  background: rgba(255,255,255,0.1);
  border-color: var(--accent-color);
}

/* ==========================================
   VIDEO OVERLAY
   ========================================== */

/* Video Overlay - Now invisible, used only for gesture detection */
.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  pointer-events: none;
  z-index: 10;
}

/* Gesture Feedback Animation */
.gesture-feedback {
  position: absolute;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-size: 1.2rem;
  font-weight: bold;
  pointer-events: none;
  z-index: 20;
  animation: gestureFade 0.6s ease-out forwards;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

@keyframes gestureFade {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.2);
  }
}

/* Fullscreen Mode Enhancements */
#video-wrapper:fullscreen {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#video-wrapper:fullscreen #main-video,
#video-wrapper:fullscreen .plyr {
  width: 100%;
  height: 100%;
  max-height: 100vh;
  object-fit: contain;
}

#video-wrapper:fullscreen .video-overlay {
  z-index: 30;
}

#video-wrapper:-webkit-full-screen {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#video-wrapper:-webkit-full-screen #main-video,
#video-wrapper:-webkit-full-screen .plyr {
  width: 100%;
  height: 100%;
  max-height: 100vh;
  object-fit: contain;
}

/* TV Safe Zone for Fullscreen */
.device-smart-tv #video-wrapper:fullscreen {
  margin: 5vh 5vw;
}

/* ==========================================
   MIX DASHBOARD
   ========================================== */

.mix-dashboard {
  position: fixed;
  top: var(--nav-height);
  right: calc(-1 * 380px);
  width: 360px;
  height: calc(100vh - var(--nav-height) - var(--mini-player-height));
  background: var(--bg-darker);
  border-left: 3px solid var(--secondary-color);
  z-index: 250;
  transition: right var(--transition-speed) ease;
  display: flex;
  flex-direction: column;
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
}

.mix-dashboard.open {
  right: 0;
}

.mix-dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem;
  background: var(--bg-dark);
  border-bottom: 2px solid var(--secondary-color);
}

.mix-dashboard-header h3 {
  color: var(--primary-color);
  font-size: 1.3rem;
  margin: 0;
}

.mix-dashboard-close {
  background: transparent;
  border: 2px solid var(--text-muted);
  color: var(--text-light);
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mix-dashboard-close:hover {
  border-color: var(--accent-color);
  background: var(--secondary-color);
}

.mix-dashboard-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
}

.mix-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--bg-light);
}

.mix-section:last-child {
  border-bottom: none;
}

.mix-section h4 {
  color: var(--primary-color);
  font-size: 1rem;
  margin-bottom: 0.8rem;
}

.mix-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  font-size: 0.9rem;
}

.mix-label {
  color: var(--text-muted);
  font-weight: bold;
}

#mix-mode {
  background: var(--secondary-color);
  padding: 0.4rem 0.8rem;
  border-radius: var(--border-radius);
  font-weight: bold;
}

/* ==========================================
   GAME INFO MODAL
   ========================================== */

.game-info-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
}

.game-info-modal.visible {
  display: flex;
}

.game-info-content {
  background: var(--bg-darker);
  border: 3px solid var(--secondary-color);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 450px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.game-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem;
  background: var(--bg-dark);
  border-bottom: 2px solid var(--secondary-color);
}

.game-info-header h3 {
  color: var(--primary-color);
  font-size: 1.3rem;
  margin: 0;
}

.game-info-close {
  background: transparent;
  border: 2px solid var(--text-muted);
  color: var(--text-light);
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-info-close:hover {
  border-color: var(--accent-color);
  background: var(--secondary-color);
}

.game-info-body {
  padding: 1.2rem;
}

.game-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--bg-light);
  font-size: 0.95rem;
}

.game-info-item:last-child {
  border-bottom: none;
}

.game-info-label {
  color: var(--text-muted);
  font-weight: bold;
}

/* ==========================================
   RESUME OVERLAY
   ========================================== */

.resume-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in 0.3s ease;
}

.resume-content {
  background: var(--bg-dark);
  padding: 1.5rem;
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--accent-color);
}

.resume-content p {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text-light);
}

.resume-buttons {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================
   CAR MODE
   ========================================== */

.car-mode {
  font-size: 150%; /* AG-03: Minimum 24px font size (16px * 1.5 = 24px) */
}

.car-mode #main-nav {
  padding: 1.2rem;
}

.car-mode .nav-tab {
  font-size: 1.3rem;
  padding: 1rem 2rem;
  min-height: 50px;
}

/* AG-03: Cap game grid at 2 columns for 800x480 car displays */
.car-mode .game-grid {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 1rem;
}

.car-mode .game-card {
  min-height: 120px;
  min-width: 160px;
  padding: 1.2rem;
}

.car-mode .game-card h3 {
  font-size: 1.2rem;
}

.car-mode .playlist-item {
  min-height: 70px;
  padding: 1rem;
}

/* ==========================================
   CAR MODE - VIDEO PLAYER OPTIMIZATION
   ========================================== */

/* Hide section header to maximize video display area on small screens */
.car-mode #video-section .section-header {
  display: none;
}

/* Make video player take full height in car mode */
.car-mode #video-player-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: none;
}

.car-mode .video-container-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100vw;
}

.car-mode #main-video,
.car-mode .plyr {
  max-height: none;
  height: auto;
  width: 100%;
  max-width: 100%;
  border: none;
  border-radius: 0;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

/* Optimize for short screen car displays (landscape orientation) */
@media (max-aspect-ratio: 2/1) and (max-height: 500px) {
  .car-mode .video-container-wrapper {
    height: 60vh;
    max-height: 400px;
  }

  .car-mode #main-video,
  .car-mode .plyr {
    width: 100%;
    height: auto;
    max-height: 100%;
  }
}

/* Hide video info and playlist in car mode to save space */
.car-mode #video-info,
.car-mode #video-playlist {
  display: none;
}

/* Car mode drawer optimization - make lyrics area larger */
.car-mode .right-drawer {
  width: 400px;
}

.car-mode .drawer-content {
  max-height: 30%;
}

.car-mode .lyrics-section {
  flex: 1;
  min-height: 250px;
}

.car-mode .lyrics-text {
  font-size: 1.2rem;
  line-height: 2;
}

.car-mode .lyrics-video-fallback {
  min-height: 250px;
}

/* Show video title in mini-player when in car mode */
.car-mode .mini-player-content {
  padding: 0.3rem 0.6rem;
}

.car-mode .mini-player-title {
  font-size: 0.9rem;
  font-weight: bold;
}

.car-mode .mini-player-artist {
  font-size: 0.75rem;
}

.car-mode .mini-control-btn {
  min-height: 40px;
  min-width: 40px;
}

/* Passenger Mode - restore normal UI in car */
.passenger-mode.car-mode {
  font-size: 100% !important;
}

.passenger-mode.car-mode .nav-tab {
  font-size: 1rem !important;
  padding: 0.6rem 1.2rem !important;
}

.passenger-mode.car-mode .game-card {
  min-height: 100px !important;
}

/* Car Night Mode indicator */
.car-night-mode::after {
  content: '🌙';
  position: fixed;
  top: 10px;
  right: 10px;
  font-size: 1.5rem;
  opacity: 0.5;
  pointer-events: none;
  z-index: 9999;
}

/* ==========================================
   iPad WITH KEYBOARD/TRACKPAD
   ========================================== */

/* Enable hover effects when iPad has keyboard/trackpad connected */
.device-ipad-keyboard .game-card:hover,
.device-ipad-keyboard .nav-tab:hover,
.device-ipad-keyboard .playlist-item:hover,
.device-ipad-keyboard .sidebar-item:hover {
  transform: translateY(-2px);
  transition: transform 0.2s ease;
}

.device-ipad-keyboard .game-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ==========================================
   iPad SPLIT VIEW / STAGE MANAGER
   ========================================== */

/* Handle iPad in split view - reduce layout to fit smaller window */
.device-ipad-split #main-nav {
  padding: 0.4rem;
}

.device-ipad-split .nav-brand h2 {
  font-size: 1rem;
}

.device-ipad-split .nav-tab {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.device-ipad-split .game-grid {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

/* iPad in half-screen split view */
@media (min-width: 769px) and (max-width: 1023px) {
  .device-ipad-split #main-nav {
    flex-wrap: wrap;
  }
  
  .device-ipad-split .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
  
  .device-ipad-split .left-sidebar {
    width: 50px;
  }
}

/* ==========================================
   TV BOX DEVICE STYLES
   ========================================== */

/* Add 48px min-heights on interactive elements (same as .device-tv rules) */
.device-tv-box .nav-tab {
  min-height: 48px;
}

.device-tv-box .playlist-item {
  min-height: 48px;
}

.device-tv-box .sidebar-item {
  min-height: 48px;
}

.device-tv-box .console-btn {
  min-height: 48px;
}

/* ==========================================
   SKELETON LOADING STATES
   ========================================== */

.skeleton-loader {
  background: var(--skeleton-base);
  border-radius: var(--border-radius);
  position: relative;
  overflow: hidden;
}

.skeleton-loader::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, var(--skeleton-highlight), transparent);
  animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  overflow: hidden;
  height: 180px;                    /* Fixed height — no stretching */
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

.skeleton-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(
    90deg,
    #1a1a2e 0%,
    #2a2a4a 20%,
    #4a4a7a 50%,
    #2a2a4a 80%,
    #1a1a2e 100%
  );
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  background-size: 200% 100%;
}

.skeleton-card-img {
  width: 100%;
  height: 110px;                    /* Fixed image area */
  background: var(--skeleton-base);
  flex-shrink: 0;
}

.skeleton-card-title {
  height: 14px;
  width: 75%;
  margin: 10px 12px 6px;
  background: var(--skeleton-base);
  border-radius: 4px;
  flex-shrink: 0;
}

.skeleton-card-meta {
  height: 10px;
  width: 50%;
  margin: 0 12px 12px;
  background: var(--skeleton-base);
  border-radius: 4px;
  opacity: 0.6;
  flex-shrink: 0;
}

/* ==========================================
   TOAST NOTIFICATION SYSTEM
   ========================================== */

.toast-container {
  position: fixed;
  bottom: calc(var(--mini-player-height) + 20px);
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 350px;
}

.toast {
  background: var(--bg-card);
  border: 2px solid var(--secondary-color);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: toast-slide-in 0.3s ease-out;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  position: relative;
}

.toast.toast-exit {
  animation: toast-slide-out 0.3s ease-in forwards;
}

.toast-success { border-left: 4px solid var(--success-color); }
.toast-error { border-left: 4px solid var(--error-color); }
.toast-warning { border-left: 4px solid var(--warning-color); }
.toast-info { border-left: 4px solid var(--info-color); }

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.toast-message {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--primary-color);
  animation: toast-progress 5s linear;
}

@keyframes toast-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-slide-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

@keyframes toast-progress {
  from { width: 100%; }
  to { width: 0%; }
}

/* ==========================================
   DISABLED BUTTON STATES
   ========================================== */

button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-auth:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(50%);
}

button:disabled:hover,
.btn-primary:disabled:hover,
.btn-secondary:disabled:hover {
  transform: none;
  background-color: inherit;
  border-color: inherit;
}

/* ==========================================
   ERROR RECOVERY STATES
   ========================================== */

.error-state {
  text-align: center;
  padding: 2rem;
  background: rgba(239, 68, 68, 0.05);
  border: 2px solid var(--error-color);
  border-radius: var(--border-radius);
}

.error-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.error-state-title {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--error-color);
  margin-bottom: 0.5rem;
}

.error-state-message {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.error-state-retry {
  background: var(--error-color);
  border: none;
  color: white;
  padding: 0.6rem 1.5rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s ease;
}

.error-state-retry:hover {
  background: #dc2626;
  transform: scale(1.05);
}

/* ==========================================
   SCROLLBAR STYLING
   ========================================== */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--secondary-color), var(--primary-color));
  border-radius: 8px;
  border: 1px solid var(--bg-dark);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--primary-color), var(--accent-color));
}

/* ==========================================
   RESPONSIVE BREAKPOINTS
   ========================================== */

/* Tablet Landscape (1024px and below) */
@media (max-width: 1024px) {
  :root {
    --spacing: 15px;
    --border-radius: 10px;
    --sidebar-width-expanded: 240px;
    --drawer-width: 280px;
  }

  .nav-tabs {
    gap: 0.4rem;
  }

  .nav-tab {
    padding: 0.5rem 1.2rem;
    font-size: clamp(0.85rem, 1.5vw, 0.95rem);
  }

  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.8rem;
  }

  .video-controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  /* SCROLLBAR GUTTER - Prevent layout shift */
  .center-stage,
  .sidebar-content,
  .drawer-content,
  .game-grid,
  .playlist-container {
    scrollbar-gutter: stable;
  }

  /* FIX: Focus ring cutoff in overflow containers */
  .sidebar-content *:focus-visible,
  .drawer-content *:focus-visible,
  .game-grid *:focus-visible {
    outline-offset: 2px;
    z-index: 10;
    position: relative;
  }
}

/* Tablet Portrait (768px and below) */
@media (max-width: 768px) {
  html, body {
    overflow: auto;
  }

  #app {
    height: auto;
    min-height: 100vh;
  }

  #main-nav {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.8rem;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .nav-brand h2 {
    font-size: 1.3rem;
    text-align: center;
  }

  .nav-tabs {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .nav-tab {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    flex: 1;
    min-width: 70px;
  }

  .left-sidebar {
    width: 50px;
  }

  .left-sidebar.expanded {
    width: 200px;
  }

  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.6rem;
  }

  .right-drawer {
    width: 260px;
  }

  .music-player-container {
    flex-direction: column;
  }

  .now-playing-section {
    flex: 0 0 auto;
  }

  .fab-container {
    bottom: calc(var(--mini-player-height) + 10px);
    right: 10px;
  }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
  :root {
    --spacing: 10px;
    --border-radius: 8px;
  }

  #main-nav {
    padding: 0.5rem;
  }

  .nav-brand h2 {
    font-size: 1.1rem;
  }

  .nav-tab {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    min-width: 55px;
  }

  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.5rem;
  }

  .game-card {
    padding: 0.6rem;
  }

  .game-card h3 {
    font-size: 0.75rem;
  }

  .game-card p {
    font-size: 0.65rem;
  }

  .left-sidebar {
    width: 45px;
  }

  .right-drawer {
    width: 100%;
    right: -100%;
  }

  /* Mobile drawer optimization - lyrics area takes more space */
  .device-mobile .drawer-content {
    max-height: 25%;
  }

  .device-mobile .lyrics-section {
    flex: 1;
    min-height: 200px;
  }

  .device-mobile .lyrics-text {
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 1rem;
  }

  .device-mobile .lyrics-video-fallback {
    min-height: 200px;
  }

  /* Mobile video player optimization */
  .device-mobile .video-container-wrapper {
    width: 100%;
  }

  .device-mobile #main-video,
  .device-mobile .plyr {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
  }

  ::-webkit-scrollbar {
    width: 6px;
  }

  /* MOBILE BOTTOM NAVIGATION */
  #main-nav {
    flex-direction: row;
    padding: 0.5rem;
  }

  .nav-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-darker);
    border-top: 2px solid var(--secondary-color);
    padding: 0.5rem;
    z-index: var(--z-nav);
    gap: 0;
  }

  .nav-tab {
    flex-direction: column;
    padding: 0.5rem;
    font-size: 0.7rem;
    min-width: 60px;
  }

  .app-layout {
    padding-bottom: 140px; /* Space for bottom nav (70px) + mini-player (70px) */
  }

  /* Raise bottom nav above mini-player */
  .nav-tabs {
    bottom: var(--mini-player-height);
    z-index: 1000; /* Higher than mini-player (900) to ensure tabs are clickable */
  }

  /* Mini-player stays at bottom: 0, visible below the nav */
  /* No padding-bottom needed - it's meant to be partially visible */

  /* FAB button size for mobile */
  .fab-button {
    width: 52px;
    height: 52px;
  }

  /* FAB should be above both nav and mini-player on mobile */
  .fab-container {
    bottom: calc(var(--mini-player-height) + var(--nav-height) + 10px);
  }
}

/* SAFE AREA INSETS FOR NOTCHED DEVICES */
@supports (padding: max(0px)) {
  #app {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  #main-nav {
    padding-left: max(var(--spacing), env(safe-area-inset-left));
    padding-right: max(var(--spacing), env(safe-area-inset-right));
  }

  .toast-container {
    right: max(20px, env(safe-area-inset-right));
    bottom: max(calc(var(--mini-player-height) + 20px), env(safe-area-inset-bottom));
  }
}

/* Smart TV (1920px+) - 10-foot UI optimizations */
@media (min-width: 1920px) {
  :root {
    --spacing: 30px;
    --tv-safe-margin: 40px;
  }

  .nav-tab {
    padding: 1rem 2rem;
    font-size: 1.2rem;
  }

  .console-btn {
    padding: 1.2rem 1.5rem;
    font-size: 1.1rem;
  }

  .game-card {
    padding: 1.2rem;
  }

  .game-card h3 {
    font-size: 1.1rem;
  }

  .game-card p {
    font-size: 0.95rem;
  }

  .fab-button {
    width: 64px;
    height: 64px;
    font-size: 1.8rem;
  }

  .floating-exit-btn {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }

  /* TV text scaling for readability at distance */
  .section-header h2 {
    font-size: 1.6rem;
  }

  .playlist-item {
    min-height: 60px;
    font-size: 1.05rem;
  }

  .playlist-info h3 {
    font-size: 1.15rem;
  }

  .sidebar-item {
    font-size: 1.05rem;
    min-height: 48px;
  }

  .lyrics-text {
    font-size: 1.4rem;
    line-height: 1.8;
  }

  .now-playing-info h3 {
    font-size: 1.5rem;
  }

  .now-playing-info p {
    font-size: 1.1rem;
  }

  .toast {
    font-size: 1.5rem;
    padding: 1.5rem 2.5rem;
    border-radius: 12px;
  }
  .toast-progress { height: 4px; }

  .mini-player-title {
    font-size: 1rem;
  }

  .mini-player-artist {
    font-size: 0.9rem;
  }

  .music-btn {
    width: 52px;
    height: 52px;
    font-size: 1.4rem;
  }

  .mini-control-btn {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }

  .game-info-close,
  .mix-dashboard-close,
  .drawer-close {
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
  }
}

/* 4K displays */
@media (min-width: 3840px) {
  :root {
    font-size: 1.5rem;
    --spacing: 50px;
    --border-radius: 20px;
    --tv-safe-margin: 60px;
  }

  .nav-tab {
    padding: 1.2rem 2.5rem;
    font-size: 1.5rem;
  }

  .console-btn {
    padding: 1.5rem 2rem;
    font-size: 1.3rem;
  }

  .game-card h3 {
    font-size: 1.3rem;
  }

  .game-card p {
    font-size: 1.1rem;
  }

  .game-card { min-height: 200px; }
  .nav-tab { min-height: 80px; min-width: 120px; }
  .console-btn { min-height: 60px; }
  .playlist-item { min-height: 70px; }
  .fab-button { width: 72px; height: 72px; }
  .floating-exit-btn { width: 64px; height: 64px; }
  .sidebar-item { min-height: 60px; }

  .section-header h2 {
    font-size: 2rem;
  }

  .playlist-item {
    min-height: 200px;
    font-size: 1.2rem;
  }

  .playlist-info h3 {
    font-size: 1.3rem;
  }

  .sidebar-item {
    font-size: 1.2rem;
    min-height: 200px;
  }

  .lyrics-text {
    font-size: 1.6rem;
    line-height: 2;
  }

  .now-playing-info h3 {
    font-size: 1.8rem;
  }

  .now-playing-info p {
    font-size: 1.3rem;
  }

  .music-btn {
    width: 60px;
    height: 60px;
    font-size: 1.6rem;
  }

  .mini-control-btn {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
  }

  .fab-button {
    width: 80px;
    height: 80px;
    font-size: 2.2rem;
  }

  .floating-exit-btn {
    width: 68px;
    height: 68px;
    font-size: 1.8rem;
  }

  .game-info-close,
  .mix-dashboard-close,
  .drawer-close {
    width: 52px;
    height: 52px;
    font-size: 1.6rem;
  }
}

/* ==========================================
   AUTHENTICATION UI
   ========================================== */

/* Auth trigger button */
.btn-auth {
  background: var(--bg-light);
  border: 2px solid var(--secondary-color);
  color: var(--text-light);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: bold;
  min-height: 40px;
}

.btn-auth:hover {
  background: var(--secondary-color);
  border-color: var(--primary-color);
}

.btn-auth .auth-icon {
  font-size: 1.2rem;
}

.btn-auth.hidden {
  display: none;
}

/* User profile */
.user-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-light);
  border: 2px solid var(--secondary-color);
  border-radius: var(--border-radius);
  padding: 0.4rem 0.8rem;
  position: relative;
  min-height: 40px;
}

.user-profile.hidden {
  display: none;
}

/* Bug audit 2026-06-16 — visible build/deployment identifier (visible from
   every tab in the sidebar footer). Uses the same glass-card family as the
   rest of the sidebar so it never looks out of place, but the muted color
   keeps it subordinate to the active controls above. The tab role="note"
   and aria-label="Application version" on the element itself provide the
   accessible name. */
.app-version-banner {
  margin-top: 0.5rem;
  padding: 0.3rem 0.6rem;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  font-family: 'Inter', monospace, sans-serif;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: default;
  user-select: text;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.app-version-banner:hover,
.app-version-banner:focus-within {
  color: var(--text-light);
  border-color: rgba(0, 243, 255, 0.4);
  outline: none;
}

.user-name {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--text-light);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-badge {
  font-size: 0.7rem;
  font-weight: bold;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--secondary-color);
  color: var(--text-muted);
  text-transform: uppercase;
}

.user-badge.admin {
  background: var(--primary-color);
  color: var(--text-light);
}

.btn-user-menu {
  background: transparent;
  border: none;
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 50%;
  transition: all 0.2s ease;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-user-menu:hover {
  background: var(--secondary-color);
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--bg-dark);
  border: 2px solid var(--secondary-color);
  border-radius: var(--border-radius);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  min-width: 150px;
  z-index: 1000;
}

.user-dropdown.hidden {
  display: none;
}

.dropdown-item {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-light);
  padding: 0.8rem 1rem;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: var(--error-color);
}

/* Auth Modal */
.auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

.auth-modal.visible {
  display: flex;
}

.auth-modal.hidden {
  display: none;
}

.auth-dialog {
  background: var(--bg-darker);
  border: 3px solid var(--secondary-color);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.7);
  position: relative;
}

.auth-header {
  padding: 1.5rem;
  background: var(--bg-dark);
  border-bottom: 2px solid var(--secondary-color);
}

.auth-header h2 {
  color: var(--primary-color);
  margin: 0 0 1rem 0;
  font-size: 1.5rem;
  text-align: center;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
}

.auth-tab {
  flex: 1;
  background: var(--bg-light);
  border: 2px solid transparent;
  color: var(--text-muted);
  padding: 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: bold;
  transition: all 0.2s ease;
}

.auth-tab:hover {
  background: var(--secondary-color);
  color: var(--text-light);
}

.auth-tab.active {
  background: var(--primary-color);
  color: var(--text-light);
  border-color: var(--accent-color);
}

.auth-form {
  display: none;
  padding: 1.5rem;
}

.auth-form.active {
  display: block;
}

.auth-field {
  margin-bottom: 1.2rem;
}

.auth-field label {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.auth-field input {
  width: 100%;
  background: var(--bg-light);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: var(--text-light);
  padding: 0.8rem;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-dark);
}

.auth-field input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Remember me checkbox styling */
.auth-checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.auth-checkbox-field input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.auth-checkbox-field label {
  display: inline;
  text-transform: none;
  font-size: 0.9rem;
  font-weight: normal;
  color: var(--text-light);
  cursor: pointer;
  margin-bottom: 0;
}

.auth-error {
  color: var(--error-color);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  padding: 0.8rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error-color);
  border-radius: 8px;
  display: none;
}

.auth-error.visible {
  display: block;
}

.auth-error.hidden {
  display: none;
}

.auth-submit-btn {
  width: 100%;
  background: var(--primary-color);
  border: none;
  color: var(--text-light);
  padding: 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.2s ease;
  min-height: 48px;
}

.auth-submit-btn:hover {
  background: #ff8c5a;
  transform: scale(1.02);
}

/* OAuth Social Login Buttons */
.auth-social-login {
  margin-bottom: 1.5rem;
}

.social-divider {
  display: flex;
  align-items: center;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.social-divider::before,
.social-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.social-divider span {
  padding: 0 0.75rem;
}

.social-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--secondary-color);
  color: var(--text-light);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
}

.social-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.social-btn.google-btn:hover {
  border-color: #4285F4;
  background: rgba(66, 133, 244, 0.1);
}

.social-btn.facebook-btn:hover {
  border-color: #1877F2;
  background: rgba(24, 119, 242, 0.1);
}

.social-btn svg {
  flex-shrink: 0;
}

.auth-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: 2px solid var(--text-muted);
  color: var(--text-light);
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.auth-close:hover {
  border-color: var(--accent-color);
  background: var(--secondary-color);
}

/* ==========================================
   ACCESSIBILITY: Focus Ring
   ========================================== */

*:focus-visible {
  outline: 4px solid var(--accent-color) !important;
  outline-offset: 4px;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.playlist-item:focus-visible,
.video-cat-btn:focus-visible,
.btn-mute-toggle:focus-visible,
.nav-tab:focus-visible,
.console-btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.plyr button:focus-visible,
.plyr input:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* ==========================================
   TV DEVICE: Hover/Focus States for Remote Mouse Mode
   TV remotes in mouse mode hover elements before clicking.
   These styles ensure visual feedback matches focus-visible
   for cursor-based navigation on TV/TV box devices.
   ========================================== */

.device-tv button:focus,
.device-tv [tabindex="0"]:focus,
.device-tv .game-card:focus,
.device-tv .playlist-item:focus,
.device-tv .sidebar-item:focus,
.device-tv .sidebar-sub-item:focus,
.device-tv .sidebar-category-header:focus,
.device-tv .nav-tab:focus,
.device-tv .console-btn:focus,
.device-tv .quick-mix-item:focus,
.device-tv .playlist-option:focus,
.device-tv .video-cat-btn:focus,
.device-tv .add-to-playlist-btn:focus,
.device-tv .lang-btn:focus,
.device-tv .music-btn:focus,
.device-tv .mini-control-btn:focus,
.device-tv .fab-button:focus {
  outline: var(--focus-ring);
  outline-offset: 2px;
  z-index: 10;
  position: relative;
}

/* TV hover states - provide visual feedback when cursor moves over elements */
.device-tv .game-card:hover,
.device-tv .playlist-item:hover,
.device-tv .sidebar-item:hover,
.device-tv .sidebar-sub-item:hover,
.device-tv .sidebar-category-header:hover,
.device-tv .quick-mix-item:hover,
.device-tv .playlist-option:hover {
  outline: var(--focus-ring);
  outline-offset: 2px;
  z-index: 10;
  position: relative;
}

/* Larger hit targets for TV remote cursor precision */
.device-tv .playlist-item,
.device-tv .sidebar-item,
.device-tv .sidebar-sub-item,
.device-tv .sidebar-category-header {
  min-height: 48px;
}

.device-tv .nav-tab {
  min-height: 48px;
  min-width: 80px;
}

.device-tv button,
.device-tv .music-btn,
.device-tv .mini-control-btn {
  min-width: 44px;
  min-height: 44px;
}

/* Ensure TV cursor shows pointer on interactive elements */
.device-tv .game-card,
.device-tv .playlist-item,
.device-tv .sidebar-item,
.device-tv .sidebar-sub-item,
.device-tv .sidebar-category-header,
.device-tv .quick-mix-item,
.device-tv .playlist-option,
.device-tv [tabindex="0"] {
  cursor: pointer;
}

/* ==========================================
   PLAYLIST DIALOG
   ========================================== */

.playlist-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
}

.playlist-dialog.visible {
  display: flex;
}

.dialog-content {
  background: var(--bg-dark);
  border: 2px solid var(--secondary-color);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 450px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.dialog-content h3 {
  color: var(--primary-color);
  padding: 1.5rem;
  margin: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.playlist-options-list {
  padding: 1rem;
}

.playlist-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--bg-light);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.playlist-option:hover {
  border-color: var(--primary-color);
  background: var(--secondary-color);
}

.playlist-count {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.dialog-actions {
  display: flex;
  gap: 0.8rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.dialog-actions .btn-secondary {
  flex: 1;
}

/* ==========================================
   REMOTE CONTROL BADGE & INDICATORS
   ========================================== */

.remote-control-badge {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.remote-control-badge.visible {
  opacity: 1;
  transform: translateY(0);
}

body.remote-controlled {
  position: relative;
}

body.remote-controlled::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #ef4444, #f97316, #ef4444);
  background-size: 200% 100%;
  animation: remote-control-pulse 2s ease-in-out infinite;
  z-index: 9999;
  pointer-events: none;
}

@keyframes remote-control-pulse {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* ==========================================
   SCREEN READER ONLY UTILITY (Issue 20)
   ========================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==========================================
   REDUCED MOTION SUPPORT (Issue 15)
   ========================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .now-playing-art.pulsing {
    animation: none;
  }

  .skeleton-loader::after {
    animation: none;
  }

  .gesture-feedback {
    animation: none;
    opacity: 1;
  }

  .toast {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .toast.removing {
    animation: none;
    opacity: 0;
  }
}

/* ==========================================
   ANDROID CAR AUTO-DETECTION CSS (Issue 4)
   ========================================== */

.device-android-car {
  font-size: 120%;
}

.device-android-car #main-nav {
  padding: 1.2rem;
}

.device-android-car .nav-tab {
  font-size: 1.3rem;
  padding: 1rem 2rem;
  min-height: 50px;
}

.device-android-car .game-card {
  min-height: 150px;
  padding: 1.2rem;
}

.device-android-car .game-card h3 {
  font-size: 1.2rem;
}

.device-android-car .playlist-item {
  min-height: 70px;
  padding: 1rem;
}

.device-android-car #video-section .section-header {
  display: none;
}

.device-android-car #video-player-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: none;
}

.device-android-car .video-container-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100vw;
}

.device-android-car #main-video,
.device-android-car .plyr {
  max-height: none;
  height: auto;
  width: 100%;
  max-width: 100%;
  border: none;
  border-radius: 0;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.device-android-car #video-info,
.device-android-car #video-playlist {
  display: none;
}

.device-android-car .right-drawer {
  width: 400px;
}

.device-android-car .drawer-content {
  max-height: 30%;
}

.device-android-car .lyrics-section {
  flex: 1;
  min-height: 250px;
}

.device-android-car .lyrics-text {
  font-size: 1.2rem;
  line-height: 2;
}

.device-android-car .mini-player-content {
  padding: 0.3rem 0.6rem;
}

.device-android-car .mini-player-title {
  font-size: 0.9rem;
  font-weight: bold;
}

.device-android-car .mini-player-artist {
  font-size: 0.75rem;
}

.device-android-car .mini-control-btn {
  min-height: 44px;
  min-width: 44px;
}

/* ==========================================
   TABLET DEVICE ENHANCEMENTS (Issue 7)
   ========================================== */

.device-tablet .music-btn {
  width: 48px;
  height: 48px;
  font-size: 1.3rem;
}

.device-tablet .mini-control-btn {
  width: 44px;
  height: 44px;
}

.device-tablet .game-info-close,
.device-tablet .mix-dashboard-close,
.device-tablet .drawer-close {
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
}

/* ==========================================
   GAME SEARCH BAR STYLING
   ========================================== */

.search-container {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
  max-width: 100%;
  margin-left: auto;
}

#game-search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  color: var(--text-light);
  padding: 0.6rem 2.5rem 0.6rem 1.2rem;
  border-radius: 30px;
  font-size: 0.95rem;
  font-family: var(--font-main);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#game-search-input:focus {
  outline: none;
  border-color: var(--accent-color);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 15px rgba(255, 209, 102, 0.4);
}

#game-search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.clear-btn:hover {
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.15);
}

.clear-btn.hidden {
  display: none;
}

@media (max-width: 768px) {
  .search-container {
    width: 100%;
    margin-top: 0.5rem;
  }
}

.device-tv .search-container {
  width: 380px;
}

.device-tv #game-search-input {
  font-size: 1.1rem;
  padding: 0.75rem 2.8rem 0.75rem 1.4rem;
}

/* ==========================================
   D-PAD / REMOTE NAVIGATION FOCUS STATES
   TV remotes use arrow keys + OK — elements must show visible focus glow
   Applied to all D-pad navigable items in game grid, video & music lists
   ========================================== */

.dpad-navigable,
.game-card,
.video-item,
.music-track-item,
.playlist-item,
.sidebar-sub-item,
.sidebar-item {
  transition: transform 0.15s ease, box-shadow 0.15s ease, outline 0.15s ease;
}

/* D-pad focused state — bright orange glow like a TV menu selection */
.dpad-navigable:focus,
.game-card:focus,
.video-item:focus,
.music-track-item:focus,
.playlist-item:focus,
.sidebar-sub-item:focus,
.sidebar-item:focus {
  outline: 4px solid #ff7b4a;
  outline-offset: 3px;
  box-shadow: 0 0 20px rgba(255, 123, 74, 0.6),
              0 0 40px rgba(255, 123, 74, 0.3);
  transform: scale(1.03);
  z-index: 10;
  position: relative;
}

/* Selected item in a list gets a persistent glow */
.game-card.selected,
.video-item.selected,
.music-track-item.selected,
.playlist-item.selected {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
  background: rgba(255, 123, 74, 0.12);
}

/* ==========================================
   TV REMOTE VIDEO CONTROLS (Plyr customisation)
   Large touch targets for D-pad navigation on Smart TV
   ========================================== */

@media (min-width: 1280px) and (pointer: coarse) {

  /* Plyr control bar — taller with bigger buttons */
  .plyr__controls {
    height: 70px !important;
    padding: 0 15px !important;
    gap: 12px !important;
    align-items: center !important;
  }

  .plyr__control {
    width: 56px !important;
    height: 48px !important;
    border-radius: 8px !important;
    font-size: 1.3rem !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
  }

  .plyr__control:hover {
    background: rgba(255, 123, 74, 0.3) !important;
    border-color: var(--primary-color) !important;
  }

  .plyr__control--overlaid {
    width: 90px !important;
    height: 70px !important;
    font-size: 2rem !important;
    background: rgba(255, 123, 74, 0.85) !important;
    border-radius: 12px !important;
  }

  .plyr__control--overlaid:hover {
    background: var(--primary-color) !important;
  }

  /* Progress bar — taller seek target for D-pad */
  .plyr__progress {
    flex: 1;
    min-width: 200px;
  }

  .plyr__progress__buffer,
  .plyr__progress__played {
    height: 14px !important;
    border-radius: 7px !important;
  }

  .plyr__progress__buffer {
    margin-top: -7px !important;
  }

  .plyr__progress__played {
    margin-top: -14px !important;
  }

  .plyr__progress input[type="range"] {
    height: 14px !important;
  }

  .plyr__tooltip {
    font-size: 1rem !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    background: rgba(0, 0, 0, 0.85) !important;
  }

  /* Skip buttons — extra large for D-pad */
  .plyr__control[data-plyr="rewind"],
  .plyr__control[data-plyr="fast-forward"] {
    width: 64px !important;
    font-size: 1.5rem !important;
  }

  /* Volume slider — wider for remote navigation */
  .plyr__volume {
    min-width: 140px !important;
  }

  .plyr__volume input[type="range"] {
    min-width: 100px !important;
    height: 10px !important;
  }

  /* Time display — larger text */
  .plyr__time {
    font-size: 1rem !important;
    min-width: 60px !important;
  }

  .plyr__time + .plyr__time {
    font-size: 0.9rem !important;
  }
}

/* ==========================================
   ANDROID CAR PLAYER (800x480 primary target)
   Low-resolution landscape layout for car head-units
   ========================================== */

@media (max-width: 850px) and (max-height: 520px) {

  :root {
    --spacing: 10px;
    --nav-height: 48px;
    --sidebar-width-collapsed: 48px;
    --sidebar-width-expanded: 180px;
    --mini-player-height: 48px;
    --border-radius: 8px;
  }

  body {
    font-size: 14px;
  }

  /* Compact nav bar */
  #main-nav {
    padding: 0.25rem 0.5rem !important;
    min-height: 40px !important;
    height: 40px !important;
    flex-wrap: nowrap !important;
  }

  .nav-brand h2 {
    display: none !important;
  }

  .nav-tabs {
    gap: 0.2rem !important;
  }

  .nav-tab {
    padding: 0.25rem 0.6rem !important;
    font-size: 0.7rem !important;
    border-radius: 6px;
  }

  .nav-actions {
    flex-wrap: nowrap !important;
    gap: 0.3rem !important;
  }

  .btn-fullscreen,
  .btn-auth,
  .btn-car-mode {
    min-width: 30px !important;
    min-height: 30px !important;
    padding: 0.2rem !important;
    font-size: 0.75rem !important;
  }

  /* Compact sidebar */
  .sidebar-toggle {
    padding: 0.5rem;
    font-size: 1.1rem;
  }

  .sidebar-item {
    padding: 0.5rem 0.7rem;
  }

  .sidebar-item-icon {
    font-size: 1.2rem;
    min-width: 24px;
  }

  .sidebar-item-label {
    font-size: 0.8rem;
  }

  /* Game grid — smaller cards for low res */
  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    padding: var(--spacing);
  }

  .game-card {
    min-height: 90px;
    padding: 0.5rem;
    border-radius: 6px;
  }

  .game-card h3 {
    font-size: 0.7rem;
    max-height: 2.4em;
    line-height: 1.2;
  }

  /* Video section — focus on player */
  #video-section .section-header {
    display: none; /* Hide title bar to give more space to player */
  }

  .video-container-wrapper {
    width: 100%;
    max-width: 100vw;
    aspect-ratio: 16 / 9;
  }

  #main-video {
    width: 100%;
    height: auto;
    max-height: calc(100vh - var(--nav-height) - var(--mini-player-height) - 20px);
  }

  /* Video playlist — collapsed by default in car mode */
  #video-playlist {
    display: none;
  }

  /* Car mode button — always visible, large touch target */
  #video-car-mode {
    display: flex !important;
    padding: 0.6rem 1rem !important;
    font-size: 0.85rem !important;
    min-height: 44px !important;
    min-width: 90px !important;
    border-radius: 8px !important;
    border: 2px solid var(--primary-color) !important;
    background: rgba(255, 123, 74, 0.2) !important;
  }

  .btn-mute-toggle {
    min-height: 44px;
    min-width: 70px;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
  }

  /* Mini-player — compact, non-overlapping */
  #mini-player {
    height: var(--mini-player-height);
    z-index: 90;
  }

  .mini-player-album-art {
    width: 34px;
    height: 34px;
  }

  .mini-player-title {
    font-size: 0.72rem;
  }

  .mini-player-artist {
    font-size: 0.65rem;
  }

  .mini-control-btn {
    min-width: 34px;
    min-height: 34px;
    font-size: 0.8rem;
  }

  /* Bug audit 2026-06-20: the .car-mode overrides for the removed
     #now-playing-display card (.now-playing-display, .now-playing-
     artwork, .now-playing-video-thumb, .np-control-btn, .np-play-btn,
     .np-title) were removed along with the bar itself — the mini-
     player already has its own car-mode rules above. */

  /* Right drawer — narrower in car mode */
  .right-drawer {
    --drawer-width: 280px;
    width: var(--drawer-width);
  }

  .drawer-content {
    max-height: 25vh;
  }

  .lyrics-section {
    min-height: 120px;
  }

  .lyrics-text {
    font-size: 0.9rem;
    line-height: 1.6;
  }
}

/* ==========================================
   iPAD TABLET-SPECIFIC LAYOUT
   Optimised for iPad in both portrait and landscape
   ========================================== */

@media (min-width: 768px) and (max-width: 1024px) and (pointer: coarse) {

  :root {
    --sidebar-width-expanded: 220px;
    --spacing: 16px;
  }

  .nav-tab {
    padding: 0.5rem 1rem;
    font-size: 1rem;
  }

  /* Sidebar — auto-expandable but not obtrusive */
  .left-sidebar.expanded {
    width: 220px;
  }

  /* Game grid — 4 columns on iPad landscape */
  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
  }

  /* Video player — full width on tablet */
  .video-container-wrapper {
    width: 100%;
    max-width: 100%;
  }

  /* Right drawer — more space on tablet */
  .right-drawer {
    --drawer-width: 380px;
    width: var(--drawer-width);
  }

  /* Mini-player — slightly larger on tablet */
  .mini-player-title {
    font-size: 0.85rem;
  }

  .mini-player-artist {
    font-size: 0.75rem;
  }

  .mini-control-btn {
    min-width: 42px;
    min-height: 42px;
    font-size: 1rem;
  }

  /* Bug audit 2026-06-20: .np-control-btn / .np-play-btn iPad overrides
     removed along with the legacy #now-playing-display. The mini-player
     .mini-control-btn rule above already covers the iPad touch target
     size. */
}

/* ==========================================
   IPAD LANDSCAPE-SPECIFIC
   ========================================== */

@media (min-width: 1024px) and (max-height: 768px) and (pointer: coarse) {

  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .right-drawer {
    --drawer-width: 400px;
  }
}

/* ==========================================
   SKELETON LOADING ANIMATION
   Shown in game grid / video list while API loads
   Uses existing --skeleton-base / --skeleton-highlight vars
   ========================================== */

.skeleton-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  overflow: hidden;
  height: 180px;                    /* Fixed height — no stretching */
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

.skeleton-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(
    90deg,
    #1a1a2e 0%,
    #2a2a4a 20%,
    #4a4a7a 50%,
    #2a2a4a 80%,
    #1a1a2e 100%
  );
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  background-size: 200% 100%;
}

.skeleton-card-img {
  width: 100%;
  height: 120px;
  background: var(--skeleton-base);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.skeleton-card-title {
  height: 14px;
  width: 75%;
  margin: 10px 12px 6px;
  background: var(--skeleton-base);
  border-radius: 4px;
}

.skeleton-card-meta {
  height: 10px;
  width: 50%;
  margin: 0 12px 12px;
  background: var(--skeleton-base);
  border-radius: 4px;
  opacity: 0.6;
}

@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* 8 skeleton cards during loading */
.game-grid.skeleton-loading .game-card {
  display: none;
}

.game-grid.skeleton-loading::after {
  content: '';
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  width: 100%;
}

/* ==========================================
   iOS ADD TO HOMESCREEN GUIDE
   iOS uses a different install flow than Android
   ========================================== */

.ios-install-guide {
  position: fixed;
  bottom: 80px;
  right: 16px;
  background: var(--bg-card);
  border: 2px solid var(--primary-color);
  border-radius: var(--border-radius);
  padding: 1rem 1.2rem;
  max-width: 300px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-light);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 500;
  animation: slide-in-up 0.3s ease;
}

.ios-install-guide h4 {
  color: var(--primary-color);
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.ios-install-guide ol {
  margin: 0.4rem 0 0 1.2rem;
  padding: 0;
}

.ios-install-guide li {
  margin-bottom: 0.3rem;
}

.ios-install-guide .close-ios-guide {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

.ios-install-guide .close-ios-guide:hover {
  color: var(--text-light);
}

@keyframes slide-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .ios-install-guide {
    bottom: 70px;
    right: 8px;
    left: 8px;
    max-width: none;
  }
}

/* ==========================================
   BACKGROUND VIDEO BATTERY SAVING
   Pause bg-video when tab is hidden
   ========================================== */

@media (prefers-reduced-motion: no-preference) {
  #bg-video {
    transition: opacity 0.5s ease;
  }

  #bg-video.paused {
    opacity: 0;
  }
}



/* ==========================================
   4K TV LAYOUT
   ========================================== */
@media (min-width: 3840px) {
  html {
    font-size: 24px; /* Cap font sizes */
  }
  
  .nav-tab {
    max-width: 140px;
    padding: 0.8rem 1.2rem;
  }
}

/* ==========================================
   SHORTCUTS MODAL
   ========================================== */
.shortcuts-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shortcuts-modal.hidden {
  display: none !important;
}

.shortcuts-dialog {
  background: var(--bg-light);
  padding: 2rem;
  border-radius: 12px;
  min-width: 300px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
}

.shortcuts-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  align-items: center;
}

.shortcuts-header h2 { margin: 0; }

.shortcuts-close {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.5rem;
  cursor: pointer;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  align-items: center;
}

.shortcut-item kbd {
  padding: 0.3rem 0.6rem;
  background: var(--bg-dark);
  border-radius: 4px;
  font-family: monospace;
  border: 1px solid var(--secondary-color);
}

/* Premium Glassmorphic Theme Overrides & Micro-Animations */
#main-nav {
  background: rgba(9, 9, 14, 0.7) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.left-sidebar {
  background: rgba(9, 9, 14, 0.6) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.right-drawer {
  background: rgba(9, 9, 14, 0.6) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.game-card {
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  backdrop-filter: blur(5px) !important;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
  border-radius: 12px !important;
  overflow: hidden !important;
}

.game-card:hover, .game-card:focus {
  transform: translateY(-5px) scale(1.04) !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: var(--primary-color) !important;
  box-shadow: 0 10px 25px rgba(0, 243, 255, 0.25) !important;
}

.nav-tab {
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

.nav-tab:hover, .nav-tab.active {
  background: linear-gradient(135deg, var(--secondary-color), var(--primary-color)) !important;
  box-shadow: 0 4px 15px rgba(188, 19, 254, 0.4) !important;
  border-color: transparent !important;
}

.btn-mute-toggle, .btn-car-mode, .btn-fullscreen {
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

.btn-mute-toggle:hover, .btn-car-mode:hover, .btn-fullscreen:hover {
  transform: scale(1.05) !important;
  box-shadow: 0 4px 12px rgba(0, 243, 255, 0.2) !important;
}

/* Pulsing highlight for remote control mode */
.remote-active {
  box-shadow: 0 0 15px var(--success-color) !important;
  animation: remotePulse 2s infinite alternate !important;
}

@keyframes remotePulse {
  0% { box-shadow: 0 0 5px rgba(0, 255, 157, 0.4); }
  100% { box-shadow: 0 0 20px rgba(0, 255, 157, 0.8); }
}

/* Lock scrolling during active gameplay */
html.game-playing-active,
body.game-playing-active {
  overflow: hidden !important;
  height: 100% !important;
  width: 100% !important;
  touch-action: none !important;
}

/* Pseudo-Fullscreen for Active Gameplay (regardless of device size or pointer type) */
html.game-playing-active,
body.game-playing-active {
  overflow: hidden !important;
  position: fixed !important;
  width: 100vw !important;
  height: 100dvh !important;
  touch-action: none !important;
}
body.game-playing-active #main-nav {
  display: none !important;
}
body.game-playing-active #left-sidebar {
  display: none !important;
}
body.game-playing-active #right-drawer {
  display: none !important;
}
body.game-playing-active #mini-player {
  display: none !important;
}
body.game-playing-active .tab-content {
  padding: 0 !important;
  overflow: hidden !important;
}
body.game-playing-active #emulator-section {
  padding: 0 !important;
  height: 100dvh !important;
  width: 100vw !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 9999 !important;
  touch-action: none !important;
  overflow: hidden !important;
}
body.game-playing-active #emulator-section .section-header {
  display: none !important;
}
body.game-playing-active #emulator-container {
  height: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}
body.game-playing-active #emulator-wrapper {
  border-radius: 0 !important;
  overflow: hidden !important;
}

/* Hide PWA Banners during active gameplay to prevent covering gamepad controls */
body.game-playing-active .pwa-install-banner,
body.game-playing-active .ios-install-guide {
  display: none !important;
}

/* ==========================================
   ACTIVE EQUALIZER & PREMIUM NAV TABS
   ========================================== */

/* Active Equalizer Visualization */
.music-equalizer {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
  width: auto;
  opacity: 0.85;
  transition: opacity 0.3s ease;
}
.music-equalizer:not(.active) {
  opacity: 0.3;
}
.music-equalizer .bar {
  width: 3px;
  height: 3px;
  background-color: var(--primary-color);
  border-radius: 1.5px;
  transform-origin: bottom;
}
.music-equalizer.active .bar {
  animation: bounce-equalizer 0.8s ease-in-out infinite alternate;
}
.music-equalizer.active .bar:nth-child(1) { animation-delay: 0.1s; background-color: var(--primary-color); }
.music-equalizer.active .bar:nth-child(2) { animation-delay: 0.3s; background-color: var(--secondary-color); }
.music-equalizer.active .bar:nth-child(3) { animation-delay: 0.15s; background-color: var(--accent-color); }
.music-equalizer.active .bar:nth-child(4) { animation-delay: 0.4s; background-color: var(--primary-color); }
.music-equalizer.active .bar:nth-child(5) { animation-delay: 0.2s; background-color: var(--secondary-color); }

@keyframes bounce-equalizer {
  0% { transform: scaleY(1); }
  100% { transform: scaleY(6); }
}

/* Premium Navigation Tab Bottom Border sweep */
.nav-tab {
  position: relative;
  overflow: hidden;
}
.nav-tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 3px;
  background: var(--primary-color);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(-50%);
  border-radius: 2px;
}
.nav-tab:hover::after, .nav-tab.active::after {
  width: 70%;
}

/* Glassmorphic Play Button overlay on Game Card Hover */
.game-thumbnail {
  position: relative;
}

.game-thumbnail::after {
  content: '▶';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  width: 46px;
  height: 46px;
  background: rgba(15, 15, 26, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid var(--primary-color);
  border-radius: 50%;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: bold;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.4);
  pointer-events: none;
  padding-left: 3px; /* visual center alignment for arrow */
}

.game-card:hover .game-thumbnail::after,
.game-card:focus .game-thumbnail::after {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ==========================================
   CUSTOM VIRTUAL GAMEPAD (MAIN PAGE OVERLAY)
   ========================================== */
.custom-virtual-gamepad {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 95%;
  max-width: 480px;
  height: 160px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10000;
  pointer-events: none;
  background: rgba(18, 18, 28, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 10px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(188, 19, 254, 0.15);
}
.custom-virtual-gamepad button {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 50%;
  font-weight: bold;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: background 0.05s, transform 0.05s, box-shadow 0.05s, border-color 0.05s;
}
.custom-virtual-gamepad button:active {
  background: rgba(0, 243, 255, 0.3) !important;
  border-color: #00f3ff !important;
  transform: scale(0.9) !important;
  box-shadow: 0 0 15px #00f3ff !important;
}
/* D-Pad Layout */
.custom-virtual-gamepad .dpad {
  position: relative;
  width: 110px;
  height: 110px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.custom-virtual-gamepad .dpad-btn {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
}
.custom-virtual-gamepad .dpad-btn.up { top: 0; left: 36px; border-bottom: none; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.custom-virtual-gamepad .dpad-btn.down { bottom: 0; left: 36px; border-top: none; border-top-left-radius: 0; border-top-right-radius: 0; }
.custom-virtual-gamepad .dpad-btn.left { top: 36px; left: 0; border-right: none; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.custom-virtual-gamepad .dpad-btn.right { top: 36px; right: 0; border-left: none; border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* Center Menu Controls */
.custom-virtual-gamepad .center-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  align-items: center;
}
.custom-virtual-gamepad .menu-btn {
  width: 70px;
  height: 24px;
  border-radius: 12px;
  font-size: 10px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

/* Action AB Layout and Console Profiles */
.custom-virtual-gamepad .action-buttons {
  position: relative;
  width: 110px;
  height: 100px;
}
.custom-virtual-gamepad .action-btn {
  position: absolute;
  width: 48px;
  height: 48px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Default A/B layout colors */
.custom-virtual-gamepad .action-btn.b { bottom: 0; left: 0; background: rgba(255, 0, 85, 0.15); border-color: rgba(255, 0, 85, 0.3); }
.custom-virtual-gamepad .action-btn.a { top: 0; right: 0; background: rgba(0, 243, 255, 0.15); border-color: rgba(0, 243, 255, 0.3); }
.custom-virtual-gamepad .action-btn.b:active { background: rgba(255, 0, 85, 0.4) !important; border-color: #ff0055 !important; box-shadow: 0 0 15px #ff0055 !important; }
.custom-virtual-gamepad .action-btn.a:active { background: rgba(0, 243, 255, 0.4) !important; border-color: #00f3ff !important; box-shadow: 0 0 15px #00f3ff !important; }

/* Arcade 2x2 layout colors (A/B/C/D) */
.custom-virtual-gamepad.layout-arcade .action-buttons {
  width: 110px;
  height: 110px;
}
.custom-virtual-gamepad.layout-arcade .action-btn.c { top: 0; left: 0; background: rgba(0, 255, 102, 0.15); border-color: rgba(0, 255, 102, 0.3); }
.custom-virtual-gamepad.layout-arcade .action-btn.d { top: 0; right: 0; background: rgba(0, 243, 255, 0.15); border-color: rgba(0, 243, 255, 0.3); }
.custom-virtual-gamepad.layout-arcade .action-btn.a { bottom: 0; left: 0; background: rgba(255, 0, 85, 0.15); border-color: rgba(255, 0, 85, 0.3); }
.custom-virtual-gamepad.layout-arcade .action-btn.b { bottom: 0; right: 0; background: rgba(255, 185, 0, 0.15); border-color: rgba(255, 185, 0, 0.3); }
.custom-virtual-gamepad.layout-arcade .action-btn.c:active { background: rgba(0, 255, 102, 0.4) !important; border-color: #00ff66 !important; box-shadow: 0 0 15px #00ff66 !important; }
.custom-virtual-gamepad.layout-arcade .action-btn.d:active { background: rgba(0, 243, 255, 0.4) !important; border-color: #00f3ff !important; box-shadow: 0 0 15px #00f3ff !important; }
.custom-virtual-gamepad.layout-arcade .action-btn.a:active { background: rgba(255, 0, 85, 0.4) !important; border-color: #ff0055 !important; box-shadow: 0 0 15px #ff0055 !important; }
.custom-virtual-gamepad.layout-arcade .action-btn.b:active { background: rgba(255, 185, 0, 0.4) !important; border-color: #ffb900 !important; box-shadow: 0 0 15px #ffb900 !important; }

/* Genesis Curved 3-button layout (A/B/C) */
.custom-virtual-gamepad.layout-genesis .action-buttons {
  width: 155px;
  height: 70px;
}
.custom-virtual-gamepad.layout-genesis .action-btn {
  width: 44px;
  height: 44px;
}
.custom-virtual-gamepad.layout-genesis .action-btn.a { bottom: 0; left: 0; top: auto; right: auto; background: rgba(255, 0, 85, 0.15); border-color: rgba(255, 0, 85, 0.3); }
.custom-virtual-gamepad.layout-genesis .action-btn.b { bottom: 6px; left: 52px; top: auto; right: auto; background: rgba(255, 185, 0, 0.15); border-color: rgba(255, 185, 0, 0.3); }
.custom-virtual-gamepad.layout-genesis .action-btn.c { bottom: 12px; left: 104px; top: auto; right: auto; background: rgba(0, 243, 255, 0.15); border-color: rgba(0, 243, 255, 0.3); }
.custom-virtual-gamepad.layout-genesis .action-btn.a:active { background: rgba(255, 0, 85, 0.4) !important; border-color: #ff0055 !important; box-shadow: 0 0 15px #ff0055 !important; }
.custom-virtual-gamepad.layout-genesis .action-btn.b:active { background: rgba(255, 185, 0, 0.4) !important; border-color: #ffb900 !important; box-shadow: 0 0 15px #ffb900 !important; }
.custom-virtual-gamepad.layout-genesis .action-btn.c:active { background: rgba(0, 243, 255, 0.4) !important; border-color: #00f3ff !important; box-shadow: 0 0 15px #00f3ff !important; }

/* SNES/GBA Diamond layout (X/Y/A/B) */
.custom-virtual-gamepad.layout-snes-gba .action-buttons {
  width: 110px;
  height: 110px;
}
.custom-virtual-gamepad.layout-snes-gba .action-btn.x { top: 0; left: 31px; background: rgba(0, 243, 255, 0.15); border-color: rgba(0, 243, 255, 0.3); }
.custom-virtual-gamepad.layout-snes-gba .action-btn.y { top: 31px; left: 0; background: rgba(0, 255, 102, 0.15); border-color: rgba(0, 255, 102, 0.3); }
.custom-virtual-gamepad.layout-snes-gba .action-btn.a { top: 31px; right: 0; background: rgba(255, 0, 85, 0.15); border-color: rgba(255, 0, 85, 0.3); }
.custom-virtual-gamepad.layout-snes-gba .action-btn.b { bottom: 0; left: 31px; background: rgba(255, 185, 0, 0.15); border-color: rgba(255, 185, 0, 0.3); }
.custom-virtual-gamepad.layout-snes-gba .action-btn.x:active { background: rgba(0, 243, 255, 0.4) !important; border-color: #00f3ff !important; box-shadow: 0 0 15px #00f3ff !important; }
.custom-virtual-gamepad.layout-snes-gba .action-btn.y:active { background: rgba(0, 255, 102, 0.4) !important; border-color: #00ff66 !important; box-shadow: 0 0 15px #00ff66 !important; }
.custom-virtual-gamepad.layout-snes-gba .action-btn.a:active { background: rgba(255, 0, 85, 0.4) !important; border-color: #ff0055 !important; box-shadow: 0 0 15px #ff0055 !important; }
.custom-virtual-gamepad.layout-snes-gba .action-btn.b:active { background: rgba(255, 185, 0, 0.4) !important; border-color: #ffb900 !important; box-shadow: 0 0 15px #ffb900 !important; }

/* Shoulder L/R buttons */
.custom-virtual-gamepad .shoulder-buttons {
  position: absolute;
  top: -45px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.custom-virtual-gamepad .shoulder-btn {
  pointer-events: auto;
  width: 58px;
  height: 32px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}
.custom-virtual-gamepad .shoulder-btn:active {
  background: rgba(0, 243, 255, 0.3) !important;
  border-color: #00f3ff !important;
  transform: scale(0.9) !important;
  box-shadow: 0 0 15px #00f3ff !important;
}
.custom-virtual-gamepad.editing-layout .shoulder-buttons {
  outline: 2px dashed rgba(0, 243, 255, 0.7) !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.4) !important;
  border-radius: 8px !important;
  cursor: move !important;
}

/* Hide custom gamepad when not needed */
.custom-virtual-gamepad.hidden {
  display: none !important;
}

/* Custom Gamepad HUD Settings Control Panel */
.custom-gamepad-settings {
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: auto;
  margin-top: 10px;
}
.custom-gamepad-settings.hidden {
  display: none !important;
}
.custom-gamepad-settings label {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.custom-gamepad-settings input[type="range"] {
  width: 50px;
  height: 4px;
  accent-color: #00f3ff;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  outline: none;
}

/* WebRTC Connection Overlay */
.netplay-connection-overlay {
  position: absolute;
  top: 15px;
  left: 20px;
  z-index: 10001;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(18, 18, 28, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 243, 255, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.1);
  pointer-events: none;
}
.netplay-ping-dot {
  width: 8px;
  height: 8px;
  background: #34a853;
  border-radius: 50%;
  box-shadow: 0 0 8px #34a853;
}

/* Non-Intrusive Sponsorship Banner Overlay */
.sponsorship-banner {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  width: 90%;
  max-width: 320px;
  background: rgba(18, 18, 28, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid #bc13fe;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5), 0 0 15px rgba(188, 19, 254, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sponsorship-banner-content {
  font-size: 11px;
  color: #fff;
}
.sponsorship-banner-content strong {
  color: #00f3ff;
}
.sponsorship-banner-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 5px;
}

/* Save Game Rewarded Ad Modal */
.rewarded-ad-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(15px);
  z-index: 10100;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Edit Layout Mode Visual Indicators */
.custom-virtual-gamepad.editing-layout .dpad,
.custom-virtual-gamepad.editing-layout .center-buttons,
.custom-virtual-gamepad.editing-layout .action-buttons {
  outline: 2px dashed rgba(0, 243, 255, 0.7) !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.4) !important;
  animation: gamepadEditPulse 1.5s infinite alternate !important;
  border-radius: 8px !important;
  cursor: move !important;
}

@keyframes gamepadEditPulse {
  0% { outline-color: rgba(0, 243, 255, 0.3); }
  100% { outline-color: rgba(0, 243, 255, 0.9); }
}

/* Joystick styling for Arcade (cps) core */
.custom-virtual-gamepad .dpad.layout-joystick-mode {
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(188, 19, 254, 0.2);
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-virtual-gamepad .joystick-base {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  pointer-events: auto;
}

.custom-virtual-gamepad .joystick-base::before {
  content: '';
  position: absolute;
  width: 50%;
  height: 50%;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.custom-virtual-gamepad .joystick-knob {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 50%, rgba(0, 0, 0, 0.4) 100%), linear-gradient(135deg, #bc13fe 0%, #00f3ff 100%);
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.4), 0 0 12px rgba(188, 19, 254, 0.4);
  transition: transform 0.05s ease-out, box-shadow 0.1s;
  pointer-events: none;
}

.custom-virtual-gamepad .joystick-base:active .joystick-knob {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.5), 0 0 20px #00f3ff;
  border-color: rgba(255, 255, 255, 0.5);
}

/* ==========================================
   v2026.06.20-9 - UX/UI Audit
   Mini-player Expand Sheet (C1), Playback
   Speed (H2), Favorite Toggle (H4),
   Mini-player Expand Chevron (H5),
   Kbd-shortcut List Polish, Focus-visible.
   ========================================== */

/* C1/H5 - Mini-player favorite button (collapsed + expanded) */
.mini-favorite-btn {
  color: var(--text-muted);
  transition: color 0.2s ease, transform 0.2s ease;
}
.mini-favorite-btn[aria-pressed="true"] {
  color: var(--accent-color, #ff0055);
}
.mini-favorite-btn[aria-pressed="true"] span {
  /* filled heart */
  font-weight: 700;
}
.mini-favorite-btn:hover,
.mini-favorite-btn:focus-visible {
  color: var(--accent-color, #ff0055);
  transform: scale(1.08);
}

/* C1 - Plex-style now-playing metadata sheet */
.mini-player-sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 1000);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: mini-sheet-fade-in 0.18s ease-out;
}
.mini-player-sheet.hidden {
  display: none !important;
}
.mini-player-sheet:focus { outline: none; }

.mini-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 6, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mini-sheet-content {
  position: relative;
  width: min(420px, 100%);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 2rem 1.75rem 1.5rem;
  border-radius: 20px;
  text-align: center;
  background: var(--glass-bg, rgba(18, 18, 28, 0.92));
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: mini-sheet-pop-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.mini-sheet-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-light);
  font-size: 1.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.mini-sheet-close:hover,
.mini-sheet-close:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--glass-border, rgba(255, 255, 255, 0.18));
}

.mini-sheet-art {
  width: min(220px, 70%);
  aspect-ratio: 1 / 1;
  margin: 0 auto 1.25rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(188, 19, 254, 0.25), rgba(0, 243, 255, 0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  position: relative;
}
.mini-sheet-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mini-sheet-art-fallback {
  font-size: 4.5rem;
  color: rgba(255, 255, 255, 0.55);
  user-select: none;
}

.mini-sheet-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  line-height: 1.25;
  color: var(--text-light);
  word-break: break-word;
}
.mini-sheet-artist {
  font-size: 0.95rem;
  color: var(--text-light);
  margin: 0 0 0.75rem;
  opacity: 0.85;
}
.mini-sheet-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 0.35rem;
}

.mini-sheet-playback-speed {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin: 1.1rem 0 0.75rem;
}
.mini-sheet-speed-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.15));
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.mini-sheet-speed-btn:hover,
.mini-sheet-speed-btn:focus-visible {
  background: rgba(255, 255, 255, 0.10);
  border-color: var(--primary-color);
}
.mini-sheet-speed-btn[aria-pressed="true"] {
  background: rgba(0, 243, 255, 0.15);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.mini-sheet-favorite-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  margin-top: 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.2));
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-light);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.mini-sheet-favorite-btn:hover,
.mini-sheet-favorite-btn:focus-visible {
  background: rgba(255, 0, 85, 0.12);
  border-color: var(--accent-color, #ff0055);
  color: var(--accent-color, #ff0055);
  transform: translateY(-1px);
}
.mini-sheet-favorite-btn[aria-pressed="true"] {
  background: var(--accent-color, #ff0055);
  color: #fff;
  border-color: var(--accent-color, #ff0055);
}
.mini-sheet-favorite-btn[aria-pressed="true"] span:first-child {
  font-weight: 700;
}

@keyframes mini-sheet-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes mini-sheet-pop-in {
  from { transform: translateY(8px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* H5 - Mini-player expand chevron (existing #mini-player-toggle) pulse on hover */
.mini-player-toggle {
  transition: background 0.18s ease, transform 0.18s ease, color 0.18s ease;
}
.mini-player-toggle:hover,
.mini-player-toggle:focus-visible {
  background: rgba(0, 243, 255, 0.12);
  color: var(--primary-color);
  animation: mini-chevron-pulse 1.4s ease-in-out infinite;
}
@keyframes mini-chevron-pulse {
  0%, 100% { transform: translateY(0);    opacity: 1; }
  50%      { transform: translateY(-2px); opacity: 0.75; }
}

/* L4 - Consistent focus-visible rings (2px solid + offset) */
:focus { outline: none; }
:focus-visible {
  outline: var(--focus-ring, 2px solid var(--primary-color));
  outline-offset: 2px;
  border-radius: 6px;
}
/* Suppress focus-visible on mouse-driven focus of media controls */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

/* L4 - Keyboard shortcut list polish */
.kbd-shortcut-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
}
.kbd-shortcut-list .shortcut-item {
  margin-bottom: 0;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.kbd-shortcut-list kbd {
  display: inline-block;
  min-width: 1.6em;
  text-align: center;
  padding: 0.25rem 0.55rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.8rem;
  background: var(--bg-dark, #09090e);
  color: var(--primary-color);
  border: 1px solid var(--secondary-color);
  border-radius: 4px;
  margin: 0 0.15rem;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
@media (min-width: 480px) {
  .kbd-shortcut-list {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 0.9rem;
  }
}

/* L1 - Skeleton loader for music list (replaces blank spinner) */
.music-skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem 0;
}
.music-skeleton-row {
  height: 56px;
  border-radius: 10px;
  background: linear-gradient(
    90deg,
    var(--skeleton-base, #1c1c2e) 0%,
    var(--skeleton-highlight, #2c2c44) 50%,
    var(--skeleton-base, #1c1c2e) 100%
  );
  background-size: 200% 100%;
  animation: music-skeleton-shimmer 1.4s ease-in-out infinite;
}
.music-skeleton-row:nth-child(2) { width: 92%; }
.music-skeleton-row:nth-child(3) { width: 78%; }
.music-skeleton-row:nth-child(4) { width: 88%; }
@keyframes music-skeleton-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* L3 - Empty-state SVG illustration container */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg {
  width: 96px;
  height: 96px;
  opacity: 0.55;
}
.empty-state-title {
  color: var(--text-light);
  font-size: 1rem;
  font-weight: 600;
}
.empty-state-text {
  font-size: 0.85rem;
  max-width: 320px;
}

/* Reduced motion respect (used in transitions) */
@media (prefers-reduced-motion: reduce) {
  .mini-player-sheet,
  .mini-sheet-content,
  .mini-player-toggle,
  .music-skeleton-row,
  .mini-favorite-btn,
  .mini-sheet-favorite-btn,
  .mini-sheet-speed-btn,
  .mini-sheet-close {
    animation: none !important;
    transition: none !important;
  }
}

/* =====================================================================
   v2026.06.20-10 — Incremental parity additions
   ===================================================================== */

/* ---- L1: prefers-reduced-motion (global, covers EQ + chevron pulse) ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .music-equalizer.active .bar,
  .mini-player-toggle:hover,
  .mini-player-toggle:focus-visible {
    animation: none !important;
  }
}

/* ---- L5: Light theme via [data-theme="light"] overrides ----
   Dark is the default (commercial signage / car-mode). The light palette
   only overrides CSS custom properties so every component using var(--*)
   swaps automatically. */
:root[data-theme="light"] {
  --primary-color: #0078d4;
  --secondary-color: #8b5cf6;
  --accent-color: #d6336c;
  --bg-dark: #f4f6fb;
  --bg-darker: #e9ecf5;
  --bg-light: #ffffff;
  --bg-card: rgba(0, 0, 0, 0.04);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(0, 0, 0, 0.10);
  --glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.12);
  --text-light: #1a1d29;
  --text-muted: #4a5161;
  --disabled-color: #8a8fa6;
  --skeleton-base: #e2e6f0;
  --skeleton-highlight: #f0f3fa;
  color-scheme: light;
}

/* Auto-respect OS preference when user has not explicitly chosen */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --primary-color: #0078d4;
    --secondary-color: #8b5cf6;
    --accent-color: #d6336c;
    --bg-dark: #f4f6fb;
    --bg-darker: #e9ecf5;
    --bg-light: #ffffff;
    --bg-card: rgba(0, 0, 0, 0.04);
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(0, 0, 0, 0.10);
    --glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.12);
    --text-light: #1a1d29;
    --text-muted: #4a5161;
    --disabled-color: #8a8fa6;
    --skeleton-base: #e2e6f0;
    --skeleton-highlight: #f0f3fa;
    color-scheme: light;
  }
}

/* ---- Theme toggle button (sidebar footer) ---- */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 36px;
  padding: 0.35rem 0.8rem;
  margin-bottom: 0.4rem;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--bg-card);
  color: var(--text-light);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.theme-toggle-btn:hover,
.theme-toggle-btn:focus-visible {
  background: rgba(0, 243, 255, 0.10);
  border-color: var(--primary-color);
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* ---- L6: Drag-to-seek enlarged hit area + hover thumb on mini progress ---- */
.mini-player-progress {
  padding: 6px 0;
  cursor: pointer;
}
.mini-progress-bar {
  position: relative;
  height: 6px;
  border-radius: 3px;
}
.mini-progress-bar::after {
  content: '';
  position: absolute;
  top: 50%;
  left: var(--seek-pct, 0%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary-color);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s ease;
  pointer-events: none;
}
.mini-player-progress:hover .mini-progress-bar::after,
.mini-player-progress.dragging .mini-progress-bar::after {
  transform: translate(-50%, -50%) scale(1);
}
.mini-player-progress.dragging .mini-progress-fill {
  transition: none;
}

/* ---- M9: Sleep timer + M3: EQ controls in mini-player sheet ---- */
.min-sheet-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
}
.mini-sheet-controls-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.mini-sheet-control-btn {
  min-width: 44px;
  min-height: 40px;
  padding: 0.4rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.15));
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-light);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.mini-sheet-control-btn:hover,
.mini-sheet-control-btn:focus-visible {
  background: rgba(255, 255, 255, 0.10);
  border-color: var(--primary-color);
}
.mini-sheet-control-btn[aria-pressed="true"] {
  background: rgba(0, 243, 255, 0.15);
  border-color: var(--primary-color);
  color: var(--primary-color);
}
.sleep-timer-status {
  font-size: 0.78rem;
  color: var(--info-color);
  text-align: center;
  margin-top: 0.25rem;
  min-height: 1.1em;
}

/* ---- M4: Auto-Next toggle button in Movie section header ---- */
.auto-next-toggle.active {
  background: rgba(0, 255, 157, 0.15);
  border-color: var(--success-color);
  color: var(--success-color);
}

/* ---- Foldable spanning (Samsung Z Fold, Surface Duo) ----
   When the device reports two horizontal viewport segments (spanning the
   fold gap), pin the right drawer open into the second segment for a
   master-detail layout, and let the center stage fill the first segment. */
@media (horizontal-viewport-segments: 2) {
  .device-foldable-spanning .right-drawer {
    position: static;
    transform: none !important;
    width: var(--drawer-width);
    flex-shrink: 0;
    box-shadow: none;
    border-left: 1px solid var(--glass-border);
  }
  .device-foldable-spanning .right-drawer-autohide {
    display: flex;
  }
  .device-foldable-spanning #main-content {
    flex: 1 1 auto;
    min-width: 0;
  }
  .device-foldable-spanning .playlist-toggle-btn {
    display: none;
  }
}
