/* Game Board Dynamic Layouts */
.game-board {
    display: grid;
    gap: 12px;
    perspective: 1000px;
    /* Provides 3D depth for card flips */
}

/* Card Styling & 3D Flip Mechanics */
.memory-card {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-radius: 12px;
}

.memory-card:active {
    transform: scale(0.97);
    transition: transform 0.1s;
}

.memory-card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    overflow: hidden;
}

/* Front is the "back" of the card (the hidden symbol) */
.card-front {
    background: white;
    transform: rotateY(180deg);
    border: 2px solid #e5e7eb;
}

/* Back is the "cover" of the card (the pattern the user sees initially) */
.card-back {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: 2px solid #1d4ed8;
    /* Abstract pattern */
    background-image: radial-gradient(#60a5fa 10%, transparent 10%), radial-gradient(#60a5fa 10%, transparent 10%);
    background-color: #3b82f6;
    background-position: 0 0, 10px 10px;
    background-size: 20px 20px;
}

/* Dark mode overrides */
html.dark .card-front {
    background: #1e293b;
    border-color: #334155;
}

html.dark .card-back {
    background-image: radial-gradient(#334155 10%, transparent 10%), radial-gradient(#334155 10%, transparent 10%);
    background-color: #1e293b;
    border-color: #0f172a;
}

/* Matched Card State */
.memory-card.matched .card-front {
    background-color: #dcfce7;
    border-color: #86efac;
    opacity: 0.8;
}

html.dark .memory-card.matched .card-front {
    background-color: #064e3b;
    border-color: #065f46;
}

/* Animations */
#win-modal:not(.hidden) {
    opacity: 1;
}

#win-modal:not(.hidden) #modal-content {
    transform: scale(1);
}