/* Red Horizon V2 - Cargo Runner */
/* Retro Poster Aesthetic with Enhanced 3D Effects */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');

:root {
    --mars-red: #C1440E;
    --mars-dark: #B8390A;
    --cream: #E8D5B7;
    --black: #2B2B2B;
    --dark-black: #1A1A1A;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: var(--dark-black);
    overflow: hidden;
    color: var(--cream);
}

/* Loading Screen */
#loadingScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: url('../assets/images/intro_background.jpg') center/cover no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 0.5s;
}

#loadingScreen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
}

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

#logo {
    max-width: 400px;
    margin-bottom: 40px;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.8));
}

#loadingBar {
    width: 400px;
    height: 30px;
    background: var(--black);
    border: 4px solid var(--cream);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

#loadingProgress {
    height: 100%;
    background: var(--cream);
    width: 0%;
    transition: width 0.3s;
}

#loadingText {
    color: var(--cream);
    font-size: 18px;
    margin-top: 30px;
    letter-spacing: 2px;
}

#startButton {
    margin-top: 30px;
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    color: var(--cream);
    background: var(--rust);
    border: 3px solid var(--cream);
    border-radius: 8px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.3s;
}

#startButton:hover {
    background: #E85A0E;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(193, 68, 14, 0.8);
}

/* Game Container */
#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Parallax Layers */
.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Force GPU acceleration */
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

#bgLayer1 { z-index: 1; opacity: 1.0; }
#bgLayer2 { z-index: 2; opacity: 1.0; }
#bgLayer3 { z-index: 3; opacity: 1.0; }

/* Main Canvas */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    background: transparent;
    /* GPU acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Indicator Overlay Canvas */
#indicatorCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 150;
    background: transparent;
    pointer-events: none;
    /* Force GPU acceleration */
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* Cockpit Corner Accents */
#hud::before,
#hud::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border: 2px solid rgba(0, 212, 221, 0.3);
    pointer-events: none;
}

#hud::before {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    box-shadow: inset 5px 5px 15px rgba(0, 212, 221, 0.2);
}

#hud::after {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    box-shadow: inset -5px -5px 15px rgba(0, 212, 221, 0.2);
}

/* Top-Left: Compact FPS + ALT */
#topLeftHud {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.compact-stat {
    background: linear-gradient(135deg, rgba(0, 20, 20, 0.9), rgba(0, 30, 30, 0.9));
    border: 2px solid rgba(0, 212, 221, 0.6);
    padding: 8px 12px;
    min-width: 60px;
    box-shadow: 
        inset 0 0 15px rgba(0, 0, 0, 0.8),
        0 0 15px rgba(0, 212, 221, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.9);
}

.stat-label {
    color: rgba(0, 212, 221, 0.8);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.stat-value {
    color: #00D4DD;
    font-size: 24px;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 212, 221, 0.5);
}

/* Top-Right: Cargo Timer + Info */
#topRightHud {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
}

.cargo-info {
    background: linear-gradient(135deg, rgba(0, 20, 20, 0.9), rgba(0, 30, 30, 0.9));
    border: 2px solid rgba(0, 212, 221, 0.6);
    padding: 10px 15px;
    box-shadow: 
        inset 0 0 15px rgba(0, 0, 0, 0.8),
        0 0 15px rgba(0, 212, 221, 0.3);
}

.cargo-label {
    color: rgba(0, 212, 221, 0.8);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.cargo-label span {
    color: #00D4DD;
    text-shadow: 0 0 8px rgba(0, 212, 221, 0.4);
}

.utility-icons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.icon-btn {
    background: linear-gradient(135deg, rgba(0, 20, 20, 0.9), rgba(0, 30, 30, 0.9));
    border: 2px solid rgba(0, 212, 221, 0.6);
    color: #00D4DD;
    font-size: 20px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 212, 221, 0.3);
    pointer-events: auto;
}

.icon-btn:hover {
    background: rgba(0, 212, 221, 0.2);
    box-shadow: 0 0 20px rgba(0, 212, 221, 0.6);
    transform: scale(1.1);
}

#cargoTimerCanvas {
    flex-shrink: 0;
}

.mission-info {
    flex: 1;
}

.mission-status {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.mission-status:last-child {
    margin-bottom: 0;
}

.mission-label {
    color: var(--cream);
    font-size: 12px;
    font-weight: bold;
    opacity: 0.7;
}

.mission-value {
    color: var(--cream);
    font-size: 14px;
    font-weight: bold;
    text-shadow: 2px 2px 0 var(--black);
}


/* Bottom-Right: Score Panel */
#scorePanel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, rgba(0, 20, 20, 0.9), rgba(0, 30, 30, 0.9));
    border: 2px solid rgba(0, 212, 221, 0.6);
    padding: 12px 18px;
    box-shadow: 
        inset 0 0 15px rgba(0, 0, 0, 0.8),
        0 0 15px rgba(0, 212, 221, 0.3);
    z-index: 5;
    pointer-events: auto;
}

.score-item {
    color: rgba(0, 212, 221, 0.8);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.score-item span {
    color: #00D4DD;
    text-shadow: 0 0 8px rgba(0, 212, 221, 0.4);
}

.score-item:last-child {
    margin-bottom: 0;
}

/* Top-Center: Heat Warning */
#heatWarning {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(40, 0, 0, 0.95), rgba(60, 0, 0, 0.95));
    border: 2px solid rgba(255, 68, 68, 0.8);
    padding: 10px 20px;
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.8),
        0 0 25px rgba(255, 68, 68, 0.5);
    pointer-events: none;
}

.heat-text {
    color: #FF4444;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(255, 68, 68, 0.8);
    margin-bottom: 5px;
    animation: pulse 0.5s ease-in-out infinite;
}

.heat-bar-container {
    width: 200px;
    height: 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 68, 68, 0.5);
    overflow: hidden;
}

.heat-bar {
    height: 100%;
    background: linear-gradient(90deg, #FF4444, #FF8800);
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.8);
    transition: width 0.1s ease;
}

/* Bottom-Left: Radar */
#radarContainer {
    position: absolute;
    bottom: 20px;
    left: 20px;
    pointer-events: none;
}

#radarCanvas {
    filter: drop-shadow(0 0 15px rgba(0, 212, 221, 0.3));
}

/* Center-Right: Velocity Gauge */
#velocityGauge {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    pointer-events: none;
}

#velocityCanvas {
    filter: drop-shadow(0 0 15px rgba(0, 212, 221, 0.3));
}

/* Settings Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: auto;
}

.modal-content {
    background: linear-gradient(135deg, rgba(0, 20, 20, 0.98), rgba(0, 30, 30, 0.98));
    border: 3px solid rgba(0, 212, 221, 0.8);
    padding: 30px 40px;
    min-width: 400px;
    box-shadow: 
        inset 0 0 30px rgba(0, 0, 0, 0.8),
        0 0 40px rgba(0, 212, 221, 0.4);
}

.modal-content h2 {
    color: #00D4DD;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 25px;
    text-shadow: 0 0 15px rgba(0, 212, 221, 0.6);
    text-align: center;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 212, 221, 0.3);
}

.setting-row label {
    color: rgba(0, 212, 221, 0.9);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.setting-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.setting-row select {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(0, 212, 221, 0.6);
    color: #00D4DD;
    padding: 8px 12px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.modal-btn {
    width: 100%;
    background: linear-gradient(135deg, rgba(0, 212, 221, 0.2), rgba(0, 212, 221, 0.3));
    border: 2px solid rgba(0, 212, 221, 0.8);
    color: #00D4DD;
    padding: 12px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.modal-btn:hover {
    background: linear-gradient(135deg, rgba(0, 212, 221, 0.3), rgba(0, 212, 221, 0.4));
    box-shadow: 0 0 20px rgba(0, 212, 221, 0.6);
    transform: scale(1.02);
}

/* Message Display */
#message {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    transform: none;
    background: linear-gradient(to bottom, rgba(43, 43, 43, 0.3), rgba(26, 26, 26, 0.85));
    border-top: 4px solid var(--cream);
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 25px 40px;
    display: none;
    z-index: 280;
    backdrop-filter: blur(8px);
}

#messageText {
color: var(--cream);
font-size: 24px;
font-weight: bold;
text-align: center;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9);
opacity: 1.0;
letter-spacing: 1px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 15px;
    gap: 15px;
}

#messageText .crash-title {
    font-size: 32px;
    letter-spacing: 3px;
}

#messageText .crash-subtitle {
    font-size: 18px;
    color: #FF6600;
    font-style: italic;
}

#messageText .crash-stats {
    font-size: 20px;
    font-weight: normal;
    letter-spacing: 2px;
}

#messageText .crash-restart {
    font-size: 18px;
    opacity: 0.8;
    margin-top: 5px;
}

#leaderboardBtn {
    display: none;
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 12px 35px;
    background: var(--black);
    border: 3px solid var(--cream);
    color: var(--cream);
    font-size: 18px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    z-index: 270;
    transition: all 0.2s ease;
}

#leaderboardBtn:hover {
    background: var(--cream);
    color: var(--black);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

/* Station Interface */
#stationInterface {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 400;
    pointer-events: auto;
}

.station-panel {
    background: rgba(43, 43, 43, 0.95);
    border: 8px solid var(--cream);
    padding: 40px;
    min-width: 500px;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.9));
}

.station-panel h2 {
    color: var(--cream);
    font-size: 32px;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 3px 3px 0 var(--black);
    letter-spacing: 3px;
}

.station-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.station-btn {
    background: var(--black);
    border: 4px solid var(--cream);
    color: var(--cream);
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: auto;
    position: relative;
}

.station-btn:hover {
    background: var(--cream);
    color: var(--black);
    transform: translateY(-2px);
    filter: drop-shadow(0 4px 8px rgba(232, 213, 183, 0.5));
}

.station-btn:active {
    transform: translateY(2px);
}

.station-btn.selected {
    background: rgba(193, 68, 14, 0.3);
    border-color: var(--cream);
    box-shadow: 0 0 20px rgba(193, 68, 14, 0.6);
    transform: translateX(5px);
}

.station-btn.selected::before {
    content: '▶';
    position: absolute;
    left: -25px;
    font-size: 20px;
    color: var(--cream);
    animation: bounce 0.6s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}

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

/* Heat Gauge */
.heat-bar-container {
    width: 150px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--cream);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 5px;
}

.heat-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #FFAA00, #FF6600, #FF0000);
    transition: width 0.2s ease;
    box-shadow: 0 0 10px rgba(255, 100, 0, 0.8);
}

#heatSection {
    border: 2px solid #FF6600;
    background: rgba(255, 100, 0, 0.1);
    animation: pulse 1s ease-in-out infinite;
}

#minimap {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 250px;
    height: 150px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--cream);
    border-radius: 4px;
    z-index: 5;
}

.station-hint {
    text-align: center;
    color: var(--cream);
    font-size: 16px;
    margin-top: 20px;
    padding: 12px 20px;
    background: rgba(193, 68, 14, 0.3);
    border: 2px solid rgba(232, 213, 183, 0.5);
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 1px;
    animation: pulse 2s ease-in-out infinite;
}

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

.btn-icon {
    font-size: 24px;
    margin-right: 15px;
}

.btn-text {
    flex: 1;
    text-align: left;
}

.btn-cost {
    font-size: 14px;
    opacity: 0.8;
}

/* Music Toggle */
#musicToggle {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    border: none;
    color: var(--cream);
    font-size: 24px;
    cursor: pointer;
    z-index: 150;
    opacity: 0.7;
    transition: opacity 0.3s;
    padding: 5px;
    pointer-events: auto;
}

#musicToggle:hover {
    opacity: 1;
}

/* Leaderboard Modal */
#leaderboardModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: rgba(43, 43, 43, 0.95);
    border: 8px solid var(--cream);
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.9));
}

.modal-content h2 {
    color: var(--cream);
    font-size: 36px;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 3px 3px 0 var(--black);
}

#leaderboardList {
    margin-bottom: 20px;
}

#submitScore {
    margin-bottom: 20px;
}

#submitScore input {
    width: 100%;
    padding: 15px;
    background: var(--black);
    border: 4px solid var(--cream);
    color: var(--cream);
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}

#submitScore button {
    width: 100%;
    padding: 15px;
    background: var(--black);
    border: 4px solid var(--cream);
    color: var(--cream);
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

#submitScore button:hover {
    background: var(--cream);
    color: var(--black);
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons button {
    flex: 1;
    padding: 15px;
    background: var(--black);
    border: 4px solid var(--cream);
    color: var(--cream);
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-buttons button:hover {
    background: var(--cream);
    color: var(--black);
}

/* Instructions */
#instructions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--cream);
    opacity: 0.7;
    font-size: 14px;
    text-align: center;
    z-index: 150;
}

/* Leaderboard Modal */
#leaderboardModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
}

#leaderboardContent {
    background: var(--black);
    border: 4px solid var(--cream);
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
}

#leaderboardContent h2 {
    color: var(--mars-red);
    margin-bottom: 20px;
    font-size: 32px;
}

#leaderboardList {
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin: 5px 0;
    background: rgba(193, 68, 14, 0.1);
    border: 2px solid var(--mars-dark);
    color: var(--cream);
}

.leaderboard-entry.top3 {
    background: rgba(193, 68, 14, 0.3);
    border-color: var(--mars-red);
    font-weight: bold;
}

.leaderboard-entry.new-entry {
    background: rgba(232, 213, 183, 0.2);
    border: 3px solid var(--cream);
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(232, 213, 183, 0.5);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(232, 213, 183, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(232, 213, 183, 0.8);
    }
}

#closeLeaderboard {
    margin-top: 20px;
    padding: 12px 30px;
    background: var(--mars-red);
    color: var(--cream);
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

#closeLeaderboard:hover {
    background: var(--cream);
    color: var(--black);
}

/* Game Over Screen */
#gameOverScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10002;
}

#gameOverContent {
    background: var(--black);
    border: 4px solid var(--mars-red);
    padding: 40px;
    text-align: center;
    max-width: 500px;
}

#gameOverContent h2 {
    color: var(--mars-red);
    font-size: 48px;
    margin-bottom: 20px;
}

#gameOverContent p {
    color: var(--cream);
    font-size: 24px;
    margin: 10px 0;
}

#playerName {
    width: 100%;
    padding: 15px;
    margin: 20px 0;
    background: var(--dark-black);
    border: 2px solid var(--cream);
    color: var(--cream);
    font-size: 18px;
    text-align: center;
    font-family: 'Poppins', sans-serif;
}

#submitScore, #skipSubmit {
    padding: 15px 30px;
    margin: 10px;
    background: var(--mars-red);
    color: var(--cream);
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

#submitScore:hover, #skipSubmit:hover {
    background: var(--cream);
    color: var(--black);
}

#skipSubmit {
    background: var(--dark-black);
    border: 2px solid var(--cream);
}
