/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #050510;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* Canvas */
#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(180deg, #050510 0%, #0a0a20 50%, #0f0a1a 100%);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Overlay Base */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(5, 5, 16, 0.95);
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Menu Container */
.menu-container {
    text-align: center;
    padding: 40px;
    max-width: 500px;
    width: 90%;
}

/* Game Title */
.game-title {
    font-size: 3.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 30px #ff6600, 0 0 60px #ff4400;
    letter-spacing: 6px;
    line-height: 1.1;
    margin-bottom: 10px;
}

.game-subtitle {
    color: #888;
    font-size: 1.1rem;
    margin-bottom: 40px;
    letter-spacing: 3px;
}

/* Menu Buttons */
.menu-btn {
    display: block;
    width: 100%;
    padding: 18px 40px;
    margin: 12px 0;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 2px;
    border: 2px solid #444;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #ff6600;
    transform: scale(1.02);
}

.menu-btn.primary {
    background: linear-gradient(135deg, #ff6600 0%, #ff3300 100%);
    border: none;
    color: #fff;
}

.menu-btn.primary:hover {
    background: linear-gradient(135deg, #ff7700 0%, #ff4400 100%);
    box-shadow: 0 0 30px rgba(255, 102, 0, 0.5);
}

/* Instructions */
.instructions {
    margin: 30px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    text-align: left;
}

.instructions h3 {
    color: #ff6600;
    font-size: 0.9rem;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.instructions p {
    color: #aaa;
    font-size: 0.95rem;
    margin: 8px 0;
    line-height: 1.4;
}

/* Best Score */
.best-score {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    color: #ffd700;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 2px;
}

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    z-index: 50;
    pointer-events: none;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.hud-left, .hud-right {
    flex: 1;
}

.hud-center {
    flex: 1;
    text-align: center;
}

.hud-right {
    text-align: right;
}

/* Stat Bars */
.stat-bar {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #888;
    letter-spacing: 1px;
    width: 55px;
}

.bar-container {
    width: 120px;
    height: 14px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #333;
    border-radius: 7px;
    overflow: hidden;
    margin: 0 8px;
}

.bar {
    height: 100%;
    transition: width 0.2s ease;
    border-radius: 6px;
}

.shield-bar {
    background: linear-gradient(90deg, #00aaff, #00ffff);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.health-bar {
    background: linear-gradient(90deg, #ff4444, #ff8800);
    box-shadow: 0 0 10px rgba(255, 100, 100, 0.5);
}

.fuel-bar {
    background: linear-gradient(90deg, #44ff44, #88ff00);
    box-shadow: 0 0 10px rgba(100, 255, 100, 0.5);
}

.stat-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    width: 35px;
}

.ammo-display {
    font-size: 1rem;
    font-weight: 700;
    color: #ffaa00;
    margin-left: 10px;
}

/* Level & Timer Display */
#levelDisplay {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ff6600;
    letter-spacing: 3px;
    text-shadow: 0 0 15px rgba(255, 102, 0, 0.5);
}

#timerDisplay {
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Score Display */
.score-display {
    margin-bottom: 5px;
}

.score-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Landing HUD */
#landingHud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    z-index: 50;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
}

.landing-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 10px;
}

.landing-stat {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fuel-bar-container {
    width: 150px;
}

.velocity-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #00ff00;
    min-width: 50px;
}

.velocity-value.warning {
    color: #ffaa00;
}

.velocity-value.danger {
    color: #ff4444;
}

.landing-instructions {
    text-align: center;
    color: #aaa;
    font-size: 0.85rem;
}

.landing-instructions p {
    margin: 5px 0;
}

/* Mobile Controls */
#mobileControls {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    z-index: 60;
    padding: 0 20px;
}

.mobile-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    font-weight: 700;
    cursor: pointer;
    border: 3px solid;
    transition: transform 0.1s, box-shadow 0.1s;
}

.mobile-btn:active {
    transform: scale(0.9);
}

.rotate-btn {
    background: linear-gradient(135deg, #333 0%, #222 100%);
    border-color: #666;
    color: #fff;
}

.rotate-btn:active {
    background: linear-gradient(135deg, #444 0%, #333 100%);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.thrust-btn {
    width: 85px;
    height: 85px;
    background: linear-gradient(135deg, #00aa00 0%, #006600 100%);
    border-color: #00ff00;
    color: #fff;
    font-size: 2rem;
}

.thrust-btn:active {
    background: linear-gradient(135deg, #00cc00 0%, #008800 100%);
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.5);
}

.fire-btn {
    background: linear-gradient(135deg, #ff4400 0%, #cc0000 100%);
    border-color: #ff6600;
    color: #fff;
}

.fire-btn:active {
    background: linear-gradient(135deg, #ff6600 0%, #ff2200 100%);
    box-shadow: 0 0 20px rgba(255, 100, 0, 0.5);
}

.fire-btn.landing-mode {
    opacity: 0.3;
    pointer-events: none;
}

/* Station Menu */
.station-container {
    max-width: 450px;
}

.station-title {
    font-size: 2.5rem;
    color: #00ffff;
    text-shadow: 0 0 30px rgba(0, 255, 255, 0.7);
    margin-bottom: 10px;
}

.station-subtitle {
    color: #888;
    margin-bottom: 25px;
}

.station-stats {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
}

.station-stat {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
}

.station-stat:last-child {
    border-bottom: none;
}

.station-stat span:first-child {
    color: #888;
}

.station-stat span:last-child {
    color: #fff;
    font-weight: 700;
}

.station-options {
    margin-top: 20px;
}

/* Checkpoint Banner */
.checkpoint-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 75;
    background: rgba(255, 170, 0, 0.9);
    color: #000;
    padding: 20px 40px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 3px;
    border-radius: 10px;
    animation: checkpointPulse 0.5s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes checkpointPulse {
    from { transform: translate(-50%, -50%) scale(1); }
    to { transform: translate(-50%, -50%) scale(1.05); }
}

/* Game Over */
.game-over-title {
    font-size: 3rem;
    color: #ff4444;
    text-shadow: 0 0 30px rgba(255, 68, 68, 0.7);
    margin-bottom: 10px;
    letter-spacing: 5px;
}

.death-reason {
    color: #ff8888;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.final-stats {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span:first-child {
    color: #888;
}

.stat-row span:last-child {
    color: #fff;
    font-weight: 700;
}

.stat-row.highlight {
    color: #ffd700 !important;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
}

.stat-row.highlight span {
    color: #ffd700 !important;
}

/* Level Banner */
.level-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 75;
    font-size: 4rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 40px #ff6600, 0 0 80px #ff4400;
    letter-spacing: 10px;
    animation: levelPulse 1s ease-out forwards;
    pointer-events: none;
}

@keyframes levelPulse {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* Floating Texts */
#floatingTexts {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 60;
}

.floating-text {
    position: absolute;
    font-size: 1.2rem;
    font-weight: 700;
    text-shadow: 0 0 10px currentColor;
    animation: floatUp 1s ease-out forwards;
    pointer-events: none;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.2);
    }
}

/* Responsive */
@media (max-width: 600px) {
    .game-title {
        font-size: 2.5rem;
        letter-spacing: 4px;
    }
    
    .menu-container {
        padding: 20px;
    }
    
    .bar-container {
        width: 80px;
    }
    
    #timerDisplay {
        font-size: 1.8rem;
    }
    
    #levelDisplay {
        font-size: 1rem;
    }
    
    .level-banner {
        font-size: 2.5rem;
    }
    
    .hud-top {
        flex-wrap: wrap;
    }
    
    .hud-center {
        order: -1;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .landing-stats {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .checkpoint-banner {
        font-size: 1rem;
        padding: 15px 20px;
    }
    
    .mobile-btn {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .thrust-btn {
        width: 75px;
        height: 75px;
        font-size: 1.8rem;
    }
}