/* ==========================================================================
   DESIGN SYSTEM & THEME VARIABLES — PREMIUM RETRO TV CABINET EDITION
   ========================================================================== */
:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-retro: 'Press Start 2P', monospace;

  /* ── Sleek Theme Accent Colors ── */
  --color-gold: #d2b793;            /* Premium Luxury Gold/Champagne */
  --color-gold-hover: #e5cfae;
  --color-gold-glow: rgba(210, 183, 147, 0.2);
  --color-blue: #3b82f6;            /* Tech Blue */
  --color-blue-glow: rgba(59, 130, 246, 0.2);
  --color-cyan: #06b6d4;            /* Cyber Cyan */
  --color-cyan-glow: rgba(6, 182, 212, 0.2);
  --color-green: #10b981;           /* Active green */
  --color-green-glow: rgba(16, 185, 129, 0.15);
  --color-red: #e02020;             /* NES power-red */
  --color-red-glow: rgba(224, 32, 32, 0.4);

  /* ── 3D CRT TV Body Palette (Retained for nostalgia) ── */
  --tv-body: #1e1a14;
  --tv-body-light: #2e2820;
  --tv-body-rim: #141008;
  --tv-bezel: #2c241a;
  --tv-screen-border: #0e0b06;
  --tv-knob: #c08040;
  --tv-knob-shine: #e8b060;
  --tv-chin: #181410;
  --tv-vent: #120e0a;
  --tv-speaker: #1a1510;
  --tv-led-off: #310612;
  --tv-led-on: #ff2020;

  /* ── Sleek Glass Surface Colors ── */
  --bg-app: #080a0f;                /* Deep Space Void */
  --bg-header: rgba(10, 14, 23, 0.45);
  --bg-sidebar: rgba(10, 14, 23, 0.45);
  --bg-panel: rgba(17, 24, 39, 0.45);
  --bg-card: rgba(17, 24, 39, 0.3);
  --bg-card-hover: rgba(28, 38, 60, 0.55);
  
  /* ── Text Colors ── */
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  /* ── Borders & Glass Shadows ── */
  --border-glass: rgba(255, 255, 255, 0.05);
  --border-glass-bright: rgba(255, 255, 255, 0.12);
  --border-tv: rgba(255, 220, 150, 0.08);

  --shadow-premium: 0 24px 60px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --shadow-gold-glow: 0 0 20px rgba(210, 183, 147, 0.12);
  --shadow-cyan-glow: 0 0 20px rgba(6, 182, 212, 0.15);
  --shadow-bezel: 0 30px 80px rgba(0,0,0,0.85), 0 0 0 2px rgba(255,220,120,0.06), inset 0 1px 0 rgba(255,220,120,0.07);
  --shadow-crt-glow: 0 0 60px rgba(0, 200, 255, 0.12), 0 0 20px rgba(100, 80, 40, 0.3), inset 0 0 40px rgba(0,0,0,0.8);
  --shadow-tv-depth: 0 40px 100px rgba(0,0,0,0.9), 0 10px 30px rgba(0,0,0,0.6), inset 0 2px 0 rgba(255,220,120,0.04);

  --transition-smooth: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-bounce: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  --scrollbar-thumb: rgba(255, 255, 255, 0.08);
  --scrollbar-track: transparent;
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.04) 0%, transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.003) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.003) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 30px 30px, 30px 30px;
  background-attachment: fixed;
  animation: backgroundShift 25s ease-in-out infinite alternate;
}

@keyframes backgroundShift {
  0% {
    background-position: 0% 0%, 0% 0%, 0% 0%, 0px 0px, 0px 0px;
  }
  100% {
    background-position: 10% 5%, -10% -5%, 5% 5%, 0px 0px, 0px 0px;
  }
}

/* Only capitalize header logo */
.logo-text {
  text-transform: uppercase !important;
}

.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  padding: 16px;
  gap: 16px;
}

/* Custom Scrollbars */
.scroller {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

@supports not (scrollbar-color: auto) {
  .scroller::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  .scroller::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
  }
  .scroller::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

/* ==========================================================================
   HEADER BAR (CAPSULE NAVIGATION)
   ========================================================================== */
.app-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  background: var(--bg-header);
  /* backdrop-filter: blur(20px); - Removed for performance */
  border: none;
  border-bottom: 1px solid var(--border-glass);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.35), inset 0 -1px 0 rgba(255, 255, 255, 0.02);
  border-radius: 0;
  height: 58px;
  flex-shrink: 0;
  margin: -16px -16px 0 -16px;
  width: calc(100% + 32px);
  z-index: 10;
  gap: 12px;
}

.header-start {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Sidebar toggle buttons — visible only when sidebars collapse */
.sidebar-toggle-btn {
  display: none; /* Hidden by default; shown via staggered media queries */
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  color: var(--color-gold);
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-smooth);
}

.sidebar-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--color-gold);
  box-shadow: var(--shadow-gold-glow);
}

.sidebar-toggle-btn.is-active {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--color-gold);
}

#btn-toggle-controls {
  display: flex; /* Always show controls toggle button to support desktop hide/show */
}

.logo-text {
  font-family: var(--font-retro);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 2px;
  color: var(--color-gold);
  text-shadow: var(--shadow-gold-glow);
  line-height: 1.2;
  white-space: nowrap;
  transition: text-shadow 0.3s ease;
}

.logo-text:hover {
  text-shadow: 0 0 15px var(--color-gold), 0 0 30px rgba(210, 183, 147, 0.4);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
}

.logo-img {
  height: 42px;
  width: auto;
  display: block;
}

.logo-author {
  font-family: var(--font-main);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--color-gold);
  opacity: 0.8;
  letter-spacing: 0.5px;
  text-transform: none;
}

.logo-nes {
  color: var(--color-gold);
}

.accent-neon {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
  margin-left: 4px;
  letter-spacing: 3px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

/* Header Credits & Made-by badge styling */
.header-credits {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--border-glass);
  height: 24px;
}

.credit-text {
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.author-highlight {
  color: var(--color-gold);
  font-weight: 700;
}

.linkedin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.linkedin-link:hover {
  color: var(--color-gold);
  filter: drop-shadow(0 0 4px var(--color-gold-glow));
}

.linkedin-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* Nav Menu (Frosted Modern Glass Pills) */
.nav-menu {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.45);
  padding: 4px;
  border-radius: 100px;
  border: 1px solid var(--border-glass);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid transparent;
  padding: 6px 18px;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.nav-icon {
  width: 14px;
  height: 14px;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass-bright);
  color: #fff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.03), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

/* Sidebar Backdrop — clickable dark overlay behind open sidebar drawers */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  /* backdrop-filter: blur(6px); - Removed for performance */
  z-index: 199;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   WORKSPACE LAYOUT
   ========================================================================== */
.main-layout {
  display: flex;
  flex: 1;
  gap: 16px;
  min-height: 0;
}

/* ==========================================================================
   LEFT COLUMN: GAME LIBRARY
   ========================================================================== */
.sidebar-library {
  width: clamp(220px, 22vw, 300px);
  background: var(--bg-sidebar);
  /* backdrop-filter: blur(28px); - Removed for performance */
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: var(--shadow-premium);
  transition: transform 0.32s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.25s ease;
}

.sidebar-title {
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-main);
  text-transform: uppercase;
  padding: 18px 20px 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-title::before {
  content: '';
  width: 3px;
  height: 12px;
  background: var(--color-gold);
  border-radius: 2px;
  display: inline-block;
  box-shadow: var(--shadow-gold-glow);
}

/* Search Bar (Recessed Dark Pill) */
.search-bar-container {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px 20px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-dim);
}

#game-search {
  width: 100%;
  padding: 8px 30px 8px 32px;
  background-color: rgba(10, 11, 14, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: 100px;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.8rem;
  outline: none;
  transition: var(--transition-smooth);
}

#game-search:focus {
  border-color: var(--color-gold);
  background-color: rgba(10, 11, 14, 0.8);
  box-shadow: 0 0 10px var(--color-gold-glow);
}

.clear-search {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
}

.clear-search:hover {
  color: var(--text-main);
}

.filter-options-btn {
  background: rgba(10, 11, 14, 0.4);
  border: 1px solid var(--border-glass);
  border-radius: 100px;
  padding: 8px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  width: 34px;
  height: 34px;
}

.filter-options-btn svg {
  width: 14px;
  height: 14px;
}

.filter-options-btn:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  border-color: var(--color-gold);
}

/* Badges tabs */
.filter-badges {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px 20px;
  border-bottom: 1px solid var(--border-glass);
}

.filter-badge {
  flex: 1;
  background: rgba(10, 11, 14, 0.4);
  border: 1px solid var(--border-glass);
  padding: 6px 12px;
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 100px;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-smooth);
}

.filter-badge:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
}

.filter-badge.active {
  background: var(--color-green);
  border-color: var(--color-green);
  color: #fff;
  box-shadow: 0 0 10px var(--color-green-glow);
}

/* Game Cards Grid */
.game-cards-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  align-content: start;
}

/* Game Cards — NES Cartridge Sticker Style */
.game-card {
  display: flex;
  flex-direction: column;
  height: 140px;
  background: linear-gradient(180deg, rgba(20, 26, 42, 0.6) 0%, rgba(10, 12, 18, 0.85) 100%);
  border: 1.5px solid var(--border-glass);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, border-color 0.2s ease;
  position: relative;
  transform-style: preserve-3d;
}

/* NES cartridge bottom pin strip */
.game-card::before {
  content: '';
  height: 5px;
  background: linear-gradient(180deg, #111827 0%, #030712 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}

/* "SAVED" badge */
.game-card::after {
  content: "SAVED";
  position: absolute;
  top: 8px;
  right: 6px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-size: 0.5rem;
  font-weight: 800;
  font-family: var(--font-retro);
  padding: 2px 5px;
  border-radius: 3px;
  opacity: 0;
  transition: var(--transition-smooth);
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.game-card.has-save::after {
  opacity: 1;
}

.game-card:hover {
  border-color: rgba(59, 130, 246, 0.45);
  transform: perspective(600px) rotateX(-4deg) rotateY(2deg) translateY(-4px) scale(1.02);
  box-shadow: 
    0 12px 30px rgba(0,0,0,0.55),
    0 0 16px rgba(59, 130, 246, 0.22),
    inset 0 1px 0 rgba(255,255,255,0.05);
  z-index: 2;
}

.game-card.active {
  border-color: var(--color-blue);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.35), 0 0 0 1px rgba(59, 130, 246, 0.25);
}
.card-img-container {
  width: 100%;
  flex: 1;
  background: linear-gradient(180deg, #030712 0%, #090d16 100%);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
  position: relative;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  transition: var(--transition-smooth);
}

.game-card:hover .card-img {
  transform: scale(1.05);
}

.card-details {
  height: 32px;
  padding: 4px 8px;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.9) 0%, rgba(10, 15, 26, 0.95) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}

.card-title {
  font-family: var(--font-main);
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(240, 235, 227, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  width: 100%;
  letter-spacing: 0.3px;
}

/* ==========================================================================
   CENTER COLUMN: EMULATOR CONSOLE
   ========================================================================== */
.console-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  height: 100%;
}

/* Top LED Ticker Display */
.screen-status-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: linear-gradient(180deg, #0a0806 0%, #080604 100%);
  border: 1px solid rgba(189, 160, 122, 0.22);
  border-radius: 8px;
  height: 36px;
  font-size: 0.72rem;
  color: rgba(189, 160, 122, 0.85);
  font-family: var(--font-main);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.4), 0 0 0 1px rgba(0,0,0,0.5);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.screen-status-badge::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 1px,
    rgba(0,0,0,0.08) 1px,
    rgba(0,0,0,0.08) 2px
  );
  pointer-events: none;
  z-index: 0;
}

.status-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(80, 60, 40, 0.8);
  box-shadow: none;
  transition: var(--transition-smooth);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.status-indicator-dot.active {
  background: var(--color-green);
  box-shadow: 0 0 6px var(--color-green), 0 0 14px var(--color-green);
  animation: ledPulse 2s ease-in-out infinite;
}

@keyframes ledPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--color-green), 0 0 14px rgba(16, 185, 129, 0.5); }
  50% { opacity: 0.7; box-shadow: 0 0 3px var(--color-green), 0 0 8px rgba(16, 185, 129, 0.3); }
}

.status-text-scroll {
  flex: 1;
  overflow: hidden;
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  z-index: 1;
}

.status-text-scroll-inner {
  display: inline-block;
  white-space: nowrap;
  animation: statusMarquee 40s linear infinite;
  padding-left: 100%;
}

.status-text-scroll-inner span {
  display: inline-block;
}

@keyframes statusMarquee {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-100%, 0, 0); }
}

.marquee-sep {
  color: var(--color-gold);
  opacity: 0.5;
  display: inline-block;
}

.marquee-clone {
  display: inline-block;
}

.status-text-scroll #current-game-title {
  color: var(--text-main);
  font-weight: 700;
}

.status-text-scroll .divider {
  color: var(--text-dim);
  margin: 0 8px;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action-pill {
  background: rgba(10, 11, 14, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: 100px;
  color: var(--color-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 700;
  transition: var(--transition-smooth);
  /* backdrop-filter: blur(5px); - Removed for performance */
}

.btn-action-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--color-gold);
  box-shadow: 0 0 10px var(--color-gold-glow);
  color: var(--text-main);
}

.btn-action-pill .action-svg-icon {
  width: 14px;
  height: 14px;
  transition: var(--transition-smooth);
}

.btn-action-pill .star-icon {
  width: 14px;
  height: 14px;
  stroke: var(--color-gold);
  fill: none;
  stroke-width: 1.5;
  transition: var(--transition-smooth);
}

.btn-favorite-icon.active {
  background: rgba(189, 160, 122, 0.15);
  border-color: var(--color-gold);
}

.btn-favorite-icon.active .star-icon {
  fill: var(--color-gold);
  stroke: var(--color-gold);
  filter: drop-shadow(0 0 4px var(--color-gold-glow));
}

.btn-favorite-icon,
.btn-fullscreen-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

/* ==========================================================================
   3D CRT TV CABINET FRAME — The Crown Jewel
   ========================================================================== */
.crt-bezel-frame {
  flex: 1;
  /* Deep layered 3D TV cabinet — multiple inset levels */
  background: 
    radial-gradient(ellipse at 30% 20%, rgba(60, 50, 30, 0.6) 0%, transparent 60%),
    linear-gradient(165deg, var(--tv-body-light) 0%, var(--tv-body) 35%, var(--tv-body-rim) 100%);
  border-radius: 22px 22px 16px 16px;
  border: 1px solid rgba(255, 200, 80, 0.06);
  box-shadow: var(--shadow-tv-depth);
  padding: 20px 18px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  position: relative;
  /* Subtle perspective tilt — gives authentic 3D depth */
  transform: perspective(1200px) rotateX(0.5deg);
  transform-style: preserve-3d;
  /* Floating gentle animation */
  animation: tvFloat 8s ease-in-out infinite;
}

@keyframes tvFloat {
  0%, 100% { transform: perspective(1200px) rotateX(0.5deg) translateY(0px); }
  50% { transform: perspective(1200px) rotateX(0.5deg) translateY(-3px); }
}

/* Top speaker grille bar */
.tv-speaker-grille {
  position: absolute;
  top: 0;
  left: 20px;
  right: 18px;
  height: 14px;
  background: var(--tv-speaker);
  border-radius: 0 0 4px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 30px;
  overflow: hidden;
}

.tv-speaker-grille::before {
  content: '';
  position: absolute;
  inset: 2px 0;
  background: repeating-linear-gradient(
    90deg,
    rgba(0,0,0,0.7) 0px,
    rgba(0,0,0,0.7) 2px,
    rgba(255,200,80,0.04) 2px,
    rgba(255,200,80,0.04) 5px
  );
  border-radius: 2px;
}

/* The main TV screen area with side bezels */
.tv-screen-area {
  flex: 1;
  display: flex;
  gap: 18px;
  min-height: 0;
  padding: 14px 0;
  position: relative;
}

/* Side plastic bezel columns */
.tv-bezel-left, .tv-bezel-right {
  display: none;
}

@media (min-width: 1100px) {
  .tv-bezel-left, .tv-bezel-right {
    display: block;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, #181410 0%, #30261c 50%, #120e0b 100%);
    box-shadow: inset 1px 0 2px rgba(255,250,220,0.05), inset -1px 0 2px rgba(0,0,0,0.6);
    border-radius: 4px;
    flex-shrink: 0;
  }
}

/* TV chin bar — the panel below the screen */
.tv-chin-bar {
  flex-shrink: 0;
  height: 52px;
  background: linear-gradient(180deg, #181410 0%, #120e0b 60%, #0e0b08 100%);
  border-radius: 0 0 14px 14px;
  border-top: 1px solid rgba(0,0,0,0.6);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 1px 0 rgba(255,200,80,0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 16px;
}

/* Channel/vent block left side of chin */
.tv-chin-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Retro rotary knobs */
.tv-knob {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: 
    radial-gradient(circle at 35% 30%, var(--tv-knob-shine) 0%, var(--tv-knob) 40%, #5a3a10 100%);
  border: 2px solid #2a1a08;
  box-shadow:
    0 3px 8px rgba(0,0,0,0.7),
    0 1px 2px rgba(255,200,80,0.1),
    inset 0 1px 2px rgba(255,230,120,0.3);
  position: relative;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  flex-shrink: 0;
}

.tv-knob::before {
  /* Knob indicator dot */
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
}

.tv-knob:hover {
  transform: rotate(18deg) scale(1.08);
  box-shadow:
    0 4px 12px rgba(0,0,0,0.8),
    0 0 8px rgba(192, 128, 64, 0.3),
    inset 0 1px 3px rgba(255,230,120,0.4);
}

.tv-knob:active {
  transform: rotate(25deg) scale(0.96);
}

/* Chin label */
.tv-chin-label {
  font-family: var(--font-retro);
  font-size: 0.48rem;
  color: rgba(189, 160, 122, 0.5);
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 0 6px rgba(189, 160, 122, 0.2);
}

/* NES branding text in chin */
.tv-chin-brand {
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  color: #8b1a1a;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-style: italic;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Vent slots row in chin */
.tv-chin-vents {
  display: flex;
  gap: 4px;
  align-items: center;
}

.tv-vent-slot {
  width: 14px;
  height: 6px;
  background: #060402;
  border-radius: 2px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.9), 0 1px 0 rgba(255,200,80,0.03);
}

/* Chin right: Power LED + channel display */
.tv-chin-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tv-power-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tv-led-off);
  border: 1px solid rgba(0,0,0,0.6);
  box-shadow: inset 0 0 2px rgba(0,0,0,0.5);
  transition: all 0.4s ease;
  flex-shrink: 0;
}

.tv-power-led.on {
  background: var(--tv-led-on);
  box-shadow: 0 0 8px var(--tv-led-on), 0 0 20px rgba(224, 32, 32, 0.4), inset 0 0 3px rgba(255,100,100,0.6);
  animation: powerLedPulse 2s ease-in-out infinite;
}

@keyframes powerLedPulse {
  0%, 100% { box-shadow: 0 0 8px var(--tv-led-on), 0 0 20px rgba(224, 32, 32, 0.4); }
  50% { box-shadow: 0 0 4px var(--tv-led-on), 0 0 10px rgba(224, 32, 32, 0.2); }
}

/* Channel number indicator */
.tv-channel-display {
  font-family: var(--font-retro);
  font-size: 0.52rem;
  color: rgba(189, 160, 122, 0.4);
  letter-spacing: 1px;
  white-space: nowrap;
}


.crt-screen-container {
  flex: 1;
  width: 100%;
  height: 100%;
  max-height: 100%;
  max-width: calc(100% - 80px);
  /* Deep inset screen well — CRT authentic look */
  background-color: #030202;
  border-radius: 10px;
  overflow: hidden;
  /* Multi-layer border for 3D depth */
  border: 3px solid #0a0806;
  outline: 1px solid rgba(255,200,80,0.06);
  box-shadow: 
    var(--shadow-crt-glow),
    inset 0 0 0 2px #050402,
    0 0 0 8px rgba(10, 8, 5, 0.8),
    0 0 0 9px rgba(255,200,80,0.04);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s ease-out, border-color 0.3s ease-out;
}

.crt-screen-container.tv-off {
  background-color: #010101 !important;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.95) !important;
  border-color: #050402 !important;
  outline-color: transparent !important;
}

.crt-screen-container.tv-off .crt-screen-content {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.3s ease-out;
}

/* CRT convex curve overlay — simulates the glass bulge */
.crt-overlay.curve {
  border-radius: 10px;
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(255, 255, 255, 0.04) 0%,
    transparent 60%
  );
  box-shadow: 
    inset 0 0 60px rgba(0,0,0,0.7),
    inset 0 0 0 1px rgba(255,255,255,0.02);
}

.canvas-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: aspect-ratio 0.25s ease-out, width 0.25s ease-out, height 0.25s ease-out;
  container-type: size;
}

.canvas-wrapper canvas {
  width: var(--canvas-width, 100%) !important;
  height: var(--canvas-height, 100%) !important;
  transform: var(--canvas-transform, none) !important;
  object-fit: fill;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition: transform 0.2s ease-out, width 0.2s ease-out, height 0.2s ease-out;
  aspect-ratio: auto !important;
}

.canvas-wrapper canvas.sharp-canvas {
  image-rendering: auto !important;
  object-fit: fill !important;
}

.crt-screen-container .canvas-wrapper {
  width: 100%;
  height: 100%;
}

.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10 !important;
}

.scanlines {
  display: none;
}

.scanlines.active {
  display: block;
  background: repeating-linear-gradient(
    to bottom,
    rgba(18, 16, 16, 0) 0px,
    rgba(18, 16, 16, 0) 1px,
    rgba(0, 0, 0, 0.15) 1px,
    rgba(0, 0, 0, 0.15) 2px
  );
  background-size: 100% 2px;
  opacity: 0.8;
}

.curve {
  box-shadow: inset 0 0 80px rgba(0,0,0,0.9);
}

.static-noise {
  background-image: none;
  background-size: 128px 128px;
  opacity: 0.12;
  pointer-events: none;
  z-index: 10 !important;
  display: none;
}

.static-noise.active {
  display: block;
  animation: static-flicker 0.1s infinite steps(4);
}

@keyframes static-flicker {
  0% { background-position: 0px 0px; }
  25% { background-position: 50px 10px; }
  50% { background-position: -10px -50px; }
  75% { background-position: 20px -30px; }
  100% { background-position: -30px 10px; }
}

.screen-message {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #0b0c0e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.message-content {
  text-align: center;
}

.arcade-logo {
  font-family: var(--font-retro);
  font-size: 3.5rem;
  color: var(--color-gold);
  text-shadow: 0 0 20px var(--color-gold-glow);
  letter-spacing: -2px;
  margin-bottom: 20px;
}

.blink {
  font-family: var(--font-retro);
  font-size: 0.75rem;
  color: var(--text-muted);
  animation: text-blink 1.5s step-end infinite;
}

@keyframes text-blink {
  from, to { opacity: 1; }
  50% { opacity: 0; }
}

.bezel-side-controls {
  width: 60px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 16px 0;
  border-left: 1px solid var(--border-glass);
  padding-left: 20px;
  gap: 14px;
  height: 100%;
  /* overflow removed so scanline slider is not clipped */
}

.bezel-power-btn {
  width: 44px;
  height: 44px;
  font-size: 1.25rem;
}

.bezel-reset-btn {
  width: 40px;
  height: 40px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bezel-option-btn {
  width: 40px;
  height: 40px;
}

.bezel-power-btn,
.bezel-reset-btn,
.bezel-option-btn {
  border-radius: 50%;
  background: radial-gradient(circle, hsl(20, 10%, 25%) 0%, hsl(20, 10%, 15%) 100%);
  border: 2px solid hsl(20, 10%, 10%);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: var(--transition-smooth);
  flex-shrink: 0;
}

.bezel-power-btn:hover,
.bezel-reset-btn:hover,
.bezel-option-btn:hover {
  color: var(--text-main);
  background: radial-gradient(circle, hsl(20, 10%, 30%) 0%, hsl(20, 10%, 18%) 100%);
}

.bezel-power-btn.active {
  background: radial-gradient(circle, hsl(145, 60%, 40%) 0%, hsl(145, 60%, 25%) 100%);
  border-color: hsl(145, 60%, 15%);
  color: #fff;
  box-shadow: 0 0 12px var(--color-green-glow);
}

.bezel-option-btn.active {
  color: var(--color-gold);
  border-color: var(--color-gold);
  box-shadow: 0 0 10px var(--color-gold-glow);
}

.bezel-power-btn:active,
.bezel-reset-btn:active,
.bezel-option-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Explicit SVG styling inside bezel option buttons */
.bezel-option-btn svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2;
  transition: var(--transition-smooth);
}

.bezel-option-btn:hover svg {
  stroke: var(--text-main);
}

.bezel-option-btn.active svg {
  stroke: var(--color-gold);
}

.bezel-option-btn.btn-favorite-icon.active svg {
  fill: var(--color-gold);
  stroke: var(--color-gold);
  filter: drop-shadow(0 0 4px var(--color-gold-glow));
}

/* Volume Rocker Button Styles */
.bezel-volume-rocker {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 44px;
  height: 94px;
  background: linear-gradient(180deg, #18191d 0%, #0d0e10 100%);
  border: 1.5px solid rgba(189, 160, 122, 0.25);
  border-radius: 10px;
  box-shadow: 
    inset 0 3px 6px rgba(0, 0, 0, 0.9), 
    0 1px 2px rgba(255, 255, 255, 0.05),
    0 0 10px rgba(189, 160, 122, 0.05);
  padding: 12px 3px 6px 3px;
  position: relative;
  box-sizing: border-box;
  margin: 6px 0;
  flex-shrink: 0;
}

/* Glowing LED Indicator */
.volume-led {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981, 0 0 12px #10b981;
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  transition: all 0.25s ease;
}

.rocker-btn {
  width: 32px;
  height: 28px;
  background: 
    repeating-linear-gradient(90deg, rgba(0,0,0,0.1) 0px, rgba(0,0,0,0.1) 1px, transparent 1px, transparent 4px),
    linear-gradient(180deg, #35363d 0%, #202125 100%);
  border: 1.5px solid #141517;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-main);
  font-weight: 800;
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 
    0 3px 6px rgba(0, 0, 0, 0.5), 
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  padding: 0;
}

.rocker-btn .rocker-symbol {
  user-select: none;
  pointer-events: none;
  font-size: 1rem;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.rocker-btn:hover .rocker-symbol {
  color: var(--color-gold);
  text-shadow: 0 0 4px var(--color-gold-glow);
}

.rocker-btn.rocker-up {
  border-radius: 6px 6px 3px 3px;
  background: 
    repeating-linear-gradient(90deg, rgba(0,0,0,0.1) 0px, rgba(0,0,0,0.1) 1px, transparent 1px, transparent 4px),
    linear-gradient(180deg, #4b4c55 0%, #2a2b30 45%, #18191c 100%);
}

.rocker-btn.rocker-down {
  border-radius: 3px 3px 6px 6px;
  background: 
    repeating-linear-gradient(90deg, rgba(0,0,0,0.1) 0px, rgba(0,0,0,0.1) 1px, transparent 1px, transparent 4px),
    linear-gradient(180deg, #4b4c55 0%, #2a2b30 45%, #18191c 100%);
}

.rocker-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.45rem;
  font-weight: 700;
  color: var(--color-gold);
  letter-spacing: 0.5px;
  text-shadow: 0 0 4px var(--color-gold-glow);
  user-select: none;
  pointer-events: none;
  line-height: 1;
  margin: 4px 0;
}

.rocker-btn:hover {
  background: 
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0px, rgba(255,255,255,0.03) 1px, transparent 1px, transparent 4px),
    linear-gradient(180deg, #575963 0%, #35363d 45%, #202125 100%);
  border-color: var(--color-gold);
  box-shadow: 
    0 4px 10px rgba(189, 160, 122, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* 3D Rocking effect when pressed */
.rocker-btn:active {
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8);
}

.rocker-btn.rocker-up:active {
  transform: translateY(2px) scale(0.96);
  background: linear-gradient(180deg, #101113 0%, #202125 100%);
}

.rocker-btn.rocker-down:active {
  transform: translateY(-2px) scale(0.96);
  background: linear-gradient(180deg, #101113 0%, #202125 100%);
}

/* CRT Volume HUD Overlay */
.volume-hud {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 11, 14, 0.95);
  border: 1.5px solid var(--color-gold);
  box-shadow: var(--shadow-gold-glow), inset 0 0 15px rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  /* backdrop-filter: blur(8px); - Removed for performance */
}

.volume-hud.visible {
  opacity: 1;
}

.volume-hud-label {
  font-family: var(--font-retro);
  font-size: 0.65rem;
  color: var(--color-gold);
  letter-spacing: 1px;
}

.volume-hud-bar-container {
  width: 120px;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(189, 160, 122, 0.3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.volume-hud-bar {
  height: 100%;
  width: 80%; /* Set dynamically */
  background: var(--color-green);
  box-shadow: 0 0 8px var(--color-green);
  transition: width 0.1s ease-out;
}

.volume-hud-value {
  font-family: var(--font-retro);
  font-size: 0.65rem;
  color: var(--color-green);
  width: 35px;
  text-align: right;
}

.bezel-slider-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 80px;
  max-height: 200px;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  /* no overflow:hidden so slider thumb is not clipped */
}

.bezel-slider-label {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.slider-wrapper {
  flex: 1;
  position: relative;
  width: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80px;
}

#slider-scanlines {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 6px;
  height: 100%;
  min-height: 80px;
  /* Visible gradient track: dark→gold */
  background: linear-gradient(
    to top,
    var(--color-gold) 0%,
    rgba(189, 160, 122, 0.3) 40%,
    rgba(255, 255, 255, 0.06) 100%
  );
  border-radius: 6px;
  outline: none;
  border: 1px solid rgba(189, 160, 122, 0.3);
  box-shadow: 0 0 6px rgba(189, 160, 122, 0.15);
  appearance: none;
  cursor: pointer;
}

#slider-scanlines::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, #f0c87a 0%, var(--color-gold) 60%, #8e724a 100%);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 10px rgba(189, 160, 122, 0.6), 0 2px 4px rgba(0,0,0,0.5);
  cursor: grab;
  transition: var(--transition-smooth);
}

#slider-scanlines::-webkit-slider-thumb:active {
  cursor: grabbing;
  box-shadow: 0 0 16px rgba(189, 160, 122, 0.9), 0 2px 6px rgba(0,0,0,0.6);
  transform: scale(1.15);
}

.bezel-slider-value {
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-gold);
}

/* ==========================================================================
   RIGHT COLUMN: CONTROLLER MANAGEMENT, QUICK ACTIONS & METADATA
   ========================================================================== */
/* RIGHT SIDEBAR — clamp width same as library */
.sidebar-controls {
  width: clamp(220px, 22vw, 320px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
  height: 100%;
  overflow: hidden;
  transition: transform 0.32s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.25s ease;
}

.sidebar-scroll-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 4px;
  scrollbar-width: none;
}

.sidebar-scroll-content::-webkit-scrollbar {
  display: none;
}

.sidebar-fixed-bottom {
  flex-shrink: 0;
  margin-top: auto;
}

.control-box {
  background: var(--bg-panel);
  /* backdrop-filter: blur(28px); - Removed for performance */
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-premium);
  transition: var(--transition-smooth);
}

/* Active sidebar outline glow highlight */
.sidebar-controls .control-box {
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-premium);
}

.sidebar-controls .control-box:hover {
  border-color: var(--border-glass-bright);
}

.box-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-main);
  text-transform: uppercase;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.box-title::before {
  content: '';
  width: 3px;
  height: 10px;
  background: var(--color-gold);
  border-radius: 2px;
  display: inline-block;
  box-shadow: var(--shadow-gold-glow);
}

/* Controller Management Tab Pills */
.control-tab-pills {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 12px;
  border: 1px solid var(--border-glass);
}

.control-pill {
  flex: 1;
  background: none;
  border: none;
  padding: 6px 0;
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-smooth);
}

.control-pill:hover {
  color: #fff;
}

.control-pill.active {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-gold);
  border: 1px solid var(--border-glass-bright);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.controller-visual-container {
  background: rgba(0, 0, 0, 0.15);
  background-image: radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 10px 10px;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
}

.controller-visual-container:hover {
  border-color: var(--border-glass-bright);
  background-color: rgba(255, 255, 255, 0.01);
  box-shadow: var(--shadow-premium);
}

.nes-controller-svg {
  width: 100%;
  max-width: 220px;
  height: auto;
}

/* 3D button press active highlights */
.nes-controller-svg #ctrl-svg-a,
.nes-controller-svg #ctrl-svg-b,
.nes-controller-svg #ctrl-svg-select,
.nes-controller-svg #ctrl-svg-start,
.nes-controller-svg #ctrl-svg-dpad {
  transition: transform 0.08s ease, filter 0.08s ease;
  transform-origin: center;
}

.nes-controller-svg #ctrl-svg-a.pressed,
.nes-controller-svg #ctrl-svg-b.pressed {
  transform: translateY(0.8px) scale(0.98);
  filter: brightness(1.2) drop-shadow(0 0 4px var(--color-gold));
}

.nes-controller-svg #ctrl-svg-select.pressed,
.nes-controller-svg #ctrl-svg-start.pressed {
  transform: translateY(0.5px);
  filter: brightness(1.3) drop-shadow(0 0 2px var(--color-gold-hover));
}

.nes-controller-svg #ctrl-svg-dpad.pressed {
  filter: brightness(1.2) drop-shadow(0 0 6px var(--color-cyan-glow));
}

.controller-hover-hint {
  font-size: 0.65rem;
  color: var(--color-gold);
  margin-top: 8px;
  font-weight: 600;
  opacity: 0.7;
}

.controller-visual-container:hover .controller-hover-hint {
  opacity: 1;
}

/* Session Actions Grid */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.action-grid-btn {
  background: linear-gradient(180deg, rgba(24, 18, 10, 0.8) 0%, rgba(16, 12, 7, 0.9) 100%);
  border: 1px solid rgba(189, 160, 122, 0.15);
  border-bottom: 2px solid rgba(0,0,0,0.5);
  border-radius: 10px;
  padding: 11px 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.15s ease, border-color 0.2s ease;
  box-shadow: 0 3px 6px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,200,80,0.04);
  position: relative;
  overflow: hidden;
}

.action-grid-btn:hover {
  background: linear-gradient(180deg, rgba(34, 26, 14, 0.9) 0%, rgba(22, 17, 9, 0.95) 100%);
  border-color: rgba(189, 160, 122, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.5), 0 0 10px rgba(189, 160, 122, 0.12), inset 0 1px 0 rgba(255,200,80,0.08);
}

.action-grid-btn:active {
  transform: translateY(1px);
  border-bottom-width: 1px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5), inset 0 1px 4px rgba(0,0,0,0.3);
}

.action-btn-icon {
  font-size: 1.25rem;
  color: var(--color-gold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
}

.action-btn-shortcut {
  font-family: var(--font-main);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-gold);
}

.action-grid-btn:hover {
  background: rgba(189, 160, 122, 0.1);
  border-color: var(--color-gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold-glow);
}

/* Game Metadata Table */
.metadata-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.metadata-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.metadata-row:last-child {
  border-bottom: none;
}

.meta-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meta-icon {
  width: 14px;
  height: 14px;
  color: var(--color-gold);
}

.meta-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ==========================================================================
   BOTTOM PANEL BAR (SINGLE HORIZONTAL DIVIDED BAR)
   ========================================================================== */
.app-footer-bar {
  height: 145px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1.25fr 1fr 1.35fr;
  gap: 16px;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  padding: 0 !important;
}

.footer-panel {
  background: var(--bg-sidebar);
  /* backdrop-filter: blur(25px); - Removed for performance */
  border: 1.5px solid var(--border-glass-bright);
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  transition: var(--transition-smooth);
}

.footer-panel:hover {
  border-color: var(--color-gold);
  box-shadow: var(--shadow-gold-glow), var(--shadow-premium);
}

/* New header row for footer panels: icon + title + optional right-align text */
.footer-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(189, 160, 122, 0.12);
  padding-bottom: 8px;
  flex-shrink: 0;
}

.footer-panel-header svg {
  color: var(--color-gold);
  flex-shrink: 0;
}

.footer-panel-title {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--color-gold);
  flex: 1;
}

.footer-panel-header .state-timestamp {
  margin-left: auto;
}

/* Audio Engine Slider */
.audio-control-flex {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.volume-track-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}

.audio-mute-btn {
  background: rgba(10, 11, 14, 0.5);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  cursor: pointer;
  color: var(--color-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.audio-mute-btn:hover {
  background: rgba(189, 160, 122, 0.1);
  border-color: var(--color-gold);
  filter: drop-shadow(0 0 4px var(--color-gold-glow));
}

.audio-icon {
  width: 16px;
  height: 16px;
}

#volume-slider {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  border-radius: 4px;
  appearance: none;
  cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-gold);
  box-shadow: 0 0 8px var(--color-gold-glow);
  cursor: grab;
  transition: var(--transition-smooth);
}

#volume-slider::-webkit-slider-thumb:active {
  background: var(--color-gold-hover);
  cursor: grabbing;
}

.audio-percentage {
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-gold);
  width: 38px;
  text-align: right;
}

/* Now Playing Panel */
.now-playing-info {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.now-playing-visualizer-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.now-playing-time {
  font-family: var(--font-main);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-dim);
}

.now-playing-progress-track {
  flex: 1;
  height: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  border: 1px solid var(--border-glass);
  position: relative;
}

.now-playing-progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8e724a, var(--color-gold));
  box-shadow: 0 0 8px var(--color-gold-glow);
  border-radius: 8px;
}

/* Clean handle style */
.now-playing-progress-sparkle {
  display: none; /* remove ugly sparkle */
}

@keyframes rotateSparkle {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Game Metadata Footer Panel */
.game-metadata-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metadata-footer-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
  gap: 6px;
}

.metadata-table-horizontal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}

.metadata-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.metadata-item .meta-label {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.7rem;
}

.metadata-item .meta-value {
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.7rem;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

.credit-divider {
  height: 1px;
  background: rgba(189, 160, 122, 0.12);
  margin: 1px 0;
}

.credits-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.credit-text {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.author-highlight {
  color: var(--color-gold);
  font-weight: 700;
}

.linkedin-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #0a66c2; /* LinkedIn color */
  text-decoration: none;
  font-weight: 700;
  font-size: 0.7rem;
  transition: var(--transition-smooth);
}

.linkedin-link:hover {
  color: #00a0dc;
  text-shadow: 0 0 4px rgba(10, 102, 194, 0.4);
}

.linkedin-icon {
  fill: currentColor;
}

/* Game Library Section Headers */
.library-section-header {
  grid-column: 1 / -1;
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--color-gold);
  border-bottom: 1.5px solid rgba(189, 160, 122, 0.15);
  padding-bottom: 6px;
  margin-top: 14px;
  margin-bottom: 6px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-section-header:first-of-type {
  margin-top: 0;
}

/* ==========================================================================
   MODALS & INPUT CONFIGURATION OVERLAYS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.65);
  /* backdrop-filter: blur(16px); - Removed for performance */
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.mapping-drawer {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass-bright);
  box-shadow: var(--shadow-premium);
  border-radius: 16px;
  width: 780px;
  max-width: 95%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.92) translateY(12px);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  opacity: 0;
}

.player-columns-wrapper {
  display: flex;
  gap: 24px;
  width: 100%;
}

.player-columns-wrapper .player-mapping-section {
  flex: 1;
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .player-columns-wrapper {
    flex-direction: column;
    gap: 16px;
  }
}

.modal-overlay.active .mapping-drawer {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  transition: var(--transition-smooth);
}

.close-btn:hover {
  color: var(--text-main);
}

.drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.drawer-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.player-mapping-section {
  margin-bottom: 24px;
}

.player-mapping-section h3 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-gold);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.mapping-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mapping-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.mapping-row:hover {
  border-color: var(--color-gold);
  background: var(--bg-card-hover);
}

.mapping-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.mapping-val {
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-gold);
  background: rgba(0, 0, 0, 0.2);
  padding: 4px 8px;
  border-radius: 4px;
}

.drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.btn-primary {
  background: var(--color-gold);
  color: #000;
  font-weight: 700;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  padding: 10px 20px;
  box-shadow: 0 4px 12px var(--color-gold-glow);
  transition: var(--transition-smooth);
}

.btn-primary:hover {
  background: var(--color-gold-hover);
  box-shadow: 0 6px 16px var(--color-gold-glow);
}

/* Key Capture overlay */
.capture-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.8);
  /* backdrop-filter: blur(15px); - Removed for performance */
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.capture-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.capture-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass-bright);
  border-radius: 24px;
  padding: 30px;
  text-align: center;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-premium);
}

.capture-icon {
  font-size: 3rem;
}

.capture-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.capture-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.capture-card strong {
  color: var(--color-gold);
}

/* ==========================================================================
   TOAST NOTIFICATION SYSTEM
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  background: var(--bg-panel);
  border: 1px solid var(--color-gold);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 15px var(--color-gold-glow);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 200px;
  max-width: 320px;
  animation: slideIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
  position: relative;
  overflow: hidden;
}

@keyframes slideIn {
  from { transform: translateX(100%) translateY(0); opacity: 0; }
  to { transform: translateX(0) translateY(0); opacity: 1; }
}

.toast.fade-out {
  animation: fadeOut 0.3s forwards;
}

@keyframes fadeOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS — ADAPTIVE LAYOUT
   ========================================================================== */

/* ── Large Desktop (1350px+): Full 3-column layout, sidebars at max width ── */
@media (min-width: 1350px) {
  .sidebar-library,
  .sidebar-controls {
    width: 320px;
  }

  .sidebar-controls.desktop-hidden {
    display: none !important;
  }
}

/* ── Medium Desktop (1000px - 1350px): Right Controls Sidebar collapses ── */
@media (max-width: 1350px) {
  #btn-toggle-controls {
    display: flex;
  }

  .sidebar-controls {
    position: fixed;
    top: 56px;
    right: 0;
    height: calc(100dvh - 56px);
    width: min(320px, 80vw);
    z-index: 200;
    border-radius: 20px 0 0 20px;
    transform: translateX(110%);
    padding: 16px;
    box-sizing: border-box;
    background: var(--bg-sidebar);
    /* backdrop-filter: blur(25px); - Removed for performance */
    border: 1px solid var(--border-glass-bright);
  }

  .sidebar-controls.sidebar-open {
    transform: translateX(0);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.6), var(--shadow-gold-glow);
  }
}

/* ── Compact Desktop / Tablet (< 1000px): Both sidebars collapse, TV is wide ── */
@media (max-width: 1000px) {
  #btn-toggle-library {
    display: flex;
  }

  /* Sidebars become fixed overlay drawers */
  .sidebar-library {
    position: fixed;
    top: 56px;
    left: 0;
    height: calc(100dvh - 56px);
    width: min(320px, 80vw);
    z-index: 200;
    border-radius: 0 20px 20px 0;
    transform: translateX(-110%);
    overflow-y: auto;
    scrollbar-width: thin;
  }

  .sidebar-library.sidebar-open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.6), var(--shadow-gold-glow);
  }

  /* Console column takes full width of main-layout */
  .console-column {
    width: 100% !important;
    min-width: 0;
  }

  /* Main layout has no gap to sidebars (they're now overlays) */
  .main-layout {
    gap: 0;
  }

  /* Footer stacks as a single column */
  .app-footer-bar {
    grid-template-columns: 1fr;
    height: auto;
    gap: 10px;
  }

  .footer-panel {
    min-height: 80px;
  }

  /* Reduce app container padding on smaller screens */
  .app-container {
    padding: 10px;
    gap: 10px;
  }

  /* Status badge font gets smaller */
  .screen-status-badge {
    font-size: 0.7rem;
    height: 34px;
    padding: 6px 12px;
  }

  /* Bezel frame padding reduction */
  .crt-bezel-frame {
    padding: 16px;
    gap: 16px;
  }
}

/* ==========================================================================
   DISPLAY CALIBRATION & FLOATING FULLSCREEN SETTINGS OVERLAY
   ========================================================================== */
.screen-calibration-box {
  margin-top: 5px;
}

.calibration-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.calibration-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calibration-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calibration-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.calibration-value {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-gold);
}

.calibration-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  cursor: pointer;
}

.calibration-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-gold);
  cursor: grab;
  transition: var(--transition-smooth);
}

.calibration-slider::-webkit-slider-thumb:active {
  background: var(--color-gold-hover);
  cursor: grabbing;
}

.reset-calibration-btn {
  font-size: 0.7rem;
  padding: 8px;
  letter-spacing: 0.5px;
  margin-top: 8px;
}

/* Emulator Speed Presets */
.speed-presets-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.speed-preset-btn {
  flex: 1;
  background: rgba(10, 11, 14, 0.4);
  border: 1px solid var(--border-glass);
  padding: 6px 4px;
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-smooth);
}

.speed-preset-btn:hover {
  background: rgba(189, 160, 122, 0.1);
  color: #fff;
  border-color: var(--color-gold);
}

.speed-preset-btn.active {
  background: rgba(189, 160, 122, 0.15);
  border-color: var(--color-gold);
  color: #fff;
  box-shadow: 0 0 8px var(--color-gold-glow);
}

/* Floating Fullscreen Settings Overlay */
.fullscreen-settings-overlay {
  display: none;
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 1000;
}

.crt-screen-container:fullscreen .fullscreen-settings-overlay {
  display: block;
}

.fullscreen-overlay-trigger {
  background: rgba(20, 21, 23, 0.85);
  border: 1px solid var(--border-glass-bright);
  border-radius: 8px;
  color: var(--color-gold);
  padding: 6px 12px;
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  /* backdrop-filter: blur(10px); - Removed for performance */
  box-shadow: var(--shadow-crt-glow);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-smooth);
}

.fullscreen-overlay-trigger:hover {
  background: rgba(20, 21, 23, 0.95);
  border-color: var(--color-gold);
  box-shadow: 0 0 10px var(--color-gold-glow);
}

.fullscreen-settings-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background: rgba(20, 21, 23, 0.95);
  border: 1px solid var(--border-glass-bright);
  border-radius: 10px;
  padding: 8px;
  width: 150px;
  box-shadow: var(--shadow-bezel);
  /* backdrop-filter: blur(20px); - Removed for performance */
  flex-direction: column;
  gap: 4px;
}

.fullscreen-settings-overlay:hover .fullscreen-settings-dropdown,
.fullscreen-settings-overlay:focus-within .fullscreen-settings-dropdown {
  display: flex;
}

.fullscreen-dropdown-title {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px;
  letter-spacing: 1px;
  text-align: center;
}

.fs-aspect-btn, .fs-exit-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-smooth);
}

.fs-aspect-btn:hover, .fs-exit-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-gold);
  border-color: var(--border-glass-bright);
}

.fs-exit-btn {
  color: #ff4a4a;
}

.fs-exit-btn:hover {
  color: #ff6b6b;
  background: rgba(255, 74, 74, 0.1);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-glass);
  margin: 4px 0;
}

/* ==========================================================================
   DEVICE DETECTION & WARNINGS MARKUP
   ========================================================================== */
.mobile-block-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #1b1c21 0%, #0d0d0f 100%);
  z-index: 10000;
  display: none; /* Controlled via JS */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  /* backdrop-filter: blur(20px); - Removed for performance */
}

.mobile-block-card {
  background: var(--bg-panel);
  border: 1.5px solid var(--color-gold);
  box-shadow: var(--shadow-gold-glow), var(--shadow-premium);
  border-radius: 24px;
  padding: 40px 24px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.mobile-block-icon {
  font-size: 4rem;
  margin-bottom: 8px;
}

.mobile-block-card h2 {
  font-family: var(--font-retro);
  font-size: 0.95rem;
  color: var(--color-gold);
  line-height: 1.5;
  text-transform: uppercase;
}

.mobile-block-card p {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.5;
}

.mobile-block-card .secondary-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tablet-warning-drawer {
  background: var(--bg-panel);
  border: 1.5px solid var(--color-gold);
  box-shadow: var(--shadow-gold-glow), var(--shadow-premium);
  border-radius: 20px;
  width: 460px;
  max-width: 90%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  transition: var(--transition-smooth);
  text-align: center;
}

#modal-tablet-warning.active .tablet-warning-drawer {
  transform: translateY(0);
}

.warning-icon-wrapper {
  font-size: 3rem;
  margin-top: 24px;
  margin-bottom: 12px;
}

.instruction-prompt {
  font-size: 0.8rem;
  color: var(--color-gold);
  margin-top: 12px;
  font-weight: 600;
}

/* ROM Upload UI */
.upload-bar-container {
  padding: 0 20px 16px 20px;
  display: flex;
}

.btn-upload-rom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--color-gold) 0%, #d4a017 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #0b0c10;
  font-family: var(--font-retro);
  font-size: 0.65rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(212, 160, 23, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-upload-rom:hover {
  background: linear-gradient(135deg, #ffd700 0%, var(--color-gold) 100%);
  box-shadow: 0 6px 16px rgba(212, 160, 23, 0.4);
  transform: translateY(-1px);
}

.btn-upload-rom:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(212, 160, 23, 0.2);
}

.upload-icon {
  width: 14px;
  height: 14px;
}

/* Delete button on local game card */
.delete-local-game-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(220, 53, 69, 0.9);
  border: none;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.delete-local-game-btn:hover {
  background: #ff3344;
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(255, 51, 68, 0.5);
}

.custom-cartridge-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1f222b 0%, #0c0d11 100%);
}

.cart-placeholder-svg {
  filter: drop-shadow(0 0 4px rgba(212, 160, 23, 0.4));
}

/* --- Tooltips for Bezel Buttons --- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  background: rgba(10, 11, 14, 0.95);
  color: var(--color-gold);
  border: 1px solid var(--color-gold);
  box-shadow: 0 0 12px rgba(189, 160, 122, 0.4);
  padding: 5px 10px;
  border-radius: 6px;
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 100;
}

[data-tooltip]::before {
  content: '';
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  border-width: 6px 0 6px 6px;
  border-style: solid;
  border-color: transparent transparent transparent var(--color-gold);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* Adjustments for responsive headers & centering */
@media (max-width: 680px) {
  .header-credits {
    display: none !important;
  }
}

@media (max-width: 520px) {
  .nav-menu {
    position: static !important;
    transform: none !important;
    margin: 0 auto;
  }
}

/* CRT TV screen content container holding the phosphor display beam */
.crt-screen-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center;
  animation: crt-turn-on 0.4s cubic-bezier(0.25, 1, 0.2, 1) forwards;
  z-index: 2;
}

.crt-screen-container.tv-off .crt-screen-content {
  animation: crt-turn-off 0.4s cubic-bezier(0.25, 1, 0.2, 1) forwards;
}

/* Old CRT TV Turn-On and Turn-Off Animations */
@keyframes crt-turn-on {
  0% {
    transform: scale(0.99, 0.005);
    opacity: 0.1;
    filter: brightness(20) contrast(2);
  }
  30% {
    transform: scale(0.99, 0.005);
    opacity: 1;
    filter: brightness(20) contrast(2);
  }
  60% {
    transform: scale(0.99, 0.02);
    opacity: 1;
    filter: brightness(15) contrast(1.5);
  }
  85% {
    transform: scale(1, 1);
    opacity: 1;
    filter: brightness(2);
  }
  100% {
    transform: scale(1, 1);
    opacity: 1;
    filter: none;
  }
}

@keyframes crt-turn-off {
  0% {
    transform: scale(1, 1);
    filter: brightness(1) contrast(1);
    opacity: 1;
  }
  30% {
    transform: scale(1, 0.005);
    filter: brightness(10) contrast(2);
    opacity: 1;
  }
  60% {
    transform: scale(0.01, 0.005);
    filter: brightness(30) contrast(3);
    opacity: 0.8;
  }
  100% {
    transform: scale(0, 0);
    filter: brightness(50) contrast(5);
    opacity: 0;
  }
}

/* ==========================================================================
   CINEMATIC CARTRIDGE (CASSETTE) INSERTION ANIMATION
   ========================================================================== */

/* ── Keyframes ── */
@keyframes cinematicFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes cartFlyIn {
  0%   { transform: translateX(-50%) translateY(-480px) translateX(80px) rotateZ(-28deg) scale(0.25); opacity: 0; }
  55%  { transform: translateX(-50%) translateY(-60px) rotateZ(3deg) scale(1.08); opacity: 1; }
  70%  { transform: translateX(-50%) translateY(-20px) rotateZ(-2deg) scale(1.02); }
  82%  { transform: translateX(-50%) translateY(-40px) rotateZ(1deg) scale(1.05); }
  100% { transform: translateX(-50%) translateY(-30px) rotateZ(0deg) scale(1); opacity: 1; }
}

@keyframes cartHover {
  0%   { transform: translateX(-50%) translateY(-30px); }
  50%  { transform: translateX(-50%) translateY(-22px); }
  100% { transform: translateX(-50%) translateY(-30px); }
}

@keyframes cartInsert {
  0%   { transform: translateX(-50%) translateY(-30px) scale(1); }
  40%  { transform: translateX(-50%) translateY(36px) scale(0.9); }
  55%  { transform: translateX(-50%) translateY(20px) scale(0.88); }
  70%  { transform: translateX(-50%) translateY(30px) scale(0.87); }
  100% { transform: translateX(-50%) translateY(28px) scale(0.87); }
}

@keyframes cartDisappear {
  0%   { opacity: 1; transform: translateX(-50%) translateY(28px) scale(0.87); }
  100% { opacity: 0; transform: translateX(-50%) translateY(35px) scale(0.82); }
}

@keyframes overlayFadeOut {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes phasePulse {
  0%,100% { opacity: 0.6; letter-spacing: 3px; }
  50%      { opacity: 1;   letter-spacing: 5px; }
}

@keyframes titleReveal {
  0%   { clip-path: inset(0 100% 0 0); opacity: 0; }
  100% { clip-path: inset(0 0% 0 0);   opacity: 1; }
}

@keyframes consoleSlideUp {
  0%   { transform: translateX(-50%) translateY(120px); opacity: 0; }
  100% { transform: translateX(-50%) translateY(0);     opacity: 1; }
}

@keyframes ledBlink {
  0%,100% { opacity: 0.1; box-shadow: none; }
  50%      { opacity: 1;   box-shadow: 0 0 14px 4px #e11d48, 0 0 30px #e11d48; }
}

@keyframes ledOn {
  0%   { opacity: 0.2; box-shadow: 0 0 4px #10b981; }
  30%  { opacity: 1;   box-shadow: 0 0 18px 6px #10b981, 0 0 40px #10b981; }
  60%  { opacity: 0.7; box-shadow: 0 0 10px #10b981; }
  100% { opacity: 1;   box-shadow: 0 0 14px 4px #10b981, 0 0 30px #10b981; }
}

@keyframes wireCharge {
  0%   { stroke: #333; stroke-dashoffset: 200; opacity: 0.3; filter: none; }
  60%  { stroke: #10b981; stroke-dashoffset: 0;   opacity: 1;   filter: drop-shadow(0 0 4px #10b981); }
  80%  { stroke: #bda07a; stroke-dashoffset: 0;   opacity: 1;   filter: drop-shadow(0 0 6px #bda07a); }
  100% { stroke: #10b981; stroke-dashoffset: 0;   opacity: 1;   filter: drop-shadow(0 0 4px #10b981); }
}

@keyframes slotGlow {
  0%,100% { box-shadow: inset 0 2px 8px rgba(0,0,0,0.9); background: #0a0a0c; }
  50%      { box-shadow: inset 0 2px 8px rgba(0,0,0,0.5), 0 0 20px 6px rgba(189,160,122,0.5); background: #1a1408; }
}

@keyframes sparkFly {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: var(--spark-dest) scale(0); opacity: 0; }
}

@keyframes cartShine {
  0%   { transform: translateX(-130%) skewX(-20deg); }
  100% { transform: translateX(220%) skewX(-20deg); }
}

@keyframes scanlineScroll {
  0%   { background-position: 0 0; }
  100% { background-position: 0 100px; }
}

/* ── Main overlay container ── */
.cinematic-overlay {
  position: absolute;
  inset: 0;
  z-index: 8; /* above emulator screen elements, below CRT curve/glass */
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: visibility 0s 0.4s, opacity 0.4s ease;
  overflow: hidden;
}

.cinematic-overlay.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease;
}

/* Backdrop */
.cinematic-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, #170f2f 0%, #0a0618 55%, #020106 100%);
  z-index: 1;
}

/* Retro Synth Grid Sun */
.retro-synth-sun {
  position: absolute;
  width: 160px;
  height: 80px; /* Half sun shape */
  background: linear-gradient(to bottom, #ec4899 0%, #f59e0b 85%, transparent 100%);
  bottom: 115px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 80px 80px 0 0;
  z-index: 2;
  opacity: 0.16;
  filter: drop-shadow(0 0 20px rgba(236, 72, 153, 0.45));
  mask-image: linear-gradient(to bottom, white 55%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, white 55%, transparent 100%);
  pointer-events: none;
}

/* Perspective neon retro grid */
.cinematic-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(236, 72, 153, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(236, 72, 153, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: center bottom;
  transform: perspective(100px) rotateX(65deg) translateY(-20px) scale(2.2);
  transform-origin: top center;
  opacity: 0.55;
  z-index: 2;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 15%, rgba(0,0,0,0.85) 100%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 15%, rgba(0,0,0,0.85) 100%);
}

/* Ambient drifting space dust */
.ambient-dust {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(1px 1px at 20px 30px, #ffffff 100%, transparent),
    radial-gradient(1.5px 1.5px at 60px 120px, rgba(236, 72, 153, 0.4) 100%, transparent),
    radial-gradient(1px 1px at 140px 50px, #ffffff 100%, transparent),
    radial-gradient(2px 2px at 220px 160px, rgba(6, 182, 212, 0.45) 100%, transparent),
    radial-gradient(1.2px 1.2px at 290px 90px, #ffffff 100%, transparent);
  background-size: 340px 180px;
  z-index: 2;
  opacity: 0.5;
  animation: dustDrift 18s linear infinite;
  pointer-events: none;
}

@keyframes dustDrift {
  0% { transform: translateY(0) rotate(0deg); opacity: 0.4; }
  50% { transform: translateY(-12px) rotate(4deg); opacity: 0.65; }
  100% { transform: translateY(0) rotate(0deg); opacity: 0.4; }
}

/* Stage: flex column centering everything */
.cinematic-stage {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px 14px 12px;
  box-sizing: border-box;
}

/* Phase label */
.phase-label {
  font-family: var(--font-retro);
  font-size: 0.52rem;
  color: var(--color-gold);
  text-shadow: 0 0 8px rgba(189, 160, 122, 0.5);
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  animation: phaseLabelPulse 1.5s ease-in-out infinite;
  z-index: 5;
}

@keyframes phaseLabelPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

/* Game title */
.cinematic-game-title {
  font-family: var(--font-retro);
  font-size: 0.58rem;
  color: #fff;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 0 8px rgba(225, 29, 72, 0.7), 0 0 16px rgba(225, 29, 72, 0.4);
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  z-index: 5;
}

.cinematic-game-title.reveal {
  opacity: 1;
  transform: translateY(0);
}

/* ── Console Assembly Area (2.5D container with 3D tilts) ── */
.console-assembly-container {
  position: relative;
  width: 320px;
  height: 180px;
  margin: auto 0;
  transform: translateY(220px) rotateX(15deg) rotateY(-5deg);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.34, 1.45, 0.64, 1), opacity 0.35s ease;
  z-index: 4;
  transform-style: preserve-3d;
  perspective: 800px;
}

.console-assembly-container.slide-up {
  transform: translateY(10px) rotateX(8deg) rotateY(-2deg);
  opacity: 1;
}

/* Camera shake effect on cartridge impact insertion */
.console-assembly-container.shake {
  animation: consoleImpactShake 0.38s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes consoleImpactShake {
  10%, 90% { transform: translateY(10px) rotateX(8deg) rotateY(-2deg) translate3d(-1px, 1px, 0); }
  20%, 80% { transform: translateY(10px) rotateX(8deg) rotateY(-2deg) translate3d(1.5px, -1px, 0); }
  30%, 50%, 70% { transform: translateY(10px) rotateX(8deg) rotateY(-2deg) translate3d(-2px, 2px, 0); }
  40%, 60% { transform: translateY(10px) rotateX(8deg) rotateY(-2deg) translate3d(2px, -2px, 0); }
}

.console-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.console-back-layer {
  z-index: 1;
}

.console-front-layer {
  z-index: 3;
}

.console-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Cartridge (3D Fly-In & Bounces) ── */
.cinematic-cartridge-wrapper {
  position: absolute;
  bottom: 110px; /* Base bottom above slot */
  left: 50%;
  transform: translateX(-50%) translateY(-280px) scale(0.1) rotateX(65deg) rotateY(-65deg) rotateZ(45deg);
  width: 120px;
  height: 140px;
  z-index: 2; /* In between console-back-layer and console-front-layer */
  transform-origin: center bottom;
  opacity: 0;
  transition: transform 0.70s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.4s ease;
  perspective: 600px;
  transform-style: preserve-3d;
}

/* Phase 2: fly-in */
.cinematic-cartridge-wrapper.fly-in {
  opacity: 1;
  transform: translateX(-50%) translateY(-40px) scale(1) rotateX(12deg) rotateY(-8deg) rotateZ(-3deg);
}

/* Phase 3: hovering above slot */
.cinematic-cartridge-wrapper.hovering {
  opacity: 1;
  transform: translateX(-50%) translateY(-40px) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  animation: cartHoverAnim 2.4s ease-in-out infinite;
}

/* Phase 4: inserting */
.cinematic-cartridge-wrapper.inserting {
  opacity: 1;
  transform: translateX(-50%) translateY(20px) scale(0.96) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  transition: transform 0.20s cubic-bezier(0.6, -0.28, 0.735, 0.045); /* mechanical snap-drop */
}

/* Phase 7: disappear */
.cinematic-cartridge-wrapper.disappear {
  opacity: 0;
  transform: translateX(-50%) translateY(20px) scale(0.96);
  transition: opacity 0.25s ease;
}

@keyframes cartHoverAnim {
  0% { transform: translateX(-50%) translateY(-40px) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
  50% { transform: translateX(-50%) translateY(-32px) scale(1.01) rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: translateX(-50%) translateY(-40px) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
}

.cinematic-nes-cartridge {
  width: 100%;
  height: 100%;
  position: relative;
}

.cartridge-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Glossy sweep on cartridge */
.cart-shine-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 35%,
    rgba(255, 255, 255, 0.2) 42%,
    rgba(255, 255, 255, 0.45) 45%,
    rgba(255, 255, 255, 0.2) 48%,
    transparent 60%
  );
  background-size: 200% 100%;
  background-position: 150% 0;
  pointer-events: none;
  border-radius: 6px;
  mix-blend-mode: overlay;
  z-index: 10;
}

/* Shine effect trigger */
.cinematic-nes-cartridge.shining .cart-shine-overlay {
  animation: cartShineSweep 0.60s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes cartShineSweep {
  0% { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}

/* HTML content inside SVG Label */
.cart-svg-label-html {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 3px 2px;
  box-sizing: border-box;
  font-family: var(--font-retro);
  color: #fff;
  text-align: center;
  background-color: #030712;
  overflow: hidden;
}

.cart-svg-brand {
  font-size: 4px;
  line-height: 1;
  letter-spacing: 0.5px;
  color: #ef4444;
  font-weight: 900;
  text-transform: uppercase;
  margin-top: 1px;
}

.cart-svg-img {
  width: 44px;
  height: 48px;
  object-fit: cover;
  border: 1px solid #000;
  background-color: #000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.cart-svg-title {
  font-size: 4.5px;
  line-height: 1.1;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 2px;
  word-break: break-word;
  max-width: 100%;
  max-height: 20px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  text-shadow: 0.5px 0.5px 1px #000;
}

/* ── Console Buttons and LED ── */
.console-svg-btn {
  transition: transform 0.2s ease, fill 0.2s ease;
}

/* Depress power button when system has active LED */
.console-assembly-container:has(#console-power-led.blinking) #svg-power-btn,
.console-assembly-container:has(#console-power-led.on) #svg-power-btn {
  transform: translateY(1px);
  fill: url(#btn-depressed-grad) !important;
}

/* Power LED states */
#console-power-led {
  fill: #310612;
  transition: fill 0.3s ease, filter 0.3s ease;
}

#console-power-led.blinking {
  animation: svgLedBlink 0.45s infinite alternate;
}

#console-power-led.on {
  fill: #ef4444;
  filter: url(#led-red-glow);
}

@keyframes svgLedBlink {
  0% { fill: #310612; filter: none; }
  100% { fill: #ef4444; filter: url(#led-red-glow); }
}

/* Wiggle animation for controllers when active */
.console-assembly-container:has(#console-power-led.on) .kid-controller {
  animation: controllerWiggle 0.16s infinite alternate ease-in-out;
  transform-origin: center center;
}
.console-assembly-container:has(#console-power-led.on) .girl-controller {
  animation-delay: 0s;
}
.console-assembly-container:has(#console-power-led.on) .boy-controller {
  animation-delay: 0.08s;
}

@keyframes controllerWiggle {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-0.8px) rotate(3deg); }
}

/* Traveling Neon Currents on Wires */
.console-assembly-container:has(#console-power-led.on) .wire-glow {
  opacity: 0.85;
  animation: wireChargePulse 1.4s linear infinite;
  transition: opacity 0.6s ease;
}

@keyframes wireChargePulse {
  to {
    stroke-dashoffset: -32;
  }
}

/* Pulsating ambient TV Screen Glow reflected on kids & couch */
.console-assembly-container:has(#console-power-led.on) .screen-glow-group {
  opacity: 1;
  animation: screenGlowPulse 3.5s ease-in-out infinite alternate;
  transition: opacity 0.8s ease;
}

@keyframes screenGlowPulse {
  0% { opacity: 0.2; }
  25% { opacity: 0.45; }
  50% { opacity: 0.15; }
  75% { opacity: 0.5; }
  100% { opacity: 0.25; }
}

/* Dynamic Sparks Container and Sparks */
.cinematic-sparks-container {
  position: absolute;
  left: 50%;
  top: 48px; /* slot opening Y coordinate */
  transform: translateX(-50%);
  width: 160px;
  height: 10px;
  pointer-events: none;
  z-index: 15;
  overflow: visible;
}

.cinematic-spark-particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981, 0 0 15px #10b981;
  opacity: 0;
  pointer-events: none;
}

.cinematic-spark-particle.burst {
  animation: sparkBurstAnim 0.75s cubic-bezier(0.1, 0.8, 0.25, 1) forwards;
}

@keyframes sparkBurstAnim {
  0% {
    transform: translate(0, 0) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: var(--spark-dir) scale(0);
    opacity: 0;
  }
}

/* ==========================================================================
   DOWNLOAD ROMS SECTION (Collapsible panel at top of library sidebar)
   ========================================================================== */
.download-roms-section {
  border-bottom: 1px solid var(--border-glass);
  flex-shrink: 0;
}

/* Toggle Button (header row) */
.download-roms-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px 11px 18px;
  background: rgba(189, 160, 122, 0.04);
  border: none;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-gold);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: background 0.2s ease;
  gap: 6px;
}

.download-roms-toggle:hover {
  background: rgba(189, 160, 122, 0.09);
}

.download-roms-toggle-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.download-roms-chevron {
  color: var(--color-gold);
  opacity: 0.7;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.download-roms-toggle[aria-expanded="true"] .download-roms-chevron {
  transform: rotate(180deg);
}

/* Collapsible Panel */
.download-roms-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s ease,
              padding 0.3s ease;
  opacity: 0;
  padding: 0 14px;
}

.download-roms-panel.open {
  max-height: 260px;
  opacity: 1;
  padding: 8px 14px 12px 14px;
}

/* Info Note */
.download-roms-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-family: var(--font-main);
  font-size: 0.67rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0 0 10px 0;
  padding: 7px 9px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
}

.download-roms-note svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--color-gold);
  opacity: 0.75;
}

.download-roms-note code {
  font-family: var(--font-retro);
  font-size: 0.6rem;
  color: var(--color-gold);
  background: rgba(189, 160, 122, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Source Card List */
.rom-source-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rom-source-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border-glass);
  background: rgba(10, 11, 14, 0.45);
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.rom-source-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(90deg, rgba(189,160,122,0.04), transparent);
  transition: opacity 0.25s ease;
}

.rom-source-card:hover {
  background: rgba(189, 160, 122, 0.06);
  border-color: rgba(189, 160, 122, 0.35);
  transform: translateX(2px);
  box-shadow: -2px 0 0 var(--color-gold), 0 2px 12px rgba(0,0,0,0.3);
}

.rom-source-card:hover::before {
  opacity: 1;
}

/* Coloured Icon Badge */
.rom-source-icon {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Site Name and Description */
.rom-source-info {
  flex: 1;
  min-width: 0;
}

.rom-source-name {
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}

.rom-source-card:hover .rom-source-name {
  color: var(--color-gold);
}

.rom-source-desc {
  font-family: var(--font-main);
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* External link arrow */
.rom-source-arrow {
  color: var(--text-dim);
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.rom-source-card:hover .rom-source-arrow {
  opacity: 1;
  color: var(--color-gold);
  transform: translateX(0);
}.no-roms-banner {
  grid-column: span 2;
  background: rgba(189, 160, 122, 0.05);
  border: 1px dashed var(--border-glass-bright);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  /* backdrop-filter: blur(10px); - Removed for performance */
}

.no-roms-banner .banner-title {
  font-family: var(--font-retro);
  font-size: 0.65rem;
  color: var(--color-gold);
  text-shadow: 0 0 8px var(--color-gold-glow);
  letter-spacing: 0.5px;
}

.no-roms-banner p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.no-roms-banner p strong {
  color: var(--text-main);
}

.no-roms-banner .banner-instruction {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 8px 0;
}

.no-roms-banner .banner-download-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-gold);
  margin-top: 4px;
}

.no-roms-banner .banner-sources-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.no-roms-banner .banner-sources-list a {
  background: rgba(10, 11, 14, 0.5);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 8px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.no-roms-banner .banner-sources-list a:hover {
  background: rgba(189, 160, 122, 0.12);
  border-color: var(--color-gold);
  box-shadow: 0 0 10px var(--color-gold-glow);
  color: #fff;
}

/* Background Sync Status Styling */
.sync-status-container {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(189, 160, 122, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  margin: 0 20px 12px 20px;
  font-size: 0.72rem;
  color: var(--color-gold);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.sync-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(189, 160, 122, 0.15);
  border-top-color: var(--color-gold);
  border-radius: 50%;
  animation: sync-spin 1s linear infinite;
  flex-shrink: 0;
}

@keyframes sync-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   COMPLIANCE FOOTER
   ========================================================================== */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  background: var(--bg-header);
  border-top: 1px solid var(--border-glass);
  font-family: var(--font-main);
  font-size: 0.72rem;
  color: var(--text-muted);
  border-radius: 0;
  height: 36px;
  flex-shrink: 0;
  margin: 0 -16px -16px -16px;
  width: calc(100% + 32px);
  z-index: 10;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-smooth);
}

.footer-link:hover {
  color: var(--color-gold);
  text-shadow: 0 0 4px var(--color-gold-glow);
}

@media (max-width: 640px) {
  .app-footer {
    flex-direction: column;
    height: auto;
    padding: 10px;
    gap: 8px;
    text-align: center;
  }
  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
}

