/* משחק הזיכרון – אותה מידת מעטפת כמו המגרש */
#memory-game .mem-frame {
  position: relative;
  height: min(78vh, 900px);
  aspect-ratio: 2 / 3;              /* בדיוק כמו המגרש */
  width: auto;
  margin: 0 auto;
  background: #EAE2F2;               /* כמו ה-XML */
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  padding: 12px;
}

/* כותרת/סטטוס/ניקוד */
.mem-head {
  text-align: center;
  margin-bottom: 8px;
}
.mem-title {
  margin: 4px 0 6px;
  font-weight: 800;
  color: #2FCA9E;
  font-size: clamp(20px, 3.4vw, 28px);
}
.mem-status {
  min-height: 1.3em;
  color: #333;
  font-size: clamp(14px, 2.4vw, 18px);
  margin-bottom: 4px;
}
.mem-score {
  color: #333;
  font-size: clamp(13px, 2.2vw, 16px);
}

/* לוח 3x4 – ריבועים עם ריווח */
.mem-board {
  flex: 1 1 auto;
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 10px;
  padding: 6px;
}

/* קלף – שני צדדים (front/back) עם פליפ */
.mem-card {
  position: relative;
  perspective: 1000px;
}
.mem-card-inner {
  position: absolute;
  inset: 0;
  transition: transform 0.35s ease;
  transform-style: preserve-3d;
  border-radius: 12px;
}
.mem-card.flipped .mem-card-inner { transform: rotateY(180deg); }

.mem-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 12px;
  display: grid;
  place-items: center;
  border: 2px solid #333;
  overflow: hidden;
}

/* גב הקלף */
.mem-back {
  background: linear-gradient(135deg, #ffd6e8 0%, #eae2f2 55%, #d2f5e3 100%);
  font-weight: 900;
  font-size: clamp(24px, 4.2vw, 36px);
}

/* חזית הקלף (מילה/אות) */
.mem-front {
  background: #fff;
  transform: rotateY(180deg);
  color: #333;
  font-weight: 800;
  padding: 6px;
  font-size: clamp(18px, 3.2vw, 28px);
  text-align: center;
}

/* מצב “נלקח” – דהייה קלה ונעילת אינטראקציה */
.mem-card.taken .mem-card-inner { opacity: .35; }

/* מובייל – גובה קצת נמוך יותר (כמו שעשית למגרש) */
@media (max-width: 900px) {
  #memory-game .mem-frame {
    height: 64vh;
    max-width: 92vw;
    margin-top: 14px;
  }
}

/* ===== Memory Game – מראה כמו ה-XML ===== */

#memory-game[hidden]{ display:none !important; }

/* עוטף הכרטיס (MaterialCardView) */
.memory-cardbox{
  max-width: 880px;              /* דסקטופ */
  margin: 0 auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  overflow: hidden;              /* פינות מעוגלות גם פנימה */
}

/* הרקע הפנימי #EAE2F2 + padding */
.memory-inner{
  background:#EAE2F2;
  padding: 12px;
  min-height: 420px;             /* שלא יקרוס רגעית */
  display:flex;
  flex-direction:column;
}

/* כותרת ירקרקה */
.memory-title{
  margin: 12px 0 6px;
  text-align:center;
  color:#2FCA9E;
  font-weight:900;
  font-size: clamp(22px, 3.2vw, 28px);
}

/* סטטוס */
.memory-status{
  height:55px;                   /* כמו ב-XML */
  display:flex; align-items:center; justify-content:center;
  text-align:center;
  color:#333; font-size:20px;
  margin-top:3px;
}

/* ניקוד */
.memory-score{
  text-align:center;
  color:#333; font-size:16px;
  margin-top:4px;
}

/* לוח ריבועי ביחס 3/4 (כמו MemorySquareFrameLayout: height = width*4/3) */
.memory-board{
  margin-top:16px;
  margin-bottom:12px;
  width:100%;
  aspect-ratio: 3 / 4;
  position:relative;
}

/* הרשת עצמה */
.memory-grid{
  position:absolute; inset:0;
  display:grid;
  grid-template-columns: repeat(3, 1fr); /* 3 עמודות × 4 שורות */
  gap: 8px;
  padding: 0;
}

/* כרטיס */
.memory-card{
  position:relative;
  border:none;
  border-radius: 10px;
  overflow:hidden;
  cursor:pointer;
  perspective: 800px;           /* תלת מימד להיפוך */
  background: transparent;
}

/* שני צדדים */
.card-face{
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  backface-visibility:hidden;
  border-radius:10px;
  transition: transform .35s ease;
}

/* גב הכרטיס */
.card-back{
  background: url('assets/bg_card_front_kids.webp'), #f8f8f8;
  background-size: cover;
  background-position:center;
  border:2px solid #333;
}
.card-back::after{
  content:'?';
  color:#333; font-weight:900;
  font-size: clamp(18px, 2.8vw, 26px);
}

/* חזית (הטקסט/תמונה) */
.card-front{
  background: url('assets/bg_card_back_kids.webp'), #fff;
  background-size: cover;
  background-position:center;
  border:2px solid #333;
  transform: rotateY(180deg);
  color:#333; font-weight:900;
  font-size: clamp(18px, 2.6vw, 24px);
  padding:4px;
}

/* מצב פתוח */
.memory-card.is-open .card-back{ transform: rotateY(180deg); }
.memory-card.is-open .card-front{ transform: rotateY(0); }

/* זוג שנלקח */
.memory-card.is-matched .card-front{
  border-color:#18c47c;
  background: #f3fff9;
  color:#18c47c;
}

/* ריספונסיב */
@media (max-width:900px){
  .memory-cardbox{ max-width: 92vw; max-height: 10vw; }
   #memory-game .mem-frame { max-width: 560px; margin: 0 auto }
   .field, #tower-game, #memory-game { height: 85%; }
}
