/* ========================================
   NOVA AI GAMES - Memory Game Styles
   3D Cards, Flip Animations & Effects
   ======================================== */

.memory-game-wrapper {
    width: 100%;
    max-width: 340px;
    position: relative;
}

.memory-grid-enhanced {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    perspective: 1000px;
}

.memory-card-3d {
    aspect-ratio: 1;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    animation: cardEntrance 0.5s ease backwards;
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: scale(0.5) rotateY(180deg);
    }

    to {
        opacity: 1;
        transform: scale(1) rotateY(0);
    }
}

.memory-card-3d .card-inner {
    position: absolute;
    inset: 0;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.memory-card-3d.flipped .card-inner {
    transform: rotateY(180deg);
}

.memory-card-3d .card-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    border-radius: var(--radius-md);
    font-size: 28px;
}

.memory-card-3d .card-front-3d {
    background: linear-gradient(145deg, #1e1e2e, #2a2a40);
    border: 2px solid rgba(99, 102, 241, 0.3);
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.memory-card-3d .card-pattern {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(45deg,
            transparent,
            transparent 5px,
            rgba(99, 102, 241, 0.05) 5px,
            rgba(99, 102, 241, 0.05) 10px);
}

.memory-card-3d .card-question {
    position: relative;
    z-index: 1;
    font-size: 32px;
    color: var(--text-muted);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.memory-card-3d .card-back-3d {
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
    transform: rotateY(180deg);
    box-shadow:
        0 8px 25px rgba(99, 102, 241, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.memory-card-3d .card-emoji {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    animation: emojiPop 0.3s ease;
}

@keyframes emojiPop {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.memory-card-3d:hover:not(.flipped):not(.matched) {
    transform: translateY(-3px);
}

.memory-card-3d:hover:not(.flipped):not(.matched) .card-front-3d {
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow:
        0 8px 25px rgba(99, 102, 241, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.memory-card-3d.matched .card-inner {
    animation: matchCelebrate 0.5s ease;
}

@keyframes matchCelebrate {

    0%,
    100% {
        transform: rotateY(180deg) scale(1);
    }

    50% {
        transform: rotateY(180deg) scale(1.1);
    }
}

.memory-card-3d.matched .card-back-3d {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow:
        0 8px 30px rgba(34, 197, 94, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.memory-moves {
    text-align: center;
    margin-top: var(--spacing-lg);
    font-size: 14px;
    color: var(--text-secondary);
}

.moves-value {
    font-weight: 700;
    color: var(--accent-primary);
    margin-left: 4px;
}