:root {
    --bg-gradient: linear-gradient(135deg, #74b9ff, #a29bfe);
    --primary: #ff4757;
    --primary-hover: #ff6b81;
    --text: #2f3542;
    --panel-bg: rgba(255, 255, 255, 0.95);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Nunito', sans-serif;
    user-select: none;
}

body {
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text);
    overflow: hidden;
}

#app {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    max-height: 850px;
    position: relative;
    background: var(--panel-bg);
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    border-radius: 20px;
    overflow: hidden;
}

/* responsive rule for wider screens */
@media (max-width: 500px) {
    #app {
        border-radius: 0;
        max-height: 100vh;
    }
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.4s ease, opacity 0.4s ease;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

#garage {
    padding: 3rem 1rem;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    transform: scale(1);
    z-index: 10;
}

/* Garage UI */
h1 {
    font-size: 2.8rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.05);
}

p {
    font-size: 1.2rem;
    color: #57606f;
    margin-bottom: 1rem;
}

#car-preview {
    margin: 2rem 0;
    width: 150px;
    height: 250px;
    position: relative;
    animation: float 2.5s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.car-body {
    width: 100px;
    height: 180px;
    background: #ff4757;
    border-radius: 20px 20px 10px 10px;
    position: absolute;
    left: 25px;
    top: 35px;
    box-shadow: inset -5px -5px 15px rgba(0,0,0,0.2), 0 10px 20px rgba(0,0,0,0.3);
    transition: background 0.3s ease;
}

.windshield {
    width: 80px;
    height: 40px;
    background: #7bed9f;
    border-radius: 10px 10px 5px 5px;
    position: absolute;
    top: 30px;
    left: 10px;
    box-shadow: inset 0 5px 10px rgba(255,255,255,0.5);
}

.wheel {
    width: 30px;
    height: 50px;
    background: #2f3542;
    border-radius: 8px;
    position: absolute;
    box-shadow: inset 0 5px 10px rgba(0,0,0,0.5);
}

.wheel-top-left { top: 20px; left: -10px; }
.wheel-top-right { top: 20px; right: -10px; }
.wheel-bottom-left { bottom: 20px; left: -10px; }
.wheel-bottom-right { bottom: 20px; right: -10px; }

.color-picker {
    display: flex;
    gap: 15px;
    margin-bottom: 3rem;
}

.color-btn {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: 4px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.color-btn:hover, .color-btn.selected {
    transform: scale(1.2);
    border-color: #f1c40f;
}

.size-selection {
    margin-bottom: 2.5rem;
    text-align: center;
}

.size-picker {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.size-btn {
    padding: 10px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    background: white;
    border: 3px solid #dfe4ea;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #57606f;
}

.size-btn:hover {
    transform: translateY(-3px);
    border-color: #a29bfe;
}

.size-btn.selected {
    background: var(--primary);
    color: white;
    border-color: #f1c40f;
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 5px 15px rgba(255, 71, 87, 0.3);
}

/* Big Car scaling for preview */
#car-preview.big-car {
    transform: scale(1.4);
}

#car-preview.lkw-car {
    transform: scale(1.8);
}


#car-preview {
    margin: 2rem 0;
    width: 150px;
    height: 250px;
    position: relative;
    animation: float 2.5s ease-in-out infinite;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}


.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: 900;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 0 #ff6b81, 0 10px 20px rgba(0,0,0,0.2);
    transition: all 0.1s;
}

.primary-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0px 0 #ff6b81, 0 2px 5px rgba(0,0,0,0.2);
}

/* Game Area */
#game {
    padding: 0;
    background: #a4b0be; /* road color */
}

.game-header {
    position: absolute;
    top: 0;
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
    background: linear-gradient(to bottom, rgba(0,0,0,0.4), transparent);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-btn {
    background: white;
    border: none;
    font-size: 1.3rem;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-btn:hover {
    transform: scale(1.1) translateY(-2px);
}

.header-btn.active {
    background: var(--primary);
    color: white;
    animation: pulseHeaderBtn 1.5s infinite;
}

@keyframes pulseHeaderBtn {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 15px rgba(255, 71, 87, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}


.voice-status {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s;
    background: rgba(0,0,0,0.5);
    padding: 5px 15px;
    border-radius: 20px;
    pointer-events: none;
}

.voice-status.show {
    opacity: 1;
}


#score {
    font-size: 1.6rem;
    font-weight: 900;
    color: #f1c40f;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.6);
}

.secondary-btn {
    background: #ff7f50;
    color: white;
    border: none;
    padding: 10px 18px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 4px 0 #e55039;
    transition: all 0.1s;
}
.secondary-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #e55039;
}

canvas {
    background: #747d8c;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.controls {
    position: absolute;
    bottom: 25px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 25px;
    z-index: 20;
}

.control-btn {
    background: rgba(255,255,255,0.9);
    border: none;
    color: #2f3542;
    padding: 15px 25px;
    font-size: 1.3rem;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 5px 0 rgba(0,0,0,0.15);
    transition: transform 0.1s;
}

.control-btn:active {
    transform: translateY(5px);
    box-shadow: none;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30;
    color: white;
    backdrop-filter: blur(8px);
}

.overlay.hidden {
    display: none;
}

.overlay h2 {
    font-size: 3.5rem;
    color: var(--primary);
    margin-bottom: 15px;
}
.overlay p {
    font-size: 1.8rem;
    margin-bottom: 35px;
}
