.memory-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    max-width: 1000px;
    margin: 0 auto;
}

/* Fácil: 3x4 */
.easy-grid {
  grid-template-columns: repeat(4, 1fr);
}

/* Difícil: 6x4 */
.hard-grid {
  grid-template-columns: repeat(6, 1fr);
}

/* Carta */
.card-memo {
    width: 100%;
    aspect-ratio: 1 / 1;
}

.inner {
    width: 100%;
    /* height: 100%; */
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.flipped .inner {
    transform: rotateY(180deg);
}

.front,
.back {
    position: absolute;
    width: 100%;
    /* height: 100%; */
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    backface-visibility: hidden;
}

.front img {
    width: 100%;
    /* height: 100%; */
    object-fit: cover;
    border-radius: 10px;
    pointer-events: none;
    border: 2px solid #ccc;
}

.back {
    background: #fff;
    transform: rotateY(180deg);
}

.back img {
    width: 100%;
    /* height: 100%; */
    border-radius: 10px;
    object-fit: contain;
    pointer-events: none;
}

/* Animación de victoria */
@keyframes pop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    80% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#winMessage {
    animation: pop 0.6s ease;
}

/* Animación al acertar */
@keyframes matchSuccess {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.matched .inner {
    animation: matchSuccess 0.4s ease;
}

.matched .back {
    background: #a57f2c;
    /* verde bootstrap */
    color: white;
    box-shadow: 0 0 10px rgba(25, 135, 84, 0.8);
}

@media (max-width: 992px) {
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.match-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: #a57f2c;
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    font-weight: bold;
    opacity: 0;
    z-index: 9999;
    transition: all 0.3s ease;
    text-align: center;
    overflow: hidden;
    pointer-events: none;
}

/* .match-popup img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 10px;
}

.match-popup {
  display: flex;
  flex-direction: column;
  align-items: center;
} */

.match-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.4);
}

.match-popup::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
}

@keyframes popupBounce {
    0% {
        transform: translate(-50%, -50%) scale(0.6);
    }

    60% {
        transform: translate(-50%, -50%) scale(1.6);
    }

    100% {
        transform: translate(-50%, -50%) scale(1.4);
    }
}

.match-popup.show {
    opacity: 1;
    animation: popupBounce 0.4s ease;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    /* background: rgba(0, 0, 0, 0.4); */
    background: radial-gradient(
    circle,
    rgba(0,0,0,0.3) 0%,
    rgba(0,0,0,0.6) 100%
    );
    backdrop-filter: blur(4px);

    opacity: 0;
    pointer-events: none;
    /* 🔥 clave */
    z-index: 9998;

    transition: opacity 0.3s ease;
}

.overlay.show {
    opacity: 1;
    pointer-events: auto;
    /* solo cuando se ve */
}

#easyBtn, #hardBtn {
    width: auto !important;
}