/* ========================================================================== */
/* JUEGO FROGGER - CAPIBARA CRUZANDO CALLE Y RÍO - CONTROLES TÁCTILES */
/* ========================================================================== */

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

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

/* Tablero de juego con COLORES PLANOS Y DEFINIDOS */
.tablero-frogger {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Colores planos en lugar de gradientes */
    background: #87CEEB; /* Cielo */
    z-index: 2147483640;
    touch-action: none;
}

/* Zonas con colores planos */
.zona-cielo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 12%;
    background: #87CEEB; /* Celeste cielo */
    z-index: 2147483640;
}

.zona-segura-superior {
    position: absolute;
    top: 12%;
    left: 0;
    width: 100%;
    height: 13%;
    background: #228B22; /* Verde pasto */
    z-index: 2147483640;
}

.zona-calle-1 {
    position: absolute;
    top: 25%;
    left: 0;
    width: 100%;
    height: 10%;
    background: #808080; /* Gris calle */
    z-index: 2147483640;
}

.zona-segura-media {
    position: absolute;
    top: 35%;
    left: 0;
    width: 100%;
    height: 10%;
    background: #228B22; /* Verde pasto */
    z-index: 2147483640;
}

.zona-rio {
    position: absolute;
    top: 45%;
    left: 0;
    width: 100%;
    height: 20%;
    background: #1E90FF; /* Azul agua */
    z-index: 2147483640;
}

.zona-segura-inferior {
    position: absolute;
    top: 65%;
    left: 0;
    width: 100%;
    height: 10%;
    background: #228B22; /* Verde pasto */
    z-index: 2147483640;
}

.zona-calle-2 {
    position: absolute;
    top: 75%;
    left: 0;
    width: 100%;
    height: 10%;
    background: #808080; /* Gris calle */
    z-index: 2147483640;
}

.zona-segura-final {
    position: absolute;
    top: 85%;
    left: 0;
    width: 100%;
    height: 15%;
    background: #228B22; /* Verde pasto */
    z-index: 2147483640;
}

/* Líneas de la calle MUY VISIBLES */
.linea-calle {
    position: absolute;
    height: 4px;
    background: #FFFFFF;
    z-index: 2147483641;
    box-shadow: 0 0 5px yellow;
}

/* Olas en el río para mejor distinción */
.ola-rio {
    position: absolute;
    height: 3px;
    background: #87CEEB;
    z-index: 2147483641;
    border-radius: 50%;
}

/* Capibara jugador - 3.5cm (70px) - ARRASTRABLE COMO LA COMIDA */
.capibara {
    position: fixed;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8B7355, #A0522D);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483647 !important; /* MÁXIMO Z-INDEX PARA ESTAR DELANTE */
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: grab;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border: 3px solid rgba(255, 255, 255, 0.5);
    touch-action: none;
    user-select: none;
    pointer-events: auto;
    transform-origin: center;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
}

/* Capibara en tronco - CAMBIO DE COLOR, NO DESAPARECE */
.capibara.en-tronco {
    background: linear-gradient(135deg, #4CAF50, #2E7D32) !important;
    border-color: rgba(255, 255, 255, 0.8) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(76, 175, 80, 0.5) !important;
}

/* Capibara con inmunidad al agua - EFECTO VISUAL */
.capibara.inmune-agua {
    box-shadow: 0 0 20px rgba(30, 144, 255, 0.8) !important;
    border-color: rgba(30, 144, 255, 0.8) !important;
}

/* CENTRADO PERFECTO - IGUAL QUE LA COMIDA */
.emoji-capibara {
    font-size: 40px !important;
    line-height: 1 !important;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.9) !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;
}

.img-capibara {
    width: 120% !important; /* Más grande que el contenedor */
    height: 120% !important; /* Más grande que el contenedor */
    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;
}

.capibara.con-imagen .emoji-capibara {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Estados del capibara - IGUAL QUE LA COMIDA */
.capibara:hover {
    transform: scale(1.15) translateY(-5px);
    background: rgba(139, 115, 85, 0.9);
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.capibara:active {
    transform: scale(0.95);
}

.capibara.arrastrando {
    opacity: 0.9;
    transform: scale(1.4) rotate(8deg);
    cursor: grabbing;
    z-index: 2147483649 !important;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.5),
        0 0 50px rgba(255, 255, 255, 0.6);
    border-color: #fff;
    background: rgba(160, 82, 45, 0.9);
}

/* VEHÍCULOS MÁS GRANDES */
.vehiculo {
    position: absolute;
    width: 120px;
    height: 65px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483643;
    transition: left 0.1s linear;
    pointer-events: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    border: 2px solid #333;
    background: #FF4444; /* Color por defecto */
}

.vehiculo.derecha {
    background: #FF4444; /* Rojo para vehículos que van a la derecha */
}

.vehiculo.izquierda {
    background: #4444FF; /* Azul para vehículos que van a la izquierda */
}

/* EMOJIS CENTRADOS PERFECTAMENTE */
.emoji-vehiculo {
    font-size: 32px !important;
    line-height: 1 !important;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8) !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1 !important;
}

/* IMÁGENES SUPERPUESTAS MÁS GRANDES */
.img-vehiculo {
    width: 130% !important; /* Más grande que el contenedor */
    height: 130% !important; /* Más grande que el contenedor */
    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;
}

/* OCULTAR EMOJI CUANDO HAY IMAGEN */
.vehiculo.con-imagen .emoji-vehiculo {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* TRONCOS - TAMAÑO ORIGINAL */
.tronco {
    position: absolute;
    width: 150px;
    height: 60px;
    border-radius: 20px;
    background: linear-gradient(to right, #8B4513, #A0522D);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483643;
    transition: left 0.1s linear;
    border: 3px solid #654321;
    pointer-events: none;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

/* EMOJIS CENTRADOS PERFECTAMENTE */
.emoji-tronco {
    font-size: 28px !important;
    line-height: 1 !important;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8) !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1 !important;
}

/* IMÁGENES SUPERPUESTAS MÁS GRANDES */
.img-tronco {
    width: 130% !important; /* Más grande que el contenedor */
    height: 130% !important; /* Más grande que el contenedor */
    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;
}

/* OCULTAR EMOJI CUANDO HAY IMAGEN */
.tronco.con-imagen .emoji-tronco {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Comida objetivo - SOLO EN LA PARTE INFERIOR */
.comida-objetivo {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: gold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483644;
    box-shadow: 0 0 20px rgba(255,215,0,0.8);
    border: 3px solid orange;
    animation: brilloComida 2s infinite alternate;
    pointer-events: none;
}

@keyframes brilloComida {
    0% { transform: scale(1); box-shadow: 0 0 15px rgba(255,215,0,0.7); }
    100% { transform: scale(1.2); box-shadow: 0 0 25px rgba(255,215,0,0.9); }
}

.emoji-comida {
    font-size: 30px !important;
    line-height: 1 !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1 !important;
}

.img-comida {
    width: 130% !important; /* Más grande que el contenedor */
    height: 130% !important; /* Más grande que el contenedor */
    object-fit: contain !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 2 !important;
}

.comida-objetivo.con-imagen .emoji-comida {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Contador de juego */
.contador-frogger {
    position: fixed !important;
    bottom: 100px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: rgba(0, 0, 0, 0.8) !important;
    color: white;
    padding: 12px 20px !important;
    border-radius: 20px;
    font-size: 18px;
    z-index: 2147483647 !important;
    font-family: 'Fredoka', sans-serif;
    border: 2px solid gold !important;
    pointer-events: auto;
    backdrop-filter: blur(10px) !important;
    width: auto;
    min-width: 300px;
    box-sizing: border-box;
    text-align: center;
    display: none !important;
    justify-content: space-around;
    align-items: center;
    gap: 20px;
}

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

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

.vidas-restantes { 
    color: #ff5252 !important;
    font-size: 20px !important;
}

.objetivos-conseguidos { 
    color: #69f0ae !important;
    font-size: 20px !important;
}

.tiempo-restante { 
    color: #4fc3f7 !important;
    font-size: 20px !important;
}

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

.capibara.colision {
    animation: vibrar 0.5s ease-in-out;
    background: linear-gradient(135deg, #ff4444, #ff6b6b) !important;
}

/* Mensajes de juego */
.mensaje-frogger {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.95);
    color: white;
    padding: 30px 50px;
    border-radius: 25px;
    font-size: 32px;
    font-weight: bold;
    z-index: 2147483647;
    text-align: center;
    border: 5px solid gold;
    box-shadow: 0 0 40px rgba(255,215,0,0.6);
    display: none;
}

/* Indicador de controles táctiles */
.indicador-controles {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    z-index: 2147483647;
    font-family: 'Fredoka', sans-serif;
    border: 4px solid #4CAF50;
    display: none;
    max-width: 90%;
}

.indicador-controles.mostrar {
    display: block;
}

.indicador-controles h3 {
    margin: 0 0 15px 0;
    font-size: 24px;
    color: #4CAF50;
}

.indicador-controles p {
    margin: 10px 0;
    font-size: 18px;
}

/* Media queries */
@media (max-width: 768px) {
    .capibara {
        width: 65px;
        height: 65px;
    }
    
    .vehiculo {
        width: 110px;
        height: 60px;
    }
    
    .tronco {
        width: 140px;
        height: 55px;
    }
    
    .contador-frogger {
        bottom: 90px !important;
        padding: 10px 15px !important;
        min-width: 280px;
    }
}

@media (max-width: 480px) {
    .capibara {
        width: 60px;
        height: 60px;
    }
    
    .vehiculo {
        width: 100px;
        height: 55px;
    }
    
    .tronco {
        width: 130px;
        height: 50px;
    }
    
    .contador-frogger {
        bottom: 80px !important;
        padding: 8px 12px !important;
        min-width: 250px;
        font-size: 16px;
    }
    
    .contador-frogger div {
        font-size: 14px;
    }
}

/* Prevenir zoom y mejorar táctil */
.juego-frogger {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Advertencia orientación */
.advertencia-orientacion {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483647;
    font-family: 'Fredoka', sans-serif;
    font-size: 24px;
    text-align: center;
    padding: 20px;
}

/* OCULTAR CONTROLES DE TECLAS - NO SE USAN */
.controles-frogger {
    display: none !important;
}

.control-btn {
    display: none !important;
}

/* Añadir estilos para manejar errores de carga de imágenes */
.img-vehiculo.error,
.img-tronco.error,
.img-capibara.error,
.img-comida.error {
    display: none;
}

.img-vehiculo.error + .emoji-vehiculo,
.img-tronco.error + .emoji-tronco,
.img-capibara.error + .emoji-capibara,
.img-comida.error + .emoji-comida {
    opacity: 1 !important;
    visibility: visible !important;
}