/* Base Reset */
body {
    margin: 0;
    overflow: hidden;
    font-family: 'Montserrat', sans-serif;
    background-color: #1a1a1a;
    color: #f0f0f0;
}

canvas {
    display: block;
    cursor: crosshair;
}

.hidden {
    display: none !important;
}

/* --- UI PANEL STYLING (Cool Menus) --- */
.ui-panel {
    position: absolute;
    top: 50%;
    /* FIX: New Positioning to the LEFT */
    left: 5%;
    transform: translate(0, -50%);
    /* Increased max width for car selection menu */
    max-width: 500px;

    background-color: rgba(10, 10, 10, 0.95);
    /* Increased horizontal padding for wider menu */
    padding: 40px 50px;
    border-radius: 15px;
    text-align: center;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 2px #4CAF50;
    border: 1px solid #4CAF50;
}

.ui-panel h1 {
    margin-top: 0;
    font-size: 2em;
    /* Slightly smaller headers for less height */
    color: #4CAF50;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.8);
    letter-spacing: 2px;
    margin-bottom: 20px;
    /* Reduced margin */
}

#car-name {
    font-size: 1.5em;
    /* Slightly smaller font */
    margin: 15px 0;
    color: #ffc107;
    min-height: 1.5em;
    font-weight: bold;
    text-transform: uppercase;
}

/* Menu Buttons */
.menu-button {
    padding: 10px 20px;
    /* Slightly smaller buttons */
    font-size: 1em;
    cursor: pointer;
    background-color: #333;
    color: white;
    border: 2px solid #666;
    border-radius: 8px;
    margin: 8px;
    transition: all 0.2s ease-in-out;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.menu-button:hover {
    background-color: #4CAF50;
    color: #1a1a1a;
    border-color: #4CAF50;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.5);
}

.options-view button.selected {
    background-color: #ffc107;
    color: black;
    border-color: #ffc107;
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.8);
}

/* Arrow Buttons for Car Select */
.arrow-button {
    font-size: 2.5em;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #ffc107;
    border-radius: 12px;
    color: #ffc107;
    cursor: pointer;
    padding: 5px 20px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.arrow-button:hover {
    background-color: #ffc107;
    color: #1a1a1a;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.4);
}

.arrow-button:active {
    transform: scale(0.95);
}

/* Premium Dropdown Styling */
.premium-dropdown {
    background-color: #111;
    color: #00eaff;
    border: 2px solid #00eaff;
    border-radius: 10px;
    padding: 12px 45px 12px 15px;
    font-size: 1.1em;
    font-weight: bold;
    font-family: 'Montserrat', sans-serif;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 234, 255, 0.2);
    outline: none;
    transition: all 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300eaff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.premium-dropdown:hover {
    background-color: #1a1a1a;
    box-shadow: 0 0 20px rgba(0, 234, 255, 0.4);
    border-color: #fff;
}

.premium-dropdown:focus {
    border-color: #ffc107;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffc107' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

.premium-dropdown option {
    background-color: #111;
    color: #fff;
    padding: 15px;
    font-size: 1em;
}

/* Loading & Countdown */
#loading-text {
    font-size: 2em;
}

#countdown {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15vw;
    font-weight: 900;
    font-style: italic;
    background: linear-gradient(to bottom, #fff, #ffc107);
    -webkit-background-clip: text;
    color: transparent;
    text-shadow: 0 10px 20px rgba(0,0,0,0.5), 0 0 50px rgba(255, 193, 7, 0.4);
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
    padding: 20px 40px;
    line-height: 1;
    animation: countdown-bounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes countdown-bounce {
    from {
        transform: translate(-50%, -50%) scale(1.8) rotate(-5deg);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
}

#lap-popup {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8vw;
    font-weight: 900;
    font-style: italic;
    background: linear-gradient(to bottom, #fff, #00c6ff);
    -webkit-background-clip: text;
    color: transparent;
    text-shadow: 0 10px 20px rgba(0,0,0,0.5), 0 0 50px rgba(0, 198, 255, 0.6);
    pointer-events: none;
    z-index: 1000;
}

.lap-flash {
    animation: lap-zoom-fade 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes lap-zoom-fade {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

/* --- IN-GAME UI (Top-Left for Timer/Distance) --- */
#game-ui-container {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 1.5em;
    text-shadow: 2px 2px 4px #000;
    z-index: 10;
}

#game-ui-container div {
    margin-bottom: 10px;
}

/* --- MINIMAP CONTAINER (Top-Right) --- */
#minimap-container {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 3px solid rgba(0, 198, 255, 0.6);
    background: rgba(0, 0, 0, 0.65);
    box-shadow: 0 0 15px rgba(0, 198, 255, 0.4), inset 0 0 20px rgba(0,0,0,0.8);
    overflow: hidden;
    z-index: 10;
}

#minimap-bg, #minimap-dots {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 200px;
}

/* --- SPEEDOMETER CONTAINER (Bottom-Right) --- */
#speedometer-container {
    position: absolute;
    bottom: 120px;
    right: 20px;
    width: 200px;
    height: 100px;
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-bottom: none;
    border-radius: 100px 100px 0 0;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    pointer-events: none;
    z-index: 10;
    background-color: rgba(0, 0, 0, 0.5);
}

#speedo-needle {
    width: 2px;
    height: 90px;
    background-color: red;
    transform-origin: bottom center;
    transition: transform 0.1s linear;
    transform: rotate(-90deg);
    z-index: 11;
}

#speedo-text {
    position: absolute;
    bottom: -35px;
    font-size: 1.4em;
    font-weight: bold;
    text-shadow: 2px 2px 4px #000;
}

/* --- BOOST BAR CONTAINER (Bottom-Left) --- */
#boost-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    width: 350px;
    font-weight: bold;
    font-size: 1.5em;
    text-shadow: 2px 2px 4px #000;
    z-index: 10;
}

#boost-container span {
    width: 80px;
    margin-right: 10px;
}

#boost-bar-outer {
    flex-grow: 1;
    height: 25px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 2px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.8);
}

#boost-bar-inner {
    height: 100%;
    width: 100%;
    border-radius: 8px;
    background: linear-gradient(to right, #00c6ff, #0072ff);
    transition: width 0.2s ease-out;
}

#boost-bar-inner.low {
    background: linear-gradient(to right, #F2C94C, #F2994A);
}

#boost-bar-inner.critical {
    background: linear-gradient(to right, #EB5757, #b30000);
}

#boost-container.boosting {
    animation: pulse-text 0.5s infinite alternate;
}

#boost-container.boosting #boost-bar-inner {
    animation: pulse-bar 0.3s infinite alternate;
}

@keyframes pulse-text {
    to {
        text-shadow: 2px 2px 4px #000, 0 0 10px #00c6ff;
    }
}

@keyframes pulse-bar {
    to {
        filter: brightness(1.7);
    }
}
/* --- DEV PANEL --- */
#dev-panel {
    top: 10%;
    left: 50%;
    transform: translate(-50%, 0);
    max-width: 300px;
    border: 1px solid #ffc107;
    box-shadow: 0 5px 20px rgba(255, 193, 7, 0.4), 0 0 0 2px #ffc107;
}
#dev-panel h1 {
    color: #ffc107;
    text-shadow: 0 0 10px rgba(255, 193, 7, 0.6);
}