/* ===== RACING GAME STYLES ===== */

/* Screen Management */
.game-screen {
    display: none;
    min-height: 100vh;
    width: 100%;
}

.game-screen.active {
    display: block;
}

#gameScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#gameScreen.active {
    display: block;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Lobby Styles */
.lobby-container {
    max-width: 500px;
    margin: 2rem auto;
    padding: 2rem;
}

.player-input {
    margin-bottom: 1.5rem;
}

.player-input label,
.mode-selector label {
    display: block;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}

.player-input input {
    width: 100%;
    padding: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1.1rem;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s ease;
}

.player-input input:focus {
    outline: none;
    border-color: #f472b6;
    box-shadow: 0 0 20px rgba(244, 114, 182, 0.3);
}

/* Mode Selector */
.mode-selector {
    margin-bottom: 2rem;
}

.mode-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.mode-btn.active {
    border-color: #f472b6;
    background: rgba(244, 114, 182, 0.2);
    box-shadow: 0 0 20px rgba(244, 114, 182, 0.3);
}

.mode-icon {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.mode-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.mode-desc {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Track Selector */
.track-selector {
    margin-bottom: 2rem;
}

.track-selector label {
    display: block;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}

.track-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.track-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.track-btn:hover {
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.track-btn.active {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.2);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.track-icon {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.track-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.track-diff {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    margin-top: 0.3rem;
}

.track-diff.easy {
    background: rgba(52, 211, 153, 0.3);
    color: #34d399;
}

.track-diff.medium {
    background: rgba(251, 191, 36, 0.3);
    color: #fbbf24;
}

.track-diff.hard {
    background: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* Lobby Actions */
.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn.primary {
    background: linear-gradient(135deg, #f472b6, #a855f7);
    color: white;
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(244, 114, 182, 0.4);
}

.action-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.action-btn.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

.join-section {
    display: flex;
    gap: 0.75rem;
}

.join-section input {
    flex: 1;
    padding: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1.1rem;
    font-family: 'Outfit', sans-serif;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.2em;
}

.join-section input:focus {
    outline: none;
    border-color: #38bdf8;
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fbbf24;
    animation: pulse 2s infinite;
}

.connection-status.connected .status-dot {
    background: #34d399;
    animation: none;
}

.connection-status.error .status-dot {
    background: #f87171;
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Waiting Room */
.waiting-container {
    max-width: 500px;
    margin: 2rem auto;
    padding: 2rem;
    text-align: center;
}

.room-info {
    margin-bottom: 2rem;
}

.room-info h2 {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
}

.room-code {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.3em;
    background: linear-gradient(135deg, #f472b6, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.room-hint {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.5rem;
}

.players-list h3 {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 1rem;
}

.players-grid {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.player-card {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
    min-width: 120px;
}

.player-card.ready {
    border-color: #34d399;
    background: rgba(52, 211, 153, 0.1);
}

.player-card .player-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.player-card .player-status {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.player-card.ready .player-status {
    color: #34d399;
}

.waiting-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ready-btn.ready {
    background: #34d399;
}

.waiting-status {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Game HUD */
.game-hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem;
    pointer-events: none;
    z-index: 100;
}

.hud-left,
.hud-right {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 0.75rem 1rem;
}

.hud-center {
    text-align: center;
}

.speed-display {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.speed-value {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f472b6, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.speed-unit {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Nitro Bar */
.nitro-container {
    margin-top: 0.5rem;
}

.nitro-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.25rem;
}

.nitro-bar {
    width: 80px;
    height: 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: hidden;
}

.nitro-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 4px;
    transition: width 0.1s ease;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.nitro-fill.active {
    background: linear-gradient(90deg, #8b5cf6, #ec4899);
    animation: nitroGlow 0.2s ease infinite alternate;
}

@keyframes nitroGlow {
    from {
        box-shadow: 0 0 10px rgba(236, 72, 153, 0.5);
    }

    to {
        box-shadow: 0 0 20px rgba(236, 72, 153, 0.8);
    }
}

.lap-display {
    font-size: 1.5rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 0.5rem 1rem;
}

.race-timer {
    font-size: 1.2rem;
    font-family: monospace;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 0.25rem;
}

.position-label {
    display: block;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
}

.position-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fbbf24;
}

/* Countdown Overlay */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
}

.countdown-overlay.active {
    display: flex;
}

.countdown-number {
    font-size: 12rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f472b6, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: countdownPop 1s ease-out;
}

@keyframes countdownPop {
    0% {
        transform: scale(2);
        opacity: 0;
    }

    50% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(0.8);
        opacity: 0.8;
    }
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40vh;
    pointer-events: none;
    z-index: 100;
}

@media (max-width: 768px),
(pointer: coarse) {
    .mobile-controls {
        display: flex;
        justify-content: space-between;
        padding: 1rem;
    }
}

.control-left,
.control-right {
    pointer-events: auto;
}

.joystick-container {
    width: 120px;
    height: 120px;
}

.joystick-base {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.joystick-stick {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f472b6, #a855f7);
    box-shadow: 0 0 20px rgba(244, 114, 182, 0.5);
    transition: transform 0.1s ease-out;
}

.control-right {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pedal-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gas-btn {
    background: rgba(52, 211, 153, 0.3);
    color: #34d399;
}

.gas-btn:active,
.gas-btn.active {
    background: rgba(52, 211, 153, 0.6);
    transform: scale(0.95);
}

.brake-btn {
    background: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.brake-btn:active,
.brake-btn.active {
    background: rgba(239, 68, 68, 0.6);
    transform: scale(0.95);
}

.pedal-btn span {
    font-size: 1.5rem;
}

.pause-btn {
    position: fixed;
    top: 5rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.pause-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

/* Keys hint */
.keys-hint {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    z-index: 100;
    pointer-events: none;
}

.keys-hint kbd {
    display: inline-block;
    padding: 0.2rem 0.4rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin: 0 0.15rem;
    font-family: monospace;
}

@media (max-width: 768px) {
    .keys-hint {
        display: none;
    }
}

/* Results Screen */
.results-container {
    max-width: 500px;
    margin: 2rem auto;
    padding: 2rem;
    text-align: center;
}

.results-title {
    font-size: 2rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #fbbf24, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.results-table {
    margin-bottom: 2rem;
}

.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
}

.result-row.winner {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(244, 114, 182, 0.2));
    border: 2px solid rgba(251, 191, 36, 0.5);
}

.result-position {
    font-size: 1.5rem;
    font-weight: 800;
    width: 50px;
}

.result-position.first {
    color: #fbbf24;
}

.result-position.second {
    color: #94a3b8;
}

.result-name {
    flex: 1;
    text-align: left;
    font-weight: 600;
}

.result-time {
    font-family: monospace;
    color: rgba(255, 255, 255, 0.7);
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Responsive */
@media (max-width: 480px) {

    .lobby-container,
    .waiting-container,
    .results-container {
        margin: 1rem;
        padding: 1.5rem;
    }

    .mode-buttons {
        grid-template-columns: 1fr;
    }

    .mode-btn {
        flex-direction: row;
        justify-content: flex-start;
        gap: 1rem;
        padding: 1rem;
    }

    .room-code {
        font-size: 2.5rem;
    }

    .countdown-number {
        font-size: 8rem;
    }
}