/* ==================== GLOBAL RESET ==================== */
    /* Remove default browser margins and padding, use border-box sizing */
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    /* ==================== BODY STYLING ==================== */
    /* Set font, hide overflow, and create purple gradient background */
    body {
      font-family: 'Arial', sans-serif;
      overflow: hidden;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }

    /* ==================== GAME CANVAS ==================== */
    /* Full-screen canvas for Three.js rendering */
    #gameCanvas {
      display: block;
      width: 100%;
      height: 100vh;
    }

    /* ==================== UI OVERLAY ==================== */
    /* Container for all UI elements that sits above the game canvas */
    #ui {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      /* Allow clicks to pass through to canvas */
      z-index: 1000;
    }

    /* ==================== SCORE PANEL ==================== */
    /* Top-left panel showing score, coins, and distance */
    #score-panel {
      position: absolute;
      top: 20px;
      left: 20px;
      background: rgba(0, 0, 0, 0.7);
      padding: 15px 25px;
      border-radius: 10px;
      color: white;
      font-size: 20px;
      font-weight: bold;
    }

    #score-panel div {
      margin: 5px 0;
    }

    /* Gold color for coin count */
    #coin-count {
      color: #ffd700;
    }

    /* Green color for distance */
    #distance {
      color: #00ff88;
    }

    /* ==================== HEAT BAR ==================== */
    /* Container for the heat/energy bar at top center */
    #heat-bar-container {
      position: absolute;
      top: 20px;
      left: 50%;
      transform: translateX(-50%);
      width: 300px;
      height: 30px;
      background: rgba(0, 0, 0, 0.7);
      border: 2px solid white;
      border-radius: 15px;
      padding: 3px;
      z-index: 1000;
    }

    /* Inner fill bar that changes color based on heat level */
    #heat-bar {
      width: 0%;
      height: 100%;
      border-radius: 12px;
      background: #03a1fc;
      /* Blue at start */
      transition: width 0.1s, background 0.2s;
    }

    /* ==================== POWER BAR (NEW) ==================== */
    /* Container for the power bar below heat bar */
    #power-bar-container {
      position: absolute;
      top: 60px;
      left: 50%;
      transform: translateX(-50%);
      width: 300px;
      height: 30px;
      background: rgba(0, 0, 0, 0.7);
      border: 2px solid white;
      border-radius: 15px;
      padding: 3px;
      z-index: 1000;
    }

    /* Inner fill bar with rainbow gradient */
    #power-bar {
      width: 0%;
      height: 100%;
      border-radius: 12px;
      background: linear-gradient(90deg,
          #ff0000 0%,
          #ff7f00 16.67%,
          #ffff00 33.33%,
          #00ff00 50%,
          #0000ff 66.67%,
          #4b0082 83.33%,
          #9400d3 100%);
      transition: width 0.3s ease-out;
      box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    }

    /* Power bar label */
    #power-bar-label {
      position: absolute;
      top: 95px;
      left: 50%;
      transform: translateX(-50%);
      color: white;
      font-size: 12px;
      font-weight: bold;
      text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
      z-index: 1001;
    }

    /* ==================== POWER-UP INDICATORS ==================== */
    /* Container for active power-up displays (top-right) */
    #powerups {
      position: absolute;
      top: 100px;
      right: 20px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    /* Individual power-up indicator styling */
    .powerup-indicator {
      background: rgba(0, 0, 0, 0.8);
      padding: 10px 15px;
      border-radius: 8px;
      color: white;
      font-size: 14px;
      display: flex;
      align-items: center;
      gap: 10px;
      animation: pulse 0.5s ease-in-out;
    }

    /* Pulse animation when power-up is activated */
    @keyframes pulse {

      0%,
      100% {
        transform: scale(1);
      }

      50% {
        transform: scale(1.1);
      }
    }

    .powerup-icon {
      font-size: 24px;
    }

    .powerup-timer {
      font-size: 16px;
      font-weight: bold;
    }

    /* ==================== CONTROLS HINT ==================== */
    /* Bottom-center control instructions that fade out after 5 seconds */
    #controls {
      position: absolute;
      bottom: 30px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(0, 0, 0, 0.7);
      padding: 15px 30px;
      border-radius: 10px;
      color: white;
      font-size: 14px;
      text-align: center;
      animation: fadeOut 5s forwards;
    }

    /* Fade out animation for controls hint */
    @keyframes fadeOut {

      0%,
      80% {
        opacity: 1;
      }

      100% {
        opacity: 0;
      }
    }

    /* ==================== GAME OVER SCREEN ==================== */
    /* Modal showing final stats when game ends */
    #game-over {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%) scale(0);
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      padding: 40px 60px;
      border-radius: 20px;
      text-align: center;
      color: white;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
      transition: transform 0.3s ease-out;
      pointer-events: all;
    }

    /* Scale up animation when game over is shown */
    #game-over.show {
      transform: translate(-50%, -50%) scale(1);
    }

    #game-over h1 {
      font-size: 48px;
      margin-bottom: 20px;
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    }

    #game-over .stats {
      margin: 20px 0;
      font-size: 18px;
    }

    #game-over .stats div {
      margin: 10px 0;
    }

    /* ==================== BUTTONS ==================== */
    /* Styling for restart and pause buttons */
    #restart-btn,
    #pause-btn {
      background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
      color: white;
      border: none;
      padding: 15px 40px;
      font-size: 18px;
      font-weight: bold;
      border-radius: 50px;
      cursor: pointer;
      margin-top: 20px;
      transition: transform 0.2s;
      pointer-events: all;
    }

    /* Hover effect for buttons */
    #restart-btn:hover,
    #pause-btn:hover {
      transform: scale(1.1);
    }

    /* Pause button positioned at top-right */
    #pause-btn {
      position: absolute;
      top: 20px;
      right: 20px;
      padding: 10px 20px;
      font-size: 24px;
      z-index: 1001;
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 60px;
    }

    /* Icon styling for pause button */
    #pause-btn .pause-icon,
    #pause-btn .play-icon {
      display: flex;
      align-items: center;
      justify-content: center;
      line-height: 1;
    }


    /* ==================== LOADING SCREEN ==================== */
    #loading {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      color: white;
      z-index: 2000;
    }

    #loading-content {
      text-align: center;
    }

    #loading h1 {
      font-size: 48px;
      font-weight: bold;
      margin-bottom: 40px;
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
      animation: titlePulse 2s ease-in-out infinite;
    }

    @keyframes titlePulse {
      0%, 100% {
        opacity: 1;
        transform: scale(1);
      }
      50% {
        opacity: 0.85;
        transform: scale(1.03);
      }
    }

    #progress-bar-container {
      min-width: 250px;
      width: 400px;
      height: 30px;
      background: rgba(0, 0, 0, 0.3);
      border: 3px solid rgba(255, 255, 255, 0.5);
      border-radius: 15px;
      padding: 4px;
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }

    #progress-bar {
      min-width: 250px;
      width: 0%;
      height: 100%;
      background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
      border-radius: 10px;
      transition: width 0.3s ease;
      box-shadow: 0 0 20px rgba(79, 172, 254, 0.8);
      position: relative;
      overflow: hidden;
    }

    #progress-bar::before {
      content: "";
      position: absolute;
      top: 0;
      left: -100%;
      width: 100%;
      height: 100%;
      background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
      animation: shimmer 1.5s infinite;
    }

    @keyframes shimmer {
      0% {
        left: -100%;
      }
      100% {
        left: 100%;
      }
    }

    #progress-text {
      margin-top: 20px;
      font-size: 18px;
      font-weight: 600;
      color: rgba(255, 255, 255, 0.9);
      text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    }

    /* ==================== MOBILE CONTROLS ==================== */
    #mobile-controls {
      position: fixed;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 200px;
      display: none;
      pointer-events: all;
      z-index: 1500;
    }

    /* Show mobile controls on touch devices */
    @media (hover: none) and (pointer: coarse) {
      #mobile-controls {
        display: block;
      }
      #controls {
        display: none;
      }
    }

    /* D-pad container */
    #dpad {
      position: absolute;
      left: 30px;
      bottom: 30px;
      width: 150px;
      height: 150px;
    }

    /* Individual direction buttons */
    .dpad-btn {
      position: absolute;
      width: 50px;
      height: 50px;
      background: rgba(255, 255, 255, 0.3);
      border: 2px solid rgba(255, 255, 255, 0.6);
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 24px;
      color: white;
      cursor: pointer;
      user-select: none;
      transition: all 0.1s;
      backdrop-filter: blur(10px);
    }

    .dpad-btn:active {
      background: rgba(255, 255, 255, 0.5);
      transform: scale(0.95);
    }

    #btn-left {
      left: 0;
      top: 50px;
    }

    #btn-right {
      right: 0;
      top: 50px;
    }

    #btn-up {
      left: 50px;
      top: 0;
    }

    #btn-down {
      left: 50px;
      bottom: 0;
    }

    /* Action buttons container */
    #action-buttons {
      position: absolute;
      right: 30px;
      bottom: 30px;
      display: flex;
      gap: 15px;
    }

    .action-btn {
      width: 70px;
      height: 70px;
      background: rgba(255, 255, 255, 0.3);
      border: 3px solid rgba(255, 255, 255, 0.6);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      font-weight: bold;
      color: white;
      cursor: pointer;
      user-select: none;
      transition: all 0.1s;
      backdrop-filter: blur(10px);
      text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    }

    .action-btn:active {
      background: rgba(255, 255, 255, 0.5);
      transform: scale(0.95);
    }

    #btn-jump {
      background: rgba(79, 172, 254, 0.4);
      border-color: rgba(79, 172, 254, 0.8);
    }

    #btn-slide {
      background: rgba(255, 107, 107, 0.4);
      border-color: rgba(255, 107, 107, 0.8);
    }

    /* Swipe gesture indicator */
    #swipe-hint {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      color: rgba(255, 255, 255, 0.6);
      font-size: 14px;
      text-align: center;
      pointer-events: none;
      animation: fadeOut 5s forwards;
    }

    /* ==================== MOBILE RESPONSIVE (UNDER 768PX) ==================== */
    @media (max-width: 768px) {
      /* Heat bar - align left with max-width 200px */
      #heat-bar-container {
        left: 10px;
        transform: none;
        width: 200px;
        max-width: 200px;
        top: 10px;
        height: 25px;
      }

      /* Power bar - align left with max-width 200px, below heat bar */
      #power-bar-container {
        left: 10px;
        transform: none;
        width: 200px;
        max-width: 200px;
        top: 45px;
        height: 25px;
      }

      /* Power bar label - align left */
      #power-bar-label {
        left: 10px;
        transform: none;
        top: 75px;
        font-size: 10px;
      }

      /* Score panel - position below power bar */
      #score-panel {
        top: 100px;
        left: 10px;
        padding: 10px 15px;
        font-size: 14px;
        max-width: 200px;
      }

      #score-panel div {
        margin: 3px 0;
      }

      /* Pause button - smaller on mobile */
      #pause-btn {
        top: 10px;
        right: 10px;
        padding: 8px 15px;
        font-size: 20px;
        min-width: 50px;
      }

      /* Power-ups - adjust position */
      #powerups {
        top: 60px;
        right: 10px;
      }

      .powerup-indicator {
        padding: 8px 12px;
        font-size: 12px;
      }

      .powerup-icon {
        font-size: 20px;
      }

      .powerup-timer {
        font-size: 14px;
      }
    }