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

body {
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Arial', sans-serif;
    touch-action: none;
    user-select: none;
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#mainMenu {
    background: none;
}

.menu-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
}

.menu-car {
    width: 60%;
    max-width: 400px;
    margin: 20px 0;
    animation: bounce 2s ease-in-out infinite;
}

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

.hidden {
    display: none !important;
}

.title {
    font-size: clamp(32px, 8vw, 72px);
    color: #fff;
    text-shadow: 3px 3px 0 #000, 6px 6px 0 rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
    font-weight: bold;
    letter-spacing: 2px;
}

.subtitle {
    font-size: clamp(14px, 3vw, 24px);
    color: #ffd700;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 40px;
    opacity: 0.9;
}

.btn {
    padding: 15px 50px;
    font-size: clamp(16px, 3vw, 24px);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, #e94560 0%, #ff6b6b 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.4);
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.6);
}

.btn-secondary {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    color: white;
    border: 2px solid #e94560;
}

.btn-secondary:hover {
    transform: scale(1.05);
    background: #e94560;
}

.coins-display {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 20px;
    color: #ffd700;
    font-size: clamp(16px, 3vw, 24px);
    font-weight: bold;
    z-index: 101;
}

.garage-container {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    padding: 30px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.garage-title {
    color: #e94560;
    font-size: clamp(20px, 4vw, 32px);
    margin-bottom: 20px;
    text-align: center;
}

.upgrade-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    margin: 10px 0;
    border-radius: 10px;
}

.upgrade-info {
    flex: 1;
}

.upgrade-name {
    color: #fff;
    font-size: clamp(14px, 2.5vw, 18px);
    font-weight: bold;
}

.upgrade-level {
    color: #4ecdc4;
    font-size: clamp(12px, 2vw, 14px);
    margin-top: 5px;
}

.upgrade-bar {
    width: 100%;
    height: 8px;
    background: #333;
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}

.upgrade-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ecdc4, #44a08d);
    transition: width 0.3s;
}

.upgrade-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    border: none;
    border-radius: 20px;
    color: #1a1a2e;
    font-weight: bold;
    cursor: pointer;
    font-size: clamp(12px, 2vw, 14px);
    transition: all 0.3s;
}

.upgrade-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.upgrade-btn:disabled {
    background: #666;
    cursor: not-allowed;
}

.hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 50;
}

.hud-left,
.hud-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hud-item {
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 15px;
    border-radius: 10px;
    color: white;
    font-size: clamp(12px, 2vw, 16px);
}

.fuel-bar {
    width: 150px;
    height: 20px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
}

.fuel-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ffaa00, #44ff44);
    transition: width 0.1s;
}

.speed-display {
    font-size: clamp(18px, 3vw, 28px);
    font-weight: bold;
}

.speed-unit {
    font-size: 0.6em;
    opacity: 0.7;
}

.touch-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 60;
    pointer-events: none;
}

.touch-btn {
    width: clamp(80px, 20vw, 120px);
    height: clamp(80px, 20vw, 120px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(24px, 5vw, 36px);
    color: white;
    pointer-events: auto;
    transition: all 0.1s;
}

.touch-btn:active,
.touch-btn.active {
    background: rgba(233, 69, 96, 0.6);
    border-color: #e94560;
    transform: scale(0.95);
}

.result-screen {
    background: rgba(0, 0, 0, 0.9);
}

.result-title {
    font-size: clamp(28px, 6vw, 48px);
    color: #e94560;
    margin-bottom: 30px;
}

.result-stats {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px 40px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    color: white;
    font-size: clamp(14px, 2.5vw, 20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-value {
    color: #4ecdc4;
    font-weight: bold;
}

.record {
    color: #ffd700 !important;
}

@media (pointer: coarse) {
    .touch-controls {
        display: flex;
    }
}

.pause-btn {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    font-size: 24px;
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    z-index: 55;
    pointer-events: auto;
}

.throttle-control {
    position: absolute;
    right: 20px;
    bottom: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 10px;
    border-radius: 15px;
    z-index: 60;
}

.throttle-label {
    color: white;
    font-size: 14px;
    margin-bottom: 10px;
    font-weight: bold;
}

.throttle-slider {
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    width: 30px;
    height: 150px;
    background: #333;
    border-radius: 15px;
    outline: none;
    writing-mode: bt-lr;
}

.throttle-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 20px;
    background: linear-gradient(180deg, #ff6b6b, #e94560);
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.throttle-slider::-moz-range-thumb {
    width: 30px;
    height: 20px;
    background: linear-gradient(180deg, #ff6b6b, #e94560);
    border-radius: 5px;
    cursor: pointer;
    border: none;
}
