:root {
    --primary: #ff3e00;
    --bg-dark: #0a0a0a;
    --text-light: #f5f5f5;
    --accent: #00f2ff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

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

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#hud {
    position: absolute;
    bottom: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    z-index: 10;
}

.distance-box {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 50px;
    margin-bottom: 10px;
}

#distance-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.speedometer {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(15px);
    border: 2px solid var(--primary);
    padding: 15px 40px;
    border-radius: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 0 30px rgba(255, 62, 0, 0.3);
    text-align: center;
    margin-bottom: 20px;
}

/* Crash Overlay */
#crash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#crash-overlay h1 {
    color: white;
    font-size: 5rem;
    text-shadow: 0 0 20px red;
    margin: 0;
}

#crash-overlay p {
    color: white;
    font-size: 1.5rem;
}

/* Countdown Overlay */
#countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
}

#countdown-number {
    font-size: 12rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 0 40px var(--primary), 0 0 80px var(--primary);
    animation: countdown-pulse 1s ease-in-out infinite;
    line-height: 1;
}

@keyframes countdown-pulse {
    0%   { transform: scale(1.2); opacity: 1; }
    50%  { transform: scale(1.0); opacity: 0.8; }
    100% { transform: scale(1.2); opacity: 1; }
}

#speed-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--text-light);
    line-height: 1;
}

.unit {
    font-size: 1rem;
    color: var(--primary);
    font-weight: 700;
    display: block;
}

.controls-hint {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    padding: 15px 25px;
    border-radius: 12px;
    text-align: right;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    letter-spacing: 1px;
    border-right: 4px solid var(--accent);
}

.controls-hint p {
    margin-bottom: 5px;
}

#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.8s ease-out;
}

#loading-screen h1 {
    margin-top: 30px;
    font-size: 1.2rem;
    letter-spacing: 4px;
    color: var(--primary);
    font-weight: 300;
}

.loader {
    width: 80px;
    height: 80px;
    border: 3px solid rgba(255, 62, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Hide cursor when game is active */
body.in-game {
    cursor: none;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: none;
    justify-content: space-between;
    pointer-events: none;
    z-index: 20;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
}

.steering {
    flex-direction: row !important;
}

.ctrl-btn {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s;
}

.ctrl-btn:active {
    background: var(--primary);
}

/* Responsive Queries */
@media (max-width: 768px) {
    #hud {
        bottom: auto;
        top: 20px;
        right: 20px;
        align-items: flex-end;
    }
    
    .speedometer {
        padding: 10px 25px;
    }
    
    #speed-value {
        font-size: 2.5rem;
    }
    
    .controls-hint {
        display: none;
    }
    
    #mobile-controls {
        display: flex;
    }

    body.in-game {
        cursor: auto;
    }
}

/* Landscape optimization */
@media (max-height: 500px) {
    .ctrl-btn {
        width: 50px;
        height: 50px;
    }
}
