/* --- ESTILOS GENERALES Y RESET (TEMA NAVIDEÑO FINAL) --- */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #050b14;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: none;
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    background: url('../assets/images/fondo1.png') no-repeat center center;
    background-size: cover;
}

/* --- INTERFAZ (HUD) --- */
#uiLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 5;
}

#scoreBoard {
    font-size: 1.6rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 5px #ff0000;
    background: rgba(160, 0, 0, 0.8);
    padding: 10px 25px;
    border-radius: 20px;
    border: 2px solid #ffd700;
    font-family: monospace;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.player-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.health-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 50, 0, 0.8);
    padding: 8px 12px;
    border-radius: 15px;
    border: 1px solid #8fbc8f;
}

.health-label { font-weight: bold; font-size: 1rem; color: #ffd700; }
.health-bar-bg { width: 150px; height: 18px; background: #333; border-radius: 10px; overflow: hidden; border: 2px solid #fff; }
.health-bar-fill { height: 100%; width: 100%; transition: width 0.2s ease-out; border-radius: 8px; }

.p1-fill { background: repeating-linear-gradient(45deg, #00c800, #00c800 10px, #fff 10px, #fff 20px); box-shadow: 0 0 10px #0f0; }
.p2-fill { background: repeating-linear-gradient(45deg, #ff0000, #ff0000 10px, #fff 10px, #fff 20px); box-shadow: 0 0 10px #f00; }

/* --- PANTALLAS --- */
#startScreen, #gameOverScreen, #pauseScreen, #guideScreen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(15, 30, 60, 0.95) 0%, rgba(0, 5, 10, 0.98) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.title-container { text-align: center; margin-bottom: 20px; }

h1 {
    font-size: 4.5rem;
    margin: 0 0 5px 0;
    background: linear-gradient(to bottom, #ff3333 0%, #ffcc00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    font-weight: 900;
    letter-spacing: 2px;
    filter: drop-shadow(0 0 15px rgba(255, 0, 0, 0.5));
}

h2 { font-size: 1.5rem; margin: 0 0 30px 0; color: #89CFF0; text-transform: uppercase; letter-spacing: 5px; text-shadow: 0 0 10px #00ffff; }

/* --- CAJAS DE CONFIGURACIÓN --- */
.setup-row {
    display: flex;
    justify-content: center;
    gap: 25px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 900px;
    margin-bottom: 30px;
}

.setup-box {
    border: 2px solid rgba(135, 206, 235, 0.5);
    padding: 25px;
    border-radius: 20px;
    background: rgba(13, 24, 41, 0.6);
    backdrop-filter: blur(10px);
    width: 280px;
    max-width: 100%;
    box-shadow: 0 0 30px rgba(0, 191, 255, 0.15);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.setup-box h3 { margin: 0; color: #e0ffff; font-size: 1.2rem; text-align: center; text-shadow: 0 0 8px #0ff; text-transform: uppercase; }


/* ==========================================================================
   INPUTS Y LISTAS ARREGLADOS (CENTRADO PERFECTO + ESTILO NIEVE)
   ========================================================================== */

/* --- INPUTS Y LISTAS (CENTRADOS Y LIMPIOS) --- */

input[type="text"], select {
    /* 1. Limpieza total */
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    
    width: 100%;
    height: 50px;
    border-radius: 25px;
    
    /* 2. Estilo Oscuro (Se ve mejor con tu fondo de estrellas) */
    background-color: rgba(0, 0, 0, 0.7); 
    backdrop-filter: blur(5px);
    
    color: #fff; 
    border: 2px solid #ffd700; 
    
    font-size: 1.2rem;
    font-weight: bold;
    font-family: inherit;
    
    box-sizing: border-box;
    outline: none;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
    cursor: pointer;

    /* 3. EL CENTRADO REAL (Sin paddings locos) */
    text-align: center; 
    text-align-last: center; /* Obliga al texto seleccionado a ir al centro */
    
    /* Solo un poco de padding para que no choque con los bordes, pero SIMÉTRICO */
    padding: 0 20px; 
    
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Flecha Dorada (A la derecha, sin estorbar el centro) */
select {
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFD700%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px;
}

/* Efectos Focus */
input[type="text"]:focus, select:focus {
    background-color: #000;
    border-color: #fff;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

/* --- ESTILO DE LA LISTA DESPLEGADA (EL POPUP) --- */
select option {
    background-color: #111; /* Fondo negro */
    color: #ffd700; /* Texto dorado */
    font-size: 1rem;
    padding: 10px 0; /* Padding vertical, 0 horizontal para forzar centro */
    
    /* COMANDOS PARA CENTRAR LAS OPCIONES */
    text-align: center; 
    text-align-last: center;
    
    /* Truco para Firefox y algunos navegadores */
    display: flex;
    justify-content: center;
}

/* --- OTROS ELEMENTOS --- */
.file-upload {
    display: block; padding: 12px; border: 2px dashed #ffd700; border-radius: 15px;
    cursor: pointer; color: #ffd700; font-size: 1rem; transition: 0.3s;
    background: rgba(0, 0, 0, 0.3); text-align: center;
}
.file-upload:hover { background: rgba(255, 215, 0, 0.15); }
input[type="file"] { display: none; }

.leaderboard-box {
    background: rgba(80, 10, 10, 0.85); border: 3px solid #ffd700; border-radius: 20px;
    padding: 20px; margin-bottom: 25px; width: 350px; max-width: 90%;
    box-shadow: 0 0 25px rgba(255, 50, 50, 0.3); position: relative;
}
.leaderboard-box::before {
    content: ''; position: absolute; top: -6px; left: 15px; right: 15px; height: 6px;
    background: rgba(255,255,255,0.8); border-radius: 10px;
}
.leaderboard-box h3 {
    margin: 0 0 15px 0; color: #ffd700; font-size: 1.3rem; text-transform: uppercase;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3); padding-bottom: 10px; text-align: center;
}
#leaderboardListStart li, #leaderboardListOver li {
    padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: space-between; font-size: 1.05rem;
}

button {
    padding: 15px 40px; font-size: 1.3rem; border: none; border-radius: 50px; cursor: pointer;
    font-weight: bold; text-transform: uppercase; transition: all 0.2s; margin: 10px; position: relative;
    border: 2px solid rgba(255,255,255,0.3); text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}
button:hover { transform: translateY(-4px); filter: brightness(1.15); }
button:active { transform: scale(0.98); }

.start-btn { background: linear-gradient(180deg, #ff4444, #aa0000); color: white; box-shadow: 0 6px 20px rgba(255, 0, 0, 0.4); }
.retry-btn { background: linear-gradient(180deg, #44cc44, #006600); color: white; box-shadow: 0 6px 20px rgba(0, 255, 0, 0.3); }
.home-btn { background: linear-gradient(180deg, #00ccff, #005588); color: white; box-shadow: 0 6px 20px rgba(0, 150, 255, 0.3); }

.mode-select button { padding: 10px 20px; background: rgba(0,0,0,0.5); color: #aaa; border: 1px solid #555; font-size: 1rem; border-radius: 12px; }
.mode-select button.active { background: #006400; color: #fff; border-color: #0f0; box-shadow: 0 0 15px rgba(0, 255, 0, 0.4); }

.guide-content {
    background: #0a1a0a; border: 2px solid #c41e3a; padding: 25px; border-radius: 15px;
    max-width: 95%; width: 500px; max-height: 85vh; overflow-y: auto; box-shadow: 0 0 50px rgba(196, 30, 58, 0.4);
}
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; text-align: left; margin: 20px 0; }
.guide-item { display: flex; align-items: center; background: rgba(255,255,255,0.08); padding: 10px; border-radius: 8px; border: 1px solid #333; }
.guide-item img { width: 40px; height: 40px; margin-right: 12px; border: 2px solid #ffd700; background: rgba(0,0,0,0.5); object-fit: contain; border-radius: 5px; }
.guide-item b { color: #ffd700; display: block; font-size: 0.9rem; }
.guide-item span { color: #ddd; font-size: 0.8rem; }
.guide-item.enemy-item b { color: #ff6666; }

.hidden { display: none !important; }

/* ==========================================================================
   OPTIMIZACIÓN MÓVIL (CORREGIDA)
   ========================================================================== */
@media (max-width: 768px) {
    
    /* --- 1. REGLA DE ORO: OCULTAR JUGADOR 2 Y SELECTOR DE MODO --- */
    #p2Setup,           /* Oculta la caja del jugador 2 */
    .mode-select,       /* Oculta los botones de 1 vs 2 jugadores */
    #btn2P,             /* Por seguridad, si hay botón extra */
    .p2-only {          /* Cualquier elemento exclusivo del P2 */
        display: none !important;
    }

    /* --- 2. AJUSTE DE TÍTULOS (Para ganar espacio vertical) --- */
    h1 { 
        font-size: 2.8rem; /* Más pequeño para que no rompa la pantalla */
        margin-bottom: 5px;
    } 
    h2 { 
        font-size: 1rem; 
        margin-bottom: 15px; 
    }

    /* --- 3. CONTENEDORES VERTICALES --- */
    .setup-row {
        flex-direction: column; /* Uno debajo del otro */
        gap: 15px; /* Menos espacio entre cajas */
        margin-bottom: 20px;
        width: 100%;
    }

    .setup-box { 
        width: 85%; /* Ancho cómodo pero dejando ver el fondo */
        padding: 15px; /* Menos "gordura" interna */
        margin: 0 auto; /* Centrado perfecto */
    }

    /* --- 4. INPUTS Y SELECTS MÓVILES --- */
    input[type="text"], select {
        height: 45px; /* Un poco más compactos */
        font-size: 1.1rem;
    }

    /* --- 5. BOTÓN DE INICIO (GRANDE Y CÓMODO) --- */
    .start-btn { 
        width: 90%; 
        padding: 18px; 
        font-size: 1.6rem; 
        margin-top: 10px;
        position: relative;
        z-index: 100;
        /* Efecto pulsante sutil para llamar la atención */
        animation: pulseBtn 2s infinite;
    }

    /* --- 6. HUD DURANTE EL JUEGO (Más compacto) --- */
    #uiLayer { 
        padding: 10px; 
        flex-direction: column; /* Poner puntaje arriba y vida abajo si es necesario */
        align-items: center;
    }
    #scoreBoard { 
        font-size: 1.2rem; 
        padding: 5px 15px; 
        margin-bottom: 5px;
    }
    .health-bar-bg { 
        width: 120px; /* Barra de vida más corta para que quepa */
        height: 14px; 
    }
}

/* Animación opcional para el botón en celular */
@keyframes pulseBtn {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(255, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); }
}
#gameOverScreen button {
    padding: 15px 40px;
    font-size: 1.4rem;
    font-weight: 900; /* Texto súper grueso */
    border: 3px solid #ffd700; /* ¡BORDE DORADO GRUESO! */
    border-radius: 35px; /* Más redondeados */
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    /* Sombra doble para efecto 3D y brillo dorado */
    box-shadow: 
        0 5px 15px rgba(0,0,0,0.5), /* Sombra negra para profundidad */
        inset 0 2px 5px rgba(255,255,255,0.3), /* Brillo interior superior */
        0 0 20px rgba(255, 215, 0, 0.4); /* Halo dorado exterior */
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8); /* Sombra en el texto para que resalte */
    margin: 12px; /* Un poco más de espacio entre ellos */
}

/* Efecto al pasar el mouse (Hover) - General */
#gameOverScreen button:hover {
    transform: translateY(-4px) scale(1.02); /* Se levanta y crece un poco */
    filter: brightness(1.15); /* Se vuelve más brillante */
}

/* --- BOTÓN REINTENTAR (Verde Festivo) --- */
.retry-btn {
    /* Gradiente verde más rico y profundo, como un árbol de navidad */
    background: linear-gradient(to bottom, #009900, #005500);
    /* Reforzamos el brillo dorado específico de este botón */
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.6),
        inset 0 3px 8px rgba(255, 255, 255, 0.3),
        0 0 25px rgba(255, 215, 0, 0.7) !important;
}
.retry-btn:hover {
    /* Brillo verde y dorado intenso al pasar el mouse */
    box-shadow: 
        0 8px 25px rgba(0, 200, 0, 0.5),
        0 0 35px rgba(255, 215, 0, 0.9) !important;
}

/* --- BOTÓN INICIO (Azul Real) --- */
.home-btn {
    /* Gradiente azul real, profundo y elegante */
    background: linear-gradient(to bottom, #0066cc, #003377);
    /* Reforzamos el brillo dorado específico de este botón */
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.6),
        inset 0 3px 8px rgba(255, 255, 255, 0.3),
        0 0 25px rgba(255, 215, 0, 0.7) !important;
}
.home-btn:hover {
    /* Brillo azul y dorado intenso al pasar el mouse */
    box-shadow: 
        0 8px 25px rgba(0, 150, 255, 0.5),
        0 0 35px rgba(255, 215, 0, 0.9) !important;
}
/* --- DENTRO DE @media (max-width: 768px) --- */

/* Aseguramos que los botones de Game Over se vean grandes y centrados */
#gameOverScreen button {
    width: 85%; /* Ocupan casi todo el ancho */
    margin: 15px auto; /* Centrados horizontalmente con espacio vertical */
    padding: 20px; /* Más altos para que el dedo no falle */
    font-size: 1.6rem; /* Texto más grande */
    display: flex; /* Para centrar el icono y el texto perfectamente */
    justify-content: center;
    align-items: center;
    /* Una animación sutil para llamar la atención en móvil */
    animation: pulseGoldenBtn 3s infinite;
}

/* Animación suave de latido dorado */
@keyframes pulseGoldenBtn {
    0% { box-shadow: 0 5px 15px rgba(0,0,0,0.5), 0 0 20px rgba(255, 215, 0, 0.4); }
    50% { box-shadow: 0 5px 20px rgba(0,0,0,0.6), 0 0 35px rgba(255, 215, 0, 0.7); transform: scale(1.01); }
    100% { box-shadow: 0 5px 15px rgba(0,0,0,0.5), 0 0 20px rgba(255, 215, 0, 0.4); }
}