/* Variables de colores */
:root {
    --primary-color: #ff6b35;
    --secondary-color: #004e89;
    --success-color: #06d6a0;
    --danger-color: #ef476f;
    --road-color: #2d3436;
    --line-color: #f7f7f7;
    --grass-color: #55a630;
}

/* Pantallas base */
.screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.screen.hidden {
    display: none;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
}

/* Contenido modal */
.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.modal-content h1, .modal-content h2 {
    margin-bottom: 20px;
    color: var(--secondary-color);
}

.subtitle {
    color: #666;
    font-size: 1.1em;
    margin-bottom: 30px;
}

/* Grupos de entrada */
.input-group {
    margin-bottom: 25px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--secondary-color);
}

.input-group input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Botones del juego */
.game-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    margin: 10px;
}

.game-btn:hover {
    background: #ff5520;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 53, 0.4);
}

.game-btn.secondary {
    background: #6c757d;
}

.game-btn.secondary:hover {
    background: #5a6268;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

/* Selección de vehículo */
.vehicle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.vehicle-card {
    padding: 20px;
    border: 3px solid transparent;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    background: #f8f9fa;
}

.vehicle-card:hover {
    background: #e9ecef;
    transform: scale(1.05);
}

.vehicle-card.selected {
    border-color: var(--primary-color);
    background: #fff5f2;
    box-shadow: 0 5px 15px rgba(255, 107, 53, 0.3);
}

.vehicle-preview {
    font-size: 64px;
    margin-bottom: 10px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.vehicle-card p {
    font-weight: 600;
    color: var(--secondary-color);
}

/* Pantalla de juego */
#gameScreen {
    padding: 0;
    background: var(--grass-color);
}

.game-ui {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 100;
}

.game-stats {
    display: flex;
    gap: 30px;
}

.stat {
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary-color);
}

.stat span:last-child {
    color: var(--primary-color);
    margin-left: 5px;
}

.pause-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.pause-btn:hover {
    background: #ff5520;
    transform: scale(1.1);
}

/* Canvas del juego */
#gameCanvas {
    position: absolute;
    top: 140px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 400px;
    height: calc(100vh - 200px);
    background: var(--road-color);
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    overflow: hidden;
}

/* Elementos del juego (creados dinámicamente) */
.road-line {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 40px;
    background: var(--line-color);
    border-radius: 4px;
}

.player-vehicle {
    position: absolute;
    font-size: 52px;
    transition: left 0.15s ease-out;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
    z-index: 10;
    transform: rotate(90deg);
}

.obstacle {
    position: absolute;
    font-size: 52px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
    transform: rotate(90deg);
    animation: wobble 0.5s ease-in-out infinite alternate;
}

.explosion {
    position: absolute;
    font-size: 72px;
    animation: explode 0.5s ease-out;
    z-index: 20;
}

@keyframes explode {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes wobble {
    0% {
        transform: rotate(90deg) translateX(-2px);
    }
    100% {
        transform: rotate(90deg) translateX(2px);
    }
}

/* Controles hint */
.controls-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 100;
}

/* Estadísticas de Game Over */
.game-over-stats {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    margin: 25px 0;
}

.game-over-stats p {
    font-size: 18px;
    margin: 10px 0;
    color: #333;
}

.game-over-stats strong {
    color: var(--primary-color);
    font-size: 22px;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content {
        padding: 30px 20px;
    }

    .vehicle-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .game-stats {
        gap: 15px;
        font-size: 14px;
    }

    .stat {
        font-size: 14px;
    }

    #gameCanvas {
        max-width: 100%;
        top: 120px;
        height: calc(100vh - 180px);
    }

    .controls-hint {
        font-size: 12px;
        padding: 8px 15px;
    }

    .player-vehicle, .obstacle {
        font-size: 40px;
    }

    .button-group {
        flex-direction: column;
    }

    .game-btn {
        width: 100%;
        margin: 5px 0;
    }
}

@media (max-width: 480px) {
    .vehicle-preview {
        font-size: 48px;
    }

    .game-over-stats p {
        font-size: 16px;
    }

    .game-over-stats strong {
        font-size: 18px;
    }
}

/* Animaciones adicionales */
@keyframes slideInFromTop {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.screen:not(.hidden) .modal-content {
    animation: slideInFromTop 0.3s ease-out;
}
