/* ============================================================================
   APEX HIGHWAY: Visual Style & Cyber Supercar Telemetry HUD
   ============================================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

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

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

/* Speed lines & cinematic vignette effect */
.vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0) 62%, rgba(0,6,18,0.72) 100%);
    transition: background 0.3s ease, box-shadow 0.25s ease;
}

.nitro-active .vignette {
    box-shadow: inset 0 0 120px rgba(0, 210, 255, 0.45);
}

.high-speed .vignette {
    background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(0,6,18,0.85) 100%);
}

/* Impact Shockwave Flash */
.crash-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
    background: radial-gradient(circle at center, rgba(255, 60, 40, 0.72) 0%, rgba(180, 10, 20, 0.95) 100%);
    opacity: 0;
    transition: opacity 0.06s ease;
}

.crash-flash.active {
    opacity: 1;
}

/* ==========================================
   HEADS-UP DISPLAY (HUD)
   ========================================== */
#hud {
    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: 24px 32px;
}

/* Top Bar: Distance, High Score & Current Score */
.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.hud-pill {
    background: rgba(12, 18, 32, 0.75);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 200, 255, 0.25);
    border-radius: 12px;
    padding: 10px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.clickable {
    pointer-events: auto !important;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.15s ease, background 0.15s ease;
}

.clickable:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 210, 255, 0.65);
    background: rgba(18, 28, 48, 0.85);
    box-shadow: 0 10px 36px rgba(0, 210, 255, 0.2);
}

.clickable:active {
    transform: translateY(1px);
}

.radio-body {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 3px;
}

.radio-title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #ff0077;
    text-shadow: 0 0 10px rgba(255, 0, 119, 0.6);
    white-space: nowrap;
}

.radio-eq {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 16px;
    margin-left: 4px;
}

.eq-bar {
    width: 3px;
    height: 4px;
    background: #00d2ff;
    border-radius: 1px;
    box-shadow: 0 0 6px #00d2ff;
    transition: height 0.08s ease;
}

.weather-title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #f59e0b;
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
    margin-top: 3px;
    white-space: nowrap;
}

.hud-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #00d2ff;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.hud-value {
    font-size: 26px;
    font-weight: 900;
    letter-spacing: 1px;
    color: #ffffff;
    text-shadow: 0 0 12px rgba(0, 210, 255, 0.5);
}

/* Near Miss Alert & Combo */
.center-alerts {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

#near-miss-popup {
    opacity: 0;
    font-size: 32px;
    font-weight: 900;
    font-style: italic;
    color: #ffcc00;
    text-shadow: 0 0 20px #ff9900, 0 0 40px #ff5500;
    letter-spacing: 2px;
    transform: scale(0.8);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

#near-miss-popup.animate-pop {
    opacity: 1;
    transform: scale(1.15);
}

#hud-multiplier {
    font-size: 18px;
    font-weight: 800;
    color: #00ffaa;
    text-shadow: 0 0 15px rgba(0, 255, 170, 0.8);
    letter-spacing: 3px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#hud-notification {
    position: absolute;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #00d2ff;
    border-radius: 20px;
    padding: 6px 18px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #00d2ff;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Bottom Cluster: Speedometer, Gear, RPM, Nitro */
.hud-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.telemetry-cluster {
    background: rgba(10, 15, 28, 0.82);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 3px solid #00d2ff;
    border-radius: 16px;
    padding: 16px 24px;
    min-width: 250px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.speed-display {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

#hud-speed {
    font-size: 54px;
    font-weight: 900;
    line-height: 1;
    font-family: 'Arial Black', Impact, sans-serif;
    color: #ffffff;
    text-shadow: 0 0 15px rgba(0, 210, 255, 0.6);
}

.speed-unit {
    font-size: 14px;
    font-weight: 800;
    color: #7b8ca3;
    letter-spacing: 2px;
}

.gear-display {
    display: inline-block;
    margin-left: 20px;
    background: #00d2ff;
    color: #050a14;
    font-size: 20px;
    font-weight: 900;
    padding: 2px 10px;
    border-radius: 6px;
}

/* Bar gauges */
.gauge-row {
    margin-top: 10px;
}

.gauge-track {
    width: 100%;
    height: 7px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin-top: 4px;
}

#hud-rpm-fill {
    height: 100%;
    width: 20%;
    background: linear-gradient(90deg, #00d2ff 0%, #00ffaa 75%, #ff3366 100%);
    border-radius: 4px;
    transition: width 0.05s linear;
}

#hud-nitro-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #0055ff, #00d2ff);
    box-shadow: 0 0 10px #00d2ff;
    border-radius: 4px;
    transition: width 0.08s ease;
}

.gauge-caption {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 700;
    color: #7b8ca3;
    letter-spacing: 1px;
}

/* Controls Hint / Hotkeys */
.controls-hint {
    background: rgba(10, 15, 28, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 11px;
    color: #9cb0c9;
    line-height: 1.8;
}

.kbd {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    font-weight: 800;
    color: #fff;
    margin: 0 2px;
}

/* Touch controls overlay for mobile or click */
.touch-controls {
    position: absolute;
    bottom: 24px;
    left: 0;
    width: 100%;
    display: none; /* Can be toggled on mobile */
    justify-content: space-between;
    padding: 0 32px;
    pointer-events: auto;
}

.touch-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(0, 210, 255, 0.4);
    color: white;
    font-weight: 900;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}

.touch-btn:active {
    background: #00d2ff;
    color: #000;
}

/* ==========================================
   CINEMATIC FULL-CANVAS MOTORSPORT HUD (NO CLUNKY CARD)
   ========================================== */
.cinematic-menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    /* Transparent vignette so user directly sees the gorgeous 3D rotating Porsche and highway lights */
    background: radial-gradient(circle at center, rgba(3, 7, 18, 0.25) 0%, rgba(2, 4, 10, 0.78) 75%, rgba(1, 2, 6, 0.92) 100%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 44px 32px 36px;
    box-sizing: border-box;
    pointer-events: auto;
    user-select: none;
    animation: fadeInOverlay 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInOverlay {
    from { opacity: 0; transform: scale(1.02); }
    to { opacity: 1; transform: scale(1.0); }
}

/* 1. Header Branding */
.menu-brand-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.brand-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: #00d2ff;
    background: rgba(0, 210, 255, 0.08);
    border: 1px solid rgba(0, 210, 255, 0.35);
    padding: 5px 18px;
    border-radius: 20px;
    margin-bottom: 12px;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.2);
    backdrop-filter: blur(8px);
}

.game-title {
    font-size: 58px;
    font-weight: 950;
    font-style: italic;
    letter-spacing: 8px;
    background: linear-gradient(180deg, #ffffff 15%, #b5e4ff 60%, #00d2ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    line-height: 1.1;
    filter: drop-shadow(0 0 25px rgba(0, 210, 255, 0.4));
    text-transform: uppercase;
}

.game-subtitle {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 6px;
    color: #9cb3ce;
    text-transform: uppercase;
    margin-top: 6px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

/* 2. Center Reticle & Status Indicator */
.menu-viewport-reticle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    max-width: 680px;
    pointer-events: none;
    opacity: 0.85;
}

.reticle-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 210, 255, 0.45));
}

.reticle-right {
    background: linear-gradient(270deg, transparent, rgba(0, 210, 255, 0.45));
}

.reticle-core {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 3px;
    color: #00d2ff;
    padding: 6px 16px;
    background: rgba(4, 12, 28, 0.65);
    border: 1px solid rgba(0, 210, 255, 0.35);
    border-radius: 4px;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.15);
    backdrop-filter: blur(6px);
}

.reticle-icon {
    font-size: 12px;
    animation: pulseReticle 1.8s infinite ease-in-out;
}

@keyframes pulseReticle {
    0%, 100% { opacity: 0.5; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.15); }
}

/* 3. Ultra-Clean Model Loading Progress Bar */
.loading-bar-wrapper {
    width: 100%;
    max-width: 440px;
    margin-top: -10px;
    margin-bottom: -10px;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.loading-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #7b94b2;
    margin-bottom: 6px;
    text-transform: uppercase;
}

#loading-percent {
    color: #00d2ff;
    font-variant-numeric: tabular-nums;
}

.loading-track {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    position: relative;
}

.loading-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00d2ff, #00ffaa);
    box-shadow: 0 0 12px #00d2ff;
    transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 4. Bottom Cockpit Launch Deck */
.menu-launch-deck {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    width: 100%;
    max-width: 580px;
}

.menu-telemetry-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    background: rgba(8, 16, 32, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 40px;
    padding: 10px 32px;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

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

.telem-lbl {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 2.5px;
    color: #6a829e;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.telem-val {
    font-size: 18px;
    font-weight: 900;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.telem-unit {
    font-size: 11px;
    font-weight: 700;
    color: #00d2ff;
    letter-spacing: 1px;
}

.telem-divider {
    width: 1px;
    height: 26px;
    background: rgba(255, 255, 255, 0.12);
}

/* 5. Bespoke Glowing Engine Ignition Push-Button */
.btn-ignition {
    position: relative;
    width: 100%;
    max-width: 380px;
    height: 64px;
    background: linear-gradient(180deg, #0f2438 0%, #081422 100%);
    border: 1.5px solid #00d2ff;
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 25px rgba(0, 210, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-ignition:hover {
    transform: translateY(-2px) scale(1.015);
    background: linear-gradient(180deg, #133352 0%, #0c1f36 100%);
    border-color: #38e1ff;
    box-shadow: 0 0 45px rgba(0, 210, 255, 0.6), inset 0 0 15px rgba(0, 210, 255, 0.3);
}

.btn-ignition:active {
    transform: translateY(1px) scale(0.985);
    box-shadow: 0 0 20px rgba(0, 210, 255, 0.4);
}

.ignition-text {
    font-size: 18px;
    font-weight: 950;
    letter-spacing: 4px;
    color: #ffffff;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(0, 210, 255, 0.8);
    position: relative;
    z-index: 2;
}

.ignition-sub {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 3px;
    color: #00d2ff;
    text-transform: uppercase;
    margin-top: 3px;
    position: relative;
    z-index: 2;
    opacity: 0.85;
}

.ignition-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 210, 255, 0.35), transparent);
    transform: skewX(-25deg);
    animation: ignitionSheen 3.2s infinite ease-in-out;
}

@keyframes ignitionSheen {
    0% { left: -100%; }
    40%, 100% { left: 160%; }
}

.menu-hud-hints {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #63778f;
    text-align: center;
    line-height: 1.6;
}

.menu-hud-hints span {
    color: #9cb3ce;
}

/* ==========================================
   MODAL OVERLAYS (CRASH & PAUSE)
   ========================================== */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: rgba(4, 7, 16, 0.85);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.menu-card {
    background: linear-gradient(135deg, rgba(16, 24, 44, 0.95), rgba(8, 12, 24, 0.98));
    border: 1px solid rgba(0, 210, 255, 0.3);
    border-radius: 24px;
    padding: 44px 50px;
    text-align: center;
    max-width: 520px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 210, 255, 0.15);
}

.menu-stats-row {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 28px;
}

.menu-stat-item {
    text-align: center;
}

.menu-stat-item .val {
    font-size: 22px;
    font-weight: 800;
    color: #00d2ff;
}

.menu-stat-item .lbl {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #6d7f96;
    margin-top: 4px;
}

.btn-primary {
    background: linear-gradient(135deg, #00d2ff, #0066ff);
    color: #ffffff;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 16px 36px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0, 150, 255, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(0, 150, 255, 0.65);
}

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

.menu-instructions {
    margin-top: 24px;
    font-size: 12px;
    color: #7b8ca3;
    line-height: 1.8;
}

/* Crash Screen specifics */
.crash-header {
    color: #ff334b;
    font-size: 34px;
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 18px;
    text-shadow: 0 0 20px rgba(255, 51, 75, 0.5);
}

@media (max-width: 768px) {
    #hud {
        padding: 16px;
    }
    .hud-bottom {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 12px;
    }
    .controls-hint {
        display: none;
    }
    .touch-controls {
        display: flex;
    }
    #hud-speed {
        font-size: 42px;
    }
    .game-title {
        font-size: 30px;
    }
}

