body, html {
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100%;
    height: 100%;
    background-color: #333;
    font-family: 'Arial', sans-serif;
}

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

#vehicle-stats {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 12px;
    border-radius: 20px;
    color: white;
    font-size: 14px;
    align-items: center;
    z-index: 900;
    backdrop-filter: blur(8px);
}

#vehicle-stats .stat {
    display: flex;
    align-items: center;
    gap: 5px;
}

#vehicle-stats .stat i {
    font-size: 16px;
}

#vehicle-stats .stat:nth-child(1) i { color: hsl(325, 100%, 50%); }
#vehicle-stats .stat:nth-child(2) i { color: #00bfff; }
#vehicle-stats .stat:nth-child(3) i { color: #ff4500; }
#vehicle-stats .stat:nth-child(4) i { color: #32cd32; }
.score-stat i { color: #ffd700; }
#vehicle-stats .stat:last-child i { color: #f1e211; }
#vehicle-stats .stat:last-child { display: none; visibility: hidden; }

#gamepad-container {
    border: 2px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    padding: 3px;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 120px;
    height: 120px;
    display: grid;
    grid-template-areas:
      ". up ."
      "left power-up right"
      ". down .";
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 5px;
    z-index: 1000;
    touch-action: none;
    backdrop-filter: blur(8px);
}

#gamepad-container .gamepad-button {
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-size: 18px;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1 / 1;
    position: relative;
}

#gamepad-container .gamepad-button:active {
    background: rgba(0, 0, 0, 0.6);
}

#gamepad-container .gamepad-button[data-direction="up"] { grid-area: up; }
#gamepad-container .gamepad-button[data-direction="down"] { grid-area: down; }
#gamepad-container .gamepad-button[data-direction="left"] { grid-area: left; }
#gamepad-container .gamepad-button[data-direction="right"] { grid-area: right; }

#nitro-button {
    grid-area: power-up;
    border: none;
    padding: 0;
}

.nitro-ring {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

#nitro-button i {
    font-size: 20px;
    position: relative;
    z-index: 1;
}

.power-up-button {
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-size: 18px;
    border: none;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1 / 1;
    position: relative;
}

.nitro-ring-bg {
    stroke: rgba(255, 255, 255, 0.2);
}

.nitro-ring-fill {
    transition: stroke-dashoffset 0.1s linear;
}

.nitro-ready {
    color: gold;
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.35);
}
.nitro-ready i {
    color: gold;
}
.nitro-ready .nitro-ring-fill {
    stroke: gold !important;
}

.gas-pedal-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 70px;
    height: 70px;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    z-index: 1000;
    touch-action: none;
    backdrop-filter: blur(8px);
}

.gas-pedal-btn:active, .gas-pedal-btn.active {
    background: rgba(0, 128, 0, 0.6);
    box-shadow: 0 0 16px rgba(0, 255, 0, 0.5);
}

#minimap {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 130px;
    height: 130px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    overflow: hidden;
    z-index: 900;
    backdrop-filter: blur(8px);
}

#player-arrow {
    position: absolute;
    width: 26px;
    height: 26px;
    text-align: center;
    color: #1fb8ff;
    font-size: 21px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(0deg);
    pointer-events: none;
    filter: drop-shadow(0 0 8px rgba(31, 184, 255, 0.7));
}

#target-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: radial-gradient(circle, #ffd700 0%, #ff9800 100%);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.9);
    pointer-events: none;
}

#target-dot .distance-label {
    display: block;
    color: white;
    font-size: 10px;
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    white-space: nowrap;
}

.minimap-enemy-dot {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ff3b3b;
    box-shadow: 0 0 10px rgba(255, 60, 60, 0.85);
    pointer-events: none;
}

#score-fx-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1200;
}

.score-popup {
    position: absolute;
    color: #ffd700;
    font-weight: 800;
    font-size: 28px;
    text-shadow:
      0 0 8px rgba(255, 215, 0, 0.9),
      0 2px 0 rgba(0,0,0,0.75);
    animation: score-pop 0.9s ease-out forwards;
    transform: translate(-50%, -50%);
}

@keyframes score-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.55);
    }
    12% {
        opacity: 1;
        transform: translate(-50%, -60%) scale(1.08);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -130%) scale(1);
    }
}

.pause-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    z-index: 1000;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}
.pause-btn:hover {
    background: rgba(0,0,0,0.6);
}

.pause-popup {
    position: fixed;
    inset: 0;
    backdrop-filter: blur(3px);
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.popup-content {
    position: relative;
    background: rgba(30, 30, 30, 0.9);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    color: white;
    text-align: center;
    width: 300px;
}

.popup-content h2 {
    margin-top: 0;
    color: #00bfff;
}

.popup-content label {
    display: block;
    margin: 15px 0;
    font-size: 1em;
}
.popup-content input[type="range"] {
    width: 80%;
    margin-left: 10px;
    vertical-align: middle;
}
.popup-content input[type="checkbox"] {
    vertical-align: middle;
    margin-right: 5px;
}

.popup-content button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    margin-top: 10px;
    transition: background-color 0.3s;
}
.popup-content button:hover {
    background-color: #0056b3;
}

.popup-content .close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    color: white;
    font-size: 1.5em;
    border: none;
    padding: 5px;
}
.popup-content .close-btn:hover {
    color: #ff4500;
}

.popup-content .home-btn, .popup-content .help-btn {
    width: calc(100% - 20px);
    margin: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.popup-content .home-btn { background-color: #28a745; }
.popup-content .home-btn:hover { background-color: #1e7e34; }

.popup-content .restart-btn {
    width: calc(100% - 20px);
    margin: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: #17a2b8;
}
.popup-content .restart-btn:hover {
    background-color: #117a8b;
}

.popup-content .help-btn { background-color: #ffc107; color: black; }
.popup-content .help-btn:hover { background-color: #d39e00; }

.hidden {
    display: none !important;
}