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

body {
    overflow: hidden;
    font-family: 'Orbitron', sans-serif;
    background: #1a0a00;
    color: #fff;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#ui-overlay > * {
    pointer-events: auto;
}

/* Main Menu */
.menu-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a0a00ee, #2d1810ee, #1a0a00ee);
    backdrop-filter: blur(10px);
}

.menu-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 30% 20%, rgba(255, 107, 53, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(139, 37, 0, 0.2) 0%, transparent 50%);
    animation: pulse 4s ease-in-out infinite;
}

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

.title-container {
    text-align: center;
    z-index: 1;
    margin-bottom: 3rem;
}

.game-title {
    font-size: clamp(2rem, 8vw, 5rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    background: linear-gradient(135deg, #FF6B35, #FF8C5A, #FFD93D);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 50px rgba(255, 107, 53, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { filter: drop-shadow(0 0 20px rgba(255, 107, 53, 0.5)); }
    to { filter: drop-shadow(0 0 40px rgba(255, 107, 53, 0.8)); }
}

.subtitle {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    color: #4ECDC4;
    letter-spacing: 0.3em;
    margin-top: 1rem;
    animation: subtitlePulse 3s ease-in-out infinite;
}

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

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 1;
}

.menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 3rem;
    background: linear-gradient(135deg, #2d181088, #1a0a0088);
    border: 2px solid #FF6B35;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 280px;
}

.menu-btn:hover {
    background: linear-gradient(135deg, #FF6B3544, #8B250044);
    box-shadow: 0 0 30px rgba(255, 107, 53, 0.5);
    transform: translateY(-2px) scale(1.02);
}

.btn-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.btn-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: #FF6B35;
}

.btn-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: #888;
    margin-top: 0.3rem;
}

.menu-footer {
    position: absolute;
    bottom: 2rem;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: #666;
}

.menu-footer a {
    color: #4ECDC4;
    text-decoration: none;
    display: block;
    margin-top: 0.5rem;
}

.menu-footer a:hover {
    text-decoration: underline;
}

/* Rover Selection */
.select-container {
    width: 100%;
    height: 100%;
    padding: 2rem;
    background: linear-gradient(135deg, #1a0a00ee, #2d1810ee);
    overflow-y: auto;
}

.back-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: #2d181088;
    border: 1px solid #FF6B35;
    border-radius: 8px;
    color: #FF6B35;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    z-index: 100;
}

.back-btn:hover {
    background: #FF6B3544;
}

.select-title {
    text-align: center;
    font-size: 2rem;
    color: #FF6B35;
    margin: 2rem 0;
}

.rover-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.rover-card {
    background: linear-gradient(135deg, #2d181088, #1a0a0088);
    border: 2px solid #444;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.rover-card:hover, .rover-card.selected {
    border-color: #FF6B35;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.3);
}

.rover-preview {
    height: 100px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

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

.rover-name {
    font-size: 1.2rem;
    color: #FF6B35;
    margin-bottom: 1rem;
}

.rover-stats {
    margin-bottom: 1rem;
}

.stat {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

.stars {
    font-size: 0.7rem;
}

.select-btn {
    padding: 0.5rem 1.5rem;
    background: #FF6B35;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.select-btn:hover {
    background: #FF8C5A;
    transform: scale(1.05);
}

/* Exploration HUD */
.hud-container {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.hud-panel {
    position: absolute;
    background: rgba(26, 10, 0, 0.85);
    border: 1px solid #FF6B3588;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    backdrop-filter: blur(5px);
}

.top-left { top: 1rem; left: 1rem; }
.top-right { top: 1rem; right: 1rem; }
.bottom-center { bottom: 1rem; left: 50%; transform: translateX(-50%); }

.panel-title {
    color: #FF6B35;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.battery-bar, .health-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bar {
    flex: 1;
    height: 8px;
    background: #333;
    border-radius: 4px;
    overflow: hidden;
    min-width: 80px;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ECDC4, #2ECC71);
    transition: width 0.3s ease;
}

.health .bar-fill {
    background: linear-gradient(90deg, #FF6B35, #FF4444);
}

.weather-panel {
    text-align: right;
}

.weather-title {
    color: #4ECDC4;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.weather-item {
    margin: 0.2rem 0;
}

.weather-status {
    margin-top: 0.5rem;
    color: #FFD93D;
}

.controls-hint {
    position: absolute;
    bottom: 4rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 10, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #888;
}

.menu-return-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    background: #8B250088;
    border: 1px solid #FF6B35;
    border-radius: 6px;
    color: #FF6B35;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    pointer-events: auto;
}

/* Race Setup */
.setup-container {
    width: 100%;
    height: 100%;
    padding: 2rem;
    background: linear-gradient(135deg, #1a0a00ee, #2d1810ee);
    overflow-y: auto;
}

.setup-title {
    text-align: center;
    font-size: 2rem;
    color: #FF6B35;
    margin: 2rem 0;
}

.setup-section {
    max-width: 1000px;
    margin: 1.5rem auto;
}

.setup-section h3 {
    color: #4ECDC4;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.player-count-btns, .lap-btns {
    display: flex;
    gap: 0.5rem;
}

.count-btn, .lap-btn {
    padding: 0.5rem 1.5rem;
    background: #2d181088;
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
}

.count-btn.active, .lap-btn.active {
    border-color: #FF6B35;
    background: #FF6B3544;
}

.players-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    max-width: 1000px;
    margin: 1rem auto;
}

.player-slot {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #2d181088;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #444;
}

.player-label {
    color: #FF6B35;
    font-weight: 700;
}

.rover-dropdown {
    padding: 0.5rem;
    background: #1a0a00;
    border: 1px solid #444;
    border-radius: 4px;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
}

.color-picker {
    width: 40px;
    height: 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.track-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.track-card {
    background: #2d181088;
    border: 2px solid #444;
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.track-card:hover, .track-card.selected {
    border-color: #FF6B35;
    box-shadow: 0 0 15px rgba(255, 107, 53, 0.3);
}

.track-preview {
    height: 60px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.track-icon {
    font-size: 1.5rem;
}

.track-card h4 {
    color: #FF6B35;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.difficulty {
    font-size: 0.6rem;
    margin-bottom: 0.3rem;
}

.track-desc {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: #888;
}

.options-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option-group label {
    color: #888;
}

.toggle-btn {
    padding: 0.5rem 1.5rem;
    background: #2d181088;
    border: 1px solid #444;
    border-radius: 6px;
    color: #888;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
}

.toggle-btn.active {
    border-color: #4ECDC4;
    background: #4ECDC444;
    color: #4ECDC4;
}

.start-race-btn {
    display: block;
    margin: 2rem auto;
    padding: 1rem 3rem;
    background: linear-gradient(135deg, #FF6B35, #8B2500);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-race-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 107, 53, 0.5);
}

.start-race-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Racing HUD */
.racing-hud {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8rem;
    font-weight: 900;
    color: #FF6B35;
    text-shadow: 0 0 50px rgba(255, 107, 53, 0.8);
    animation: countdownPulse 1s ease-out;
}

@keyframes countdownPulse {
    from { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.race-panel {
    position: absolute;
    background: rgba(26, 10, 0, 0.85);
    border: 1px solid #FF6B3588;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

.race-panel.top-left { top: 1rem; left: 1rem; }
.race-panel.top-right { top: 1rem; right: 1rem; }
.race-panel.bottom-center { bottom: 3rem; left: 50%; transform: translateX(-50%); }
.race-panel.bottom-left { bottom: 1rem; left: 1rem; }
.race-panel.bottom-right { bottom: 1rem; right: 1rem; }

.position {
    font-size: 1.5rem;
    font-weight: 900;
    color: #FFD93D;
}

.lap, .timer {
    margin-top: 0.3rem;
}

.weather-mini {
    margin-top: 0.5rem;
    color: #888;
}

.powerups {
    display: flex;
    gap: 0.5rem;
}

.powerup-slot {
    width: 40px;
    height: 40px;
    background: #333;
    border: 1px solid #FF6B35;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.powerup-slot.empty {
    opacity: 0.3;
}

.race-controls {
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: #666;
}

/* Results */
.results-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a0a00ee, #2d1810ee);
    padding: 2rem;
}

.results-title {
    font-size: 2.5rem;
    color: #FFD93D;
    margin-bottom: 2rem;
}

.podium {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 2rem;
}

.podium-place {
    background: linear-gradient(135deg, #2d1810, #1a0a00);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    border: 2px solid #444;
}

.podium-place.first {
    height: 180px;
    border-color: #FFD93D;
    box-shadow: 0 0 30px rgba(255, 217, 61, 0.3);
}

.podium-place.second {
    height: 140px;
    border-color: #C0C0C0;
}

.podium-place.third {
    height: 100px;
    border-color: #CD7F32;
}

.place-rover {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.place-label {
    font-weight: 700;
    color: #FF6B35;
}

.place-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.3rem;
}

.results-weather {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: #4ECDC4;
    margin-bottom: 2rem;
}

.results-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.result-btn {
    padding: 0.75rem 1.5rem;
    background: #2d181088;
    border: 1px solid #FF6B35;
    border-radius: 8px;
    color: #FF6B35;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.result-btn:hover {
    background: #FF6B3544;
    transform: scale(1.05);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
        letter-spacing: 0.1em;
    }
    
    .menu-btn {
        min-width: 200px;
        padding: 1rem 2rem;
    }
    
    .rover-grid {
        grid-template-columns: 1fr;
    }
    
    .track-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .options-row {
        flex-direction: column;
        align-items: center;
    }
    
    .hud-panel {
        font-size: 0.7rem;
        padding: 0.5rem;
    }
    
    .countdown {
        font-size: 5rem;
    }
}