:root {
    /* 2026 Vibrant Palette */
    --primary: #6c5ce7;
    --secondary: #a29bfe;
    --accent: #fdcb6e;
    --bg-gradient: linear-gradient(135deg, #74ebd5 0%, #9face6 100%);
    --glass: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Fredoka', 'Quicksand', 'Comic Sans MS', sans-serif;
    background: var(--bg-gradient);
    height: 100vh;
    overflow: hidden;
    color: white;
    touch-action: none; /* Prevents accidental zooming on tablets */
}

/* --- Screen Transitions --- */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    height: 100vh;
    width: 100vw;
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active { display: flex; }

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: scale(1.05); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* --- High-Quality Typography --- */
h1 {
    font-size: clamp(3rem, 10vw, 5rem);
    text-transform: uppercase;
    letter-spacing: 2px;
    filter: drop-shadow(0 5px 0 rgba(0,0,0,0.2));
    margin-bottom: 20px;
}

h2 {
    font-size: 2.5rem;
    background: rgba(255,255,255,0.2);
    padding: 10px 30px;
    border-radius: 50px;
    backdrop-filter: blur(4px);
}

/* --- Premium Buttons --- */
button, .item-btn {
    all: unset;
    cursor: pointer;
    background: var(--accent);
    padding: 20px 50px;
    border-radius: 25px;
    font-size: 2rem;
    font-weight: bold;
    color: #2d3436;
    box-shadow: 0 10px 0 #e17055, 0 15px 20px rgba(0,0,0,0.2);
    transition: all 0.1s ease;
    text-align: center;
}

button:active, .item-btn:active {
    transform: translateY(6px);
    box-shadow: 0 4px 0 #e17055, 0 5px 10px rgba(0,0,0,0.2);
}

/* --- The Bento-Box Controls --- */
.controls {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 2px solid var(--glass-border);
    border-radius: 40px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 25px;
    width: 90%;
    max-height: 50vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.control-group {
    background: rgba(255, 255, 255, 0.15);
    padding: 15px;
    border-radius: 25px;
    border: 1px solid rgba(255,255,255,0.2);
}

.selection-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

/* Large Driver Icons */
.item {
    font-size: 6rem;
    background: white;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 30px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.item:hover { transform: scale(1.1) rotate(5deg); }

/* --- The Car Preview --- */
#car-preview-container {
    width: 350px;
    height: 200px;
    position: relative;
    filter: drop-shadow(0 20px 30px rgba(0,0,0,0.3));
}

.car-base {
    position: absolute;
    bottom: 50px;
    width: 100%;
    height: 80px;
    background-color: var(--car-color); /* CHANGE THIS LINE */
    border: 6px solid #2d3436;
    z-index: 2;
    transition: all 0.3s ease; /* Keep transition for smooth color swaps */
}

.body-classic { border-radius: 40px 100px 15px 15px; }
.body-truck { border-radius: 15px 15px 5px 5px; height: 110px !important; width: 85%; }

/* Wheels with spinning animation */
.wheel {
    width: 65px;
    height: 65px;
    background: #2d3436;
    border: 6px dashed #636e72;
    border-radius: 50%;
    position: relative;
    animation: drive 0.5s linear infinite;
}

@keyframes drive {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Racing Scene HUD --- */
#score-display {
    position: fixed;
    top: 30px;
    left: 30px;
    font-size: 2.5rem;
    background: var(--accent);
    color: #2d3436;
    padding: 10px 30px;
    border-radius: 50px;
    box-shadow: 0 8px 0 #e17055;
    z-index: 100;
}

#exit-btn {
    position: fixed;
    top: 30px;
    right: 30px;
    padding: 10px 25px;
    font-size: 1.5rem;
    background: #ff7675;
    box-shadow: 0 6px 0 #d63031;
}

/* Sticker & Extra Visual Polish */
.sticker-instance, .extra-item {
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.2));
    z-index: 5;
}

/* Scrollbar for the Controls (Kid-friendly width) */
.controls::-webkit-scrollbar { width: 10px; }
.controls::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 10px; }

#race-track {
    position: relative;
    width: 100%;
    height: 300px;
    overflow: hidden;
    background: rgba(0,0,0,0.1); /* Optional: just to see the track */
    border-bottom: 10px solid #555; /* The Road */
}

#racing-car {
    position: absolute;
    bottom: 20%;
    transform: scale(0.8); /* Make it slightly smaller for racing */
}

/* --- Fix Positioning of Car Parts --- */
.anchor {
    position: absolute;
    font-size: 2.5rem;
    z-index: 10;
}

.slot-roof-rear { top: -20px; left: 20%; }
.slot-roof-front { top: -25px; left: 50%; }
.slot-front { right: 10px; top: 40px; }

#driver-slot {
    position: absolute;
    top: -30px;
    left: 40%;
    font-size: 4rem;
    z-index: 3;
}

#sticker-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.sticker-instance {
    position: absolute;
    font-size: 1.5rem;
}

/* --- Wheel Positioning --- */
.wheels-container {
    position: absolute;
    bottom: 20px;
    width: 100%;
    display: flex;
    justify-content: space-around;
    z-index: 4;
}

/* --- Headlights Logic --- */
.headlight-beam {
    display: none;
    width: 100px;
    height: 40px;
    background: radial-gradient(circle at left, rgba(255,255,100,0.8), transparent);
    position: absolute;
    left: 40px;
    top: 0;
}

.lights-on .headlight-beam {
    display: block;
}