/* ===== RESET & BASE ===== */
*, *::before, *::after {
     margin: 0;
     padding: 0;
     box-sizing: border-box;
}

html, body {
     width: 100%;
     height: 100%;
     overflow: hidden;
     background: #0a0a1a;
     font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
     color: #e0e0ff;
     user-select: none;
     -webkit-user-select: none;
     -webkit-tap-highlight-color: transparent;
}

/* ===== GAME CONTAINER ===== */
#game-container {
     position: relative;
     width: 100%;
     height: 100%;
     display: flex;
     align-items: center;
     justify-content: center;
     overflow: hidden;
}

#gameCanvas {
     display: block;
     background: #0a0a1a;
     image-rendering: pixelated;
}

/* ===== HUD ===== */
#hud {
     position: absolute;
     top: 0;
     left: 0;
     right: 0;
     pointer-events: none;
     z-index: 10;
     padding: 10px 15px;
}

#hud-top {
     display: flex;
     justify-content: space-between;
     align-items: center;
     margin-bottom: 6px;
}

.hud-item {
     text-align: center;
}

.hud-label {
     font-size: 10px;
     letter-spacing: 2px;
     color: #7a7aaa;
     text-transform: uppercase;
     display: block;
}

.hud-value {
     font-size: 20px;
     font-weight: bold;
     color: #00e5ff;
     text-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

#hud-bottom {
     display: flex;
     gap: 12px;
     max-width: 300px;
}

.health-bar-container, .dash-bar-container {
     flex: 1;
     height: 8px;
     background: rgba(255, 255, 255, 0.05);
     border-radius: 4px;
     overflow: hidden;
     border: 1px solid rgba(255, 255, 255, 0.1);
}

.health-bar-bg, .dash-bar-bg {
     position: absolute;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
}

.health-bar-fill {
     height: 100%;
     background: linear-gradient(90deg, #ff1744, #ff6d00);
     transition: width 0.2s ease;
     border-radius: 3px;
     box-shadow: 0 0 8px rgba(255, 23, 68, 0.5);
}

.dash-bar-fill {
     height: 100%;
     background: linear-gradient(90deg, #7c4dff, #00e5ff);
     transition: width 0.1s ease;
     border-radius: 3px;
     box-shadow: 0 0 8px rgba(124, 77, 255, 0.5);
}

/* ===== MOBILE PAUSE BUTTON ===== */
#pause-btn {
     position: absolute;
     top: 8px;
     right: 10px;
     z-index: 15;
     background: rgba(10, 10, 26, 0.8);
     border: 1px solid #7a7aaa;
     color: #e0e0ff;
     font-size: 18px;
     width: 36px;
     height: 36px;
     border-radius: 8px;
     display: none; /* hidden on desktop */
     align-items: center;
     justify-content: center;
     cursor: pointer;
     pointer-events: auto;
}

/* ===== TOUCH CONTROLS ===== */
#touch-controls {
     position: absolute;
     bottom: 15px;
     left: 0;
     right: 0;
     z-index: 20;
     display: flex;
     justify-content: space-between;
     align-items: flex-end;
     padding: 0 20px;
     pointer-events: none;
}

.dpad {
     position: relative;
     width: 140px;
     height: 140px;
     pointer-events: auto;
}

.dpad-btn {
     position: absolute;
     width: 50px;
     height: 50px;
     background: rgba(20, 20, 50, 0.7);
     border: 2px solid rgba(0, 229, 255, 0.4);
     border-radius: 12px;
     color: #e0e0ff;
     font-size: 20px;
     display: flex;
     align-items: center;
     justify-content: center;
     cursor: pointer;
     transition: background 0.1s, border-color 0.1s;
     -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active, .dpad-btn.active {
     background: rgba(0, 229, 255, 0.3);
     border-color: #00e5ff;
}

.dpad-btn.up { top: 0; left: 45px; }
.dpad-btn.left { top: 45px; left: 0; }
.dpad-btn.down { top: 90px; left: 45px; }
.dpad-btn.right { top: 45px; left: 90px; }

.touch-dash-btn {
     pointer-events: auto;
     width: 80px;
     height: 80px;
     border-radius: 50%;
     background: rgba(124, 77, 255, 0.3);
     border: 2px solid rgba(124, 77, 255, 0.6);
     color: #e0e0ff;
     font-size: 14px;
     font-weight: bold;
     letter-spacing: 1px;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
     transition: background 0.1s;
}

.touch-dash-btn:active, .touch-dash-btn.active {
     background: rgba(124, 77, 255, 0.6);
}

/* ===== OVERLAYS (Menu, Pause, Game Over, Level) ===== */
.overlay {
     position: absolute;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     background: rgba(5, 5, 20, 0.92);
     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: center;
     z-index: 50;
     transition: opacity 0.3s;
}

.overlay.hidden {
     opacity: 0;
     pointer-events: none;
}

.overlay-title {
     font-size: 42px;
     font-weight: bold;
     margin-bottom: 10px;
     text-shadow: 0 0 20px currentColor;
}

.title {
     color: #00e5ff;
     letter-spacing: 4px;
}

.game-over-text {
     color: #ff1744;
}

.level-complete-text {
     color: #76ff03;
}

.subtitle {
     color: #7a7aaa;
     margin-bottom: 30px;
     font-size: 16px;
}

.menu-btn {
     background: rgba(0, 229, 255, 0.1);
     border: 2px solid #00e5ff;
     color: #00e5ff;
     font-size: 18px;
     padding: 14px 40px;
     border-radius: 8px;
     cursor: pointer;
     margin: 8px 0;
     letter-spacing: 2px;
     transition: all 0.2s;
     min-width: 200px;
}

.menu-btn:hover, .menu-btn:focus {
     background: rgba(0, 229, 255, 0.25);
     box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
     transform: scale(1.03);
}

.controls-info {
     margin-top: 30px;
     text-align: center;
     color: #5a5a8a;
     font-size: 13px;
     line-height: 2;
}

.stats-display {
     margin: 20px 0;
     text-align: center;
     color: #b0b0dd;
     font-size: 18px;
     line-height: 2;
}

#new-highscore {
     color: #ffeb3b;
     font-weight: bold;
     margin-top: 10px;
     text-shadow: 0 0 10px rgba(255, 235, 59, 0.6);
}

#level-score-display {
     color: #b0b0dd;
     font-size: 18px;
     margin: 15px 0;
}

.hidden { display: none !important; }

/* ===== MOBILE RESPONSIVE ===== */
@media (hover: none) and (pointer: coarse), (max-width: 768px) {
     #pause-btn { display: flex; }
     #touch-controls { display: flex !important; }
}

#touch-controls { display: none; }

@media (max-width: 480px) {
     .overlay-title { font-size: 28px; }
     .menu-btn { padding: 10px 30px; font-size: 15px; min-width: 160px; }
     .hud-value { font-size: 16px; }
     .hud-label { font-size: 9px; }
     #hud-bottom { gap: 8px; padding: 0 5px; }
}

@media (max-width: 360px) {
     .dpad { width: 120px; height: 120px; }
     .dpad-btn { width: 44px; height: 44px; font-size: 16px; }
     .dpad-btn.up { left: 38px; }
     .dpad-btn.left { top: 38px; }
     .dpad-btn.down { top: 76px; left: 38px; }
     .dpad-btn.right { top: 38px; left: 76px; }
     .touch-dash-btn { width: 70px; height: 70px; }
}
