/* ========= Variables y Estilos Globales ========= */
:root {
    --bg-dark: #06131f;
    --bg-card: #001830;
    --text-light: #e9f3ff;
    --accent-blue: #7ecbff;
    --accent-blue-dark: #003b8e;
    --accent-blue-light: #cfe9ff;
    --accent-yellow: #ffdd77;
    --accent-red: #b22222;

    --hud-bg-color: rgba(6, 19, 31, 0.65);
    --hud-blur: 8px;
    --hud-border-color: rgba(126, 203, 255, 0.4);

    --status-bar-height: 70px;
    --total-hud-height: var(--status-bar-height);
}

html, body { 
    margin: 0; 
    height: 100%; 
    background: var(--bg-dark); 
    font-family: 'Press Start 2P', monospace; 
    overflow: hidden; 
}

/* ========= Capas de Canvas (AJUSTADAS AL NUEVO LAYOUT) ========= */
canvas { 
    position: fixed; 
    left: 0;
    top: var(--total-hud-height);
    width: 100vw; 
    height: calc(100vh - var(--total-hud-height));
    display: block; 
}
/* ... (El resto de estilos de canvas permanece igual) ... */
#bgCanvas { z-index: 0; }
#gameCanvas { z-index: 1; }
#fxCanvas { z-index: 2; pointer-events: none; }
#hudCanvas { z-index: 3; pointer-events: none; }

/* ========= HUD SUPERIOR (DISEÑO EN LÍNEA ÚNICA) ========= */
#top-hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 6;
    image-rendering: pixelated;
    background-color: var(--hud-bg-color);
    backdrop-filter: blur(var(--hud-blur));
    -webkit-backdrop-filter: blur(var(--hud-blur));
    animation: fadeInHud 0.8s ease-out forwards;
}

@keyframes fadeInHud {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--status-bar-height);
    padding: 0 clamp(10px, 3vw, 20px);
    box-sizing: border-box;
    border-bottom: 1px solid var(--hud-border-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#status-left { 
    display: flex; 
    align-items: center; 
    gap: clamp(10px, 3vw, 20px); 
    flex-shrink: 0;
}
#logoHUD { height: clamp(40px, 7vh, 50px); }
#status-text {
    color: var(--text-light);
    font-size: clamp(0.8rem, 2.2vw, 1rem);
    line-height: 1.4;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}
#hud-objective-text { color: var(--accent-yellow); }

#gameplay-hints {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    color: var(--text-light);
    flex-grow: 1;
}

.hint {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: clamp(0.6rem, 1.3vw, 0.8rem);
    text-transform: uppercase;
    opacity: 0.8;
}

.hint-grid {
    display: grid;
    grid-template-areas: "title up" "left down" "right .";
    grid-template-columns: auto auto;
    gap: 4px 8px;
    align-items: center;
}
.hint-grid > span { grid-area: title; justify-self: start; align-self: center; margin-right: 0.8rem; }
.hint-grid .key-arrow-up { grid-area: up; }
.hint-grid .key-arrow-left { grid-area: left; }
.hint-grid .key-arrow-down { grid-area: down; }
.hint-grid .key-arrow-right { grid-area: right; }


kbd.key-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: #334155;
    color: var(--text-light);
    border: 1px solid #64748b;
    border-bottom: 3px solid #475569;
    font-family: 'Press Start 2P', monospace;
    height: 28px;
    border-radius: 4px;
    transition: all 0.1s ease-out;
}
kbd.key-icon:active { transform: translateY(2px); border-bottom-width: 1px; }
kbd.text-key { width: 28px; font-size: 1.1rem; }
.key-arrow-up, .key-arrow-down, .key-arrow-left, .key-arrow-right { width: 28px; }
.key-arrow-up::before { content: ''; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 9px solid var(--accent-blue-light); }
.key-arrow-down::before { content: ''; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 9px solid var(--accent-blue-light); }
.key-arrow-left::before { content: ''; width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-right: 9px solid var(--accent-blue-light); }
.key-arrow-right::before { content: ''; width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid var(--accent-blue-light); }
kbd.key-spacebar { width: 100px; height: 24px; background-color: var(--accent-blue-light); }


#status-right { 
    display: flex; 
    gap: 10px;
    flex-shrink: 0; 
}


/* ===== NUEVO Y MEJORADO ESTILO PARA LOS BOTONES DEL HUD ===== */
.spritebtn {
    /* Reseteo y dimensiones */
    padding: 0;
    width: clamp(38px, 6vh, 44px);
    height: clamp(38px, 6vh, 44px);
    
    /* Apariencia */
    background-color: #2c5a8e; /* Un azul intermedio */
    border: 2px solid var(--accent-blue-light);
    border-bottom-width: 4px;
    border-right-width: 4px;
    border-radius: 8px;
    box-shadow: inset 0 0 0 2px var(--accent-blue-dark);
    
    /* Contenido (el SVG) */
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* Interacción */
    cursor: pointer;
    transition: all 0.1s ease-out;
}

.spritebtn:hover {
    background-color: #4c7fb8; /* Un poco más claro al pasar el ratón */
    transform: translateY(-1px);
}

.spritebtn:active {
    transform: translateY(2px); /* Efecto de presionado */
    border-bottom-width: 2px;
    border-right-width: 2px;
    background-color: #244b78; /* Más oscuro al presionar */
}

/* Estilo para los iconos SVG dentro de los botones */
.spritebtn svg {
    width: 65%;
    height: 65%;
    fill: var(--accent-blue-light); /* El icono toma un color claro */
    transition: fill 0.2s ease;
}

.spritebtn:hover svg {
    fill: #ffffff; /* El icono se vuelve blanco puro al pasar el ratón */
}

/* Estilo para el botón de mute cuando está activo */
.spritebtn.muted {
    background-color: #555;
    box-shadow: inset 0 0 0 2px #333;
    border-color: #aaa;
}
.spritebtn.muted svg {
    fill: #aaa;
}

/* (El resto del CSS para overlays, menús, etc., permanece igual) */

/* ========= Media Queries para Responsividad ========= */
@media (max-width: 820px) {
    .hint > span { display: none; }
    #gameplay-hints { gap: 1rem; }
    kbd.key-spacebar { width: 80px; }
}

@media (max-width: 600px) { 
    #gameplay-hints { display: none; }
    #fsBtn, #shareBtn, #githubBtn { display: none; }
}

@media (pointer: coarse) {
    #gameplay-hints { display: none; }
}

/* ... (Todo tu CSS existente va aquí arriba) ... */


/* ========= ESTILOS PARA OVERLAYS Y MENÚS (AÑADIDO) ========= */
#overlay, #infoOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 19, 31, 0.9);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10;
    display: grid;
    place-items: center;
    color: var(--text-light);
    text-align: center;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    line-height: 1.6;
    animation: fadeInHud 0.5s ease-out forwards;
}

.menu-card {
    background: var(--bg-card);
    border: 2px solid var(--hud-border-color);
    border-radius: 12px;
    padding: clamp(1rem, 5vw, 2.5rem);
    max-width: 600px;
    width: 90%;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

.menu-card h2 {
    color: var(--accent-yellow);
    font-size: clamp(1.5rem, 6vw, 2.2rem);
    margin-bottom: 1rem;
    text-transform: uppercase;
}
.menu-card p {
    margin: 0.8rem 0;
}
.menu-card ul {
    text-align: left;
    display: inline-block;
    list-style: none;
    padding: 0;
}
.menu-card ul li {
    margin-bottom: 0.5rem;
}

#finalStats {
    margin: 1.5rem 0;
    border-top: 1px solid var(--hud-border-color);
    border-bottom: 1px solid var(--hud-border-color);
    padding: 1rem 0;
}

.menubtn {
    font-family: 'Press Start 2P', monospace;
    background-color: var(--accent-blue-dark);
    color: var(--text-light);
    border: 2px solid var(--accent-blue);
    padding: 12px 24px;
    font-size: 1rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin: 0.5rem;
}
.menubtn:hover {
    background-color: var(--accent-blue);
    color: var(--bg-dark);
    transform: scale(1.05);
}

#bossHealthContainer {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 600px;
    height: 20px;
    background-color: rgba(0,0,0,0.5);
    border: 2px solid var(--accent-red);
    border-radius: 10px;
    z-index: 5;
    padding: 2px;
    box-sizing: border-box;
}

#bossHealthBar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff4d4d, #b22222);
    border-radius: 6px;
    transition: width 0.3s ease-in-out;
}

/* ... (Todo tu CSS existente hasta el final) ... */

/* ========= ESTILOS PARA EL SELECTOR DE NIVELES (AÑADIDO) ========= */
#level-selector-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
}

.levelbtn {
    font-family: 'Press Start 2P', monospace;
    width: 60px;
    height: 60px;
    background-color: var(--accent-blue-dark);
    color: var(--text-light);
    border: 2px solid var(--accent-blue);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.levelbtn:hover:not(:disabled) {
    background-color: var(--accent-blue);
    color: var(--bg-dark);
    transform: scale(1.1);
}

.levelbtn:disabled {
    background-color: #334155;
    border-color: #64748b;
    color: #94a3b8;
    cursor: not-allowed;
}

/* Estilo para el ícono de candado en botones deshabilitados */
.levelbtn:disabled::before {
    content: '🔒'; /* Puedes usar un SVG si prefieres */
    font-size: 1.5rem;
}

/* ... (Todo tu CSS existente hasta el final) ... */

/* ========= ESTILOS PARA LA VENTANA DE INFORMACIÓN (MEJORADA) ========= */
.info-card {
    max-width: 700px;
    position: relative;
    padding-top: 80px; /* Espacio para el canvas de animación */
}

#infoAnimCanvas {
    position: absolute;
    top: -60px; /* Que sobresalga un poco */
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 120px;
    image-rendering: pixelated;
    pointer-events: none;
}

.creator-profile {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    text-align: left;
    margin: 2rem 0;
    flex-wrap: wrap; /* Para que se adapte en pantallas pequeñas */
}

.profile-pic {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--accent-blue);
    object-fit: cover;
    flex-shrink: 0;
}

.creator-info {
    flex-grow: 1;
}

.creator-info h3 {
    margin: 0 0 0.5rem;
    color: var(--accent-yellow);
    font-size: 1.2rem;
}

.creator-bio {
    font-family: monospace; /* Una fuente más legible para texto largo */
    font-size: 0.9rem;
    line-height: 1.5;
    opacity: 0.9;
}

.social-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    padding: 10px 18px;
    margin-top: 1rem;
}
.social-btn svg {
    transition: transform 0.2s ease-out;
}
.social-btn:hover svg {
    transform: scale(1.2) rotate(-10deg);
}

.gallery {
    margin: 2.5rem 0 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--hud-border-color);
}
.gallery h4 {
    margin: 0 0 1rem;
    color: var(--accent-blue-light);
}
.gallery-item {
    display: inline-block;
    position: relative;
}
.gallery-item img {
    max-width: 250px;
    width: 100%;
    border-radius: 8px;
    border: 2px solid var(--hud-border-color);
    transition: transform 0.3s ease;
}
.gallery-item:hover img {
    transform: scale(1.05);
}
.gallery-caption {
    font-family: monospace;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    opacity: 0.8;
}