/* --- RESET & GLOBALS --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Baloo 2', 'Poppins', sans-serif;
  background-color: #fef3c7; /* زرد بسیار ملایم و انرژی‌بخش */
  background-image: radial-gradient(#fde68a 2px, transparent 2px);
  background-size: 40px 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.game-container {
  text-align: center;
  width: 90%;
  max-width: 800px;
  position: relative;
}

/* --- NAVIGATION BUTTONS --- */
.nav-btn {
  position: absolute;
  top: -40px;
  background-color: #ffffff;
  color: #d97706;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  border: 2px solid #fde68a;
  transition: transform 0.2s;
}
.btn-back { left: 0; }
.btn-home { right: 0; }
.nav-btn:hover { transform: scale(1.05); }

/* --- HEADER --- */
.game-header h1 {
  font-size: 48px;
  color: #d97706;
  margin-bottom: 10px;
}
.game-header p {
  font-size: 24px;
  color: #475569;
  background-color: white;
  display: inline-block;
  padding: 10px 30px;
  border-radius: 30px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  margin-bottom: 30px;
}

/* --- MEMORY GRID --- */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 ستون */
  gap: 15px;
  perspective: 1000px; /* برای افکت سه بعدی */
  margin: 0 auto;
  max-width: 600px;
}

/* --- MEMORY CARD (3D Flip Effect) --- */
.memory-card {
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d; /* نگهداری حالت سه بعدی */
  transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1);
}

/* وقتی کلاس flip اضافه می‌شود، کارت 180 درجه می‌چرخد */
.memory-card.flip {
  transform: rotateY(180deg);
}

.front-face, .back-face {
  width: 100%;
  height: 100%;
  position: absolute;
  border-radius: 15px;
  backface-visibility: hidden; /* مخفی کردن پشت کارت وقتی برگشته */
  display: flex;
  justify-content: center;
  align-items: center;
  border: 4px solid #fcd34d;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* روی کارت (عکس‌ها) که در ابتدا مخفی است */
.front-face {
  background-color: white;
  transform: rotateY(180deg);
}

.front-face img {
  width: 70%;
  height: 70%;
  object-fit: contain;
}

/* پشت کارت (علامت سوال) که در ابتدا پیداست */
.back-face {
  background-color: #fbbf24;
  font-size: 50px;
  color: white;
}

.memory-card:hover .back-face {
  background-color: #f59e0b;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .nav-btn { top: -60px; font-size: 14px; }
  .game-header h1 { font-size: 36px; }
  .memory-grid { gap: 10px; }
  .back-face { font-size: 30px; }
}