/* ═══════════════════════════════════════════════════════════════════
   Hanzi Memory Match Game — styles
   Hero: fuchsia #c026d3  (distinct from teal, purple, indigo, rose,
   emerald, amber, violet, cyan used by the other quizzes)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Hero ────────────────────────────────────────────────────────── */
.memory-match-hero {
    background: linear-gradient(135deg, #c026d3 0%, #a21caf 100%);
    border-radius: 0.5rem;
}

/* ── Game card shadow ─────────────────────────────────────────────── */
.game-card {
    min-height: 420px;
}

/* ── Card grid ───────────────────────────────────────────────────── */
.mm-grid {
    display: grid;
    gap: 0.6rem;
    justify-content: center;
}

.mm-grid.grid-easy {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mm-grid.grid-medium {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mm-grid.grid-hard {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 575.98px) {
    .mm-grid {
        gap: 0.4rem;
    }

    .mm-grid.grid-hard {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ── Card (3D flip) ──────────────────────────────────────────────── */
.mm-card {
    perspective: 600px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mm-card-inner {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    min-height: 86px;
    transform-style: preserve-3d;
    transition: transform 0.4s;
}

.mm-card.flipped .mm-card-inner,
.mm-card.matched .mm-card-inner {
    transform: rotateY(180deg);
}

.mm-card-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 0.6rem;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    padding: 0.3rem;
    text-align: center;
    overflow: hidden;
}

/* Face-down side */
.mm-card-back {
    background: linear-gradient(135deg, #c026d3 0%, #a21caf 100%);
    color: rgba(255, 255, 255, 0.85);
    border: 2px solid #a21caf;
    font-size: 1.5rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: transform 0.12s, box-shadow 0.12s;
}

.mm-card:not(.flipped):not(.matched):hover .mm-card-back {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Face-up side */
.mm-card-front {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    color: #1e293b;
    transform: rotateY(180deg);
}

.mm-card.matched .mm-card-front {
    border-color: #198754;
    background: #d1e7dd;
    color: #0a3622;
    animation: mm-match-pulse 0.45s ease;
}

.mm-card.mismatch .mm-card-front {
    border-color: #dc3545;
    background: #f8d7da;
    color: #58151c;
}

@keyframes mm-match-pulse {
    0% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.08); }
    100% { transform: rotateY(180deg) scale(1); }
}

/* ── Card text by face type ──────────────────────────────────────── */
.mm-face-char {
    font-size: clamp(1.5rem, 5.5vw, 2.2rem);
    line-height: 1.1;
}

.mm-face-pinyin {
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    font-style: italic;
    word-break: break-word;
}

.mm-face-english {
    font-size: clamp(0.7rem, 2.4vw, 0.85rem);
    font-weight: 600;
    line-height: 1.2;
    word-break: break-word;
}

/* Small type label in the card corner (汉/拼/EN) */
.mm-face-tag {
    position: absolute;
    top: 0.2rem;
    right: 0.3rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #94a3b8;
}

.mm-card.matched .mm-face-tag {
    color: #198754;
}

/* ── Stats bar above the grid ─────────────────────────────────────── */
.mm-stat {
    min-width: 70px;
}

.mm-stat .mm-stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.1;
}

/* ── Matched-words panel entries ─────────────────────────────────── */
.mm-matched-word {
    border-bottom: 1px solid #f1f5f9;
    padding: 0.35rem 0;
}

.mm-matched-word:last-child {
    border-bottom: none;
}

.mm-matched-word .mm-matched-char {
    font-size: 1.25rem;
}

/* ── Win screen ──────────────────────────────────────────────────── */
.score-display {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
}

.results-card {
    border-radius: 0.75rem;
}

.mm-stars {
    font-size: 2rem;
    letter-spacing: 0.3rem;
    color: #f59e0b;
}

/* ── Sidebar panel header ─────────────────────────────────────────── */
.panel-header {
    background: linear-gradient(135deg, #c026d3 0%, #a21caf 100%);
    color: #fff;
    border-radius: 0.375rem 0.375rem 0 0;
}

/* ── Dark mode ───────────────────────────────────────────────────────
   Face-up cards and the stats use dark/slate text meant for a white
   card, so lift them to readable light-on-dark. Matched/mismatch
   feedback colors stay as-is (they carry their own backgrounds). */
[data-bs-theme="dark"] .mm-card-front {
    background: var(--pl-card-bg, #2b3035);
    border-color: var(--pl-border, #3a4049);
    color: var(--pl-text, #e4e6eb);
}

[data-bs-theme="dark"] .mm-card.matched .mm-card-front {
    background: #d1e7dd;
    color: #0a3622;
}

[data-bs-theme="dark"] .mm-card.mismatch .mm-card-front {
    background: #f8d7da;
    color: #58151c;
}

[data-bs-theme="dark"] .mm-matched-word {
    border-bottom-color: var(--pl-border, #3a4049);
}
