/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #06060c;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    color: #ffffff;
}

#game-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* UI Overlay Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
}

/* Glassmorphism Panel Base */
.glass-panel {
    background: rgba(13, 17, 30, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 0 12px rgba(0, 240, 255, 0.05);
    pointer-events: auto;
}

/* Top HUD Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.level-info-card {
    padding: 12px 18px;
    max-width: 320px;
}

.level-info-card h3 {
    font-size: 16px;
    color: #00f0ff;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.level-info-card p {
    font-size: 12px;
    color: #a0aec0;
    line-height: 1.4;
}

/* Flight Telemetry Dashboard */
.telemetry-dashboard {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    align-items: center;
}

.meter-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 65px;
}

.meter-label {
    font-size: 10px;
    color: #718096;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.hud-val {
    font-size: 15px;
    font-weight: 800;
    font-family: 'Courier New', monospace;
}

.hud-val.safe {
    color: #00ff88;
    text-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
}

.hud-val.danger {
    color: #ff3366;
    text-shadow: 0 0 8px rgba(255, 51, 102, 0.6);
}

.blink {
    animation: blinker 0.6s infinite alternate;
}

@keyframes blinker {
    from { opacity: 1; }
    to { opacity: 0.2; }
}

/* Fuel Bar */
.fuel-container {
    display: flex;
    flex-direction: column;
    width: 110px;
}

.fuel-bar-bg {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.fuel-bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.1s linear, background-color 0.3s;
    border-radius: 5px;
}

.fuel-bar-fill.normal {
    background: linear-gradient(90deg, #00bbff, #00ff88);
    box-shadow: 0 0 8px #00ff88;
}

.fuel-bar-fill.warning {
    background: linear-gradient(90deg, #ffaa00, #ffdd00);
    box-shadow: 0 0 8px #ffaa00;
}

.fuel-bar-fill.critical {
    background: #ff3366;
    box-shadow: 0 0 10px #ff3366;
    animation: blinker 0.4s infinite alternate;
}

/* Radar Mini-Map Panel */
.radar-panel {
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.radar-header {
    font-size: 10px;
    color: #00f0ff;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: 1px;
}

#radar-canvas {
    background: radial-gradient(circle, rgba(0, 40, 60, 0.8) 0%, rgba(5, 12, 25, 0.95) 100%);
    border-radius: 50%;
    border: 1px solid #00f0ff;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}

/* Action Button Bar */
.action-bar {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-hud {
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    border: 1px solid rgba(0, 240, 255, 0.35);
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    pointer-events: auto;
}

.btn-hud:hover {
    background: rgba(0, 240, 255, 0.2);
    border-color: #00f0ff;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
    transform: translateY(-1px);
}

.btn-hud:active {
    transform: translateY(1px);
}

/* Level Banner Slide-In */
#level-banner {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(10, 15, 30, 0.9);
    border: 2px solid #00f0ff;
    border-radius: 16px;
    padding: 20px 40px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 240, 255, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 20;
}

#level-banner.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#level-banner h2 {
    font-size: 28px;
    color: #00f0ff;
    margin-bottom: 8px;
    text-shadow: 0 0 16px rgba(0, 240, 255, 0.8);
}

#level-banner p {
    font-size: 14px;
    color: #e2e8f0;
}

/* Touch & Mobile Controls */
.touch-controls-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    pointer-events: none;
    margin-bottom: 8px;
}

.touch-cluster {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

.touch-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(20, 30, 50, 0.8);
    border: 2px solid rgba(0, 240, 255, 0.4);
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    transition: all 0.1s ease;
}

.touch-btn .icon {
    font-size: 20px;
    margin-bottom: 2px;
}

.touch-btn.active, .touch-btn:active {
    background: rgba(0, 240, 255, 0.4);
    border-color: #00f0ff;
    box-shadow: 0 0 20px #00f0ff;
    transform: scale(0.92);
}

.touch-btn.btn-main-thrust {
    width: 86px;
    height: 86px;
    background: linear-gradient(135deg, rgba(255, 100, 0, 0.7), rgba(255, 200, 0, 0.8));
    border-color: #ffaa00;
}

.touch-btn.btn-main-thrust.active, .touch-btn.btn-main-thrust:active {
    background: linear-gradient(135deg, rgba(255, 80, 0, 0.95), rgba(255, 230, 50, 1.0));
    box-shadow: 0 0 25px #ff9900;
}

/* Modals */
.game-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(11, 17, 33, 0.96);
    border: 2px solid rgba(0, 240, 255, 0.4);
    border-radius: 20px;
    padding: 28px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 240, 255, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.game-modal.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 26px;
    letter-spacing: 1px;
}

.modal-header.success h2 {
    color: #00ff88;
    text-shadow: 0 0 15px rgba(0, 255, 136, 0.6);
}

.modal-header.crash h2 {
    color: #ff3366;
    text-shadow: 0 0 15px rgba(255, 51, 102, 0.6);
}

.modal-stats {
    background: rgba(20, 28, 48, 0.6);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 20px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: #a0aec0;
}

.stat-value {
    color: #ffffff;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

.score-highlight {
    font-size: 24px;
    font-weight: 800;
    color: #ffd700;
    text-align: center;
    margin: 12px 0;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, #00c6ff, #0072ff);
    color: #ffffff;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    box-shadow: 0 0 15px rgba(0, 198, 255, 0.6);
    transform: translateY(-2px);
}

.btn-secondary {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Level Grid & Hangar Grid */
.level-list-grid, .skins-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding-right: 6px;
}

.level-list-card, .skin-card {
    background: rgba(20, 28, 48, 0.7);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.level-list-card:hover, .skin-card:hover {
    border-color: #00f0ff;
    background: rgba(0, 240, 255, 0.15);
}

.level-list-card .lvl-num {
    font-size: 11px;
    color: #00f0ff;
    font-weight: 800;
}

.level-list-card .lvl-name, .skin-card h4 {
    font-size: 15px;
    font-weight: 700;
    margin: 3px 0;
    color: #ffffff;
}

.level-list-card .lvl-desc, .skin-card p {
    font-size: 12px;
    color: #a0aec0;
}

.skin-card.active {
    border-color: #00ff88;
    background: rgba(0, 255, 136, 0.15);
}

.btn-select-skin {
    margin-top: 8px;
    background: #00f0ff;
    color: #000000;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

/* Sandbox Sliders */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.setting-row label {
    font-size: 13px;
    color: #e2e8f0;
}

.setting-row input[type="range"] {
    width: 140px;
}

/* Keyboard Helper Legend */
.controls-legend {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    background: rgba(10, 15, 25, 0.7);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    color: #a0aec0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
}

.controls-legend kbd {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: bold;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .level-info-card {
        max-width: 100%;
    }
    .telemetry-dashboard {
        justify-content: space-between;
    }
    .radar-panel {
        display: none;
    }
    .controls-legend {
        display: none;
    }
}
