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

html, body {
    height: 100dvh;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    touch-action: none;
    background: #1a1a2e;
}

body {
    font-family: 'Press Start 2P', monospace;
    color: #eee;
    /* Escena pintada a sangre. El canvas del mapa es transparente, asi que la
       silueta de Mexico y los nodos flotan sobre este fondo. */
    background: #1a1a2e url('../assets/full-cover.png') center center / cover no-repeat;
}

#app {
    width: 100vw;
    height: 100dvh;
    height: 100vh;
    max-width: 100vw;
    max-height: 100dvh;
    max-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.scene {
    width: 100vw;
    height: 100dvh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.map-header,
.game-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background: linear-gradient(to bottom, rgba(26, 26, 46, 0.95) 0%, rgba(26, 26, 46, 0.7) 70%, transparent 100%);
    z-index: 20;
    gap: 5px;
    pointer-events: none;
}

.map-header *,
.game-header * {
    pointer-events: auto;
}

.game-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
}

.map-header h1 {
    font-size: 24px;
    color: #f39c12;
    text-shadow: 3px 3px #c0392b;
}

.map-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.music-btn[aria-pressed="false"] {
    opacity: 0.45;
}

.map-header p,
.game-info {
    font-size: 8px;
}

.game-info {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.game-info span {
    background: rgba(44, 62, 80, 0.95);
    padding: 6px 10px;
    border: 2px solid #34495e;
}

.game-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.canvas-wrapper {
    width: 100vw;
    height: 100dvh;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: none;
    /* Transparente para que el mapa deje ver el fondo de la pagina. */
    background: transparent;
    display: block;
}

#mapCanvas,
#gameCanvas {
    width: 800px;
    height: 400px;
    max-width: none;
    max-height: none;
}

.map-instructions,
.game-instructions {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    padding: 8px;
    background: linear-gradient(to top, rgba(26, 26, 46, 0.95) 0%, rgba(26, 26, 46, 0.7) 70%, transparent 100%);
    z-index: 20;
    font-size: 6px;
    pointer-events: none;
}

.map-instructions p,
.game-instructions p {
    font-size: 6px;
}

.pixel-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 8px 12px;
    background: #f39c12;
    color: #000;
    border: 2px solid #e67e22;
    cursor: pointer;
}

.pixel-btn:hover {
    background: #f1c40f;
}

/* Opcion seleccionada por teclado en los cuadros de dialogo. */
.overlay .pixel-btn:focus {
    outline: 3px solid #f1c40f;
    outline-offset: 2px;
}

/* Confeti tricolor (verde, blanco, rojo) del nivel 3. */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 300;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confetti-fall linear infinite;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100px) rotateZ(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotateZ(360deg);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    #confetti-container {
        display: none;
    }
}

.back-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    padding: 6px 10px;
    background: rgba(52, 73, 94, 0.95);
    color: #eee;
    border: 2px solid #2c3e50;
    cursor: pointer;
}

.touch-controls {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
}

.touch-zone {
    position: absolute;
    width: 100%;
    height: 50%;
    pointer-events: auto;
    touch-action: none;
}

.jump-zone {
    top: 0;
}

.duck-zone {
    bottom: 0;
}

.overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 40px;
    border: 4px solid #f39c12;
    text-align: center;
    z-index: 100;
}

.overlay.gameover {
    border-color: #e74c3c;
}

.overlay h2 {
    font-size: 18px;
    margin-bottom: 15px;
}

.overlay p {
    font-size: 8px;
    margin-bottom: 20px;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* El atributo hidden debe ganar a los estilos de boton. */
.pixel-btn[hidden] {
    display: none !important;
}

.overlay .save-status {
    min-height: 1.2em;
    margin: 12px 0 0;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    line-height: 1.6;
    color: #f1c40f;
}

#levelCompleteScene,
#gameOverScene {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

#levelCompleteScene[style*="display: none"],
#gameOverScene[style*="display: none"] {
    display: none !important;
}

@media (pointer: coarse) {
    .touch-controls {
        display: block;
    }
    
    .map-instructions,
    .game-instructions {
        font-size: 5px;
    }
    
    .map-instructions p,
    .game-instructions p {
        font-size: 5px;
    }
    
    .map-header h1 {
        font-size: 16px;
    }
    
    .map-header p,
    .game-info {
        font-size: 6px;
    }
    
    .overlay h2 {
        font-size: 14px;
    }
    
    .overlay p {
        font-size: 6px;
    }
}
