/* ===== Base Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #000;
    font-family: 'Rajdhani', sans-serif;
    color: #fff;
    user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.hidden {
    display: none !important;
}

/* ===== Loading Screen ===== */
#loading {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0a0a1a, #1a0a2e);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#loading-content {
    text-align: center;
}

#loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #00ff88;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#loading p {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    color: #00ff88;
    letter-spacing: 2px;
}

/* ===== Start Screen ===== */
#start-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, rgba(10, 10, 30, 0.95), rgba(30, 10, 50, 0.95));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(10px);
}

#start-content {
    text-align: center;
    max-width: 500px;
    padding: 40px;
}

#game-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 4rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #00ff88, #00aaff, #ff3366);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    animation: titlePulse 3s ease-in-out infinite;
}

#game-title span {
    font-size: 5rem;
    background: linear-gradient(135deg, #ff3366, #ffaa00, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes titlePulse {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.3);
    }
}

#car-select {
    margin-bottom: 25px;
}

#car-select h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
}

#car-colors {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.color-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.3s;
}

.color-btn:hover {
    transform: scale(1.2);
    border-color: rgba(255, 255, 255, 0.6);
}

.color-btn.selected {
    border-color: #fff;
    transform: scale(1.2);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

#controls-info {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
}

.key {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 4px 10px;
    color: #00ff88;
    letter-spacing: 1px;
}

#start-btn,
#restart-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 15px 50px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #00ff88, #00aaff);
    color: #0a0a1a;
    cursor: pointer;
    letter-spacing: 3px;
    transition: all 0.3s;
    text-transform: uppercase;
}

#start-btn:hover,
#restart-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(0, 255, 136, 0.4);
}

/* ===== HUD ===== */
#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
}

/* Speed Panel */
#speed-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 15px 25px 10px;
    backdrop-filter: blur(15px);
    text-align: center;
    min-width: 180px;
}

#speed-gauge {
    width: 160px;
    height: 100px;
    margin: 0 auto;
}

#gauge-svg {
    width: 100%;
    height: 100%;
}

#speed-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.8rem;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    margin-top: -5px;
}

#speed-unit {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 3px;
}

/* Race Info */
#race-info {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    align-items: center;
}

#position-display {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 8px 18px;
    backdrop-filter: blur(15px);
    text-align: center;
}

#position-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    color: #ffaa00;
}

#position-suffix {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    vertical-align: super;
}

#lap-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 12px 18px;
    backdrop-filter: blur(15px);
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.8);
}

#lap-display span {
    color: #00ff88;
    font-weight: 700;
}

#timer-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 12px 18px;
    backdrop-filter: blur(15px);
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.8);
}

/* Minimap */
#minimap {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    backdrop-filter: blur(15px);
}

/* Drift Indicator */
#drift-indicator {
    position: absolute;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
    color: #ffaa00;
    text-shadow: 0 0 20px rgba(255, 170, 0, 0.6);
    animation: driftPulse 0.3s ease-in-out infinite alternate;
    letter-spacing: 5px;
}

@keyframes driftPulse {
    from {
        opacity: 0.7;
        transform: translateX(-50%) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) scale(1.05);
    }
}

/* ===== Countdown ===== */
#countdown {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    pointer-events: none;
}

#countdown-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 10rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 60px rgba(0, 255, 136, 0.6), 0 0 120px rgba(0, 170, 255, 0.3);
    animation: countdownPop 0.5s ease-out;
}

@keyframes countdownPop {
    0% {
        transform: scale(2);
        opacity: 0;
    }

    50% {
        transform: scale(0.9);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== Results Screen ===== */
#results-screen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(15px);
}

#results-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 40px 60px;
    backdrop-filter: blur(20px);
    max-width: 500px;
}

#results-content h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.2rem;
    margin-bottom: 25px;
    background: linear-gradient(135deg, #ffaa00, #ff3366);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#results-details {
    margin-bottom: 30px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
}

.result-row .label {
    color: rgba(255, 255, 255, 0.6);
}

.result-row .value {
    font-family: 'Orbitron', sans-serif;
    color: #00ff88;
    font-weight: 700;
}

.result-position {
    font-family: 'Orbitron', sans-serif;
    font-size: 4rem;
    font-weight: 900;
    margin-bottom: 10px;
}

.result-position.gold {
    color: #ffd700;
}

.result-position.silver {
    color: #c0c0c0;
}

.result-position.bronze {
    color: #cd7f32;
}

.result-position.other {
    color: #fff;
}

#restart-btn {
    margin-top: 10px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    #game-title {
        font-size: 2.5rem;
    }

    #game-title span {
        font-size: 3.2rem;
    }

    #speed-panel {
        transform: scale(0.8);
        transform-origin: bottom left;
    }

    #minimap {
        transform: scale(0.7);
        transform-origin: bottom right;
    }

    #race-info {
        gap: 8px;
    }

    #position-value {
        font-size: 1.4rem;
    }

    #lap-display,
    #timer-display {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
}