/* =====================================================================
   English Master — Vocabulary Games  (تصميم التمارين والألعاب)
   ---------------------------------------------------------------------
   يعتمد على tokens ومكوّنات shared.css.
   ===================================================================== */

.gm-wrap { max-width: 620px; margin: 0 auto; }

/* ---------- هيدر ---------- */
.gm-head { text-align: center; margin-bottom: 16px; }
.gm-head h1 { font-family: var(--font-heading); font-size: clamp(1.4rem, 5vw, 1.9rem); color: var(--ink-blue); font-weight: 700; }
.gm-head .gm-en { font-family: var(--font-english); color: var(--ink-pink); font-weight: 600; direction: ltr; display: block; margin-top: 2px; font-size: 0.95rem; }

/* ---------- قائمة الألعاب ---------- */
.gm-topic {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.gm-topic label { font-weight: 700; color: var(--text); font-size: 0.95rem; }
.gm-topic select {
  font-family: var(--font-body); font-size: 0.95rem; font-weight: 600;
  color: var(--ink-blue); background: #f8fafc;
  border: 2px solid var(--border); border-radius: 10px; padding: 8px 14px; cursor: pointer;
}
.gm-topic select:focus { outline: none; border-color: var(--ink-teal); }

.games-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.game-tile {
  --accent: var(--ink-teal);
  background: white; border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 16px; text-align: center; cursor: pointer;
  font: inherit; color: var(--text); width: 100%;
  transition: transform 0.2s, box-shadow 0.2s;
}
.game-tile:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(30,58,138,0.14); }
.game-tile .gt-ico {
  width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 15px;
  display: flex; align-items: center; justify-content: center; font-size: 1.7rem;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, white);
}
@supports not (background: color-mix(in srgb, red, white)) { .game-tile .gt-ico { background: #eef2ff; } }
.game-tile .gt-title { font-family: var(--font-heading); font-weight: 700; font-size: 1.1rem; color: var(--accent); }
.game-tile .gt-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.game-tile.g-meaning  { --accent: var(--ink-blue); }
.game-tile.g-sentence { --accent: var(--ink-purple); }
.game-tile.g-match    { --accent: var(--ink-green); }
.game-tile.g-audio    { --accent: var(--ink-orange); }

/* ---------- مسرح اللعب ---------- */
.game-stage { }
.game-topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.exit-game {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  background: white; border: 1px solid var(--border); color: var(--ink-blue); font-size: 1.2rem;
}
.exit-game:hover { background: #eff6ff; }
.game-titles { flex: 1; }
.game-titles .gt-name { font-family: var(--font-heading); font-weight: 700; color: var(--ink-blue); font-size: 1.1rem; line-height: 1.1; }
.game-titles .gt-en { font-family: var(--font-english); font-size: 0.78rem; color: var(--text-muted); direction: ltr; }

.game-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.game-progress .gp-track { flex: 1; height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.game-progress .gp-fill { height: 100%; width: 0%; border-radius: 5px; background: linear-gradient(90deg, var(--ink-teal), var(--ink-green)); transition: width 0.35s ease; }
.game-progress .gp-counter { font-family: var(--font-english); font-weight: 700; color: var(--ink-blue); font-size: 0.85rem; white-space: nowrap; }

/* ---------- بطاقة السؤال ---------- */
.game-card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.05);
  padding: 24px 22px; animation: gFade 0.3s ease-out;
}
@keyframes gFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.q-head { font-family: var(--font-hand); color: var(--ink-purple); font-size: 1.3rem; text-align: center; margin-bottom: 14px; }
.q-word { font-family: var(--font-english); font-size: 2.2rem; font-weight: 700; color: var(--ink-blue); text-align: center; direction: ltr; }
.q-phonetic { font-family: var(--font-english); color: var(--text-muted); direction: ltr; text-align: center; margin-top: 4px; }

.q-sentence {
  font-family: var(--font-english); font-size: 1.2rem; color: var(--ink-blue);
  direction: ltr; text-align: center; line-height: 1.7; font-weight: 600;
}
.q-sentence .blank-slot { color: var(--ink-red); font-weight: 800; letter-spacing: 1px; }
.q-sentence-ar { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-top: 6px; }

/* خيارات */
.g-options { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.g-opt {
  width: 100%; padding: 13px 16px; border-radius: 12px;
  border: 2px solid var(--border); background: #f8fafc; cursor: pointer;
  font-family: var(--font-body); font-size: 1rem; font-weight: 600; color: var(--text);
  text-align: right; transition: all 0.18s;
}
.g-options.en .g-opt { font-family: var(--font-english); direction: ltr; text-align: left; }
.g-opt:hover:not(:disabled) { border-color: var(--ink-teal); background: white; }
.g-opt:disabled { cursor: default; }
.g-opt.correct { border-color: var(--ink-green); background: #f0fdf4; color: var(--ink-green); font-weight: 700; }
.g-opt.wrong { border-color: var(--ink-red); background: #fee2e2; color: var(--ink-red); }

/* ---------- من الصوت ---------- */
.audio-play {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 6px auto 18px; padding: 14px 28px; border: none; border-radius: 30px;
  background: linear-gradient(135deg, var(--ink-orange), #f59e0b); color: white;
  font-family: var(--font-body); font-weight: 700; font-size: 1.05rem; cursor: pointer;
  box-shadow: 0 6px 16px rgba(234,88,12,0.28);
}
.audio-play:hover { filter: brightness(1.05); }
.audio-play .em-icon { width: 1.2em; height: 1.2em; }
.audio-input {
  width: 100%; padding: 13px 16px; border-radius: 12px; border: 2px dashed var(--ink-orange);
  background: #fffbeb; font-family: var(--font-english); font-size: 1.2rem; font-weight: 600;
  color: var(--ink-blue); text-align: center; direction: ltr;
}
.audio-input:focus { outline: none; border-style: solid; background: white; }
.audio-input.correct { border-color: var(--ink-green); background: #dcfce7; color: var(--ink-green); }
.audio-input.wrong { border-color: var(--ink-red); background: #fee2e2; color: var(--ink-red); }
.g-submit {
  width: 100%; margin-top: 12px; padding: 13px; border: none; border-radius: 12px;
  background: var(--ink-blue); color: white; font-family: var(--font-body);
  font-weight: 700; font-size: 1rem; cursor: pointer;
}
.g-submit:hover:not(:disabled) { background: var(--ink-blue-light); }
.g-submit:disabled { opacity: 0.5; cursor: default; }
.audio-feedback { display: none; margin-top: 12px; text-align: center; font-weight: 600; }
.audio-feedback.show { display: block; animation: gFade 0.25s; }
.audio-feedback.ok { color: var(--ink-green); }
.audio-feedback.no { color: var(--ink-red); }
.audio-feedback strong { font-family: var(--font-english); }

/* ---------- وصّل ---------- */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item {
  padding: 13px 12px; border-radius: 12px; border: 2px solid var(--border);
  background: #f8fafc; cursor: pointer; font-family: var(--font-body);
  font-weight: 600; font-size: 0.98rem; color: var(--text); transition: all 0.15s; width: 100%;
}
.match-item.en { font-family: var(--font-english); direction: ltr; }
.match-item:hover:not(.done) { border-color: var(--ink-teal); background: white; }
.match-item.sel { border-color: var(--ink-purple); background: #ede9fe; }
.match-item.done { border-color: var(--ink-green); background: #f0fdf4; color: var(--ink-green); cursor: default; opacity: 0.85; }
.match-item.shake-wrong { border-color: var(--ink-red); background: #fee2e2; animation: shake 0.4s; }
@keyframes shake { 0%,100% { transform: translateX(0);} 25% { transform: translateX(-5px);} 75% { transform: translateX(5px);} }

.too-few { text-align: center; color: var(--text-muted); padding: 20px 10px; line-height: 1.7; }

/* ---------- النتيجة ---------- */
.game-result {
  display: none; background: white; border-radius: var(--radius);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.05);
  padding: 30px 24px; text-align: center;
}
.game-result.show { animation: gPop 0.45s ease-out; }
@keyframes gPop { from { opacity: 0; transform: scale(0.9);} to { opacity: 1; transform: scale(1);} }
.game-result .gr-emoji { font-size: 3rem; }
.game-result .gr-score { font-family: var(--font-english); font-size: 2.6rem; font-weight: 900; color: var(--ink-teal); line-height: 1; margin-top: 6px; }
.game-result .gr-pct { font-family: var(--font-english); font-size: 1.1rem; color: var(--text-muted); }
.game-result .gr-msg { font-size: 1.15rem; font-weight: 700; color: var(--ink-blue); margin: 10px 0 20px; }
.gr-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.g-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 12px 22px;
  border-radius: 12px; font-family: var(--font-body); font-weight: 700; font-size: 0.95rem;
  cursor: pointer; border: 2px solid var(--ink-blue);
}
.g-btn.primary { background: var(--ink-blue); color: white; }
.g-btn.primary:hover { background: var(--ink-blue-light); }
.g-btn.ghost { background: white; color: var(--ink-blue); }
.g-btn.ghost:hover { background: #eff6ff; }

.game-stage.finished .game-progress { display: none; }

@media (max-width: 480px) {
  .games-grid { grid-template-columns: 1fr 1fr; }
  .game-card { padding: 20px 16px; }
  .q-word { font-size: 1.9rem; }
}
