/* ═══════════ تحدّي أعلام العالم — نظام التصميم ═══════════ */
:root {
  --bg:           #060b18;
  --bg-2:         #0b1428;
  --bg-3:         #101c36;
  --card:         rgba(255, 255, 255, .045);
  --card-strong:  rgba(255, 255, 255, .07);
  --border:       rgba(255, 255, 255, .09);
  --border-strong:rgba(255, 255, 255, .18);
  --text:         #f3f6ff;
  --text-soft:    #c3ccE6;
  --muted:        #8b98bb;
  --gold:         #f0b93c;
  --gold-2:       #ffd979;
  --gold-deep:    #c8901a;
  --gold-grad:    linear-gradient(135deg, #ffd979, #f0b93c 45%, #c8901a);
  --blue:         #3b82f6;
  --success:      #34d77f;
  --success-bg:   rgba(52, 215, 127, .13);
  --danger:       #ff6b6b;
  --danger-bg:    rgba(255, 107, 107, .13);
  --radius-sm:    10px;
  --radius:       16px;
  --radius-lg:    24px;
  --ring:         0 0 0 3px rgba(240, 185, 60, .28);
  --shadow:       0 10px 34px rgba(0, 0, 0, .45);
  --shadow-lg:    0 24px 70px rgba(0, 0, 0, .6);
  --font-head:    'Noto Naskh Arabic', 'Cairo', 'Tahoma', system-ui, sans-serif;
  --font-body:    'Noto Sans Arabic', 'Segoe UI', 'Tahoma', system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: clamp(15px, 1.6vw, 17px);
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.3; }
button { font-family: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

/* ═══════════ خلفية متوهجة ═══════════ */
.glow { position: fixed; pointer-events: none; z-index: 0; filter: blur(10px); }
.glow-a {
  inset: -30% -10% auto -10%; height: 78vh;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(59, 130, 246, .16), transparent 70%),
    radial-gradient(ellipse 45% 40% at 80% 8%, rgba(240, 185, 60, .14), transparent 72%);
}
.glow-b {
  inset: auto -20% -30% -20%; height: 60vh;
  background: radial-gradient(ellipse 55% 50% at 50% 100%, rgba(240, 185, 60, .10), transparent 72%);
}
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }

/* ═══════════ الحاويات والشاشات ═══════════ */
.app {
  position: relative; z-index: 1;
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 32px);
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
}
.screen { display: none; width: 100%; }
.screen.is-active { display: block; animation: fadeUp .45s ease both; }

/* ═══════════ الأزرار ═══════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .8rem 1.6rem; border: none; border-radius: 999px;
  font-size: 1rem; font-weight: 700; cursor: pointer; color: #fff;
  background: var(--card-strong);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, opacity .2s ease;
}
.btn svg { width: 1.15em; height: 1.15em; }
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--gold-grad); color: #20160a; box-shadow: 0 8px 26px rgba(240, 185, 60, .28); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 38px rgba(240, 185, 60, .45); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border-strong); color: var(--text-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--card); color: var(--text); }
.btn-xl { padding: 1.05rem 2.6rem; font-size: 1.2rem; }
.btn-lg { padding: .95rem 2rem; font-size: 1.08rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--card);
  color: var(--text-soft); cursor: pointer;
  transition: transform .16s ease, background .16s ease, color .16s ease;
}
.icon-btn:hover { background: var(--card-strong); color: var(--gold-2); transform: translateY(-2px); }
.icon-btn.is-off { color: var(--muted); opacity: .6; }

/* ═══════════ شاشة البداية ═══════════ */
.start-card {
  max-width: 720px; margin: 0 auto; text-align: center;
  padding: clamp(26px, 5vw, 54px) clamp(18px, 4vw, 44px);
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  backdrop-filter: blur(14px); box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.start-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--gold-grad);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .06em;
  color: var(--gold-2); background: rgba(240, 185, 60, .12);
  border: 1px solid rgba(240, 185, 60, .3);
  padding: .35rem .9rem; border-radius: 999px; margin-bottom: 1.1rem;
}
.eyebrow svg { width: 1em; height: 1em; }
.game-title {
  font-size: clamp(2.1rem, 6.4vw, 3.5rem); font-weight: 700; line-height: 1.15;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  margin-bottom: .8rem; letter-spacing: -.01em;
}
.lead { color: var(--text-soft); max-width: 54ch; margin: 0 auto 1.6rem; }

.start-stats {
  list-style: none; display: grid; gap: .7rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 1.5rem;
}
.start-stats li {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: 1rem .6rem; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border);
  transition: transform .18s ease, border-color .18s ease;
}
.start-stats li:hover { transform: translateY(-3px); border-color: rgba(240, 185, 60, .4); }
.start-stats svg { width: 1.4rem; height: 1.4rem; color: var(--gold); }
.start-stats b { font-size: 1.5rem; font-family: var(--font-head); }
.start-stats span { font-size: .82rem; color: var(--muted); }
.best-score { margin-bottom: 1.3rem; font-size: .92rem; color: var(--gold-2); min-height: 1.4em; }
.best-score b { font-family: var(--font-head); font-size: 1.15em; }
.hint { margin-top: 1.2rem; font-size: .82rem; color: var(--muted); }
kbd {
  font-family: inherit; font-size: .78rem; padding: .12rem .45rem; margin: 0 .1rem;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: rgba(255, 255, 255, .07); color: var(--text-soft);
}

/* ═══════════ شريط الأعلى ═══════════ */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  flex-wrap: wrap;
  padding: .7rem .9rem; border-radius: var(--radius);
  background: rgba(10, 18, 36, .82); border: 1px solid var(--border);
  backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.topbar-title { display: flex; align-items: center; gap: .5rem; font-family: var(--font-head); font-weight: 700; font-size: 1.02rem; }
.topbar-title svg { width: 1.15rem; height: 1.15rem; color: var(--gold); }
.topbar-meters { display: flex; align-items: center; gap: .5rem; order: 3; width: 100%; }
.topbar-actions { display: flex; gap: .4rem; }

.meter {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .4rem .85rem; border-radius: 999px; white-space: nowrap;
  font-size: .86rem; font-weight: 600; color: var(--text-soft);
  background: var(--card); border: 1px solid var(--border);
}
.meter svg { width: 1em; height: 1em; color: var(--muted); }
.meter-score { margin-inline-start: auto; border-color: rgba(240, 185, 60, .35); background: rgba(240, 185, 60, .1); color: var(--gold-2); }
.meter-score svg { color: var(--gold); }
.meter-score b { font-family: var(--font-head); font-size: 1.15em; }

/* ═══════════ شريط التقدّم ═══════════ */
.progress {
  height: 7px; margin: 12px 2px 2px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, .07);
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 999px; background: var(--gold-grad);
  transition: width .4s cubic-bezier(.22, .8, .3, 1);
}

/* ═══════════ منطقة اللعب ═══════════ */
.play-area {
  margin-top: clamp(14px, 2.6vw, 26px);
  padding: clamp(16px, 3.4vw, 34px);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .015));
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.flag-stage { position: relative; display: grid; place-items: center; margin-bottom: 1.1rem; }
.flag-card {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  width: min(100%, 460px); padding: clamp(10px, 1.8vw, 18px);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .03));
  border: 1px solid rgba(240, 185, 60, .32);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .05);
  min-height: 190px;
  animation: flagIn .5s cubic-bezier(.2, .9, .3, 1) both;
}
.flag-card.is-loaded { min-height: 0; }
#flag-img { width: 100%; height: auto; border-radius: 8px; object-fit: contain; }
.flag-fallback {
  font-family: var(--font-head); font-size: 2rem; color: var(--gold-2);
  letter-spacing: .1em; text-transform: uppercase;
}
.flag-glare {
  position: absolute; inset: auto 0 -22px 0; height: 60px; z-index: 0;
  background: radial-gradient(ellipse 50% 100% at 50% 0%, rgba(240, 185, 60, .3), transparent 70%);
  filter: blur(6px);
}
.question {
  text-align: center; font-size: clamp(1.15rem, 3vw, 1.6rem); font-weight: 700;
  margin-bottom: clamp(14px, 2.4vw, 22px);
}
.question::after {
  content: ''; display: block; width: 72px; height: 3px; margin: .7rem auto 0;
  border-radius: 999px; background: var(--gold-grad); opacity: .85;
}

/* ═══════════ الخيارات ═══════════ */
.options { display: grid; gap: .75rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
.option {
  display: flex; align-items: center; gap: .85rem; text-align: start;
  width: 100%; padding: .95rem 1.1rem; cursor: pointer;
  border-radius: var(--radius); border: 1.5px solid var(--border-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02));
  color: var(--text); font-size: clamp(1rem, 2.4vw, 1.16rem); font-weight: 600;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease, opacity .3s ease;
}
.option:hover:not(:disabled) {
  transform: translateY(-3px); border-color: var(--gold);
  box-shadow: 0 12px 34px rgba(240, 185, 60, .18);
}
.option:disabled { cursor: default; }
.opt-key {
  flex: none; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  font-family: var(--font-head); font-weight: 700; font-size: 1.05rem;
  background: rgba(255, 255, 255, .08); border: 1px solid var(--border-strong);
  color: var(--gold-2);
}
.opt-label { flex: 1; }
.opt-mark { flex: none; width: 22px; height: 22px; opacity: 0; transition: opacity .25s ease; }
.opt-mark svg { width: 100%; height: 100%; }

/* ═══════════ حالات الخيارات بعد الإجابة ═══════════ */
.options.is-locked .option { opacity: .55; }
.options.is-locked .option.is-correct {
  opacity: 1; border-color: var(--success); background: var(--success-bg);
  box-shadow: 0 12px 34px rgba(52, 215, 127, .2);
}
.options.is-locked .option.is-wrong {
  opacity: 1; border-color: var(--danger); background: var(--danger-bg);
  box-shadow: 0 12px 34px rgba(255, 107, 107, .18);
  animation: shake .45s ease;
}
.option.is-correct .opt-key { background: var(--success); color: #06210f; border-color: transparent; }
.option.is-wrong .opt-key { background: var(--danger); color: #2a0808; border-color: transparent; }
.option.is-correct .opt-mark, .option.is-wrong .opt-mark { opacity: 1; }
.option.is-correct .opt-mark { color: var(--success); }
.option.is-wrong .opt-mark { color: var(--danger); }
.option.is-correct .opt-label { font-weight: 700; }

/* ═══════════ رسائل التقييم ═══════════ */
.feedback {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .9rem 1.1rem; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600; margin-bottom: 1rem;
  animation: fadeUp .3s ease both;
}
.feedback svg { flex: none; width: 1.35rem; height: 1.35rem; margin-top: .18rem; }
.feedback .fb-body { flex: 1; }
.feedback .fb-sub { display: block; margin-top: .2rem; font-size: .88rem; font-weight: 500; opacity: .9; }
.feedback.ok { background: var(--success-bg); border: 1px solid rgba(52, 215, 127, .42); color: #9df3c4; }
.feedback.no { background: var(--danger-bg); border: 1px solid rgba(255, 107, 107, .42); color: #ffc0c0; }
.feedback b { color: #fff; font-weight: 700; }

/* ═══════════ أزرار الإجراءات ═══════════ */
.actions { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; }
.actions.center { justify-content: center; margin-top: 1.6rem; }
#btn-next { animation: pop .35s cubic-bezier(.2, .9, .3, 1) both; }

/* ═══════════ شاشة النتيجة ═══════════ */
.result-card {
  max-width: 760px; margin: 0 auto; text-align: center;
  padding: clamp(24px, 4.4vw, 48px) clamp(16px, 4vw, 40px);
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  backdrop-filter: blur(14px); box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.result-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--gold-grad); }
.medal {
  display: grid; place-items: center; width: 88px; height: 88px; margin: 0 auto 1rem;
  border-radius: 50%; background: var(--gold-grad); color: #20160a;
  box-shadow: 0 0 0 8px rgba(240, 185, 60, .12), 0 18px 44px rgba(240, 185, 60, .32);
  animation: pop .5s cubic-bezier(.2, .9, .3, 1) both;
}
.medal svg { width: 42px; height: 42px; }
.result-title { font-size: clamp(1.5rem, 4vw, 2.1rem); margin-bottom: .3rem; }
.result-rating { font-family: var(--font-head); font-size: clamp(1.1rem, 3vw, 1.45rem); font-weight: 700; color: var(--gold-2); margin-bottom: 1.3rem; }

/* ═══════════ النتيجة الكبيرة والنسبة ═══════════ */
.score-hero { display: flex; align-items: center; justify-content: center; gap: clamp(18px, 5vw, 44px); flex-wrap: wrap; margin-bottom: 1.5rem; }
.big-score { display: flex; align-items: baseline; gap: .35rem; font-family: var(--font-head); }
.big-score span {
  font-size: clamp(3.2rem, 12vw, 5rem); font-weight: 700; line-height: 1;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.big-score small { font-size: clamp(1.1rem, 3.4vw, 1.6rem); color: var(--muted); }
.percent-ring {
  --p: 0;
  display: grid; place-items: center; width: 128px; height: 128px; border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--bg-2) 79%, transparent 80% 100%),
    conic-gradient(var(--gold) calc(var(--p) * 1%), rgba(255, 255, 255, .09) 0);
  transition: --p .8s ease;
}
.percent-ring span { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; color: var(--gold-2); }

.result-grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 1.1rem; }
.stat {
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  padding: 1rem .5rem; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border);
}
.stat svg { width: 1.3rem; height: 1.3rem; color: var(--muted); }
.stat b { font-family: var(--font-head); font-size: 1.7rem; }
.stat span { font-size: .82rem; color: var(--muted); }
.stat.ok { border-color: rgba(52, 215, 127, .35); background: var(--success-bg); }
.stat.ok svg, .stat.ok b { color: var(--success); }
.stat.no { border-color: rgba(255, 107, 107, .35); background: var(--danger-bg); }
.stat.no svg, .stat.no b { color: var(--danger); }
.stat.gold { border-color: rgba(240, 185, 60, .35); background: rgba(240, 185, 60, .1); }
.stat.gold svg, .stat.gold b { color: var(--gold-2); }
.result-note { color: var(--muted); font-size: .9rem; }

/* ═══════════ مراجعة الأخطاء ═══════════ */
.review { margin-top: 1.5rem; text-align: start; }
.review h3 {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.05rem; margin-bottom: .7rem; color: var(--text-soft);
}
.review h3 svg { width: 1.1rem; height: 1.1rem; color: var(--gold); }
.review-list { list-style: none; display: grid; gap: .5rem; max-height: 300px; overflow-y: auto; padding-inline-end: .2rem; }
.review-list li {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .8rem; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--border); font-size: .92rem;
}
.review-list img { width: 46px; height: auto; border-radius: 4px; border: 1px solid var(--border); flex: none; }
.review-list .rv-name { font-weight: 700; }
.review-list .rv-meta { color: var(--muted); font-size: .82rem; margin-inline-start: auto; text-align: end; }
/* ═══════════ الحركات ═══════════ */
@property --p { syntax: '<number>'; inherits: false; initial-value: 0; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes flagIn { from { opacity: 0; transform: scale(.9) rotate(-1.5deg); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(.82); } 60% { transform: scale(1.04); } 100% { opacity: 1; transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}
@keyframes confettiFall {
  0% { opacity: 1; transform: translate3d(0, -10vh, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate3d(var(--dx, 0), 105vh, 0) rotate(720deg); }
}
.confetti-piece { position: absolute; top: 0; width: 9px; height: 9px; border-radius: 2px; animation: confettiFall linear forwards; }
.pop-badge { animation: pop .45s cubic-bezier(.2, .9, .3, 1) both; }

/* ═══════════ التذييل ═══════════ */
.site-foot {
  position: relative; z-index: 1; text-align: center;
  padding: 1.6rem 1rem 2.2rem; font-size: .8rem; color: var(--muted);
}

/* ═══════════ التجاوب ═══════════ */
@media (min-width: 760px) {
  .options { grid-template-columns: repeat(3, 1fr); }
  .option { flex-direction: column; align-items: flex-start; gap: .6rem; padding: 1.15rem 1.1rem; min-height: 132px; text-align: start; }
  .opt-key { width: 42px; height: 42px; }
  .opt-label { flex: 1; }
  .opt-mark { align-self: flex-end; }
  .topbar-meters { order: 0; width: auto; }
  .topbar { flex-wrap: nowrap; }
  .flag-card { width: min(100%, 560px); }
}
@media (max-width: 520px) {
  .topbar-title span { display: none; }
  .big-score span { font-size: 3.4rem; }
  .percent-ring { width: 108px; height: 108px; }
  .actions .btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
