/* ================================
   Card Memory - Layout
   ================================ */
.card-memory-main {
    min-height: calc(100vh - 80px);
    background: var(--light);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1.5rem 4rem;
}

.card-memory-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    animation: fadeInUp 0.6s ease-out backwards;
}

.card-memory-header {
    padding: 2rem 2rem 1.75rem;
    background: linear-gradient(135deg, #06D6A0 0%, #004E89 100%);
    color: white;
    text-align: center;
}

.card-memory-header .game-icon { font-size: 3rem; margin-bottom: 0.4rem; }
.card-memory-header .game-title { font-size: 1.8rem; font-weight: 900; margin-bottom: 0.4rem; }
.card-memory-header .game-subtitle { font-size: 0.95rem; opacity: 0.9; }

.card-memory-body { padding: 1.75rem 2rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* ================================
   Info Bar
   ================================ */
.cm-info {
    display: flex;
    justify-content: space-around;
    background: var(--light);
    border-radius: 12px;
    padding: 0.85rem 1rem;
}

.cm-info-item { text-align: center; }
.cm-info-label { font-size: 0.78rem; color: #888; margin-bottom: 0.2rem; }
.cm-info-value { font-size: 1.3rem; font-weight: 900; color: var(--primary); }

/* ================================
   Card Grid
   ================================ */
.cm-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.cm-cell {
    aspect-ratio: 1 / 1;
    perspective: 800px;
    cursor: pointer;
}

.cm-cell-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.42s;
    transform-style: preserve-3d;
}

.cm-cell.open .cm-cell-inner,
.cm-cell.matched .cm-cell-inner {
    transform: rotateY(180deg);
}

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

.cm-front {
    background: linear-gradient(135deg, #06D6A0 0%, #004E89 100%);
    color: white;
    font-size: 1.4rem;
    font-weight: 900;
}

.cm-back {
    background: white;
    border: 2px solid #eee;
    transform: rotateY(180deg);
}

.cm-cell.matched .cm-front,
.cm-cell.matched .cm-back {
    border-color: var(--success);
}

.cm-cell.matched .cm-back { background: #f0fff8; }

/* ================================
   Result & Buttons
   ================================ */
.cm-result {
    background: linear-gradient(135deg, #06D6A0 0%, #004E89 100%);
    color: white;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    display: none;
    animation: scaleIn 0.3s ease-out;
}

.cm-restart-btn {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    font-family: 'Noto Sans KR', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
}

.cm-restart-btn:hover { background: var(--primary-dark); transform: scale(1.02); }

header .logo { text-decoration: none; color: white; }

.back-link {
    display: block;
    text-align: center;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding-top: 0.25rem;
    transition: color 0.2s;
}
.back-link:hover { color: var(--primary-dark); text-decoration: underline; }

/* ================================
   Responsive
   ================================ */
@media (max-width: 480px) {
    .card-memory-main { padding: 1.5rem 0.75rem 3rem; }
    .card-memory-body { padding: 1.25rem 1rem; }
    .cm-grid { gap: 7px; }
    .cm-front { font-size: 1.1rem; }
    .cm-back { font-size: 1.5rem; }
}
