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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: white;
    overflow: hidden;
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    position: relative;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.screen.hidden {
    display: none;
}

/* Меню */
#menu h1 {
    font-size: 4rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

button {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

button:active {
    transform: translateY(0);
}

/* Лобби */
.lobby-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#roomInput {
    padding: 0.8rem;
    font-size: 1.1rem;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    text-align: center;
    text-transform: uppercase;
}

#roomInput::placeholder {
    color: rgba(255,255,255,0.7);
}

#roomInfo {
    text-align: center;
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

/* Игровой экран */
#gameScreen {
    justify-content: flex-start;
    align-items: flex-start;
}

#gameCanvas {
    display: block;
    background: #2c3e50;
    cursor: none;
}

#gameUI {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#minimap {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    background: rgba(0,0,0,0.7);
    border: 2px solid #fff;
    border-radius: 8px;
}

#speedometer {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(0,0,0,0.8), rgba(0,0,0,0.6));
    border: 3px solid #00ff88;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

#speedValue {
    font-size: 2rem;
    color: #00ff88;
}

.speed-text {
    font-size: 0.8rem;
    color: #ccc;
}

#lapCounter {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0,0,0,0.7);
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
}

#raceTimer {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #00ff88;
}

/* Мобильные элементы управления */
.mobile-only {
    display: none;
}

#mobileControls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 20px;
    pointer-events: none;
}

.control-pad, .throttle-controls {
    display: flex;
    gap: 10px;
    pointer-events: all;
}

.control-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    border: 3px solid rgba(255,255,255,0.3);
    background: rgba(0,0,0,0.6);
    color: white;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.control-btn:active {
    background: rgba(255,255,255,0.2);
    transform: scale(0.95);
}

.control-btn.gas {
    background: rgba(0,255,0,0.3);
}

.control-btn.brake {
    background: rgba(255,0,0,0.3);
}

/* Экран результатов */
#resultsTable {
    background: rgba(0,0,0,0.7);
    padding: 2rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    min-width: 400px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    font-size: 1.1rem;
}

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

.result-position {
    font-weight: bold;
    color: #ffd700;
}

/* Адаптивность */
@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    #menu h1 {
        font-size: 2.5rem;
    }
    
    button {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
    
    #minimap {
        width: 150px;
        height: 100px;
        top: 10px;
        right: 10px;
    }
    
    #speedometer {
        width: 80px;
        height: 80px;
        bottom: 220px;
        right: 20px;
    }
    
    #speedValue {
        font-size: 1.2rem;
    }
    
    .speed-text {
        font-size: 0.6rem;
    }
    
    #lapCounter {
        top: 10px;
        left: 10px;
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    #raceTimer {
        font-size: 1.2rem;
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 480px) {
    #menu h1 {
        font-size: 2rem;
    }
    
    .menu-buttons {
        width: 90%;
    }
    
    button {
        width: 100%;
    }
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen:not(.hidden) {
    animation: fadeIn 0.5s ease;
}

/* Эффекты для игры */
.drift-effect {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
    pointer-events: none;
    animation: driftParticle 1s ease-out forwards;
}

@keyframes driftParticle {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.2);
    }
}