/* ========================================================================== */
/* JUEGO DE DEFENSA - VERSIÓN FÁCIL PARA NIÑOS */
/* ========================================================================== */

.juego-defensa {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    pointer-events: none;
    z-index: 2147483645;
}

.juego-defensa > * {
    pointer-events: auto;
}

.dinosaurio-defensa {
    z-index: 2147483645;
    transition: all 0.3s ease;
}

.insectos-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 2147483640;
}

.insecto {
    pointer-events: auto;
    transition: all 0.3s ease;
    z-index: 2147483640;
    border-radius: 50%;
    overflow: visible;
    animation: flotarInsecto 2s ease-in-out infinite, aparecerInsecto 0.6s ease-out;
    
    /* CENTRADO PERFECTO - IGUAL QUE JUEGO COMIDA */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1 !important;
}

.insecto:hover {
    transform: scale(1.2);
    filter: brightness(1.4) drop-shadow(0 0 8px rgba(255,255,255,0.9));
    animation: flotarInsecto 0.5s ease-in-out infinite;
}

.insecto:active {
    transform: scale(0.9);
}

/* Insectos con imagen */
.insecto-con-imagen {
    display: none; /* Ocultos, se usarán como plantillas */
}

/* ========================================================================== */
/* CENTRADO PERFECTO PARA EMOJIS E IMÁGENES - IGUAL QUE JUEGO COMIDA */
/* ========================================================================== */

/* EMOJIS CENTRADOS PERFECTAMENTE */
.emoji-insecto {
    font-size: 40px !important;
    line-height: 1 !important;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8) !important;
    color: white !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 SUPERPUESTAS SIN ESPACIO */
.img-insecto {
    width: 80% !important;
    height: 80% !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 EMOJI CUANDO HAY IMAGEN */
.insecto:has(.img-insecto) .emoji-insecto {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* ========================================================================== */
/* TABLERO DE DEFENSA - POSICIÓN CONSISTENTE EN TODOS LOS DISPOSITIVOS */
/* ========================================================================== */

.contador-defensa {
    position: fixed !important;
    bottom: 90px !important; /* 70px arriba de la barra de botones - MISMA POSICIÓN EN TODOS LOS DISPOSITIVOS */
    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: 2147483646 !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 !important;
    justify-content: space-around;
    align-items: center;
    flex-wrap: nowrap;
}

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

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

.tiempo-restante { 
    color: #4fc3f7 !important;
}

.insectos-eliminados { 
    color: #69f0ae !important;
}

.vidas-restantes { 
    color: #ff5252 !important;
}

/* ========================================================================== */
/* ESTILOS PARA MENSAJES - IGUAL QUE JUEGO LINTERNA */
/* ========================================================================== */

.mensaje-defensa {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.2) !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    color: white;
    padding: 25px 35px !important;
    border-radius: 12px;
    font-size: 26px;
    z-index: 2147483648 !important;
    text-align: center;
    max-width: 80%;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    text-transform: uppercase !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: aparecerMensaje 0.3s ease-out;
    line-height: 1.4;
    margin: 0 !important;
}

@keyframes aparecerMensaje {
    0% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Animaciones mejoradas para la versión fácil */
@keyframes flotarInsecto {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.05); }
}

@keyframes aparecerInsecto {
    0% { transform: scale(0) rotate(0deg); opacity: 0; }
    70% { transform: scale(1.1) rotate(10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes victoriaDino {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(5deg); }
    50% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.2) rotate(3deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes vibrar {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    50% { transform: translateX(3px); }
    75% { transform: translateX(-2px); }
}

@keyframes flotarPuntos {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-50px) scale(1.5); opacity: 0; }
}

.dinosaurio-defensa.danio {
    animation: vibrar 0.5s ease-in-out;
}

/* Efectos de partículas para victoria */
.confeti {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: caerConfeti 3s linear forwards;
}

/* ========================================================================== */
/* MEDIA QUERIES - SOLO AJUSTES DE TAMAÑO, NO POSICIÓN */
/* ========================================================================== */

/* Tablets */
@media (max-width: 768px) {
    .contador-defensa {
        padding: 8px 12px !important;
        font-size: 16px;
        max-width: 400px;
        /* NO modificar bottom - posición consistente */
    }
    
    .contador-defensa div {
        font-size: 16px;
    }
    
    /* AJUSTES PARA INSECTOS EN TABLETS */
    .emoji-insecto {
        font-size: 35px !important;
    }
    
    .img-insecto {
        width: 75% !important;
        height: 75% !important;
    }
    
    /* AJUSTES PARA MENSAJES EN TABLETS */
    .mensaje-defensa {
        font-size: 22px;
        padding: 20px 30px !important;
        max-width: 85%;
    }
}

/* Móviles */
@media (max-width: 480px) {
    .contador-defensa {
        padding: 6px 10px !important;
        font-size: 16px;
        max-width: 300px;
        /* NO modificar bottom - posición consistente */
    }
    
    .contador-defensa div {
        font-size: 16px;
    }
    
    /* AJUSTES PARA INSECTOS EN MÓVILES */
    .emoji-insecto {
        font-size: 30px !important;
    }
    
    .img-insecto {
        width: 70% !important;
        height: 70% !important;
    }
    
    /* AJUSTES PARA MENSAJES EN MÓVILES */
    .mensaje-defensa {
        font-size: 20px;
        padding: 18px 25px !important;
        max-width: 90%;
    }
}

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

html body .contador-defensa {
    bottom: 80px !important; /* POSICIÓN FIJA EN TODOS LOS DISPOSITIVOS */
}