/* game.css — شاشات اللعب (M1): الشبكة + السؤال + التغذية الراجعة + النهاية
   يستهلك متغيرات الثيم الـ16 من core.css (--box/--correct/--wrong/...)
   قواعد D6: موشن transform/opacity فقط · @media (prefers-reduced-motion) يلغي الأنيميشن
   قواعد D12: أهداف لمس ≥64px (يفضَّل 80) · لا hover — رد لمسي :active فقط */

.game-root { display: flex; flex-direction: column; gap: clamp(8px, 1.6vh, 16px); height: 100%; min-height: 0; overflow: hidden; }
.game-root.is-locked { pointer-events: none; } /* قفل إدخال أثناء الفتح (D12) */

/* ===== الترويسة: الجولة + عدّاد التقدم + الشريط + التحفيز (D5) ===== */
.game-header { flex: 0 0 auto; }
.game-header { display: flex; flex-direction: column; gap: 10px; }
.game-header-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.game-round-label { font-family: var(--font-display); font-size: clamp(20px, 2.6vw, 28px); font-weight: 700; }
.game-progress-text { font-family: var(--font-display); font-size: clamp(18px, 2.4vw, 26px); font-weight: 700; color: var(--accent); }
.progress-track { height: 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.12); overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 999px; background: var(--accent);
  transform-origin: right center;                 /* يتقدم من اليمين (RTL) */
  transform: scaleX(0);                           /* transform فقط (D6) */
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.milestone-msg { font-family: var(--font-display); font-size: clamp(18px, 2.4vw, 24px); font-weight: 700; color: var(--accent); min-height: 1.4em; }

/* ===== شبكة الصناديق (فتح الصناديق) — تتكيف مع الشاشة بلا تمرير ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(clamp(84px, 13vw, 150px), 1fr)); gap: clamp(8px, 1.6vw, 14px); flex: 1 1 auto; min-height: 0; align-content: center; overflow: hidden; }
.box {
  font-family: var(--font-display);
  font-size: clamp(26px, 5.5vw, 42px);            /* يتكيف مع الشاشة (مبدأ بندر) */
  font-weight: 700;
  min-height: clamp(64px, 13vh, 110px);           /* هدف لمس ≥64 + يتكيف */
  border-radius: var(--radius);
  border: 3px solid var(--box-border);
  background: linear-gradient(160deg, var(--box), var(--box-border));
  color: #ffffff;
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease;
}
.box:active { transform: scale(0.97); }           /* رد لمسي فقط — لا hover (D12) */
.box.opened {
  background: var(--box-open); border-color: var(--box-open);
  color: rgba(255, 255, 255, 0.8); box-shadow: none; cursor: default;
  opacity: 0.6;                               /* تمييز واضح: «مستهلك» (ملاحظة بندر) */
}
.box.deferred { opacity: 0.5; border-style: dashed; } /* أُجيب خطأً — مؤجل (قرار بندر) */

/* ===== شاشة السؤال المشتركة — تتكيف مع الشاشة بلا تمرير ===== */
.game-screen { display: flex; flex-direction: column; gap: clamp(8px, 1.6vh, 16px); height: 100%; min-height: 0; overflow: hidden; }
.question-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(10px, 1.8vw, 20px); align-items: stretch; flex: 1 1 auto; min-height: 0; }
.question-card {
  background: var(--panel); border: 3px solid var(--panel-border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(10px, 2vw, 22px); min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.question-text {
  font-size: clamp(18px, 3vw, 34px);              /* يتكيف (مبدأ بندر) */
  font-weight: 700; line-height: 1.5; text-align: right;
  overflow-wrap: anywhere;                        /* يلتف بدل القطع (إصلاح بندر) */
}
.choices {
  display: grid;
  grid-auto-flow: column;                         /* D11: «أ» أعلى اليمين ثم «ب» تحته */
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 14px);
  min-height: 0;
}
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  background: var(--panel); border: 3px solid var(--panel-border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(8px, 1.2vw, 14px); min-height: clamp(64px, 13vh, 118px);
  cursor: pointer; touch-action: manipulation;
  text-align: right; font-family: var(--font-body);
  transition: transform 0.12s ease, opacity 0.2s ease;
  overflow: hidden;
}
.choice:active { transform: scale(0.97); }        /* لا hover */
.choice:disabled { cursor: default; }
.choice-badge {
  font-family: var(--font-display); font-size: clamp(18px, 2.4vw, 28px); font-weight: 700;
  width: clamp(34px, 3.4vw, 46px); height: clamp(34px, 3.4vw, 46px); border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.choice-text { font-size: clamp(15px, 1.9vw, 26px); line-height: 1.4; overflow-wrap: anywhere; }

/* التغذية الراجعة D9: خطأ أول ← استبعاد رمادي مشطوب */
.choice.wrong { background: var(--panel); border-color: var(--box-open); box-shadow: none; opacity: 0.75; }
.choice.wrong .choice-badge { background: var(--box-open); }
.choice.wrong .choice-text { text-decoration: line-through; color: #607d8b; }
/* تلميح: هذا الخيار اختير خطأً سابقاً (قرار بندر) — يُنمَّط حسب الثيم */
.choice.hint-wrong { opacity: 0.6; border-style: dashed; }
.choice.hint-wrong .choice-badge { background: var(--box-open); }
/* دفعة النجاح: بقي خيار واحد غير مجرّب */
.hint-note { font-family: var(--font-body); font-size: clamp(16px, 2vw, 22px); font-weight: 700; color: var(--accent); text-align: center; padding: 4px 0; }
/* كشف الصواب: حدود خضراء + ✓ */
.choice.revealed { border-color: var(--correct); }
.choice.revealed .choice-badge { background: var(--correct); }
.choice.revealed .choice-text { color: var(--correct); font-weight: 700; }

/* ===== منطقة التغذية الراجعة + زر المتابعة — ثابتة أسفل الإطار ===== */
.feedback { flex: 0 0 auto; min-height: 2.6em; display: flex; align-items: center; justify-content: center; }
.feedback-msg {
  font-family: var(--font-body); font-size: clamp(22px, 3vw, 30px); font-weight: 700;
  padding: 10px 26px; border-radius: 999px; text-align: center;
  background: var(--panel); border: 3px solid currentColor;
}
.feedback-msg.is-wrong { color: var(--wrong); }
.feedback-msg.is-correct, .feedback-msg.is-reveal { color: var(--correct); }
.game-actions { flex: 0 0 auto; display: flex; justify-content: center; gap: 14px; }
.game-btn {
  font-family: var(--font-body); font-size: clamp(20px, 2.6vw, 26px); font-weight: 700;
  padding: 14px 36px; min-height: 64px; border-radius: 14px; border: none;
  background: var(--accent); color: #fff; cursor: pointer; touch-action: manipulation;
  transition: transform 0.12s ease;
}
.game-btn:active { transform: scale(0.97); }
.game-btn.btn-secondary { background: var(--panel); color: var(--text); border: 2px solid var(--panel-border); box-shadow: var(--shadow); }

/* ===== شاشة النهاية (إعادة / رجوع للمكتبة) — وسط الإطار ===== */
.finish-screen { align-items: center; justify-content: center; text-align: center; height: 100%; padding: clamp(12px, 3vh, 40px); }
.finish-title { font-family: var(--font-display); font-size: clamp(32px, 5vw, 56px); font-weight: 700; }
.finish-sub { font-size: clamp(20px, 2.8vw, 28px); color: #546e7a; }
.finish-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

/* ===== عناصر الاحتفال الخفيف (8-12 عنصراً بألوان الثيم — D9) ===== */
.celebration-particle { position: fixed; z-index: 9999; font-size: 20px; pointer-events: none; will-change: transform, opacity; }

/* ===== الاستجابة: تكديس عمودي على الشاشات الضيقة ===== */
@media (max-width: 880px) {
  .question-layout { grid-template-columns: 1fr; }
  .question-card { min-height: 160px; }
}

/* ===== D6: إلغاء الحركة لمن يفضّل تقليلها ===== */
@media (prefers-reduced-motion: reduce) {
  .game-root, .game-root * { animation: none !important; transition: none !important; }
}
