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

body {
    font-family: 'Cinzel', Georgia, serif;
    background: radial-gradient(ellipse at center, #1e3a5f 0%, #0a1628 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #d4af37;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-x pan-y;
    -webkit-touch-callout: none;
}

/* Burbujas de oxígeno - simplificadas */
.burbuja {
    position: fixed;
    bottom: -50px;
    width: 15px;
    height: 15px;
    background: rgba(100, 180, 220, 0.3);
    border-radius: 50%;
    pointer-events: none;
    animation: subir 8s linear infinite;
    z-index: 0;
}

.burbuja:nth-child(1) { left: 10%; animation-delay: 0s; }
.burbuja:nth-child(2) { left: 25%; animation-delay: 1s; }
.burbuja:nth-child(3) { left: 40%; animation-delay: 2s; }
.burbuja:nth-child(4) { left: 55%; animation-delay: 3s; }
.burbuja:nth-child(5) { left: 70%; animation-delay: 4s; }
.burbuja:nth-child(6) { left: 85%; animation-delay: 5s; }
.burbuja:nth-child(7) { left: 5%; animation-delay: 6s; }
.burbuja:nth-child(8) { left: 90%; animation-delay: 7s; }

@keyframes subir {
    0% { transform: translateY(0); opacity: 0; }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% { transform: translateY(-100vh); opacity: 0; }
}

h1 {
    text-align: center;
    font-size: 3rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    color: #d4af37;
    user-select: none;
    flex: 1;
    font-family: 'Pirata One', cursive;
    letter-spacing: 2px;
}

.cabecera {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin-bottom: 20px;
    position: relative;
}

#boton-musica {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(212, 175, 55, 0.2);
    border: 2px solid #d4af37;
    color: #d4af37;
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.9rem;
    white-space: nowrap;
}

#home {
    position: fixed;
    top: 25px;
    left: 25px;
    height: 75px;
    width: 75px;
    border-radius: 100%;
    border: 3px solid #d4af37;
    padding: 15px;
    background-color: rgba(212, 175, 55, 0.2);
    cursor: pointer;
    opacity: 0.8;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
#home:hover {
    transition: 0.3s ease;
    transform: scale(1.05);
    opacity: 1;
    background-color: rgba(212, 175, 55, 0.4);
}
#home svg {
    width: 28px;
    height: 28px;
    color: #d4af37;
}

@media (max-width: 1200px) {
    #boton-musica {
        position: static;
        margin-top: 10px;
    }
    .boton-volver {
        position: static;
        margin-bottom: 10px;
    }
}

#boton-musica.music-on {
    background: rgba(76, 175, 80, 0.3);
    color: #4caf50;
    border-color: #4caf50;
}

#boton-musica.music-off {
    background: rgba(244, 67, 54, 0.3);
    color: #f44336;
    border-color: #f44336;
}

.contenedor {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    max-width: 1400px;
    position: relative;
    z-index: 1;
}

.zona {
    background: rgba(255, 215, 0, 0.1);
    border: 3px dashed #d4af37;
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
    flex: 1;
    min-width: 300px;
}

.zona:last-child {
    margin-left: auto;
}

.zona h2 {
    margin-bottom: 10px;
    color: #d4af37;
    font-size: 1.3rem;
    user-select: none;
}

.rejilla-puzzle {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 0;
    border: 3px solid #8b4513;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    user-select: none;
    width: 100%;
    aspect-ratio: 512 / 384;
    background-image: url('images/mapa_dark.png');
    background-size: cover;
    background-position: center;
}

.celda-rejilla {
    aspect-ratio: 128 / 192;
    border: 1px solid rgba(139, 69, 19, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.celda-rejilla.correct {
    border-color: #4caf50;
}

.celda-rejilla .pieza-puzzle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    cursor: default;
    transform: none !important;
    user-select: none;
}

.celda-rejilla .pieza-puzzle:hover {
    transform: none;
    box-shadow: none;
}

.contenedor-piezas {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 10px;
    width: 100%;
    align-content: start;
    user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
}

.pieza-puzzle {
    aspect-ratio: 128 / 192;
    cursor: grab;
    border: 2px solid #8b4513;
    border-radius: 8px;
    user-select: none;
    overflow: hidden;
    touch-action: none;
    -webkit-touch-callout: none;
}

.pieza-puzzle:hover {
    border-color: #d4af37;
}

.pieza-puzzle:active {
    cursor: grabbing;
}

.pieza-puzzle.dragging {
    opacity: 0.5;
}

.pieza-puzzle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

#mensaje {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 90%;
    background: #1a1a2e;
    border: 4px solid #d4af37;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    z-index: 1000;
    display: none;
    box-shadow: 0 0 50px rgba(212, 175, 55, 0.5);
    overflow: auto;
}

#mensaje.show {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#mensaje h2 {
    font-size: 2rem;
    color: #4caf50;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    user-select: none;
}

#mensaje p {
    font-size: 1rem;
    color: #d4af37;
    margin-bottom: 15px;
    user-select: none;
}

#boton-reiniciar {
    background: #d4af37;
    color: #1a1a2e;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Cinzel', Georgia, serif;
    font-weight: bold;
    user-select: none;
}

#boton-reiniciar:hover {
    box-shadow: 0 5px 20px rgba(212, 175, 55, 0.5);
}

@media (max-width: 1200px) {
    .contenedor {
        flex-direction: column;
        align-items: center;
    }
    
    .zona {
        width: 100%;
        max-width: 542px;
    }
    
    .zona:last-child {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    #mensaje {
        width: 95%;
        padding: 15px;
        border-width: 3px;
    }
    
    #mensaje h2 {
        font-size: 1.5rem;
    }
    
    #mensaje p {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    #boton-reiniciar {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .zona h2 {
        font-size: 1.1rem;
    }
}
