:root {
      color-scheme: dark;
      /* Dark Grey Palette */
      --bg-base: #121316;
      --bg-gradient-start: #1b1c21;
      --bg-gradient-end: #090a0c;
      --forest-glow: rgba(255, 255, 255, 0.05);
      
      /* UI Theme - Flat, Solid Colors */
      --panel-bg: #141518;
      --panel-border: #2c2d33;
      --panel-border-hover: #40424a;
      --text-primary: #f3f4f6;
      --text-secondary: #9ca3af;
      --accent: #33ff33; /* Phosphor green — matches loading message */
      --accent-hover: #22cc22;
      
      --font-heading: 'Orbitron', 'Outfit', sans-serif;
      --font-body: 'Inter', sans-serif;
      --font-retro: 'VT323', monospace;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    html {
      background-color: #090a0c; /* Pre-render black background */
    }

    html, body {
      height: 100%;
      height: -webkit-fill-available;
      margin: 0;
      padding: 0;
      overflow: hidden; /* Prevent default scrollbar flashing on load */
    }

    body {
      background-color: transparent;
      color: var(--text-primary);
      font-family: var(--font-body);
      height: 100%;
      height: 100dvh;
      overflow: hidden;
      position: relative;
      -webkit-user-select: none;
      user-select: none;
      -webkit-touch-callout: none;
    }

    #bg-container {
      --bg-cloud-mult: 1.3;
      position: fixed;
      top: -10%;
      left: -10%;
      right: -10%;
      bottom: -10%;
      z-index: -8;
      pointer-events: none;
      contain: strict;
      will-change: transform;
      transform: translateZ(0);
    }

    #bg-container > div {
      transition: opacity 1.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* Optimized Intel Mac Background: Consolidates 9 full-screen animated gradient layers down to 4 primary colors, saving 45% GPU compositor overdraw */
    #bg-container.intel-mac-bg #bg-anim-red,
    #bg-container.intel-mac-bg #bg-anim-violet,
    #bg-container.intel-mac-bg #bg-anim-gold,
    #bg-container.intel-mac-bg #bg-anim-shockwave {
      display: none !important;
    }

    /* Low Power Mode Background Flattening: Smoothly fades out 8 independent layered divs to eliminate GPU fill-rate & compositing bottleneck */
    #bg-container.low-power-bg > div:not(#bg-static-grey) {
      opacity: 0 !important;
      visibility: hidden;
      transition: opacity 1.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s 1.5s;
    }
    #bg-container.low-power-bg #bg-dither-grain,
    body.low-power-active #bg-dither-grain {
      display: none !important;
    }
    #bg-container.low-power-bg #bg-static-grey {
      background-image: 
        radial-gradient(ellipse 70% 50% at 70% 30%, rgba(82, 14, 67, 0.20) 0%, transparent 70%),
        radial-gradient(ellipse 80% 45% at 35% 60%, rgba(26, 34, 94, 0.22) 0%, transparent 75%),
        radial-gradient(ellipse 65% 40% at 75% 75%, rgba(12, 61, 58, 0.16) 0%, transparent 70%),
        radial-gradient(circle at 50% 50%, #070a14 0%, #020306 100%);
    }

    /* Static Galactic Deep Base Layer (Multi-stop smoothstep easing eliminates 8-bit banding) */
    #bg-static-grey {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-image: radial-gradient(ellipse 90% 80% at 50% 50%, 
        #070a14 0%, 
        #060912 18%, 
        #05070e 38%, 
        #04050a 58%, 
        #030408 78%, 
        #020306 100%);
      z-index: -8;
      pointer-events: none;
    }

    /* Astrophotography Micro-Dither Film Grain Overlay (Breaks up 8-bit color quantization / Mach banding) */
    #bg-dither-grain {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.80' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.038'/%3E%3C/svg%3E");
      pointer-events: none;
      z-index: -2;
      opacity: 0.65;
    }

    /* Top-Right & Mid Electric Magenta / Pink Nebula Cloud (Organic multi-lobe tendrils with smoothstep stops) */
    #bg-anim-purple {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: 
        radial-gradient(ellipse 95% 38% at var(--purple-x, 70%) var(--purple-y, 30%), 
          rgba(82, 14, 67, 0.65) 0%, 
          rgba(72, 12, 59, 0.52) 20%, 
          rgba(58, 9, 47, 0.36) 42%, 
          rgba(42, 6, 34, 0.18) 65%, 
          rgba(28, 4, 22, 0.06) 84%, 
          transparent 100%),
         radial-gradient(ellipse 35% 85% at calc(var(--purple-x, 70%) + var(--purple-dx1, -15%)) calc(var(--purple-y, 30%) + var(--purple-dy1, 18%)), 
          rgba(66, 10, 53, 0.50) 0%, 
          rgba(52, 7, 41, 0.35) 28%, 
          rgba(36, 5, 28, 0.18) 58%, 
          rgba(22, 3, 17, 0.05) 82%, 
          transparent 100%),
        radial-gradient(ellipse 65% 22% at calc(var(--purple-x, 70%) + var(--purple-dx2, 12%)) calc(var(--purple-y, 70%) + var(--purple-dy2, -12%)), 
          rgba(54, 8, 43, 0.40) 0%, 
          rgba(38, 5, 30, 0.22) 38%, 
          rgba(22, 3, 17, 0.07) 72%, 
          transparent 100%);
      pointer-events: none;
      opacity: calc(0.20 * var(--bg-cloud-mult, 1.0));
    }

    /* Center & Left Cosmic Royal Indigo / Deep Blue Dust Cloud (Multi-stop smoothstep easing) */
    #bg-anim-blue {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: 
        radial-gradient(ellipse 95% 35% at var(--blue-x, 35%) var(--blue-y, 60%), 
          rgba(26, 34, 94, 0.65) 0%, 
          rgba(22, 29, 82, 0.52) 22%, 
          rgba(17, 23, 66, 0.35) 45%, 
          rgba(12, 16, 48, 0.18) 68%, 
          rgba(7, 9, 28, 0.05) 86%, 
          transparent 100%),
        radial-gradient(ellipse 38% 90% at calc(var(--blue-x, 35%) + var(--blue-dx1, 18%)) calc(var(--blue-y, 60%) + var(--blue-dy1, -15%)), 
          rgba(20, 25, 72, 0.50) 0%, 
          rgba(15, 19, 56, 0.35) 28%, 
          rgba(10, 13, 38, 0.16) 60%, 
          rgba(5, 7, 20, 0.04) 84%, 
          transparent 100%),
        radial-gradient(ellipse 55% 22% at calc(var(--blue-x, 35%) + var(--blue-dx2, -12%)) calc(var(--blue-y, 60%) + var(--blue-dy2, 12%)), 
          rgba(16, 20, 56, 0.40) 0%, 
          rgba(11, 14, 40, 0.20) 40%, 
          rgba(6, 8, 24, 0.06) 74%, 
          transparent 100%);
      pointer-events: none;
      opacity: calc(0.22 * var(--bg-cloud-mult, 1.0));
    }

    /* Bottom-Right Emerald Cyan / Teal Stardust Gas (Multi-stop smoothstep easing) */
    #bg-anim-green {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: 
        radial-gradient(ellipse 85% 32% at var(--green-x, 75%) var(--green-y, 75%), 
          rgba(12, 61, 58, 0.65) 0%, 
          rgba(10, 50, 48, 0.50) 22%, 
          rgba(7, 36, 35, 0.32) 48%, 
          rgba(5, 23, 23, 0.14) 72%, 
          transparent 100%),
        radial-gradient(ellipse 28% 85% at calc(var(--green-x, 75%) + var(--green-dx1, -16%)) calc(var(--green-y, 75%) + var(--green-dy1, -12%)), 
          rgba(8, 43, 40, 0.45) 0%, 
          rgba(6, 32, 30, 0.26) 36%, 
          rgba(4, 18, 17, 0.08) 72%, 
          transparent 100%),
        radial-gradient(ellipse 60% 20% at calc(var(--green-x, 75%) + var(--green-dx2, 12%)) calc(var(--green-y, 75%) + var(--green-dy2, 10%)), 
          rgba(6, 32, 30, 0.35) 0%, 
          rgba(4, 22, 20, 0.16) 40%, 
          transparent 100%);
      pointer-events: none;
      opacity: calc(0.18 * var(--bg-cloud-mult, 1.0));
    }

    /* Mid-Left Warm Amber / Golden Stellar Core (Multi-stop smoothstep easing) */
    #bg-anim-brown {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: 
        radial-gradient(ellipse 75% 28% at var(--brown-x, 40%) var(--brown-y, 45%), 
          rgba(72, 39, 11, 0.65) 0%, 
          rgba(58, 31, 8, 0.48) 24%, 
          rgba(42, 22, 5, 0.28) 52%, 
          rgba(24, 12, 3, 0.10) 78%, 
          transparent 100%),
        radial-gradient(ellipse 65% 20% at calc(var(--brown-x, 40%) + var(--brown-dx1, 14%)) calc(var(--brown-y, 45%) + var(--brown-dy1, -10%)), 
          rgba(52, 27, 7, 0.45) 0%, 
          rgba(36, 18, 4, 0.22) 42%, 
          transparent 100%),
        radial-gradient(ellipse 22% 80% at calc(var(--brown-x, 40%) + var(--brown-dx2, -10%)) calc(var(--brown-y, 45%) + var(--brown-dy2, 12%)), 
          rgba(41, 21, 5, 0.35) 0%, 
          rgba(26, 13, 3, 0.16) 45%, 
          transparent 100%);
      pointer-events: none;
      opacity: calc(0.18 * var(--bg-cloud-mult, 1.0));
    }

    /* Bottom-Left Bright Pink / Crimson Flare Accent (Multi-stop smoothstep easing) */
    #bg-anim-red {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: 
        radial-gradient(ellipse 80% 25% at var(--red-x, 25%) var(--red-y, 75%), 
          rgba(92, 18, 52, 0.65) 0%, 
          rgba(75, 14, 42, 0.48) 24%, 
          rgba(52, 9, 29, 0.28) 52%, 
          rgba(30, 5, 16, 0.10) 78%, 
          transparent 100%),
        radial-gradient(ellipse 22% 75% at calc(var(--red-x, 25%) + var(--red-dx1, 14%)) calc(var(--red-y, 75%) + var(--red-dy1, -14%)), 
          rgba(64, 10, 35, 0.45) 0%, 
          rgba(45, 7, 24, 0.22) 40%, 
          transparent 100%);
      pointer-events: none;
      opacity: calc(0.16 * var(--bg-cloud-mult, 1.0));
    }

    /* Deep Ultraviolet / Cosmic Violet Filament Layer (Multi-stop smoothstep easing) */
    #bg-anim-violet {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: 
        radial-gradient(ellipse 45% 95% at var(--violet-x, 50%) var(--violet-y, 40%), 
          rgba(58, 16, 88, 0.55) 0%, 
          rgba(46, 12, 70, 0.40) 26%, 
          rgba(32, 8, 50, 0.22) 55%, 
          rgba(18, 4, 28, 0.07) 80%, 
          transparent 100%),
        radial-gradient(ellipse 90% 24% at calc(var(--violet-x, 50%) + var(--violet-dx1, -18%)) calc(var(--violet-y, 40%) + var(--violet-dy1, 14%)), 
          rgba(42, 10, 68, 0.40) 0%, 
          rgba(28, 6, 46, 0.20) 42%, 
          transparent 100%);
      pointer-events: none;
      opacity: calc(0.18 * var(--bg-cloud-mult, 1.0));
    }

    /* Solar Amber & Golden Gas Flare Layer (Multi-stop smoothstep easing) */
    #bg-anim-gold {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: 
        radial-gradient(ellipse 85% 28% at var(--gold-x, 60%) var(--gold-y, 65%), 
          rgba(98, 62, 14, 0.50) 0%, 
          rgba(78, 48, 10, 0.35) 26%, 
          rgba(55, 33, 6, 0.18) 55%, 
          rgba(30, 18, 3, 0.06) 80%, 
          transparent 100%),
        radial-gradient(ellipse 26% 75% at calc(var(--gold-x, 60%) + var(--gold-dx1, 15%)) calc(var(--gold-y, 65%) + var(--gold-dy1, -16%)), 
          rgba(76, 46, 8, 0.35) 0%, 
          rgba(48, 28, 5, 0.16) 42%, 
          transparent 100%);
      pointer-events: none;
      opacity: calc(0.16 * var(--bg-cloud-mult, 1.0));
    }

    /* Deep Aquamarine & Horizon Cyan Filament Layer (Multi-stop smoothstep easing) */
    #bg-anim-cyan {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: 
        radial-gradient(ellipse 90% 28% at var(--cyan-x, 30%) var(--cyan-y, 35%), 
          rgba(10, 72, 85, 0.55) 0%, 
          rgba(7, 54, 64, 0.38) 26%, 
          rgba(5, 36, 43, 0.20) 55%, 
          rgba(3, 18, 22, 0.06) 80%, 
          transparent 100%),
        radial-gradient(ellipse 26% 85% at calc(var(--cyan-x, 30%) + var(--cyan-dx1, -14%)) calc(var(--cyan-y, 35%) + var(--cyan-dy1, 16%)), 
          rgba(6, 52, 62, 0.35) 0%, 
          rgba(4, 32, 38, 0.16) 42%, 
          transparent 100%);
      pointer-events: none;
      opacity: calc(0.18 * var(--bg-cloud-mult, 1.0));
    }

    /* Supernova Arc & Radial Shockwave Layer (Perceptual cubic falloff eliminates stepped oval rings) */
    #bg-anim-shockwave {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: 
        radial-gradient(ellipse 92% 52% at var(--shockwave-x, 48%) var(--shockwave-y, 46%), 
          rgba(65, 20, 80, 0.22) 0%, 
          rgba(56, 17, 70, 0.17) 18%, 
          rgba(45, 13, 56, 0.11) 38%, 
          rgba(32, 9, 40, 0.06) 60%, 
          rgba(18, 5, 24, 0.02) 80%, 
          transparent 100%),
        radial-gradient(ellipse 52% 88% at calc(var(--shockwave-x, 48%) + 8%) calc(var(--shockwave-y, 46%) - 8%), 
          rgba(45, 15, 65, 0.16) 0%, 
          rgba(36, 11, 52, 0.10) 28%, 
          rgba(24, 7, 36, 0.05) 58%, 
          rgba(12, 3, 18, 0.015) 82%, 
          transparent 100%);
      pointer-events: none;
      opacity: calc(0.10 * var(--bg-cloud-mult, 1.0));
    }

    /* Major Dark Cosmic Interstellar Dust Rift (Soft Feathered Dark Silhouettes) */
    #bg-anim-dust {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: radial-gradient(ellipse 50% 50% at 50% 50%, rgba(0, 0, 0, 0) 0%, transparent 100%);
      pointer-events: none;
      opacity: 0;
      display: none;
    }

    /* Secondary Fine Interstellar Dust Filaments & Pillars */
    #bg-anim-dust2 {
      position: absolute;
      width: 100%;
      height: 100%;
      background-image: radial-gradient(ellipse 50% 50% at 50% 50%, rgba(0, 0, 0, 0) 0%, transparent 100%);
      pointer-events: none;
      opacity: 0;
      display: none;
    }

    /* Background Starfield Canvas */
    #bg-starfield {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 1;
      pointer-events: none;
      contain: strict;
      will-change: transform;
      transform: translateZ(0);
    }

    /* Mid-Plane Spacecraft Canvas (Passes OVER background squares z:2 and UNDER foreground squares z:4) */
    #mid-spacecraft {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 3;
      pointer-events: none;
      contain: strict;
      will-change: transform;
      transform: translateZ(0);
    }

    /* Foreground Spacecraft Canvas (Passes OVER all floating squares) */
    #fg-spacecraft {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 5;
      pointer-events: none;
      contain: strict;
      will-change: transform;
      transform: translateZ(0);
    }

    /* Razor-Sharp Celestial Waypoint & Constellation Labels Overlay */
    #celestial-labels-layer {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      z-index: 200;
      overflow: hidden;
    }
    .celestial-label-card {
      position: absolute;
      background: rgba(10, 8, 26, 0.82);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      padding: 7px 14px 8px 14px;
      user-select: none;
      -webkit-user-select: none;
      box-sizing: border-box;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      text-rendering: optimizeLegibility;
      border: 1px solid rgba(255, 255, 255, 0.08);
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
      border-radius: 0px;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.35s ease-out;
      transform: translate3d(0, 0, 0);
      will-change: opacity, transform;
    }
    #bg-container.low-power-bg ~ #celestial-labels-layer .celestial-label-card,
    body.low-power-active .celestial-label-card {
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      background: rgba(10, 8, 26, 0.95);
    }
    .celestial-label-card.clickable {
      pointer-events: auto;
      cursor: pointer;
    }
    .celestial-label-card.visible {
      opacity: 1;
    }
    .celestial-label-name {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      font-size: 12px;
      font-weight: 700;
      line-height: 1.25;
      color: rgba(255, 255, 255, 0.95);
      letter-spacing: 0.5px;
      text-transform: uppercase;
      white-space: nowrap;
    }
    .celestial-label-sub {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      font-size: 10px;
      font-weight: 400;
      line-height: 1.2;
      color: rgba(180, 210, 255, 0.85);
      margin-top: 2px;
      white-space: nowrap;
    }

    .settings-perf-btn {
      cursor: pointer;
      outline: none;
      transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    }
    .settings-perf-btn:hover {
      background: rgba(255, 255, 255, 0.08) !important;
      border-color: rgba(0, 212, 255, 0.4) !important;
      box-shadow: 0 0 10px rgba(0, 212, 255, 0.25) !important;
    }
    .settings-eco-btn:hover {
      border-color: rgba(255, 153, 0, 0.4) !important;
      box-shadow: 0 0 10px rgba(255, 153, 0, 0.25) !important;
    }
    .settings-perf-btn:active {
      transform: scale(0.96);
    }
    .settings-square-badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 26px;
      height: 26px;
      min-width: 26px;
      border-radius: 4px;
      background: rgba(0, 240, 255, 0.18);
      border: 1px solid #00f0ff;
      color: #00f0ff;
      font-family: var(--font-retro);
      font-size: 1.15rem;
      font-weight: 700;
      line-height: 1;
      text-shadow: 0 0 6px rgba(0, 240, 255, 0.5);
      box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
      user-select: none;
      box-sizing: border-box;
      transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
      cursor: default;
      flex-shrink: 0;
    }
    .settings-square-badge:hover {
      background: rgba(0, 240, 255, 0.28);
      box-shadow: 0 0 12px rgba(0, 240, 255, 0.45);
    }

    @keyframes bgPulseMagenta {
      0% { opacity: 0.30; }
      100% { opacity: 0.38; }
    }
    @keyframes bgPulseIndigo {
      0% { opacity: 0.35; }
      100% { opacity: 0.43; }
    }
    @keyframes bgPulseCyan {
      0% { opacity: 0.25; }
      100% { opacity: 0.33; }
    }
    @keyframes bgPulseAmber {
      0% { opacity: 0.28; }
      100% { opacity: 0.36; }
    }
    @keyframes bgPulseCrimson {
      0% { opacity: 0.22; }
      100% { opacity: 0.30; }
    }
    @keyframes bgPulseViolet {
      0% { opacity: 0.28; }
      100% { opacity: 0.36; }
    }
    @keyframes bgPulseGold {
      0% { opacity: 0.25; }
      100% { opacity: 0.33; }
    }
    @keyframes bgPulseHorizonCyan {
      0% { opacity: 0.28; }
      100% { opacity: 0.36; }
    }
    @keyframes bgPulseShockwave {
      0% { opacity: 0.18; }
      100% { opacity: 0.24; }
    }
    @keyframes bgPulseDust {
      0% { opacity: 0.45; }
      100% { opacity: 0.55; }
    }

    @keyframes bgPulseDust2 {
      0% { opacity: 0.35; }
      100% { opacity: 0.45; }
    }

    .square-trail {
      position: absolute;
      width: 100px;
      height: 100px;
      border-radius: 0;
      pointer-events: none;
      opacity: 0.02;
      z-index: 1;
      contain: strict;
      will-change: opacity, scale;
      transform: translate3d(0, 0, 0);
      backface-visibility: hidden;
      -webkit-backface-visibility: hidden;
    }

    /* Containers for floating squares (Root stacking context with explicit depth) */
    #canvas-container,
    #canvas-container-bg,
    #canvas-container-fg {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none; /* Pass clicks through to elements below (e.g. soccer ball) */
    }

    #canvas-container-bg {
      z-index: 2;
    }

    #canvas-container-fg {
      z-index: 4;
    }

    /* Square elements */
    .square {
      position: absolute;
      width: 100px;
      height: 100px;
      border-radius: 0;
      cursor: grab;
      will-change: translate;
      transform: translate3d(0, 0, 0);
      backface-visibility: hidden;
      -webkit-backface-visibility: hidden;
      contain: layout style paint;
      transition: box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
      border: none;
      pointer-events: auto; /* Re-enable interaction on individual squares */
    }

    .square:active, .square.is-dragging {
      cursor: grabbing;
      z-index: 100 !important;
    }

    .square:hover {
      box-shadow: 0 5px 12px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.3);
      z-index: 100 !important; /* Bring hovered square to front */
    }

    .square.loading-active {
      transition: none !important;
      animation: loadPulseFast 0.6s infinite ease-in-out !important;
    }
    @keyframes loadPulseFast {
      0%, 100% {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
      }
      50% {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
        outline: 1px solid rgba(255, 255, 255, 0.40);
      }
    }

    /* Subtle glitch animation */
    .glitch-effect {
      animation: glitch-anim 0.3s steps(2, end);
    }

    /* Intense ready-to-play visualizer glitch */
    .glitch-play {
      animation: glitchPlayAnim 0.1s steps(3, end) !important;
    }

    /* Retro CRT TV turn-off collapse animation */
    .tv-off {
      animation: tv-turn-off 0.5s cubic-bezier(0.25, 1, 0.3, 1) forwards !important;
      transform-origin: center center !important;
      pointer-events: none; /* prevent drag/interaction during collapse */
    }

    @keyframes tv-turn-off {
      0% {
        transform: var(--tv-translate, translateY(0)) scale(1, 1);
        opacity: 1;
        filter: brightness(1) contrast(1);
      }
      /* Collapse vertically snap-fast to a horizontal line */
      40% {
        transform: var(--tv-translate, translateY(0)) scale(1, 0.03);
        opacity: 1;
        filter: brightness(2.5) contrast(1.5);
      }
      /* Collapse horizontally snap-fast to a center pinpoint dot */
      80% {
        transform: var(--tv-translate, translateY(0)) scale(0.03, 0.03);
        opacity: 0.95;
        filter: brightness(4);
      }
      100% {
        transform: var(--tv-translate, translateY(0)) scale(0, 0);
        opacity: 0;
        filter: brightness(0);
      }
    }

    @keyframes marquee {
      0%, 15% {
        transform: translate3d(0, 0, 0);
      }
      85%, 100% {
        transform: translate3d(var(--marquee-distance, 0px), 0, 0);
      }
    }

    @keyframes glitch-anim {
      0% {
        clip-path: inset(10% 0 85% 0);
        transform: translate(-2px, -1px);
      }
      10% {
        clip-path: inset(80% 0 5% 0);
        transform: translate(2px, 1px);
      }
      20% {
        clip-path: inset(40% 0 45% 0);
        transform: translate(-1px, 2px);
      }
      30% {
        clip-path: inset(70% 0 10% 0);
        transform: translate(1px, -2px);
      }
      40% {
        clip-path: inset(5% 0 80% 0);
        transform: translate(-2px, 1px);
      }
      50% {
        clip-path: inset(85% 0 5% 0);
        transform: translate(2px, -1px);
      }
      60% {
        clip-path: inset(30% 0 60% 0);
        transform: translate(-1px, -2px);
      }
      70% {
        clip-path: inset(60% 0 30% 0);
        transform: translate(2px, 1px);
      }
      80% {
        clip-path: inset(15% 0 75% 0);
        transform: translate(-2px, -1px);
      }
      90% {
        clip-path: inset(75% 0 15% 0);
        transform: translate(1px, 2px);
      }
    }

    @keyframes glitchPlayAnim {
      0% {
        clip-path: inset(40% 0 30% 0);
        transform: skewX(-12deg) scale(1.1);
        filter: hue-rotate(90deg) brightness(1.8) contrast(1.5);
      }
      33% {
        clip-path: inset(10% 0 70% 0);
        transform: skewX(15deg) scaleY(0.9);
        filter: hue-rotate(-60deg) brightness(2.0) saturate(2);
      }
      66% {
        clip-path: inset(60% 0 10% 0);
        transform: skewX(-5deg) scaleX(1.2);
        filter: hue-rotate(180deg) contrast(2) brightness(1.5);
      }
      100% {
        clip-path: none;
        transform: none;
        filter: none;
      }
    }

    /* Artwork Overlay for smooth fade-in/out transitions */
    .artwork-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      box-sizing: border-box;
      opacity: 0;
      transition: opacity 0.4s ease;
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
      pointer-events: none; /* Let clicks pass through to the square */
      contain: strict;
      transform: translate3d(0, 0, 0);
      backface-visibility: hidden;
      -webkit-backface-visibility: hidden;
    }

    /* Flat Control Dashboard with Sharp Corners */
    .dashboard {
      position: fixed;
      bottom: 2rem;
      left: 50%;
      transform: translate(-50%, 20px);
      z-index: 10;
      background: var(--panel-bg);
      border: 1px solid var(--panel-border);
      border-radius: 0;
      padding: 1.5rem 2rem;
      width: 90%;
      max-width: 760px;
      max-height: calc(100vh - 4rem);
      max-height: calc(100dvh - 4rem);
      overflow-y: auto;
      overflow-x: hidden;
      box-sizing: border-box;
      -webkit-overflow-scrolling: touch;
      touch-action: pan-y;
      overscroll-behavior: contain;
      scrollbar-width: thin;
      scrollbar-color: rgba(0, 240, 255, 0.3) rgba(0, 0, 0, 0.2);
      box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
      display: flex;
      flex-direction: column;
      gap: 1.25rem;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.5s, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease, box-shadow 0.3s ease;
    }

    .dashboard::-webkit-scrollbar {
      width: 6px;
    }

    .dashboard::-webkit-scrollbar-track {
      background: rgba(0, 0, 0, 0.25);
    }

    .dashboard::-webkit-scrollbar-thumb {
      background: rgba(0, 240, 255, 0.25);
      border-radius: 0;
    }

    .dashboard::-webkit-scrollbar-thumb:hover {
      background: rgba(0, 240, 255, 0.55);
    }

    .dashboard.visible {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transform: translate(-50%, 0);
      z-index: 100;
    }

    .dashboard.glitch-effect {
      animation: dashboard-glitch 0.3s steps(2, end) !important;
    }

    @keyframes dashboard-glitch {
      0% {
        clip-path: inset(10% 0 85% 0);
        transform: translate(calc(-50% - 2px), -1px);
      }
      10% {
        clip-path: inset(80% 0 5% 0);
        transform: translate(calc(-50% + 2px), 1px);
      }
      20% {
        clip-path: inset(40% 0 45% 0);
        transform: translate(calc(-50% - 1px), 2px);
      }
      30% {
        clip-path: inset(70% 0 10% 0);
        transform: translate(calc(-50% + 1px), -2px);
      }
      40% {
        clip-path: inset(5% 0 80% 0);
        transform: translate(calc(-50% - 2px), 1px);
      }
      50% {
        clip-path: inset(85% 0 5% 0);
        transform: translate(calc(-50% + 2px), -1px);
      }
      60% {
        clip-path: inset(30% 0 60% 0);
        transform: translate(calc(-50% - 1px), -2px);
      }
      70% {
        clip-path: inset(60% 0 30% 0);
        transform: translate(calc(-50% + 2px), 1px);
      }
      80% {
        clip-path: inset(15% 0 75% 0);
        transform: translate(calc(-50% - 2px), -1px);
      }
      90% {
        clip-path: inset(50% 0 35% 0);
        transform: translate(calc(-50% + 1px), 2px);
      }
      100% {
        clip-path: inset(0 0 0 0);
        transform: translate(-50%, 0);
      }
    }

    .dashboard.tv-off {
      --tv-translate: translate(-50%, 0);
      animation: tv-turn-off 0.5s cubic-bezier(0.25, 1, 0.3, 1) forwards !important;
      pointer-events: none;
    }

    .dashboard:hover {
      border-color: var(--panel-border-hover);
      box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7);
    }

    .dashboard-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid rgba(0, 240, 255, 0.18);
      padding-bottom: 0.75rem;
    }

    .dashboard-title-row {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      width: 100%;
      gap: 0.5rem;
    }

    .dashboard-title {
      display: flex;
      align-items: flex-start;
      gap: 0.55rem;
      flex: 1 1 auto;
      min-width: 0;
    }

    .dashboard-title-icon {
      width: 19px;
      height: 19px;
      flex-shrink: 0;
      display: block;
      pointer-events: none;
      filter: drop-shadow(0 0 6px rgba(0, 240, 255, 0.45));
      margin-top: calc((1.65rem * 1.1 - 19px) / 2);
    }

    .dashboard-title-text {
      display: inline;
      line-height: 1.1;
    }

    .dashboard-title h1 {
      margin: 0;
      font-family: var(--font-retro);
      font-size: 1.65rem;
      font-weight: 400;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: #00f0ff;
      text-shadow: 0 0 10px rgba(0, 240, 255, 0.45);
      line-height: 1.1;
      display: inline;
    }

    #settings-version-badge {
      font-size: 1.05rem;
      font-family: var(--font-retro);
      color: var(--text-secondary);
      opacity: 0.75;
      user-select: none;
      line-height: 1;
      margin-left: 0.35rem;
      display: inline-block;
      vertical-align: 0.12em;
      white-space: nowrap;
    }

    .dashboard-header-actions {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      height: calc(1.65rem * 1.1);
      align-self: flex-start;
      flex-shrink: 0;
    }

    .dashboard-header-right {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 0.5rem;
      width: 100%;
    }

    .dashboard-perf-group {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 0.45rem;
      flex-wrap: wrap;
      flex: 1 1 auto;
      min-width: 0;
    }



    .parameters-container {
      width: 100%;
    }

    .parameters-toggle {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      background: rgba(0, 0, 0, 0.4);
      border: 1px solid rgba(0, 240, 255, 0.2);
      border-radius: 4px;
      color: var(--text-secondary);
      padding: 0.45rem 0.75rem;
      font-size: 1.15rem;
      font-weight: 400;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      font-family: var(--font-retro);
      cursor: pointer;
      user-select: none;
      transition: background 0.2s, border-color 0.2s, color 0.2s;
    }

    .parameters-toggle:hover {
      background: rgba(0, 240, 255, 0.1);
      border-color: rgba(0, 240, 255, 0.4);
      color: var(--text-primary);
    }

    .parameters-toggle.open {
      background: rgba(0, 240, 255, 0.08);
      border-color: rgba(0, 240, 255, 0.35);
      color: #00f0ff;
    }

    .parameters-chevron {
      width: 13px;
      height: 13px;
      transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .parameters-toggle.open .parameters-chevron {
      transform: rotate(180deg);
    }

    .parameters-content {
      display: none;
      padding-top: 0.85rem;
      margin-bottom: 0.25rem;
    }

    .parameters-content.open {
      display: block;
      animation: fadeInParams 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes fadeInParams {
      from { opacity: 0; transform: translateY(-4px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .controls-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 1rem;
      align-items: center;
    }

    .parameters-actions {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      margin-top: 1rem;
      padding-top: 0.75rem;
      border-top: 1px dashed rgba(0, 240, 255, 0.18);
    }

    .btn-reset-params {
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      background: rgba(0, 0, 0, 0.45);
      border: 1px solid rgba(0, 240, 255, 0.25);
      border-radius: 4px;
      color: var(--text-secondary);
      font-size: 0.72rem;
      font-weight: 600;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      font-family: monospace;
      padding: 0.35rem 0.65rem;
      cursor: pointer;
      user-select: none;
      transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.1s;
    }

    .btn-reset-params:hover {
      background: rgba(0, 240, 255, 0.12);
      border-color: rgba(0, 240, 255, 0.5);
      color: #00f0ff;
    }

    .btn-reset-params:active {
      transform: scale(0.96);
    }

    #btn-play-pause {
      min-width: 80px;
    }

    .control-item {
      display: flex;
      flex-direction: column;
      gap: 0.45rem;
      padding: 0.25rem 0;
    }

    .control-label {
      font-family: var(--font-retro);
      font-size: 1.05rem;
      font-weight: 400;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-secondary);
      user-select: none;
    }

    /* Custom Range Slider - Generous touch hit target & vibrant thumb */
    .slider {
      -webkit-appearance: none;
      appearance: none;
      width: 100%;
      height: 8px;
      border-radius: 4px;
      background: rgba(0, 240, 255, 0.18);
      outline: none;
      padding: 10px 0;
      margin: -6px 0;
      box-sizing: content-box;
      cursor: pointer;
      touch-action: pan-y;
      transition: background 0.3s;
    }

    .slider:hover {
      background: rgba(0, 240, 255, 0.28);
    }

    .slider::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 22px;
      height: 22px;
      border-radius: 4px;
      background: #00f0ff;
      cursor: pointer;
      border: 1px solid #00f0ff;
      box-shadow: 0 0 8px rgba(0, 240, 255, 0.45);
      transition: transform 0.12s ease, background-color 0.2s, box-shadow 0.2s;
    }

    .slider::-webkit-slider-thumb:hover {
      transform: scale(1.18);
      background: #e0ffff;
      box-shadow: 0 0 12px rgba(0, 240, 255, 0.75);
    }

    .slider::-webkit-slider-thumb:active {
      transform: scale(1.25);
      background: #ffffff;
      box-shadow: 0 0 16px rgba(0, 240, 255, 0.95);
    }

    .slider::-moz-range-thumb {
      width: 22px;
      height: 22px;
      border-radius: 4px;
      background: #00f0ff;
      cursor: pointer;
      border: 1px solid #00f0ff;
      box-shadow: 0 0 8px rgba(0, 240, 255, 0.45);
      transition: transform 0.12s ease, background-color 0.2s, box-shadow 0.2s;
    }

    .slider::-moz-range-thumb:hover {
      transform: scale(1.18);
      background: #e0ffff;
      box-shadow: 0 0 12px rgba(0, 240, 255, 0.75);
    }

    .slider::-moz-range-thumb:active {
      transform: scale(1.25);
      background: #ffffff;
      box-shadow: 0 0 16px rgba(0, 240, 255, 0.95);
    }

    .slider::-moz-range-track {
      width: 100%;
      height: 8px;
      border-radius: 4px;
      background: rgba(0, 240, 255, 0.18);
      border: none;
    }

    @media (pointer: coarse) {
      .slider {
        padding: 14px 0;
        margin: -8px 0;
      }
      .slider::-webkit-slider-thumb {
        width: 26px;
        height: 26px;
        border-radius: 5px;
        box-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
      }
      .slider::-moz-range-thumb {
        width: 26px;
        height: 26px;
        border-radius: 5px;
        box-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
      }
    }

    /* Flat Buttons with Sharp Corners */
    .btn {
      background: rgba(0, 240, 255, 0.08);
      border: 1px solid rgba(0, 240, 255, 0.25);
      color: var(--text-primary);
      padding: 0.5rem 1rem;
      border-radius: 0;
      font-family: var(--font-body);
      font-size: 0.8rem;
      font-weight: 600;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
      box-sizing: border-box;
      transform: none;
      transition: background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @media (hover: hover) and (pointer: fine) {
      .btn:hover:not(:disabled):not(.active) {
        background: rgba(0, 240, 255, 0.16);
        border-color: rgba(0, 240, 255, 0.45);
        color: #00f0ff;
      }
    }

    .btn:focus,
    .btn:focus-visible,
    .btn-hotkey:focus,
    .btn-hotkey:focus-visible {
      outline: none;
    }

    .btn-primary {
      background: #00f0ff;
      border: 1px solid #00f0ff;
      color: #000000;
    }

    @media (hover: hover) and (pointer: fine) {
      .btn-primary:hover {
        background: #00f0ff;
        color: #000000;
      }
    }

    .btn-danger {
      background: rgba(239, 68, 68, 0.1);
      border-color: rgba(239, 68, 68, 0.3);
      color: #fca5a5;
    }

    @media (hover: hover) and (pointer: fine) {
      .btn-danger:hover {
        background: rgba(239, 68, 68, 0.2);
        border-color: rgba(239, 68, 68, 0.5);
      }
    }

    .dbg-header-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 26px;
      height: 26px;
      border-radius: 4px;
      background: rgba(0, 240, 255, 0.08);
      border: 1px solid rgba(0, 240, 255, 0.35);
      color: #00f0ff;
      cursor: pointer;
      padding: 0;
      flex-shrink: 0;
      pointer-events: auto;
      transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    }
    .dbg-header-btn:hover {
      background: rgba(0, 240, 255, 0.20) !important;
      border-color: #00f0ff !important;
      box-shadow: 0 0 8px rgba(0, 240, 255, 0.4) !important;
      color: #ffffff !important;
    }
    .dbg-header-btn:active {
      transform: scale(0.94);
    }
    .dbg-header-btn.active {
      background: rgba(0, 240, 255, 0.25) !important;
      border-color: #00f0ff !important;
      color: #00f0ff !important;
      box-shadow: 0 0 12px rgba(0, 240, 255, 0.35) !important;
    }

    #agy-debug-panel {
      max-height: calc(100vh - 20px);
      max-height: calc(100dvh - 20px);
      box-sizing: border-box;
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }

    #agy-debug-panel.glitch-effect {
      animation: debugger-glitch 0.3s steps(2, end) !important;
    }

    @keyframes debugger-glitch {
      0% {
        clip-path: inset(10% 0 85% 0);
        transform: translate(-2px, -1px);
      }
      10% {
        clip-path: inset(80% 0 5% 0);
        transform: translate(2px, 1px);
      }
      20% {
        clip-path: inset(40% 0 45% 0);
        transform: translate(-1px, 2px);
      }
      30% {
        clip-path: inset(70% 0 10% 0);
        transform: translate(1px, -2px);
      }
      40% {
        clip-path: inset(5% 0 80% 0);
        transform: translate(-2px, 1px);
      }
      50% {
        clip-path: inset(85% 0 5% 0);
        transform: translate(2px, -1px);
      }
      60% {
        clip-path: inset(30% 0 60% 0);
        transform: translate(-1px, -2px);
      }
      70% {
        clip-path: inset(60% 0 30% 0);
        transform: translate(2px, 1px);
      }
      80% {
        clip-path: inset(15% 0 75% 0);
        transform: translate(-2px, -1px);
      }
      90% {
        clip-path: inset(50% 0 35% 0);
        transform: translate(1px, 2px);
      }
      100% {
        clip-path: inset(0 0 0 0);
        transform: translate(0, 0);
      }
    }

    #agy-debug-panel.tv-off {
      transform-origin: center center !important;
      animation: tv-turn-off 0.5s cubic-bezier(0.25, 1, 0.3, 1) forwards !important;
      pointer-events: none;
    }

    #dbg-header {
      position: sticky;
      top: 0;
      z-index: 10;
      background: rgba(0, 0, 0, 0.95);
      border-bottom: 1px solid rgba(0, 255, 0, 0.25);
      flex-shrink: 0;
    }

    #dbg-body {
      overflow-y: auto;
      overflow-x: hidden;
      flex: 1 1 auto;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
      scrollbar-width: thin;
      scrollbar-color: rgba(51, 255, 51, 0.35) rgba(0, 0, 0, 0.2);
    }

    #dbg-body::-webkit-scrollbar {
      width: 6px;
    }

    #dbg-body::-webkit-scrollbar-track {
      background: rgba(0, 0, 0, 0.25);
    }

    #dbg-body::-webkit-scrollbar-thumb {
      background: rgba(51, 255, 51, 0.25);
      border-radius: 0;
    }

    #dbg-body::-webkit-scrollbar-thumb:hover {
      background: rgba(51, 255, 51, 0.55);
    }

    #agy-debug-panel details summary {
      color: #00f0ff;
    }
    #agy-debug-panel details summary::marker {
      color: #33ff33 !important;
      text-shadow: 0 0 8px rgba(51, 255, 51, 0.6);
    }
    #agy-debug-panel details summary::-webkit-details-marker {
      color: #33ff33 !important;
    }

    #btn-zen-mode.active,
    #btn-hotkey-w.active,
    .btn.active {
      background: rgba(0, 240, 255, 0.25) !important;
      border-color: #00f0ff !important;
      color: #00f0ff !important;
      box-shadow: 0 0 12px rgba(0, 240, 255, 0.35) !important;
    }

    #btn-debugger.active {
      background: rgba(51, 255, 51, 0.25) !important;
      border-color: #33ff33 !important;
      color: #33ff33 !important;
      box-shadow: 0 0 12px rgba(51, 255, 51, 0.35) !important;
    }

    @media (hover: hover) and (pointer: fine) {
      .dbg-header-btn.active:hover,
      #btn-debugger.active:hover {
        background: rgba(51, 255, 51, 0.32) !important;
        border-color: #33ff33 !important;
        box-shadow: 0 0 14px rgba(51, 255, 51, 0.45) !important;
      }
      #btn-zen-mode.active:hover,
      #btn-hotkey-w.active:hover,
      .btn.active:hover {
        background: rgba(0, 240, 255, 0.32) !important;
        border-color: #00f0ff !important;
        box-shadow: 0 0 14px rgba(0, 240, 255, 0.45) !important;
      }
    }

    .btn-hotkey {
      min-width: 2.2rem;
      height: 2.2rem;
      padding: 0 0.5rem;
      font-family: 'Space Mono', 'Courier New', monospace, var(--font-body);
      font-weight: 700;
      font-size: 0.85rem;
      text-transform: uppercase;
      letter-spacing: 0;
      box-sizing: border-box;
      transform: none !important;
    }

    .btn:disabled,
    .btn[disabled] {
      opacity: 0.3;
      cursor: not-allowed;
      pointer-events: none;
      transform: none !important;
      background: rgba(0, 240, 255, 0.03);
      border-color: rgba(0, 240, 255, 0.1);
      color: rgba(255, 255, 255, 0.3);
      box-shadow: none;
    }

    /* Custom Toggle Switch - Flat & Sharp */
    .switch-container {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      cursor: pointer;
    }

    .switch {
      position: relative;
      display: inline-block;
      width: 40px;
      height: 20px;
    }

    .switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .switch-slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(0, 240, 255, 0.15);
      transition: .3s;
      border-radius: 0;
      border: 1px solid rgba(0, 240, 255, 0.2);
    }

    .switch-slider:before {
      position: absolute;
      content: "";
      height: 12px;
      width: 12px;
      left: 3px;
      bottom: 3px;
      background-color: #00f0ff;
      transition: .3s;
      border-radius: 0;
    }

    input:checked + .switch-slider {
      background-color: rgba(0, 240, 255, 0.4);
    }

    input:checked + .switch-slider:before {
      transform: translateX(20px);
      background-color: #00f0ff;
    }

    /* Live Counter */
    .counter {
      background: rgba(0, 0, 0, 0.2);
      padding: 0.25rem 0.5rem;
      border-radius: 0;
      font-family: monospace;
      font-size: 0.85rem;
      border: 1px solid rgba(0, 240, 255, 0.2);
      color: #00f0ff;
    }

    /* Song Indicator in Lower Right Corner */
    .song-indicator {
      position: absolute;
      bottom: 2rem;
      right: 2rem;
      z-index: 10;
      font-family: var(--font-body);
      font-size: 0.8rem;
      font-weight: 700;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: #00f0ff;
      pointer-events: none;
      opacity: 0;
      transform: translateY(5px);
      transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
      text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
      user-select: none;
      max-width: calc(100vw - 8rem);
      display: flex;
      align-items: center;
      height: 32px;
      gap: 0.5rem;
      contain: layout style;
      isolation: isolate;
      transform: translateZ(0);
    }

    #song-info-wrapper {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      justify-content: center;
      flex-grow: 1;
      height: 32px;
      min-width: 0;
      overflow: hidden;
      gap: 2px;
      padding-top: 0;
    }

    #song-progress-container {
      height: 16px;
      background: transparent;
      border-radius: 2px;
      width: 100%;
      transition: width 0.2s ease;
      /* Re-enable pointer events so seek clicks work */
      pointer-events: all;
      cursor: pointer;
      position: relative;
      display: flex;
      align-items: center;
    }

    /* Visual track background — 2px, grows to 4px on hover */
    #song-progress-container::before {
      content: '';
      position: absolute;
      left: 0;
      right: 0;
      height: 2px;
      background-color: rgba(255, 255, 255, 0.12);
      border-radius: 2px;
      transition: height 0.15s ease;
      pointer-events: none;
    }

    #song-progress-container:hover::before,
    #song-progress-container:active::before {
      height: 4px;
    }

    #song-progress-bar {
      height: 2px;
      width: 0%;
      background-color: currentColor;
      transition: width 0.1s linear, height 0.15s ease;
      border-radius: 2px;
      position: relative;
      z-index: 1;
    }

    #song-progress-container:hover #song-progress-bar,
    #song-progress-container:active #song-progress-bar {
      height: 4px;
    }

    #song-title-container {
      width: 100%;
      overflow: hidden;
      white-space: nowrap;
      display: flex;
      justify-content: flex-end;
      position: relative;
      align-items: center;
    }

    #song-title-text {
      pointer-events: auto;
      cursor: pointer;
      transition: opacity 0.2s ease;
      display: inline-block;
      white-space: nowrap;
    }

    #song-title-text:hover {
      opacity: 0.85;
    }

    .song-indicator.visible {
      opacity: 0.75;
      transform: translateY(0);
    }

    /* Tiny loading spinner inside song indicator - rotating square */
    .song-spinner {
      width: 14px;
      height: 14px;
      border: 2px solid currentColor;
      border-radius: 0;
      animation: spin 0.6s linear infinite;
      display: none;
      flex-shrink: 0;
    }

    .song-spinner.show {
      display: inline-block;
    }

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

    /* Retro Green-Screen Terminal Typewriter Overlay */
    .slow-connection-overlay {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: 50;
      pointer-events: none;
      background: transparent;
      border: none;
      display: inline-flex;
      align-items: center;
      justify-content: flex-start;
      width: 22ch;
      white-space: nowrap;
      font-family: 'Courier New', 'VT323', 'Space Mono', monospace, var(--font-body);
      font-size: 1.15rem;
      font-weight: 700;
      letter-spacing: 0.16em;
      color: #33ff33;
      text-shadow: 0 0 4px #33ff33, 0 0 10px #33ff33, 0 0 18px rgba(51, 255, 51, 0.75);
      opacity: 0;
      transition: opacity 0.5s ease-in-out;
      box-sizing: border-box;
    }

    .slow-connection-overlay.visible {
      opacity: 1;
      transform: translate(-50%, -50%);
    }

    /* Retro CRT TV turn-off collapse animation for slow connection loading overlay */
    .slow-connection-overlay.tv-off {
      --tv-translate: translate(-50%, -50%);
      animation: tv-turn-off 0.5s cubic-bezier(0.25, 1, 0.3, 1) forwards !important;
      pointer-events: none;
    }

    .slow-conn-cursor {
      display: inline-block;
      width: 0.65em;
      height: 1.15em;
      background-color: #33ff33;
      box-shadow: 0 0 6px #33ff33, 0 0 14px rgba(51, 255, 51, 0.9);
      vertical-align: middle;
      margin-left: 4px;
      flex-shrink: 0;
      animation: retroCursorBlink 0.7s step-start infinite;
    }

    @keyframes retroCursorBlink {
      0%, 100% { opacity: 1; }
      50% { opacity: 0; }
    }

    /* Flat song toggle buttons with sharp corners */
    .song-toggle-btn {
      background: none;
      border: none;
      color: inherit;
      cursor: pointer;
      font-size: 0.9rem;
      line-height: 1;
      padding: 0;
      pointer-events: auto;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
      width: 32px;
      height: 32px;
      border-radius: 0;
      background-color: #24262d;
      border: 1px solid #383a45;
      opacity: 0.7;
      flex-shrink: 0;
      outline: none;
    }

    .song-toggle-btn svg {
      width: 16px;
      height: 16px;
      display: block;
      pointer-events: none;
    }

    .song-toggle-btn:hover {
      opacity: 1;
      transform: scale(1.1);
      background-color: #343742;
      border-color: #4b4f5e;
    }

    .song-toggle-btn:active {
      transform: scale(0.95);
    }

    .song-continuous-btn {
      font-size: 1.25rem; /* Make infinity symbol fit the visual weight of other buttons */
      line-height: 1;
      letter-spacing: 0; /* Remove inherited tracking to center symbol without right offset */
      padding: 0;
      box-sizing: border-box;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .song-continuous-btn svg {
      width: 16px;
      height: 16px;
      display: block;
      pointer-events: none;
    }

    .song-continuous-btn.active {
      opacity: 0.85;
      background-color: #2c2d33;
      border-color: currentColor;
    }

    .song-continuous-btn.active:hover {
      opacity: 1;
      background-color: #3f424c;
      border-color: currentColor;
    }

    /* Zen-Only State for Song Indicator when playback is stopped / no track active in Zen Mode */
    .song-indicator.zen-only {
      width: auto !important;
      max-width: none !important;
      height: 32px !important;
      gap: 0 !important;
      justify-content: flex-end;
      color: #00f0ff !important;
    }

    .song-indicator.zen-only #song-info-wrapper,
    .song-indicator.zen-only #song-toggle-btn {
      display: none !important;
    }

    .song-indicator.zen-only #song-continuous-btn {
      color: #00f0ff;
      border-color: #383a45;
      background-color: #24262d;
      opacity: 0.7;
    }

    .song-indicator.zen-only #song-continuous-btn:hover {
      opacity: 1;
      transform: scale(1.1);
      background-color: #343742;
      border-color: #4b4f5e;
    }

    /* Info container and flat popover modal */
    .info-container {
      position: absolute;
      bottom: 2rem;
      left: 2rem;
      z-index: 10;
      display: flex;
      align-items: center;
      pointer-events: none;
      color: #00f0ff; /* 80s terminal white-blue */
    }

    .info-container.active,
    .info-container:has(.info-modal.visible),
    .info-container:has(.info-modal.tv-off) {
      z-index: 100;
    }

    #info-btn {
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.4s ease-in-out, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease, border-color 0.2s ease;
      font-weight: 600;
      font-size: 1.1rem;
    }

    #info-btn.ready {
      opacity: 0.7;
      pointer-events: auto;
    }

    #info-btn.ready:hover {
      opacity: 1;
    }

    #info-btn.playing {
      border-color: var(--help-btn-color, #00f0ff);
      color: var(--help-btn-color, #00f0ff);
      box-shadow: 0 0 10px var(--help-btn-glow, rgba(0, 240, 255, 0.4)), inset 0 0 4px var(--help-btn-glow, rgba(0, 240, 255, 0.2));
      opacity: 0.95;
    }

    #info-btn .eq-icon {
      width: 16px;
      height: 16px;
      display: block;
      pointer-events: none;
    }

    #info-btn .eq-bar {
      transition: height 0.05s ease, y 0.05s ease;
    }

    @keyframes spin-slow {
      from { transform: scale(1.1) rotate(0deg); }
      to { transform: scale(1.1) rotate(360deg); }
    }

    @keyframes spin-fast {
      from { transform: scale(1.1) rotate(0deg); }
      to { transform: scale(1.1) rotate(360deg); }
    }

    @keyframes drop-bounce {
      0% {
        opacity: 0;
        transform: translate(15px, -100vh);
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      10% {
        opacity: 0.6;
      }
      38% {
        transform: translate(6px, 0);
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      55% {
        transform: translate(3px, -50px);
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      70% {
        transform: translate(1px, 0);
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      82% {
        transform: translate(0, -18px);
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      90% {
        transform: translate(0, 0);
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      95% {
        transform: translate(0, -5px);
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      100% {
        opacity: 0.6;
        transform: translate(0, 0);
      }
    }

    /* ========================================================================= */
    /* GLOBAL APP NAVIGATION COMPONENT (Upper RH Corner)                          */
    /* ========================================================================= */
    .app-nav-container {
      position: absolute;
      top: 2rem;
      right: 2rem;
      z-index: 10;
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      pointer-events: auto;
      color: #00f0ff;
      transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .app-nav-container.ball-present {
      transform: translateY(26px);
      transition: transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.25);
    }

    .app-nav-container.active,
    .app-nav-container:has(.app-nav-modal.visible),
    .app-nav-container:has(.app-nav-modal.tv-off) {
      z-index: 100;
    }

    #app-nav-btn,
    .app-nav-btn {
      position: relative;
      cursor: pointer;
      color: #00f0ff;
      border: 1px solid #383a45;
      background-color: #24262d;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.4s ease-in-out, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
      outline: none;
      width: 32px;
      height: 32px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      flex-shrink: 0;
      user-select: none;
    }

    #app-nav-btn.ready,
    .app-nav-btn.ready {
      opacity: 0.7;
      pointer-events: auto;
    }

    #app-nav-btn.ready:hover,
    .app-nav-btn.ready:hover,
    .app-nav-btn:hover {
      opacity: 1;
      transform: scale(1.1);
      background-color: #343742;
      border-color: #4b4f5e;
      box-shadow: 0 0 10px rgba(0, 240, 255, 0.35);
    }

    .app-nav-btn:active {
      transform: scale(0.95);
    }

    .app-nav-btn.active {
      opacity: 1;
      border-color: #00f0ff;
      color: #00f0ff;
      background-color: #2c2d33;
      box-shadow: 0 0 12px rgba(0, 240, 255, 0.45);
    }

    .app-nav-btn svg {
      width: 15px;
      height: 15px;
      display: block;
      pointer-events: none;
    }

    /* Popover Modal / Dropdown Menu */
    .app-nav-modal {
      position: absolute;
      top: calc(100% + 0.6rem);
      right: 0;
      z-index: 11;
      background: var(--panel-bg, rgba(22, 27, 44, 0.94));
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border: 1px solid var(--panel-border, rgba(0, 240, 255, 0.25));
      border-radius: 0;
      padding: 0.75rem 0.5rem;
      width: 260px;
      box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7), 0 0 15px rgba(0, 240, 255, 0.15);
      opacity: 0;
      pointer-events: none;
      transform: translateY(-8px);
      transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      text-align: left;
      font-family: 'VT323', monospace;
      user-select: none;
    }

    .app-nav-modal.visible {
      opacity: 1;
      pointer-events: auto;
      transform: translateY(0);
      z-index: 100;
    }

    .app-nav-modal.tv-off {
      --tv-translate: translateY(0);
      transform-origin: center center !important;
      animation: tv-turn-off 0.5s cubic-bezier(0.25, 1, 0.3, 1) forwards !important;
      pointer-events: none;
      z-index: 100;
    }

    .app-nav-title {
      font-family: 'VT323', monospace;
      font-size: 1.1rem;
      font-weight: 400;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: #00f0ff;
      text-shadow: 0 0 6px rgba(0, 240, 255, 0.5);
      padding: 0.2rem 0.6rem 0.45rem 0.6rem;
      border-bottom: 1px solid rgba(0, 240, 255, 0.18);
      margin-bottom: 0.4rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .app-nav-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .app-nav-item {
      margin: 0;
      padding: 0;
    }

    .app-nav-link {
      display: flex;
      align-items: flex-start;
      gap: 0.65rem;
      padding: 0.45rem 0.6rem;
      color: rgba(255, 255, 255, 0.85);
      text-decoration: none;
      border: 1px solid transparent;
      transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
      cursor: pointer;
    }

    .app-nav-icon {
      width: 30px;
      height: 30px;
      margin-top: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: rgba(255, 255, 255, 0.04);
      transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    }

    .app-nav-icon svg {
      width: 22px;
      height: 22px;
      display: block;
    }

    .app-nav-icon.icon-1kx {
      color: #00f0ff;
      border-color: rgba(0, 240, 255, 0.25);
      background: rgba(0, 240, 255, 0.08);
    }

    .app-nav-icon.icon-1kx svg {
      width: 24px;
      height: 24px;
    }

    .app-nav-icon.icon-football {
      color: #33ff33;
      border-color: rgba(51, 255, 51, 0.25);
      background: rgba(51, 255, 51, 0.08);
    }

    .app-nav-icon.icon-football svg {
      width: 18px;
      height: 18px;
    }

    .app-nav-icon.icon-caseyland {
      color: #ff88ff;
      border-color: rgba(255, 0, 255, 0.25);
      background: rgba(255, 0, 255, 0.08);
    }

    .app-nav-icon.icon-caseyland svg {
      width: 28px;
      height: 28px;
    }

    .app-nav-icon.icon-liambot {
      color: #a5b4fc;
      border-color: rgba(165, 180, 252, 0.25);
      background: rgba(165, 180, 252, 0.08);
    }

    .app-nav-icon.icon-caseycase {
      color: #7ed2e6;
      border-color: rgba(79, 162, 184, 0.25);
      background: rgba(79, 162, 184, 0.08);
    }

    .app-nav-icon.icon-caseycase svg {
      width: 24px;
      height: 24px;
    }

    .app-nav-icon.icon-casey {
      color: #13f8f1;
      border-color: rgba(19, 248, 241, 0.25);
      background: rgba(19, 248, 241, 0.08);
    }

    .app-nav-icon.icon-casey svg {
      width: 20px;
      height: 20px;
    }

    .app-nav-link:hover .app-nav-icon.icon-1kx {
      border-color: rgba(0, 240, 255, 0.6);
      background: rgba(0, 240, 255, 0.16);
      box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
    }

    .app-nav-link:hover .app-nav-icon.icon-football {
      border-color: rgba(51, 255, 51, 0.6);
      background: rgba(51, 255, 51, 0.16);
      box-shadow: 0 0 8px rgba(51, 255, 51, 0.3);
    }

    .app-nav-link:hover .app-nav-icon.icon-caseyland {
      border-color: rgba(255, 0, 255, 0.6);
      background: rgba(255, 0, 255, 0.16);
      box-shadow: 0 0 8px rgba(255, 0, 255, 0.3);
    }

    .app-nav-link:hover .app-nav-icon.icon-liambot {
      border-color: rgba(165, 180, 252, 0.6);
      background: rgba(165, 180, 252, 0.16);
      box-shadow: 0 0 8px rgba(165, 180, 252, 0.3);
    }

    .app-nav-link:hover .app-nav-icon.icon-caseycase {
      border-color: rgba(79, 162, 184, 0.6);
      background: rgba(79, 162, 184, 0.16);
      box-shadow: 0 0 8px rgba(79, 162, 184, 0.3);
    }

    .app-nav-link:hover .app-nav-icon.icon-casey {
      border-color: rgba(19, 248, 241, 0.6);
      background: rgba(19, 248, 241, 0.16);
      box-shadow: 0 0 8px rgba(19, 248, 241, 0.3);
    }

    .app-nav-text-col {
      display: flex;
      flex-direction: column;
      gap: 2px;
      width: 100%;
    }

    .app-nav-header-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
    }

    .app-nav-name {
      font-family: 'VT323', monospace;
      font-size: 1.15rem;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      font-weight: 400;
      display: flex;
      align-items: center;
      gap: 0.4rem;
      text-shadow: 0 0 4px rgba(0, 240, 255, 0.3);
    }

    .app-nav-sub {
      font-family: 'VT323', monospace;
      font-size: 0.95rem;
      color: var(--text-dim, #9ca3af);
      letter-spacing: 0.04em;
      line-height: 1.15;
      font-weight: 400;
      text-transform: none;
      transition: color 0.15s ease;
    }

    .app-nav-link:hover {
      background: rgba(0, 240, 255, 0.1);
      border-color: rgba(0, 240, 255, 0.35);
      color: #00f0ff;
      transform: translateX(-2px);
    }

    .app-nav-link:hover .app-nav-name {
      color: #00f0ff;
      text-shadow: 0 0 8px rgba(0, 240, 255, 0.7);
    }

    .app-nav-link:hover .app-nav-sub {
      color: rgba(255, 255, 255, 0.95);
    }

    .app-nav-link:active {
      transform: scale(0.98);
    }

    .app-nav-link.current-app {
      background: rgba(0, 240, 255, 0.08);
      border-color: rgba(0, 240, 255, 0.25);
    }

    .app-nav-link.current-app .app-nav-name {
      color: #00f0ff;
      font-weight: 400;
      text-shadow: 0 0 6px rgba(0, 240, 255, 0.5);
    }

    .app-nav-active-dot {
      width: 6px;
      height: 6px;
      border-radius: 0;
      background-color: #00f0ff;
      box-shadow: 0 0 8px rgba(0, 240, 255, 0.85), 0 0 12px rgba(0, 240, 255, 0.45);
      display: inline-block;
      flex-shrink: 0;
    }

    .app-nav-ext {
      opacity: 0.65;
      transition: opacity 0.15s ease, transform 0.15s ease;
    }

    .app-nav-link:hover .app-nav-ext {
      opacity: 1;
      transform: translate(1px, -1px);
    }

    .football-link {
      position: absolute;
      top: 2rem;
      right: 2rem;
      width: 32px;
      height: 32px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      z-index: 15;
      font-size: 1.1rem;
      text-decoration: none;
      opacity: 0;
      cursor: pointer;
      line-height: 1;
      pointer-events: none;
      transform-origin: bottom center;
    }

    .football-link canvas {
      display: block;
      width: 20px;
      height: 20px;
      image-rendering: pixelated;
      image-rendering: crisp-edges;
      transform: rotate(45deg);
      transform-origin: center;
      pointer-events: none;
    }

    @keyframes drop-bounce-roll-off {
      0% {
        opacity: 0.6;
        transform: translate(0, 0);
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      /* 1st Bounce Landing */
      22% {
        transform: translate(10px, calc(100vh - 4rem));
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      /* 1st Bounce Peak */
      35% {
        transform: translate(22px, calc(100vh - 7.5rem));
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      /* 2nd Bounce Landing */
      46% {
        transform: translate(34px, calc(100vh - 4rem));
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      /* 2nd Bounce Peak */
      55% {
        transform: translate(44px, calc(100vh - 5.5rem));
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      /* 3rd Bounce Landing */
      63% {
        transform: translate(54px, calc(100vh - 4rem));
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      /* 3rd Bounce Peak */
      69% {
        transform: translate(62px, calc(100vh - 4.8rem));
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      /* 4th Bounce Landing */
      74% {
        transform: translate(70px, calc(100vh - 4rem));
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      /* 4th Bounce Peak */
      78% {
        transform: translate(76px, calc(100vh - 4.3rem));
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      /* 5th Bounce Landing */
      81% {
        transform: translate(82px, calc(100vh - 4rem));
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      /* 5th Micro-skip */
      83% {
        transform: translate(86px, calc(100vh - 4.1rem));
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      /* Floor Settle */
      85% {
        transform: translate(90px, calc(100vh - 4rem));
        animation-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
      }
      /* Slow Roll Offscreen Right */
      96% {
        opacity: 0.6;
        transform: translate(170px, calc(100vh - 4rem));
      }
      100% {
        opacity: 0;
        transform: translate(210px, calc(100vh - 4rem));
      }
    }

    .football-link.visible {
      opacity: 0.6;
      pointer-events: auto;
      animation: drop-bounce 2.4s forwards;
    }

    .football-link.visible:hover {
      opacity: 1;
    }

    @keyframes drop-bounce-roll-off-on-icon {
      0% {
        opacity: 0.6;
        transform: translate(0, 0);
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      /* 1. Landing on Top of Playback Controls Box (Stair 1) */
      20% {
        transform: translate(10px, calc(100vh - 7.25rem));
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      /* Bounce Peak off Box Top */
      32% {
        transform: translate(22px, calc(100vh - 9.8rem));
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      /* 2. Step off Box edge & Drop down to Bottom of Playback Controls Floor Level (Stair 2) */
      45% {
        transform: translate(38px, calc(100vh - 5.25rem));
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      /* Bounce Peak off Bottom Level */
      58% {
        transform: translate(54px, calc(100vh - 7.0rem));
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      /* Landing on Bottom Level */
      68% {
        transform: translate(70px, calc(100vh - 5.25rem));
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      }
      /* Micro-skip on Bottom Level */
      76% {
        transform: translate(82px, calc(100vh - 5.75rem));
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
      }
      /* Bottom Level Settle */
      82% {
        transform: translate(92px, calc(100vh - 5.25rem));
        animation-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
      }
      /* Roll Offscreen Right along Bottom Level */
      94% {
        opacity: 0.6;
        transform: translate(170px, calc(100vh - 5.25rem));
      }
      100% {
        opacity: 0;
        transform: translate(210px, calc(100vh - 5.25rem));
      }
    }

    .football-link.rolling-off {
      animation: drop-bounce-roll-off 4.5s forwards;
      pointer-events: none;
    }

    .football-link.rolling-off-on-icon {
      animation: drop-bounce-roll-off-on-icon 4.5s forwards;
      pointer-events: none;
    }

    .football-link.spinning-fast {
      opacity: 1 !important;
      pointer-events: none;
    }

    .info-modal {
      position: absolute;
      bottom: 3rem; /* Sits cleanly above the info button */
      left: 0;
      z-index: 11;
      background: var(--panel-bg);
      border: 1px solid var(--panel-border);
      border-radius: 0;
      padding: 1.25rem 1.5rem;
      width: calc(100vw - 4rem);
      max-width: 360px;
      box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
      opacity: 0;
      pointer-events: none;
      transform: translateY(10px);
      transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out;
      text-align: left;
      
      /* Style text in VT323 phosphor terminal typography */
      font-family: 'VT323', monospace;
      font-size: 1.05rem;
      font-weight: 400;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: #00f0ff;
      text-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
    }

    .info-modal.visible {
      opacity: 1;
      pointer-events: auto;
      transform: translateY(0);
      transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
      z-index: 100;
    }

    .info-modal.tv-off {
      --tv-translate: translateY(0);
      transform-origin: center center !important;
      animation: tv-turn-off 0.5s cubic-bezier(0.25, 1, 0.3, 1) forwards !important;
      pointer-events: none;
      z-index: 100;
    }

    .info-modal-title {
      font-family: inherit;
      font-size: inherit;
      font-weight: inherit;
      letter-spacing: inherit;
      text-transform: inherit;
      color: inherit;
      margin-bottom: 0.6rem;
      border-bottom: 1px solid rgba(0, 240, 255, 0.18);
      padding-bottom: 0.4rem;
    }

    .info-modal-content {
      font-size: inherit;
      line-height: 1.4;
      color: inherit;
    }

    .info-modal-content p {
      margin-bottom: 0.5rem;
    }

    .info-modal-content ul {
      list-style: none;
      margin-bottom: 0.6rem;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
    }

    .info-modal-content li {
      display: flex;
      align-items: flex-start;
      padding: 0.35rem 0.45rem;
      margin-bottom: 0;
      color: rgba(255, 255, 255, 0.85); /* Slightly brighter for contrast */
      border: 1px solid transparent;
      border-radius: 0;
      cursor: pointer;
      user-select: none;
      transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, opacity 0.25s ease, transform 0.15s ease;
    }

    .info-modal-content li:hover {
      background: rgba(0, 240, 255, 0.10);
      border-color: rgba(0, 240, 255, 0.35);
      color: #ffffff;
      box-shadow: 0 0 10px rgba(0, 240, 255, 0.18);
    }

    .info-modal-content li:hover .artist-logo-toggle {
      transform: scale(1.12);
    }

    .info-modal-content li:hover span {
      color: #ffffff;
      text-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
    }

    .info-modal-content li:active {
      transform: scale(0.98);
    }

    .info-modal-content li:active .artist-logo-toggle {
      transform: scale(0.95);
    }

    .info-modal-content li.inactive,
    .info-modal-content li:has(.artist-logo-toggle.inactive) {
      opacity: 0.45;
    }

    .info-modal-content li.inactive:hover,
    .info-modal-content li:has(.artist-logo-toggle.inactive):hover {
      opacity: 0.85;
      background: rgba(255, 255, 255, 0.05);
      border-color: rgba(255, 255, 255, 0.2);
      color: #ffffff;
      box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
    }

    .info-modal-content li.inactive:hover .artist-logo-toggle,
    .info-modal-content li:has(.artist-logo-toggle.inactive):hover .artist-logo-toggle {
      opacity: 0.75;
      filter: grayscale(40%);
    }

    .info-modal-content a {
      color: inherit;
      text-decoration: underline;
      transition: opacity 0.2s ease;
    }

    .info-modal-content a:hover {
      opacity: 0.8;
    }

    .casey-pink-link {
      color: #00f0ff !important;
      text-decoration: underline;
      transition: opacity 0.2s ease, text-shadow 0.2s ease;
    }

    .casey-pink-link:hover {
      opacity: 0.85;
      text-shadow: 0 0 6px rgba(0, 240, 255, 0.6);
    }

    .blue-1kx-link,
    .green-1kx-link {
      color: #00f0ff !important;
      text-decoration: underline;
      transition: opacity 0.2s ease, text-shadow 0.2s ease;
    }

    .blue-1kx-link:hover,
    .green-1kx-link:hover {
      opacity: 0.85;
      text-shadow: 0 0 6px rgba(0, 240, 255, 0.6);
    }

    .artist-logo-toggle {
      height: 2.2rem;
      width: 2.2rem;
      border-radius: 0;
      vertical-align: middle;
      margin-top: 5px;
      margin-right: 0.6rem;
      object-fit: cover;
      border: 1px solid #333;
      background: #000;
      display: inline-block;
      flex-shrink: 0;
      cursor: pointer;
      user-select: none;
      box-shadow: none;
      transition: filter 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
    }

    .artist-logo-toggle.active {
      filter: grayscale(0%);
      opacity: 1;
      box-shadow: none;
    }

    .artist-logo-toggle.inactive {
      filter: grayscale(100%);
      opacity: 0.35;
      box-shadow: none;
      border-color: #222;
    }

    .artist-logo-toggle:hover {
      transform: scale(1.12);
    }

    .artist-logo-toggle:active {
      transform: scale(0.95);
    }


    .info-modal-copyright {
      font-size: 0.55rem;
      color: rgba(255, 255, 255, 0.55);
      border-top: 1px solid rgba(0, 240, 255, 0.18);
      padding-top: 0.4rem;
      margin-top: 0.4rem;
    }

    .info-football-link {
      color: rgba(255, 255, 255, 0.75);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      line-height: 1;
      text-decoration: none;
      transition: transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
      cursor: pointer;
      opacity: 0.8;
    }

    .info-football-link .info-football-white {
      fill: #ffffff;
    }

    .info-football-link .info-football-black {
      fill: #000000;
    }

    .info-football-link:hover,
    .info-football-link.spinning {
      opacity: 1;
      transform: scale(1.2);
      filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
    }

    .info-football-link:hover .info-football-svg,
    .info-football-link.spinning .info-football-svg {
      animation: info-football-spin 1.2s linear infinite;
    }

    @keyframes info-football-spin {
      from { transform: rotate(0deg); }
      to { transform: rotate(360deg); }
    }

    /* Mobile adjustments */
    @media (max-width: 600px) {
      .dashboard {
        position: fixed;
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        padding: 1rem;
        border-radius: 0;
        max-height: calc(100dvh - 2rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        overscroll-behavior: contain;
      }
      .dashboard.visible {
        z-index: 500 !important;
      }
      .dashboard-hotkeys {
        display: grid !important;
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 0.35rem !important;
        width: 100% !important;
      }
      .btn-hotkey {
        min-width: 0 !important;
        width: 100% !important;
        height: 2.2rem !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
      }
      .controls-grid {
        grid-template-columns: 1fr 1fr;
      }
      .controls-grid > .control-item:last-child {
        grid-column: span 2;
        justify-content: center !important;
      }
      .song-indicator {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        top: auto;
        right: calc(1rem + env(safe-area-inset-right, 0px));
        font-size: 0.75rem;
        height: 28px;
        width: 320px;
        max-width: calc(100vw - 2rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
      }
      .song-indicator.zen-only {
        height: 28px !important;
      }
      #song-info-wrapper {
        height: 28px;
      }
      .song-toggle-btn,
      #info-btn,
      #app-nav-btn,
      .app-nav-btn {
        width: 28px;
        height: 28px;
        font-size: 1.1rem;
      }
      .song-toggle-btn svg,
      #info-btn svg,
      .app-nav-btn svg {
        width: 14px;
        height: 14px;
      }
      .song-continuous-btn {
        font-size: 1.05rem;
        line-height: 1;
        letter-spacing: 0;
      }
      .info-container {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        top: auto;
        left: calc(1rem + env(safe-area-inset-left, 0px));
      }
      .info-modal {
        bottom: calc(3rem + env(safe-area-inset-bottom, 0px)); /* Sits above the info button on mobile */
        top: auto;
        left: 0;
        width: calc(100vw - 2rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        max-width: calc(100vw - 2rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        padding: 0.9rem 1rem;
        box-sizing: border-box;
      }
      .info-modal-content {
        line-height: 1.32;
      }
      .info-modal-content p {
        margin-bottom: 0.35rem;
      }
      .info-modal-content ul {
        margin-bottom: 0.4rem;
        gap: 0.25rem;
      }
      .info-modal-content li {
        padding: 0.25rem 0.35rem;
        margin-bottom: 0;
      }
      .artist-logo-toggle {
        height: 2rem;
        width: 2rem;
        min-width: 2rem;
        margin-top: 4px;
        margin-right: 0.55rem;
      }
      .info-modal-copyright {
        font-size: 0.62rem;
        line-height: 1.25;
        margin-top: 0.4rem;
        padding-top: 0.4rem;
      }
      .app-nav-container {
        top: calc(1rem + env(safe-area-inset-top, 0px));
        right: calc(1rem + env(safe-area-inset-right, 0px));
      }
      .app-nav-container.ball-present {
        transform: translateY(24px);
      }
      .app-nav-modal {
        top: calc(100% + 0.5rem);
        right: 0;
        width: calc(100vw - 2rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        max-width: 270px;
      }
      .football-link {
        top: calc(1rem + env(safe-area-inset-top, 0px));
        right: calc(1rem + env(safe-area-inset-right, 0px));
        width: 28px;
        height: 28px;
      }

      @keyframes drop-bounce-roll-off-on-icon {
        0% {
          opacity: 0.6;
          transform: translate(0, 0);
          animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
        }
        /* 1. First bounce off TOP of playback controls box */
        20% {
          transform: translate(10px, calc(100vh - 5.5rem));
          animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        }
        /* Bounce peak off Box Top */
        32% {
          transform: translate(22px, calc(100vh - 8.0rem));
          animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
        }
        /* 2. Step off Box edge & Drop down to Bottom of Playback Controls Floor Level */
        45% {
          transform: translate(38px, calc(100vh - 3.75rem));
          animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        }
        /* Bounce peak off Bottom Level */
        58% {
          transform: translate(54px, calc(100vh - 5.2rem));
          animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
        }
        /* Landing on Bottom Level */
        68% {
          transform: translate(70px, calc(100vh - 3.75rem));
          animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        }
        /* Micro-skip on Bottom Level */
        76% {
          transform: translate(82px, calc(100vh - 4.15rem));
          animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
        }
        /* Bottom Level Settle */
        82% {
          transform: translate(92px, calc(100vh - 3.75rem));
          animation-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
        }
        /* Roll Offscreen Right along Bottom Level */
        94% {
          opacity: 0.6;
          transform: translate(170px, calc(100vh - 3.75rem));
        }
        100% {
          opacity: 0;
          transform: translate(210px, calc(100vh - 3.75rem));
        }
      }
      .dashboard-header {
        position: relative;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        width: 100%;
      }
      .dashboard-header-right {
        align-items: flex-start;
        gap: 0.35rem;
        width: 100%;
      }
      .dashboard-perf-group {
        gap: 0.35rem;
        justify-content: flex-end;
      }
      .header-divider {
        display: none;
      }
      #agy-debug-panel {
        top: calc(10px + env(safe-area-inset-top, 0px));
        left: calc(10px + env(safe-area-inset-left, 0px));
        max-width: calc(100vw - 20px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        max-height: calc(100dvh - 20px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
      }
    }

    @media (max-height: 520px) {
      .dashboard {
        position: fixed;
        bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
        padding: 0.75rem 1rem;
        gap: 0.75rem;
        max-height: calc(100dvh - 1rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        overscroll-behavior: contain;
      }
      .dashboard-title h1 {
        font-size: 1.3rem;
      }
      .dashboard-title-icon {
        margin-top: calc((1.3rem * 1.1 - 19px) / 2);
      }
      .dashboard-header-actions {
        height: calc(1.3rem * 1.1) !important;
      }
      .dashboard-header {
        padding-bottom: 0.4rem;
      }
      #agy-debug-panel {
        top: calc(6px + env(safe-area-inset-top, 0px));
        left: calc(6px + env(safe-area-inset-left, 0px));
        max-height: calc(100dvh - 12px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
      }
      #dbg-header {
        padding: 6px 10px 4px 10px !important;
      }
      #dbg-body {
        padding: 4px 10px 8px 10px !important;
      }
    }
