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

body {
    background-color: #1a1a2e;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
    touch-action: none;
    image-rendering: pixelated;
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 10, 30, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.panel {
    background: #16213e;
    padding: 2.5rem;
    border-radius: 4px;
    text-align: center;
    box-shadow: 0 0 0 4px #e74c3c, 0 0 0 8px #16213e, 0 0 30px rgba(231, 76, 60, 0.3);
    border: 4px solid #e74c3c;
    max-width: 600px;
    width: 92%;
    max-height: 95vh;
    overflow-y: auto;
}

.selection-panel {
    max-width: 920px;
}

.car-container {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.car-card {
    background: #0f3460;
    border: 3px solid #1a1a2e;
    border-radius: 4px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    width: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.car-card:hover {
    transform: translateY(-4px);
    background: #1a4a7a;
    border-color: #e94560;
}

.car-card.selected {
    border-color: #f1c40f;
    background: rgba(241, 196, 15, 0.15);
    box-shadow: 0 0 0 3px #f1c40f, 0 0 20px rgba(241, 196, 15, 0.3);
}

.car-card img {
    width: 120px;
    height: 120px;
    margin-bottom: 12px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6));
}

.car-card h3 {
    color: #fff;
    margin-bottom: 8px;
    font-size: 0.65rem;
    line-height: 1.4;
}

.car-stats {
    font-size: 0.55rem;
    color: #bdc3c7;
    width: 100%;
}

.car-stats div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

h1 {
    color: #e94560;
    margin-bottom: 1rem;
    font-size: 1.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 4px 4px 0 rgba(0,0,0,0.5), 0 0 20px rgba(233, 69, 96, 0.4);
}

p {
    margin-bottom: 1.2rem;
    font-size: 0.7rem;
    color: #ecf0f1;
    line-height: 1.8;
}

button {
    font-family: 'Press Start 2P', monospace;
    background: #e94560;
    color: white;
    border: none;
    padding: 14px 30px;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    box-shadow: 0 4px 0 #a3233f, 0 6px 15px rgba(231, 76, 60, 0.3);
    position: relative;
    top: 0;
}

button:hover:not(:disabled) {
    background: #c0392b;
    top: -2px;
    box-shadow: 0 6px 0 #a3233f, 0 10px 20px rgba(231, 76, 60, 0.4);
}

button:active:not(:disabled) {
    top: 4px;
    box-shadow: 0 0px 0 #a3233f;
}

button:disabled {
    background: #4a4a6a;
    cursor: not-allowed;
    box-shadow: 0 4px 0 #333355;
    opacity: 0.6;
}

#loadingStatus {
    margin-top: 1.2rem;
    color: #f1c40f;
    font-size: 0.6rem;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

#uiLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 50;
}

#hud {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(15, 15, 40, 0.88);
    padding: 16px;
    border-radius: 4px;
    font-size: 0.65rem;
    border: 3px solid #e94560;
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.25);
    pointer-events: auto;
}

#hud div {
    margin-bottom: 8px;
    color: #8892b0;
}

.hud-value {
    color: #ccd6f6;
    font-size: 0.7rem;
}

#driftScoreContainer {
    margin-top: 12px !important;
    color: #f1c40f !important;
    font-size: 0.75rem !important;
    text-shadow: 0 0 8px rgba(241, 196, 15, 0.5);
    transition: transform 0.1s, color 0.1s;
}

#driftScoreContainer .hud-value {
    color: inherit;
    font-size: 0.85rem;
}

#controlsInfo {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 10, 30, 0.85);
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 0.55rem;
    letter-spacing: 1px;
    border: 2px solid #0f3460;
    box-shadow: 0 0 10px rgba(0,0,0,0.4);
    white-space: nowrap;
}

#debugPanel {
    position: absolute;
    bottom: 24px;
    right: 16px;
    background: rgba(0, 10, 0, 0.85);
    padding: 12px;
    border-radius: 4px;
    font-size: 0.55rem;
    color: #2ecc71;
    border: 2px solid #2ecc71;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.15);
    pointer-events: auto;
}

.debug-title {
    color: #f1c40f;
    margin-bottom: 6px;
    border-bottom: 2px solid #1a3a1a;
    padding-bottom: 4px;
    font-size: 0.5rem;
}

.ui-buttons {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
    z-index: 10;
}

#restartBtn, #changeCarBtn {
    position: relative;
    font-size: 0.6rem;
    padding: 10px 16px;
    width: 100%;
}

#restartBtn {
    background: #e94560;
    box-shadow: 0 4px 0 #a3233f;
}

#restartBtn:hover {
    background: #c0392b;
}

#changeCarBtn {
    font-size: 0.55rem;
    padding: 8px 14px;
    background: #0f3460;
    box-shadow: 0 4px 0 #0a2040;
}

#changeCarBtn:hover {
    background: #1a4a7a;
}

/* Responsive */
@media (max-width: 900px) {
    h1 { font-size: 1.2rem; }
    p { font-size: 0.6rem; }
    .panel { padding: 1.5rem; }

    .car-card { width: 180px; padding: 10px; }
    .car-card img { width: 90px; height: 90px; }
    .car-card h3 { font-size: 0.55rem; }
    .car-stats { font-size: 0.45rem; }

    #hud {
        font-size: 0.55rem;
        padding: 12px;
        top: 8px;
        left: 8px;
    }
    .hud-value { font-size: 0.6rem; }
    #driftScoreContainer { font-size: 0.6rem !important; }
    #driftScoreContainer .hud-value { font-size: 0.65rem; }

    .ui-buttons {
        top: 8px;
        right: 8px;
        gap: 5px;
    }

    #restartBtn, #changeCarBtn {
        padding: 7px 10px;
        font-size: 0.5rem;
    }

    #controlsInfo {
        font-size: 0.45rem;
        width: 92%;
        text-align: center;
        bottom: 8px;
        white-space: normal;
    }

    #debugPanel {
        font-size: 0.45rem;
        bottom: 50px;
        right: 8px;
        padding: 8px;
    }
}

@media (max-width: 500px) {
    h1 { font-size: 0.9rem; }
    .panel { padding: 1rem; }
    .car-card { width: 140px; padding: 8px; }
    .car-card img { width: 70px; height: 70px; }
    .car-card h3 { font-size: 0.45rem; }
    button { font-size: 0.6rem; padding: 10px 16px; }
}
