body {
    margin: 0;
    overflow: hidden;
    background: url('assets/background.png') repeat-x bottom;
    background-size: auto 100dvh;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;    /* fallback */
    height: 100dvh;   /* stable dynamic viewport on iOS/Android */
    overflow: hidden;
  }

/* Mute toggle */
#mute-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 240;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.7);
    background: rgba(0,0,0,0.35);
    color: #fff;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#mute-toggle.is-muted { opacity: 0.7; }

#bull {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 150px;
    width: 150px;
    display: block;
    z-index: 100;
    object-fit: contain;
    /* Consistent size for all frames - no dynamic resizing */
}

/* Platform Styles */
.platform {
    position: absolute;
    display: block;
    image-rendering: pixelated; /* Keep pixelated look for retro games */
}

/* Bear Styles */
.bear {
    position: absolute;
    display: block;
    image-rendering: pixelated;
    animation: bearGlow 2s ease-in-out infinite alternate;
}

@keyframes bearGlow {
    0% { filter: brightness(1) drop-shadow(0 0 5px rgba(255, 165, 0, 0.3)); }
    100% { filter: brightness(1.1) drop-shadow(0 0 15px rgba(255, 165, 0, 0.6)); }
}

/* Game UI Styles */
#game-ui {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 200;
    color: white;
    font-family: Arial, sans-serif;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.score, .timer {
    margin-bottom: 10px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    border: 2px solid #00ffff;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.score {
    color: #ff6b35;
}

.timer {
    color: #00ffff;
}

/* Start Screen Styles - SolBull.space Theme */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;    /* fallback */
    height: 100dvh;   /* stable dynamic viewport on iOS/Android */
    background: linear-gradient(135deg, #1a0033 0%, #2d1b5a 25%, #0f4c75 50%, #1a0033 100%);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    z-index: 1000;
    position: relative;
}

#start-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 0, 150, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(255, 0, 150, 0.05) 0%, transparent 50%);
    animation: neonPulse 4s ease-in-out infinite alternate;
}

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

@keyframes neonPulse {
    0% { opacity: 0.3; }
    100% { opacity: 0.7; }
}

@keyframes titleGlow {
    0%, 100% { 
        text-shadow: 0 0 10px #ff0096, 0 0 20px #ff0096, 0 0 30px #ff0096;
        transform: scale(1);
    }
    50% { 
        text-shadow: 0 0 20px #ff0096, 0 0 30px #ff0096, 0 0 40px #ff0096;
        transform: scale(1.02);
    }
}

#start-screen h1 {
    font-size: 4rem;
    margin: 0 0 1rem 0;
    color: #00ffff;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
    animation: titleGlow 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
    text-shadow: 0 0 20px #00ffff, 0 0 40px #00ffff;
}

#start-screen p {
    font-size: 1.4rem;
    margin: 0.5rem 0;
    color: #ff0096;
    font-weight: 600;
    text-shadow: 0 0 10px #ff0096;
    position: relative;
    z-index: 2;
}

#start-button {
    font-size: 1.6rem;
    padding: 18px 45px;
    background: linear-gradient(45deg, transparent, rgba(0, 255, 255, 0.1), transparent);
    color: #00ffff;
    border: 2px solid #00ffff;
    border-radius: 8px;
    cursor: pointer;
    margin: 2rem 0;
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 0 0 10px #00ffff;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.3),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
}

#start-button:hover {
    background: linear-gradient(45deg, rgba(0, 255, 255, 0.1), rgba(255, 0, 150, 0.1), rgba(0, 255, 255, 0.1));
    color: #ffffff;
    border-color: #ff0096;
    text-shadow: 0 0 15px #ff0096;
    box-shadow: 
        0 0 30px rgba(255, 0, 150, 0.5),
        inset 0 0 30px rgba(255, 0, 150, 0.2);
    transform: translateY(-2px) scale(1.05);
}

.controls {
    margin-top: 2rem;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    position: relative;
    z-index: 2;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.2),
        inset 0 0 20px rgba(0, 255, 255, 0.05);
}

.controls p {
    margin: 0.4rem 0;
    font-size: 1.1rem;
    color: #ffffff;
    font-weight: 500;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.controls p:first-child {
    color: #00ffff;
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: 0.8rem;
    text-shadow: 0 0 10px #00ffff;
}

/* End Screen Styles */
#end-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0c0c1a, #1a0c2e, #2e0c1a, #0c1a2e);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 300;
    font-family: 'Orbitron', Arial, sans-serif;
    color: white;
    text-align: center;
}

#end-screen::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: neonPulse 3s ease-in-out infinite alternate;
}

#end-screen h1 {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #00d4ff;
    text-shadow: 0 0 20px #00d4ff, 0 0 40px #00d4ff, 0 0 80px #00d4ff;
    animation: titleGlow 2s ease-in-out infinite alternate;
    z-index: 1;
}

.death-reason {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    font-weight: bold;
    text-shadow: 0 0 10px currentColor;
    z-index: 1;
}

.final-score {
    background: rgba(0, 0, 0, 0.8);
    padding: 2rem;
    border-radius: 15px;
    margin: 2rem 0;
    border: 3px solid #00d4ff;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.4);
    z-index: 1;
}

.final-score h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #fff;
}

.score-number {
    font-size: 5rem;
    font-weight: bold;
    color: #00d4ff;
    text-shadow: 0 0 20px #00d4ff;
    margin: 1rem 0;
}

.score-label {
    font-size: 1.5rem;
    color: #ccc;
    margin-top: 0;
}

.end-buttons {
    display: flex;
    gap: 2rem;
    margin: 2rem 0;
    z-index: 1;
}

#restart-button, #main-menu-button {
    padding: 1rem 2rem;
    font-size: 1.5rem;
    font-weight: bold;
    background: transparent;
    border: 3px solid #00d4ff;
    color: #00d4ff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Orbitron', Arial, sans-serif;
}

#restart-button:hover, #main-menu-button:hover {
    background: #00d4ff;
    color: #000;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
    transform: translateY(-2px);
}

.end-controls {
    margin-top: 2rem;
    font-size: 1rem;
    color: #888;
    z-index: 1;
}

.end-controls strong {
    color: #00d4ff;
}

/* Laser Styles */
.laser {
    background: linear-gradient(90deg, 
        transparent 0%, 
        #ff0000 10%, 
        #ff4444 50%, 
        #ff0000 90%, 
        transparent 100%);
    box-shadow: 
        0 0 10px #ff0000,
        0 0 20px #ff0000,
        0 0 30px #ff4444;
    border-radius: 2px;
    animation: laserPulse 0.1s ease-in-out infinite alternate;
    z-index: 150;
    display: block !important;
    opacity: 1 !important;
}

@keyframes laserPulse {
    0% { 
        opacity: 0.8;
        transform: scaleY(1);
    }
    100% { 
        opacity: 1;
        transform: scaleY(1.2);
    }
}

/* Speed boost pickup */
.speed-orb {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(closest-side, #ffd54f 40%, #ffb300 65%, rgba(255,179,0,0.0) 70%);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.85), 0 0 28px rgba(255, 215, 0, 0.45);
    animation: orbPulse 1.2s ease-in-out infinite alternate;
    image-rendering: pixelated;
    z-index: 90;
    pointer-events: none;
  }
  
  @keyframes orbPulse {
    from { transform: scale(0.95); filter: brightness(1); }
    to   { transform: scale(1.05); filter: brightness(1.15); }
  }
  
  /* HUD icon for active speed boost */
  #speed-boost-icon {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    color: #111;
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, #ffe082, #ffca28);
    border: 2px solid #ffb300;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.6);
    z-index: 220;
  }

  /* Pause overlay */
  #pause-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    z-index: 260;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  #pause-overlay .po-card {
    background: rgba(0, 0, 0, 0.65);
    border: 2px solid #00ffff;
    border-radius: 12px;
    padding: 16px 24px;
    color: #fff;
    text-align: center;
    box-shadow: 0 0 20px rgba(0,255,255,0.3);
  }

  #start-screen .about {
    margin-top: 1rem;
    padding: 14px 22px;
    background: rgba(0, 0, 0, 0.32);
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 255, 0.25);
    position: relative;
    z-index: 2;
    box-shadow:
      0 0 14px rgba(0, 255, 255, 0.16),
      inset 0 0 14px rgba(0, 255, 255, 0.04);
  }
  
  #start-screen .about p {
    margin: 0.35rem 0;
    font-size: 1.15rem;
    color: #ffffff;
    font-weight: 500;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.45);
  }
  
  #start-screen .about p:first-child {
    color: #00ffff;
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 0.6rem;
    text-shadow: 0 0 10px #00ffff;
  }

  
  /* ===== Mobile Touch Controls =====
   Shows only on touch devices; hidden on desktop/laptop.
   Paste at the end of styles.css.
*/

/* Container (hidden by default; enabled via media query below) */
#touch-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    display: none;                /* will be set to flex on mobile via media query */
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 250;
    pointer-events: none;         /* container ignores events; buttons accept */
    user-select: none;
    -webkit-user-select: none;
    transition: opacity 0.25s ease;
  }
  
  /* Left and right clusters */
  #touch-controls .tc-left,
  #touch-controls .tc-right {
    display: flex;
    gap: 12px;
    pointer-events: auto;         /* buttons receive touch */
  }
  
  /* Buttons: big, circular, high‑contrast */
  #touch-controls button {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.65);
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.3), rgba(0,0,0,0.45));
    box-shadow:
      0 4px 14px rgba(0, 0, 0, 0.45),
      inset 0 0 12px rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: translateZ(0);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;   /* prevent double‑tap zoom */
  }

  /* Dim controls when idle */
  #touch-controls.dimmed { opacity: 0.45; }
  
  /* Visual press feedback */
  #touch-controls button:active,
  #touch-controls button.is-pressed {
    transform: scale(0.92);
    box-shadow:
      0 2px 10px rgba(0, 0, 0, 0.5),
      inset 0 0 16px rgba(255, 255, 255, 0.2);
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.28), rgba(0,0,0,0.55));
  }
  
  /* Optional: subtle glass behind each cluster for readability */
  #touch-controls .tc-left::before,
  #touch-controls .tc-right::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.18);
    filter: blur(0.5px);
    z-index: -1;
    pointer-events: none;
  }
  
  /* Ensure cluster pseudo‑background positions correctly */
  #touch-controls .tc-left,
  #touch-controls .tc-right {
    position: relative;
    padding: 6px;
    border-radius: 16px;
  }
  
  /* Show controls only on touch/coarse pointer devices */
  @media (hover: none) and (pointer: coarse) {
    #touch-controls {
      display: flex;
    }
  }
  
  /* Small devices: slightly smaller buttons */
  @media (max-width: 380px) {
    #touch-controls button {
      width: 60px;
      height: 60px;
      font-size: 24px;
    }
  }

  /* ===== Mobile layout tweaks ===== */
  @media (max-width: 640px) {
    /* Reduce start screen typography and spacing */
    #start-screen h1 { font-size: 2.4rem; letter-spacing: 2px; }
    #start-button { font-size: 1.2rem; padding: 14px 28px; margin: 1.4rem 0; }
    .controls { padding: 14px 18px; }
    .controls p { font-size: 1rem; }

    /* In-game HUD size */
    #game-ui { top: 14px; left: 14px; font-size: 1rem; }
    .score, .timer { margin-bottom: 8px; padding: 8px 10px; }

    /* End screen sizes */
    #end-screen h1 { font-size: 2.6rem; }
    .death-reason { font-size: 1.2rem; }
    .final-score { padding: 1.2rem; margin: 1.2rem 0; }
    .final-score h2 { font-size: 1.4rem; }
    .score-number { font-size: 3.2rem; }
    .score-label { font-size: 1.1rem; }
    .end-buttons { gap: 1rem; margin: 1.2rem 0; }
    #restart-button, #main-menu-button { padding: 0.8rem 1.2rem; font-size: 1.1rem; }

    /* Avoid accidental scroll/zoom while playing */
    #game-container { touch-action: none; overscroll-behavior: contain; }
    body { overscroll-behavior-y: contain; }
  }
  