/* =====================================================
   MEMORY — TROBA L'AMIC
   ===================================================== */

.mem-section {
    padding-top: calc(var(--header-h) + 1rem);
    padding-bottom: 2rem;
    min-height: calc(100vh - 80px);
}

.mem-panel {
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem;
    text-align: center;
    position: relative;
}

/* ==================== INICI ==================== */
.mem-title {
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    font-weight: 900;
    color: var(--verde);
    margin-bottom: .5rem;
}

.mem-intro {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: .3rem;
}

.mem-hint {
    font-size: .9rem;
    color: var(--muted);
    margin-bottom: 1.25rem;
}

.mem-levels {
    display: flex;
    gap: .75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.mem-level-btn {
    padding: .75rem 1.25rem;
    border-radius: var(--r-full);
    background: var(--bg);
    border: 2px solid transparent;
    font-family: var(--font);
    font-size: .95rem;
    font-weight: 800;
    color: var(--text);
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .15s;
}

.mem-level-btn:hover {
    border-color: var(--verde);
    transform: translateY(-2px);
}

.mem-level-btn small {
    font-size: .75rem;
    font-weight: 600;
    color: var(--muted);
}

/* ==================== JOC ==================== */
.mem-exit {
    position: absolute;
    top: .75rem;
    right: .75rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--muted);
    font-size: .9rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.mem-exit:hover {
    background: var(--verde);
    color: var(--white);
}

.mem-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    margin-bottom: 1rem;
    font-weight: 800;
}

.mem-level-label {
    color: var(--verde);
    font-size: .95rem;
}

.mem-stats {
    font-size: .95rem;
    color: var(--muted);
}

/* ==================== GRID DE CARTES ==================== */
.mem-grid {
    display: grid;
    gap: .5rem;
    justify-content: center;
    margin: 0 auto;
}

/* Carta */
.mem-card {
    width: var(--card-w, 80px);
    height: var(--card-h, 100px);
    perspective: 600px;
    cursor: pointer;
}

.mem-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform .4s ease;
    border-radius: var(--r);
}

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

.mem-card.matched .mem-card-inner {
    transform: rotateY(180deg);
}

.mem-card.matched {
    cursor: default;
}

.mem-card-front,
.mem-card-back {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--r);
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Revers — moebius5r */
.mem-card-back {
    background: var(--verde);
    border: 3px solid #7aa31a;
}

.mem-card-back img {
    width: 90%;
    height: 90%;
    object-fit: contain;
}

/* Davant — personatge */
.mem-card-front {
    transform: rotateY(180deg);
    background: var(--white);
    border: 3px solid var(--bg);
}

.mem-card-front img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

/* Animació parella trobada */
.mem-card.matched .mem-card-front {
    border-color: var(--verde);
    animation: mem-match-pop .4s ease;
}

@keyframes mem-match-pop {
    0% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.1); }
    100% { transform: rotateY(180deg) scale(1); }
}

/* Animació error */
.mem-card.wrong .mem-card-front {
    border-color: #e53935;
}

/* ==================== VICTÒRIA ==================== */
.mem-win-title {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 900;
    color: var(--verde);
    margin-bottom: .5rem;
}

.mem-win-score {
    font-size: 1rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

/* ==================== FINAL ==================== */
.mem-final-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 900;
    color: var(--verde);
    margin-bottom: .5rem;
}

.mem-final-msg {
    font-size: 1.1rem;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.mem-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 500px) {
    .mem-panel { padding: 1.25rem .75rem; }
    .mem-grid { gap: .35rem; }
    .mem-actions { flex-direction: column; align-items: stretch; }
}
