/* =========================================================================
   ESTILOS GENERALES Y RESETEO (Juego del Topo)
   ========================================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Mantiene la tipografía original */
}

body {
    background-image: url('fondo.png'); /* Mantiene tu imagen de fondo original */
    background-size: cover;          
    background-position: center;     
    background-repeat: no-repeat;    
    display: flex;
    justify-content: flex-start;     /* NUEVO: Alinea todo el contenido hacia la IZQUIERDA */
    align-items: center;
    height: 100vh;
    padding-left: 40px;              /* NUEVO: Margen sutil respecto al borde del iframe */
    overflow: hidden;                /* Evita barras de desplazamiento molestas */
}

/* =========================================================================
   CONTENEDOR PRINCIPAL (Flexbox Lado a Lado)
   ========================================================================= */
.game-container {
    background-color: rgba(52, 73, 94, 0.85); /* Fondo original con transparencia */
    backdrop-filter: blur(5px);                 
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    text-align: center;
    
    display: flex;                   /* NUEVO: Alinea el juego y el modal horizontalmente */
    align-items: center;
    gap: 25px;                       /* NUEVO: Espacio de separación entre el juego y el cartel */
}

/* NUEVO: Bloque que aísla el área de juego para mantener su tamaño */
.game-play-side {
    width: 320px;
}

/* =========================================================================
   CABECERA (Puntaje y Tiempo)
   ========================================================================= */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

.score-board, .timer-board {
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =========================================================================
   CUADRÍCULA Y AGUJEROS
   ========================================================================= */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 15px;
    margin-bottom: 20px;
}

.hole {
    width: 90px;
    height: 90px;
    background-color: #1a252f; 
    border-radius: 50%;
    overflow: hidden; 
    position: relative;
    box-shadow: inset 0 8px 12px rgba(0,0,0,0.6);
}

/* =========================================================================
   ESTÉTICA DINÁMICA DEL TOPO
   ========================================================================= */
.mole {
    width: 100%;
    height: 100%;
    background-size: cover; /* Llenado óptimo del círculo */
    background-repeat: no-repeat;
    background-position: center bottom; 
    position: absolute;
    top: 100%; 
    transition: top 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.hole.up .mole {
    top: 0; 
}

.mole:active {
    transform: scale(0.9) rotate(5deg);
}

/* =========================================================================
   CONTENEDOR DEL CURSOR (Martillo)
   ========================================================================= */
.hammer {
    position: fixed;
    width: 60px;
    height: 60px;
    pointer-events: none; 
    z-index: 1000;
    display: block;
    transform: translate(-50px, -30px); 
}

.hammer-img {
    width: 100%;
    height: 100%;
    background-image: url('martillo.png'); /* Ruta actualizada a la carpeta assets */
    background-size: contain;
    background-repeat: no-repeat;
    transform-origin: bottom left; 
    transform: rotate(35deg); 
    transition: transform 0.05s ease-in-out;
}

.hammer.swing .hammer-img {
    transform: rotate(-25deg); 
}

/* =========================================================================
   BOTONES DE CONTROL
   ========================================================================= */
#start-btn, #restart-btn {
    background-color: #2ecc71;
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}

#start-btn:hover, #restart-btn:hover {
    background-color: #27ae60;
}

/* =========================================================================
   NUEVO: REDISEÑO DE PANTALLA MODAL (Aparición Lateral)
   ========================================================================= */
.modal {
    position: relative;            /* MODIFICADO: Ya no bloquea toda la pantalla por encima */
    display: block; 
    background-color: transparent; /* MODIFICADO: Sin fondo gris oscuro general */
    transition: all 0.3s ease;
}

/* Oculta la sección flex de forma limpia */
.modal.hidden {
    display: none; 
}

/* --- Estilos para el contenido interior del cuadro blanco --- */
.modal-content {
    background: white;
    padding: 25px 20px;
    border-radius: 12px;
    text-align: center;
    width: 280px; /* Ancho controlado del recuadro blanco */
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    gap: 1px; /* Añade una separación uniforme entre cada bloque */
}

.modal-content h2 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.4rem;
}

.modal-content p {
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: #555;
}

/* Alineación de la palabra "Resultado" */
.result-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.1rem;
    color: #333;
    font-weight: 500;
}

/* --- Ajuste del contenedor de la imagen --- */
.result-image-box {
    width: 100%;
    /* Eliminamos max-height y overflow hidden para que no actúen como guillotina */
    overflow: visible; 
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 5px 0; /* Añade un espacio sano arriba y abajo */
}

.result-image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 15px 0;
}

/* --- Ajuste estricto de la foto para que no se recorte --- */
#result-img {
    width: 100%;        /* Ocupa el ancho completo del cuadro blanco */
    height: auto;       /* Modifica la altura automáticamente sin deformar ni recortar */
    display: block;
    border-radius: 2px;
}

/* Margen superior al botón para separarlo elegantemente de la imagen */
#restart-btn {
    margin-top: 10px;
}

/* Animación fluida de deslizamiento lateral */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
/* =========================================================================
   SOLUCIÓN POP-UP COMPLETA Y REPARACIÓN DE PANTALLA
   ========================================================================= */
@media (max-width: 768px) {
    /* Reparamos el cuerpo para que no congele ni corte el botón verde */
    body {
        padding: 10px 5px;
        margin: 0;
        display: flex;
        justify-content: center;
        align-items: flex-start; /* Permite flujo natural hacia abajo */
        height: auto !important; /* Liberamos la altura bloqueada */
        overflow: visible !important; /* Hacemos visible el botón verde */
    }

    /* La caja gris ahora es flexible y muestra todo su contenido */
    .game-container {
        width: 100% !important;
        max-width: 330px;
        padding: 12px;
        position: relative; /* Base indispensable para que el cartel flote */
        flex-direction: column !important;
        height: auto !important;
    }

    .game-play-side {
        width: 100% !important;
        max-width: 100%;
    }

    /* Reducción ideal de los agujeros para que quepan en la pantalla */
    .grid {
        gap: 8px;
        margin-bottom: 15px;
    }

    .hole {
        width: 82px;
        height: 82px;
    }

    /* --- EL POP-UP FLOTANTE --- */
    /* Modificamos el modal para que cuando aparezca se posicione encima del juego */
    .modal {
        position: absolute !important;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.7) !important; /* Fondo oscuro transparente */
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 9999;
        padding: 10px;
        box-sizing: border-box;
    }

    .modal.hidden {
        display: none !important;
    }

    /* Tarjeta blanca adaptada al tamaño de los celulares */
    .modal-content {
        width: 100% !important;
        max-width: 280px;
        padding: 15px;
        border-radius: 12px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    }
    
    .modal-content h2 {
        font-size: 1.25rem;
        margin-bottom: 6px;
    }

    .modal-content p {
        font-size: 1rem;
        margin-bottom: 10px;
    }

    /* Control riguroso del tamaño de la foto final */
    .result-image-box {
        max-width: 140px;
        margin: 4px auto;
    }

    #result-img {
        width: 100%;
        height: auto;
    }
}