/* ═══════════ Memory Match Game ═══════════ */
.memory-container { text-align: center; }

.memory-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-style: italic;
    font-size: 1.9rem;
    color: var(--amber-bright);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.memory-subtitle {
    font-family: var(--font-body);
    font-weight: 200;
    font-size: 0.88rem;
    color: var(--cream-muted);
    opacity: 0.45;
    margin-bottom: 2.5rem;
    letter-spacing: 1px;
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 130px);
    gap: 16px;
    justify-content: center;
    margin-bottom: 2rem;
}

.memory-card {
    width: 140px; height: 180px;
    perspective: 900px;
    cursor: pointer;
}

.memory-card-inner {
    position: relative;
    width: 100%; height: 100%;
    transition: transform 0.65s var(--ease-out-expo);
    transform-style: preserve-3d;
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
    transform: rotateY(180deg);
}
.memory-card.matched { pointer-events: none; }

.memory-card-front, .memory-card-back {
    position: absolute;
    width: 100%; height: 100%;
    backface-visibility: hidden;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Front (revealed) side */
.memory-card-front {
    background: var(--glass);
    border: 1px solid rgba(232, 168, 124, 0.2);
    transform: rotateY(180deg);
    overflow: hidden;
}
.memory-card-front img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 13px;
}
/* Vignette overlay on photos */
.memory-card-front::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 13px;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(5, 5, 17, 0.3) 100%);
    pointer-events: none;
}

/* Back (hidden) side - ornate pattern */
.memory-card-back {
    background:
        linear-gradient(45deg, rgba(232, 168, 124, 0.05) 25%, transparent 25%, transparent 75%, rgba(232, 168, 124, 0.05) 75%),
        linear-gradient(45deg, rgba(232, 168, 124, 0.05) 25%, transparent 25%, transparent 75%, rgba(232, 168, 124, 0.05) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    background-color: rgba(12, 18, 34, 0.85);
    border: 1px solid rgba(232, 168, 124, 0.15);
    overflow: hidden;
}

/* Inner border frame */
.memory-card-back::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(232, 168, 124, 0.1);
    border-radius: 8px;
}

/* Heart icon */
.memory-card-back::after {
    content: '';
    position: relative;
    z-index: 1;
    width: 20px; height: 18px;
    background: var(--amber);
    clip-path: path('M10 3.5C10 0 6.5-1.5 4.5 1.5 2.5 4.5 0 5.5 0 8.5 0 13 10 18 10 18S20 13 20 8.5C20 5.5 17.5 4.5 15.5 1.5 13.5-1.5 10 0 10 3.5Z');
    opacity: 0.4;
    animation: heartPulse 2.5s ease-in-out infinite;
}
@keyframes heartPulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.1); opacity: 0.6; }
}

/* Hover glow */
.memory-card:hover .memory-card-back {
    border-color: rgba(232, 168, 124, 0.35);
    box-shadow:
        0 0 25px rgba(232, 168, 124, 0.1),
        inset 0 0 20px rgba(232, 168, 124, 0.03);
}

/* Flip glow flash — applied to front face, not inner, to preserve 3D context */
.memory-card.flipped .memory-card-front {
    filter: brightness(1.15);
    transition: filter 0.3s ease;
}

/* Matched state */
.memory-card.matched .memory-card-front {
    border-color: var(--sage);
    box-shadow:
        0 0 20px var(--sage-glow),
        0 0 40px rgba(126, 200, 160, 0.08);
    animation: matchReveal 0.6s var(--ease-out-back);
}

/* Match ring burst */
.memory-card.matched .memory-card-front::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 16px;
    border: 2px solid var(--sage);
    animation: matchRing 0.8s var(--ease-out-expo) forwards;
    pointer-events: none;
    z-index: 5;
}

@keyframes matchReveal {
    0% { transform: rotateY(180deg) scale(1); }
    40% { transform: rotateY(180deg) scale(1.1); }
    100% { transform: rotateY(180deg) scale(1); }
}

@keyframes matchRing {
    from { inset: -4px; opacity: 1; }
    to { inset: -18px; opacity: 0; }
}

/* Text label cards */
.memory-text-label {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--cream);
    text-align: center;
    padding: 0.75rem;
    line-height: 1.4;
    letter-spacing: 0.5px;
}

.memory-moves {
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 300;
    color: var(--cream-muted);
    opacity: 0.35;
    letter-spacing: 1.5px;
}
