/* Contenedor principal */
.pp-contentall {
    font-family: "Arial", "Helvetica", "Segoe UI", "Tahoma", "Verdana", sans-serif;	
    font-size: 16px; 
    margin: auto;
    background: linear-gradient(to bottom, rgba(100,100,150,0.8), rgba(50,50,100,0.8)), url('');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    color: black;
    padding: 7px;
    width: auto;  
    height: calc(100vh - 120px);
    line-height: 1;
    text-align: center;
    justify-items: center; 
    align-items: center;	
    touch-action: manipulation;
    user-select: none;
    position: relative;
   /*  overflow: hidden; 🔒 NUEVO: contiene al modal dentro */    
}  

.pp-contentall p { margin: 5px auto; }

#contentgame {
    background: #f9f9f9;
    width: 640px;
    max-width: 100%;
    border: 1px solid gray;
    border-radius: 7px;
    padding: 10px;
    display: flex;
    justify-content: center;
    gap: 15px;
    box-sizing: border-box;
}

.pp-image-puzzle { 
    background: #e0e0e0;
    width: 380px; 
    height: 380px;
    max-width: 100%;
    border: 1px solid #bbb;
    border-radius: 7px;
    box-shadow: 0px 0px 0px 2px white, 0px 0px 0px 6px #bbb;   
    margin: 0 5px 0 0;
    position: relative;
    display: grid;
}

/* Atenuación dinámica */
.pp-image-puzzle::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, var(--attenuation, 0.3));
    border-radius: 7px;
    pointer-events: none;
    z-index: 1;
}

#bar-images { 
    width: 200px; 
    max-width: 100%;
    max-height:380px;
    padding: 10px;
    background: #f0f0f0;
    border: 1px solid #bbb;
    border-radius: 7px;
    display: flex; 
    flex-flow: column;
    align-items: center;
    box-shadow: 0px 0px 0px 2px white, 0px 0px 0px 6px #bbb; 
} 

#image-obj { 
    width: 114px; 
    height: 114px;
    margin: 0 auto 7px;
    border: 1px solid gray;
    border-radius: 7px;
    background: #d4edda;
    background-size: cover; 
    background-position: center;
    flex-shrink: 0;
} 

/* ZONA DE PIEZAS MINI: Contenido estrictamente controlado */
#image-pieces {
    width: 100%; 
    min-height: 200px;
    max-height: 240px;
    overflow-y: auto;
    overscroll-behavior: contain; /* 🔒 NUEVO: evita que el scroll "se fugue" al padre */
    border: 1px solid gray;
    border-radius: 7px;
    background: #e9ecef;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    gap: 4px;
    padding: 8px;
    box-sizing: border-box;
}


/* Scrollbar bonita para la zona de piezas */
#image-pieces::-webkit-scrollbar { width: 6px; }
#image-pieces::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
#image-pieces::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }


div#config-puzzle {
    display: flex;
    justify-content: center;
    align-items: center;
}

.bar-info {
    width: 100%;
    max-width: 640px;
    padding: 7px; 
    margin: 1px auto;
    border: 1px solid gray;
    border-radius: 7px;
    background: #f8f9fa;
    box-sizing: border-box;
    display:flex; justify-content:center; align-items:center;
}  

.pp-btn {
    padding: 4px 12px;
    box-shadow: 0px 0px 4px 2px inset #999;
    border-radius: 5px;
    background: #bbf;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.pp-btn:hover { background: #e2e6ea; }
.pp-btn.active { background: #007cba; color: white; border-color: #005a87; }

/* Piezas del puzzle */
.pp-piece {
    border: 1px solid rgba(0,0,0,0.3);
    box-sizing: border-box;
    cursor: grab;
    touch-action: none;
    position: relative;
    z-index: 10;
    background-repeat: no-repeat;
    /* La transición permite el efecto de "crecer" al arrastrar */
    transition: width 0.2s ease, height 0.2s ease, box-shadow 0.2s;
}
.pp-piece:active { cursor: grabbing; z-index: 1000; box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
.pp-piece.locked { cursor: default; border: 1px solid #28a745; z-index: 5; }

/* Modal */
/* Modal contenido dentro de #contentall */
.pp-modal {
    position: absolute; /* antes era fixed */
    z-index: 2000;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /*
    width: 90%;
    max-width: 500px; */
    width: 100%;
    height:100%;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: ppFadeIn 0.3s ease;
}

@keyframes ppFadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.pp-modal-content {
    background-color: #fefefe;
    padding: 25px;
    border-radius: 10px;
    width: 100%;
    max-width: 500px;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.pp-modal-content h2, .pp-modal-content p {
    margin: 5px auto !important;
}

.pp-close {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 26px;
    font-weight: bold;
    cursor: pointer;
    color: #666;
    line-height: 1;
}
.pp-close:hover { color: #000; }



#pp-back-sound {
    /* El elemento audio queda oculto pero accesible */
    display: none;
}








/* RESPONSIVE: Móvil */
/*
@media (orientation: landscape) and (min-width: 1025px) {
    .pp-contentall {    
        height: calc(100vh - 20px);
    }
    #secundario { zoom: 0.77; }
} */

@media (max-width: 1024px) and (pointer: coarse) {
    .pp-contentall {    
        height: calc(100vh - 20px);
    }
    #secundario { zoom: 0.75; }
}    

@media (max-width: 1024px) and (max-height: 360px) {
    .pp-contentall {    
        height: calc(100vh - 20px);
    }
    #secundario { zoom: 0.67; }
}



@media (max-width: 440px) {
    .pp-contentall {    
        /* height: calc(100vh - 20px); */
        height:max-content;
        padding:4px auto 10px;
    }
    #secundario { zoom: 1; width:100%; }   
    
    #contentgame { flex-direction: column; align-items: center; }
    .pp-image-puzzle { width: 85vw; max-width: 350px; height: auto; aspect-ratio: 1 / 1; }
    
    #bar-images { 
        width: 85vw; 
        max-width: 350px; 
        flex-direction: row; 
        justify-content: space-between; 
        align-items: flex-start; 
    }
    #image-obj { width: 70px; height: 70px; margin: 0; }
    
    #image-pieces { 
        width: calc(100% - 80px); 
        min-height: 120px; 
        max-height: 150px; /* Más compacto en móvil */
    }
    div#config-puzzle {
        display: grid;
    }    
    
    
}








