/* ========================================================================== */
/* ESTILOS PARA JUEGO DE LETRAS - CON ANIMACIONES Y DISEÑO RESPONSIVO */
/* ========================================================================== */

/* CONTENEDOR PRINCIPAL DEL MINIJUEGO */
.contenedor-minijuego {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    z-index: 2147483646 !important;
    pointer-events: none !important;
}

/* CONTENEDOR DEL JUEGO DE LETRAS - CENTRADO VERTICALMENTE */
.juego-letras {
    position: absolute !important;
    top: 50% !important; /* CENTRADO VERTICALMENTE */
    left: 50% !important;
    transform: translate(-50%, -50%) !important; /* CENTRADO PERFECTO */
    width: 100%;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 0 20px;
    z-index: 2147483647 !important;
    pointer-events: auto !important;
}

/* CONTENEDOR DE LETRAS ARRASTRABLES - MÁS PEQUEÑAS */
.letra-arrastrable {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #4CAF50;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: grab;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    z-index: 2147483647 !important;
    transform-origin: center;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    overflow: hidden;
    padding: 0 !important;
    box-sizing: border-box !important;
    font-family: 'Fredoka', sans-serif;
    font-weight: bold;
    pointer-events: auto !important;
}

/* TEXTO DE LA LETRA - MÁS PEQUEÑO */
.texto-letra {
    font-size: 32px !important;
    line-height: 1 !important;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3) !important;
    color: #2E7D32 !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    display: block !important;
    text-align: center !important;
}

/* IMÁGENES DE LETRAS (si se usan) - MÁS PEQUEÑAS */
.img-letra {
    width: 40px !important;
    height: 40px !important;
    object-fit: contain !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 2 !important;
    pointer-events: none !important;
    margin: 0 !important;
}

/* OCULTAR TEXTO CUANDO HAY IMAGEN */
.letra-arrastrable:has(.img-letra) .texto-letra {
    opacity: 0 !important;
    visibility: hidden !important;
}

.letra-arrastrable:hover {
    transform: scale(1.15) translateY(-5px);
    background: rgba(255, 255, 255, 1);
    border-color: #2E7D32;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.letra-arrastrable:active {
    transform: scale(0.95);
}

/* Efecto de brillo al seleccionar */
.letra-arrastrable.seleccionada {
    animation: brilloSeleccionLetra 0.6s ease-in-out;
    transform: scale(1.2);
    box-shadow: 
        0 0 20px rgba(76, 175, 80, 0.8),
        0 0 40px rgba(76, 175, 80, 0.4),
        inset 0 0 12px rgba(76, 175, 80, 0.2);
    border-color: #2E7D32;
    background: rgba(76, 175, 80, 0.1);
}

@keyframes brilloSeleccionLetra {
    0% {
        box-shadow: 
            0 6px 20px rgba(0, 0, 0, 0.25),
            0 0 0 rgba(76, 175, 80, 0);
    }
    50% {
        box-shadow: 
            0 6px 20px rgba(0, 0, 0, 0.25),
            0 0 30px rgba(76, 175, 80, 0.6),
            inset 0 0 12px rgba(76, 175, 80, 0.2);
    }
    100% {
        box-shadow: 
            0 6px 20px rgba(0, 0, 0, 0.25),
            0 0 0 rgba(76, 175, 80, 0);
    }
}

.letra-arrastrable.arrastrando {
    opacity: 0.9;
    transform: scale(1.3) rotate(5deg);
    cursor: grabbing;
    z-index: 2147483648 !important;
    box-shadow: 
        0 12px 30px rgba(0, 0, 0, 0.35),
        0 0 35px rgba(76, 175, 80, 0.5);
    border-color: #2E7D32;
    background: rgba(255, 255, 255, 1);
}

/* Animación para letra correcta */
@keyframes letraCorrecta {
    0% { 
        transform: scale(1); 
        opacity: 1; 
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    }
    50% { 
        transform: scale(1.6); 
        opacity: 0.8;
        box-shadow: 
            0 0 40px rgba(76, 175, 80, 0.8),
            0 0 70px rgba(76, 175, 80, 0.4);
    }
    100% { 
        transform: scale(0); 
        opacity: 0; 
    }
}

.letra-arrastrable.correcta {
    animation: letraCorrecta 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    border-color: #4CAF50;
    background: radial-gradient(circle, rgba(76, 175, 80, 0.2), transparent);
}

/* Animación para letra incorrecta */
@keyframes letraIncorrecta {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    10% { transform: translateX(-12px) rotate(-5deg); }
    20% { transform: translateX(12px) rotate(5deg); }
    30% { transform: translateX(-8px) rotate(-3deg); }
    40% { transform: translateX(8px) rotate(3deg); }
    50% { transform: translateX(-4px) rotate(-2deg); }
    60% { transform: translateX(4px) rotate(2deg); }
}

.letra-arrastrable.incorrecta {
    animation: letraIncorrecta 0.7s ease-in-out;
    background: radial-gradient(circle, rgba(244, 67, 54, 0.3), transparent);
    border-color: #f44336;
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.5);
}

/* ========================================================================== */
/* CONTENEDOR DE PALABRA OBJETIVO - POSICIÓN MODIFICADA (20px MÁS ARRIBA) */
/* ========================================================================== */

.contenedor-palabra {
    position: fixed !important;
    bottom: 140px !important; /* SUBIDO 20px MÁS - era 120px */
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: rgba(190, 150, 120, 0.85);
    padding: 12px 20px;
    border-radius: 18px;
    z-index: 2147483647 !important;
    font-family: 'Fredoka', sans-serif;
    font-size: 22px;
    font-weight: bold;
    color: white;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    display: none;
    max-width: 90%;
    box-sizing: border-box;
    pointer-events: none !important;
}

.contenedor-palabra.mostrar {
    display: block !important;
}

/* SLOTS PARA LAS LETRAS - MÁS PEQUEÑOS Y PUNTEADOS */
.slots-palabra {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

.slot-letra {
    width: 60px;
    height: 60px;
    border: 3px dashed rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: bold;
    font-family: 'Fredoka', sans-serif;
}

.slot-letra.ocupado {
    border: 3px solid #4CAF50;
    background: rgba(76, 175, 80, 0.25);
    color: white;
}

.slot-letra.correcto {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.35);
    animation: pulsoCorrecto 0.5s ease-in-out;
}

@keyframes pulsoCorrecto {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ========================================================================== */
/* TABLERO DE PUNTUACIÓN - POSICIÓN FIJA */
/* ========================================================================== */

.contador-letras {
    position: fixed !important;
    bottom: 80px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: rgba(190, 150, 120, 0.6) !important;
    color: white;
    padding: 8px 15px !important;
    border-radius: 14px;
    font-size: 16px;
    z-index: 2147483647 !important;
    font-family: 'Fredoka', sans-serif;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    pointer-events: auto;
    backdrop-filter: blur(5px) !important;
    width: 90%;
    max-width: 500px;
    box-sizing: border-box;
    text-align: center;
    display: none;
    justify-content: space-around;
    align-items: center;
}

.contador-letras.mostrar {
    display: flex !important;
}

.contador-letras div {
    margin: 0 !important;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.9);
    font-weight: bold;
    white-space: nowrap;
}

.letras-correctas { 
    color: #69f0ae;
}

.letras-restantes { 
    color: #ff9800;
}

/* Ajustes para pantallas más pequeñas */
@media (max-width: 768px) {
    .letra-arrastrable {
        width: 50px;
        height: 50px;
    }
    
    .texto-letra {
        font-size: 26px !important;
    }
    
    .img-letra {
        width: 32px !important;
        height: 32px !important;
    }
    
    .juego-letras {
        gap: 12px;
    }
    
    .contenedor-palabra {
        bottom: 130px !important;
        font-size: 20px;
        padding: 10px 16px;
    }
    
    .slot-letra {
        width: 50px;
        height: 50px;
        font-size: 20px;
        border: 2px dashed rgba(255, 255, 255, 0.6);
    }
    
    .contador-letras {
        bottom: 70px !important;
        padding: 8px 12px !important;
        font-size: 16px;
        max-width: 400px;
    }
}

@media (max-width: 480px) {
    .letra-arrastrable {
        width: 45px;
        height: 45px;
    }
    
    .texto-letra {
        font-size: 22px !important;
    }
    
    .img-letra {
        width: 28px !important;
        height: 28px !important;
    }
    
    .juego-letras {
        gap: 10px;
    }
    
    .contenedor-palabra {
        bottom: 120px !important;
        font-size: 18px;
        padding: 8px 14px;
    }
    
    .slot-letra {
        width: 45px;
        height: 45px;
        font-size: 18px;
        border: 2px dashed rgba(255, 255, 255, 0.6);
    }
    
    .contador-letras {
        bottom: 60px !important;
        padding: 6px 10px !important;
        font-size: 16px;
        max-width: 300px;
    }
}

/* ========================================================================== */
/* FORZAR POSICIÓN CON SELECTORES ESPECÍFICOS */
/* ========================================================================== */

html body .contenedor-minijuego {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
}

html body .juego-letras {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

html body .contenedor-palabra {
    bottom: 140px !important;
}

html body .contador-letras {
    bottom: 80px !important;
}