/* =================================
   کد نهایی و یکپارچه برای بازی حافظه
   ================================= */

#games-section .game-title {
    margin-bottom: 10px;
    color: #333;
    font-size: 2rem;
    font-weight: bold;
}

#games-section .game-description {
   margin-bottom: 20px;
   color: #555;
   font-size: 1.1rem;
}

.memory-game {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 ستون در حالت دسکتاپ */
    gap: 15px; /* فاصله بین کارت‌ها */
    max-width: 700px;
    margin: 20px auto;
    padding: 15px;
    background-color: #f0f4f8;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.memory-card {
    position: relative;
    width: 100%;
    /* استفاده از aspect-ratio برای حفظ نسبت ابعاد مربع کارت‌ها */
    aspect-ratio: 1 / 1;
    cursor: pointer;
}

.front-face,
.back-face {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    
    /* مهم: این دو خط انیمیشن چرخش و محو شدن را کنترل می‌کنند */
    transition: transform 0.6s ease, opacity 0.5s;
    backface-visibility: hidden; /* بهبود عملکرد انیمیشن */
}

/* ★★★ پشت کارت (آنچه در ابتدا دیده می‌شود) ★★★ */
.back-face {
    /* <<< اینجا می‌توانید رنگ یا گرادینت زیبای اولیه خود را قرار دهید >>> */
    background: linear-gradient(135deg, #1A759F, #16A085); 
    
    transform: rotateY(0deg); /* در ابتدا قابل مشاهده است */
    opacity: 1;
}

/* ★★★ روی کارت (عکس و کلمه) ★★★ */
.front-face {
    background-color: #ffffff;
    color: #333;

    /* در ابتدا چرخیده و کاملاً نامرئی است */
    transform: rotateY(180deg);
    opacity: 0;
}

/* --- وضعیت پس از کلیک (کلاس .flipped) --- */

.memory-card.flipped .back-face {
    transform: rotateY(-180deg); /* پشت کارت می‌چرخد و نامرئی می‌شود */
    opacity: 0;
}

.memory-card.flipped .front-face {
    transform: rotateY(0deg); /* روی کارت نمایان می‌شود */
    opacity: 1;
}

/* استایل کارت‌های جفت شده */
.memory-card.matched {
    cursor: default;
    /* یک افکت برای نشان دادن جفت شدن موفق */
    box-shadow: 0 0 15px 5px rgba(22, 160, 133, 0.6);
}


/* --- استایل محتوای داخل کارت --- */

.card-image {
    max-width: 90%;
    max-height: 60%;
    object-fit: contain;
    margin-bottom: 5px;
}

.card-text {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
    text-align: center;
    direction: ltr; /* اطمینان از نمایش صحیح کلمات انگلیسی */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.audio-button {
    background: none;
    border: none;
    color: #1A759F;
    font-size: 1.4rem;
    cursor: pointer;
    margin-top: auto; /* دکمه را به پایین هل می‌دهد */
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.audio-button:hover {
    color: #16A085;
}

/* =================================
   واکنش‌گرایی (Responsive)
   ================================= */

/* تبلت و صفحات متوسط */
@media (max-width: 768px) {
    .memory-game {
        grid-template-columns: repeat(3, 1fr);
        max-width: 500px;
        gap: 10px;
        padding: 10px;
    }
    
    .card-text {
        font-size: 1rem;
    }

    .audio-button {
        font-size: 1.3rem;
    }
}

/* موبایل */
@media (max-width: 480px) {
    .memory-game {
        grid-template-columns: repeat(2, 1fr);
        max-width: 100%;
        padding: 10px 5px;
        gap: 8px;
    }

    .front-face, .back-face {
        padding: 5px;
    }

    .card-image {
        max-height: 55%;
    }

    .card-text {
        font-size: 0.9rem;
    }
    
    .audio-button {
        font-size: 1.2rem;
    }
}
.learning-game-container {
    align-items: center; /* محتوا را به صورت افقی در مرکز قرار می‌دهد */
}

.