#modal-instrucciones {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow: hidden; /* Evita scroll en el fondo */
}

#modal-content {
    background: linear-gradient(135deg, #e1f5fe, #b3e5fc, #81d4fa);
    padding: 20px 15px;           /* MUCHO menos padding */
    border-radius: 25px;
    max-width: 92%;
    width: 92%;
    max-height: 78vh;             /* Máximo 78% de la altura de la pantalla */
    overflow-y: auto;             /* Permite scroll interno SI es necesario */
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    text-align: center;
    border: 6px solid #fff176;
    position: relative;
}

/* Título y explicación más compactos */
#modal-content h2 {
    color: #d81b60;
    margin-bottom: 12px;
    font-size: 32px;
    font-family: 'Fredoka One', cursive;
    text-shadow: 3px 3px 0 #fff, 5px 5px 0 #ff5722;
}

#modal-content .explicacion {
    font-size: 18px;
    margin: 10px 0;
    line-height: 1.3;
    color: #333;
    font-family: 'Chewy', cursive;
}

/* Contenedor de ejemplo mucho más pequeño */
#ejemplo-container {
    margin: 15px 0;
    padding: 15px;
    background: #fffde7;
    border-radius: 20px;
    border: 4px dashed #ffeb3b;
}

#ejemplo-container h3 {
    color: #ff5722;
    font-size: 24px;
    margin-bottom: 10px;
    font-family: 'Fredoka One', cursive;
}

#ejemplo-carta {
    width: 100%;
    max-width: 160px;             /* carta mucho más pequeña */
    height: auto;
    border-radius: 15px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
    margin-bottom: 12px;
    border: 5px solid #fff176;
    animation: bounce 2s infinite;
}

#ejemplo-objetos {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0;
}

#ejemplo-objetos img {
    width: 55px;                  /* mini-imágenes mucho más pequeñas */
    height: 55px;
    cursor: pointer;
    border: 4px solid #fff176;
    border-radius: 14px;
    transition: all 0.3s;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

#ejemplo-objetos img:hover {
    transform: scale(1.2) rotate(8deg);
    border-color: #ff5722;
}

#ejemplo-objetos img.correcto {
    border: 5px solid #4caf50 !important;
    box-shadow: 0 0 15px #4caf50;
    animation: pulse 1s infinite;
}

#ejemplo-objetos img.incorrecto {
    border: 5px solid #f44336 !important;
    box-shadow: 0 0 15px #f44336;
    animation: shake 0.5s;
}

#ejemplo-mensaje {
    font-size: 18px;
    font-weight: bold;
    margin-top: 12px;
    min-height: 25px;
    color: #d81b60;
    font-family: 'Chewy', cursive;
}

#modal-content button {
    background: linear-gradient(135deg, #ff5722, #f50057);
    color: white;
    font-size: 22px;              /* botón más pequeño */
    padding: 12px 40px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 15px;
    font-family: 'Fredoka One', cursive;
    box-shadow: 0 5px 12px rgba(244, 67, 54, 0.4);
    transition: all 0.3s;
}

#modal-content button:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 20px rgba(244, 67, 54, 0.6);
}

/* Animaciones (mantengo las tuyas) */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes bounce {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0); }
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive ultra compacto para móvil */
@media (max-width: 768px) {
    #modal-content {
        padding: 18px 12px;
        max-width: 95%;
        max-height: 80vh;
        border-radius: 25px;
        border-width: 5px;
        overflow-y: auto;
    }

    #modal-content h2 {
        font-size: 28px;
        margin-bottom: 10px;
    }

    #modal-content .explicacion {
        font-size: 16px;
        margin: 8px 0;
    }

    #ejemplo-container {
        margin: 12px 0;
        padding: 12px;
    }

    #ejemplo-container h3 {
        font-size: 22px;
        margin-bottom: 8px;
    }

    #ejemplo-carta {
        max-width: 140px;
        margin-bottom: 10px;
    }

    #ejemplo-objetos {
        gap: 8px;
    }

    #ejemplo-objetos img {
        width: 50px;
        height: 50px;
    }

    #ejemplo-mensaje {
        font-size: 16px;
        margin-top: 10px;
    }

    #modal-content button {
        font-size: 20px;
        padding: 10px 35px;
        margin-top: 12px;
    }
}

/* Muy pequeños (iPhone SE, etc.) */
@media (max-width: 480px) {
    #modal-content {
        padding: 15px 10px;
        border-width: 4px;
    }

    #modal-content h2 {
        font-size: 26px;
    }

    #modal-content .explicacion {
        font-size: 15px;
    }

    #ejemplo-container h3 {
        font-size: 20px;
    }

    #ejemplo-carta {
        max-width: 130px;
    }

    #ejemplo-objetos img {
        width: 45px;
        height: 45px;
    }

    #modal-content button {
        font-size: 18px;
        padding: 10px 30px;
    }
}