:root {
    --primary-color: #00f2ff;
    --secondary-color: #ff0055;
    --bg-dark: #0a0a12;
    --text-light: #ffffff;
    --glass-bg: rgba(20, 20, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
}

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

body {
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: var(--font-main);
    color: var(--text-light);
}

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

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to canvas if needed, but buttons will re-enable them */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    transition: opacity 0.4s ease, visibility 0.4s;
    pointer-events: auto;
}

.screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.game-title {
    font-size: 5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -2px;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 30px rgba(0, 242, 255, 0.5);
    transform: skew(-5deg);
}

.highlight {
    color: var(--secondary-color);
    text-shadow: 0 0 30px rgba(255, 0, 85, 0.5);
}

.subtitle {
    font-size: 1.5rem;
    font-weight: 300;
    opacity: 0.8;
    margin-bottom: 3rem;
    letter-spacing: 2px;
}

.controls-hint {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Car Selector */
.car-selector-container {
    margin-bottom: 2rem;
    text-align: center;
}

.select-label {
    font-size: 0.9rem;
    letter-spacing: 2px;
    opacity: 0.6;
    margin-bottom: 1rem;
}

.car-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.car-option {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.car-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--car-color);
    opacity: 0.5;
}

.car-option:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.car-option.selected {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--car-color);
    box-shadow: 0 0 15px var(--car-color);
}

.car-option.selected::before {
    opacity: 1;
}

.key {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), #00c3cc);
    border: none;
    padding: 1.2rem 4rem;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--bg-dark);
    border-radius: 50px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
}

.primary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(0, 242, 255, 0.6);
}

.primary-btn:active {
    transform: scale(0.98);
}

/* HUD (Heads Up Display) */
#hud {
    background: none;
    backdrop-filter: none;
    justify-content: space-between;
    flex-direction: row;
    align-items: flex-start;
    padding: 2rem;
    pointer-events: none;
}

.score-container,
.speed-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    border-radius: 16px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.score-container .label {
    font-size: 0.8rem;
    opacity: 0.7;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
}

#score-display {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
}

.speed-container {
    align-items: flex-end;
}

#speed-display {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--text-light);
    line-height: 0.9;
}

.speed-container .unit {
    font-size: 1rem;
    font-weight: 600;
    color: var(--secondary-color);
}

/* Game Over Screen */
#game-over-screen h2 {
    font-size: 4rem;
    color: var(--secondary-color);
    text-shadow: 0 0 30px rgba(255, 0, 85, 0.6);
    margin-bottom: 1rem;
    font-weight: 800;
    text-transform: uppercase;
}

.final-score-box {
    text-align: center;
    margin-bottom: 3rem;
}

.final-score-box .label {
    font-size: 1.2rem;
    opacity: 0.8;
}

#final-score {
    font-size: 5rem;
    font-weight: 800;
    background: -webkit-linear-gradient(var(--text-light), var(--primary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.button-group {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    padding: 1.2rem 3rem;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-light);
    border-radius: 50px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.5);
}

.secondary-btn:active {
    transform: scale(0.98);
}
#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    height: 100%;
    /* Cover full screen for positioning, but pointer-events handled */
    padding: 20px;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 100;
}

/* Show on mobile landscape primarily, or just small screens */
@media (max-width: 1024px) {
    #mobile-controls {
        display: flex;
    }
}

.control-group {
    pointer-events: auto;
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

/* Left controls: Arrows */
.left-controls {
    position: absolute;
    bottom: 30px;
    left: 30px;
    gap: 30px;
}

.touch-btn {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.8);
    backdrop-filter: none;
    touch-action: none;
    user-select: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s, background 0.1s;
    -webkit-tap-highlight-color: transparent;
    box-shadow: none;
    outline: none;
}

.touch-btn:active,
.touch-btn.active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.95);
    border-color: #fff;
}

/* Arrow specific */
.arrow-btn {
    width: 80px;
    height: 80px;
    font-size: 3rem;
    border-radius: 50%;
    /* Image shows vague shapes, but circles or just arrows work. */
    border: none;
    /* Reference often has no border for arrows, just the icon. Let's try semi-transparent shape. */
    background: rgba(0, 0, 0, 0.2);
    /* Slight backing */
}

/* Right controls: Pedals */
.right-controls {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    gap: 20px;
}

.pedal-btn {
    border-radius: 10px;
    font-size: 0;
    /* Hide text, just shape */
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.2));
    border: 2px solid rgba(255, 255, 255, 0.4);
}

/* Brake: Wider, shorter */
.pedal-btn.brake {
    width: 80px;
    height: 60px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M4 4h16v16H4z"/></svg>');
    /* Simple icon placeholder or just logic */
    background-size: 30%;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(255, 50, 50, 0.2);
}

/* Gas: Taller, narrower */
.pedal-btn.gas {
    width: 60px;
    height: 120px;
    /* Tall pedal */
    background-color: rgba(50, 255, 100, 0.2);
    align-self: flex-end;
    /* Align bottom */
}

/* Pedal markings (simulate the dots in image) */
.pedal-btn.gas::after {
    content: '::::';
    color: rgba(255, 255, 255, 0.5);
    font-size: 20px;
    writing-mode: vertical-rl;
    text-orientation: upright;
    letter-spacing: 5px;
}

.pedal-btn.brake::after {
    content: ':::';
    color: rgba(255, 255, 255, 0.5);
    font-size: 20px;
    letter-spacing: 5px;
}


/* Landscape Mobile Optimizations */
/* Landscape Mobile Optimizations */
@media (max-width: 1024px) and (orientation: landscape) {
    #start-screen {
        justify-content: space-evenly;
        /* Better distribution */
        padding: 5px;
        overflow: hidden;
    }

    .game-title {
        font-size: 1.8rem;
        /* Smaller title */
        margin-bottom: 0px;
        line-height: 1;
    }

    /* Hide non-essential text */
    .subtitle,
    .select-label,
    .controls-hint {
        display: none !important;
    }

    .car-selector-container {
        margin-bottom: 5px;
        width: 90%;
        margin-top: 5px;
    }

    .car-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 8px;
    }

    .car-option {
        padding: 0.4rem 0.2rem;
        font-size: 0.7rem;
        border-radius: 8px;
    }

    .primary-btn {
        padding: 0.5rem 3rem;
        font-size: 1.2rem;
        margin-top: 0;
        margin-bottom: 5px;
        border-radius: 30px;
    }
}

/* Mobile Controls Layout Updates */
.left-controls {
    flex-direction: column-reverse;
    /* Action buttons above arrows */
    align-items: flex-start;
    gap: 15px;
}

.steer-row {
    display: flex;
    gap: 20px;
}

.action-row {
    display: flex;
    gap: 10px;
    margin-left: 10px;
}

.small-btn {
    width: 50px;
    height: 50px;
    font-size: 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.small-btn:active {
    background: rgba(0, 242, 255, 0.4);
}