/* ============================================================
   كويزنا — التصميم الرئيسي
   هوية: ليل أزرق دافئ + ألوان ألعاب مبهجة، واجهة عربية RTL
   ============================================================ */

:root {
  --bg: #10162f;
  --bg-2: #1b2447;
  --card: #222d55;
  --card-2: #2a3765;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f6ff;
  --muted: #9aa5cc;
  --yellow: #ffb020;
  --coral: #f05252;
  --teal: #31c48d;
  --blue: #3f83f8;
  --pink: #e74694;
  --violet: #9061f9;
  --radius: 20px;
  --shadow: 0 12px 32px rgba(5, 9, 26, 0.45);
  --font-display: "Baloo Bhaijaan 2", "Rubik", sans-serif;
  --font-body: "Rubik", "Baloo Bhaijaan 2", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* قاعدة عامة: أي عنصر عليه hidden يختفي مهما كانت قواعد عرضه */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: radial-gradient(1200px 600px at 85% -10%, #26346b 0%, var(--bg) 55%) fixed;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* وشاح لون خفيف يتنفس ببطء خلف كل شيء — تأثير opacity فقط (رخيص على
   المعالج) بدل تحريك ألوان الخلفية نفسها، ودورة طويلة (26 ثانية) كي يبقى
   إحساسًا لا يُلاحَظ مباشرة بدل أن يشتت الانتباه. لونه (--mood-hue) يتغيّر
   بلطف مع القسم الظاهر حاليًا (bindSectionMood في app.js) فيعطي كل قسم مزاجًا
   مختلفًا قليلًا بدل نفس الخلفية الثابتة طوال الصفحة */
@property --mood-hue {
  syntax: "<number>";
  inherits: true;
  initial-value: 265;
}
:root { --mood-hue: 265; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(1000px 700px at 12% 105%, hsl(var(--mood-hue) 70% 55%) 0%, transparent 60%);
  opacity: 0; animation: bgBreathe 26s ease-in-out infinite;
  transition: --mood-hue 1.4s ease;
}
@keyframes bgBreathe {
  0%, 100% { opacity: 0; }
  50%      { opacity: 0.16; }
}
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}
html.light body::before { background: radial-gradient(1000px 700px at 12% 105%, hsl(var(--mood-hue) 75% 65%) 0%, transparent 60%); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ---------- الكائن السائل: يسبح تابعًا للمؤشر عبر الموقع كله ---------- */
/* pointer-events: none إلزامي — لا يجب أن يعترض أي نقرة أبدًا مهما كانت
   مكانه فوق العناصر؛ position:fixed + JS transform (لا top/left) للحركة
   السلسة عبر GPU بلا إعادة تخطيط.
   left:0 (فيزيائي وليس inset-inline-start المنطقي): الموقع RTL بالكامل،
   وinset-inline-start:0 كان يثبّت الصندوق عند الحافة اليمنى الفعلية بدل
   اليسار، فتصطدم كل حسابات translate(x,y) في app.js (فيزيائية بطبيعتها)
   بنقطة انطلاق خاطئة ويظهر الكائن عالقًا عند حافة الشاشة بجسم مقصوص */
.lifeform {
  position: fixed; top: 0; left: 0;
  width: 112px; height: 180px;
  z-index: 45; pointer-events: none;
  animation: lifeformBreathe 3.4s ease-in-out infinite;
  filter: drop-shadow(0 10px 20px rgba(106, 79, 216, 0.4));
}
@keyframes lifeformBreathe {
  0%, 100% { scale: 0.94; }
  50%      { scale: 1.1; }
}
.lifeform-svg { width: 100%; height: 100%; overflow: visible; }
/* تبديل سلس بين ألوان "السكينات" المختلفة بدل قفزة لونية مفاجئة */
#lifeformSkinStop1, #lifeformSkinStop2, #lifeformSkinStop3 { transition: stop-color 1.6s ease; }
.lifeform-eye { fill: rgba(255, 255, 255, 0.95); }
.lifeform-pupil { fill: #1a1440; }
.lifeform-glint { fill: #fff; }
.lifeform-mouth { stroke: #3a2f6e; stroke-width: 1.6; stroke-linecap: round; }
.lifeform-brow { stroke: #3a2f6e; stroke-width: 1.8; stroke-linecap: round; transition: d 0.2s ease; }
/* نظارة مرحة يرتديها الكائن أحيانًا — مخفية افتراضيًا، تظهر بلمسة "pop" خفيفة */
.lifeform-glasses {
  fill: rgba(20, 16, 50, 0.15); stroke: #1a1440; stroke-width: 2; stroke-linecap: round;
  transform-origin: 50px 33px; transform-box: fill-box;
  opacity: 0; scale: 0.6;
  transition: opacity 0.25s ease, scale 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lifeform-glasses.on { opacity: 1; scale: 1; }
/* يمكن الإمساك بالكائن نفسه وسحبه رغم أن حاويته الخارجية pointer-events:none —
   منطقة اللمس مستطيل شفاف أوسع بكثير من رسمه الفعلي (lifeformHitArea)، لا حواف
   الشكل العضوي الدقيقة نفسها؛ إصبع على الجوال يصعب أن يصيب حافة دقيقة بدقة.
   touch-action: none إلزامي — بدونها يفسّر الجوال لمس السحب على أنه
   تكبير/تصغير أو تمرير للصفحة بدل تحريك الكائن، فيصير مسكه مستحيلًا باللمس */
#lifeformHitArea { pointer-events: auto; cursor: grab; touch-action: none; }
#lifeformHitArea:active { cursor: grabbing; }
/* نجوم الدوار الكوميدية — تظهر فقط أثناء السحب العنيف، خارج فلتر الهلام كي تبقى حادّة */
.lifeform-dizzy { opacity: 0; transition: opacity 0.15s; }
.lifeform-dizzy.on { opacity: 1; }
.lifeform-star { fill: #ffd93d; stroke: #1a1440; stroke-width: 0.6; }
/* شرر احتفالي — مثل نجوم الدوار لكن بلون فرحٍ وتظهر فقط أثناء الرقص/الاحتفال */
.lifeform-sparkle { opacity: 0; transition: opacity 0.2s; }
.lifeform-sparkle.on .lifeform-star { fill: #7ee7c0; }
.lifeform-sparkle.on { opacity: 1; }
/* دمعتان تظهران فقط في التعبير الحزين — إسقاط بسيط بدل رسم مسار متحرك معقّد */
.lifeform-tears { fill: #6fc3ff; opacity: 0; transition: opacity 0.25s; }
.lifeform-tears.on { opacity: 0.9; }
/* ومضة لونية موجزة تعكس صواب أو خطأ إجابتك — تُضاف للحاوية الخارجية فتُلوّن السائل كله.
   flash-angry أطول أثرًا (لا تختفي تلقائيًا بسرعة) لأنها ترافق سلسلة أخطاء متتالية لا إجابة واحدة */
.lifeform { transition: filter 0.35s ease; }
.lifeform.flash-good { filter: drop-shadow(0 10px 20px rgba(49, 196, 141, 0.5)) hue-rotate(75deg) saturate(1.4); }
.lifeform.flash-wrong { filter: drop-shadow(0 10px 20px rgba(240, 82, 82, 0.5)) hue-rotate(-70deg) saturate(1.5); }
.lifeform.flash-angry { filter: drop-shadow(0 10px 20px rgba(240, 82, 82, 0.6)) hue-rotate(-70deg) saturate(1.7); }
@media (prefers-reduced-motion: reduce) {
  .lifeform { animation: none; }
}
/* اختفاء دوري مؤقت — لا يبقى ظاهرًا طوال الوقت كي لا يزعج، خصوصًا بشاشة الجوال الصغيرة */
.lifeform.lifeform-away { opacity: 0; }
/* فقاعة كلام قصيرة يستخدمها للترحيب والتوجيه — عنصر HTML عادي، أبسط من رسم نص داخل SVG */
.lifeform-bubble {
  /* top/left فيزيائيان صريحان (لا inset-inline) — نفس درس RTL: JS تحسب
     translate() من نقطة (0,0) فيزيائية، وبدونها يثبَّت الصندوق بموضع مختلف في RTL */
  position: fixed; top: 0; left: 0; z-index: 46; max-width: 190px;
  padding: 10px 14px; border-radius: 16px;
  background: #fff; color: #1a1440;
  font-family: var(--font-body); font-size: 13.5px; font-weight: 700; line-height: 1.5;
  text-align: center; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none; opacity: 0; scale: 0.85; transform-origin: 50% 100%;
  transition: opacity 0.2s ease, scale 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lifeform-bubble.show { opacity: 1; scale: 1; }
.lifeform-bubble::after {
  content: ""; position: absolute; bottom: -7px; left: 50%; translate: -50% 0;
  border: 7px solid transparent; border-top-color: #fff;
}
/* اهتزاز مرح للبطاقة حين "يعبث" بها الكائن أثناء تجواله الذاتي */
@keyframes lifeformJostle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25%      { transform: translateY(-4px) rotate(-2deg); }
  75%      { transform: translateY(2px) rotate(2deg); }
}
.lifeform-jostled { animation: lifeformJostle 0.5s ease; }

/* ---------- الأشكال العائمة في الخلفية ---------- */
.bg-shapes {
  position: fixed; inset: -5%; pointer-events: none; z-index: 0;
  /* الانزياح اللطيف مع حركة المؤشر يُحدَّث من app.js عبر هذين المتغيرين */
  --px: 0px; --py: 0px;
  transition: transform 0.6s ease-out;
}
.bg-shapes .shape {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 800;
  opacity: 0.07;
  animation: floaty 7s ease-in-out infinite;
  user-select: none;
  will-change: transform;
}
/* كل شكل يتحرك بعمق مختلف (parallax) عبر --depth: الأقرب يتحرك أكثر مع المؤشر */
.bg-shapes .shape { transform: translate(calc(var(--px) * var(--depth, 1)), calc(var(--py) * var(--depth, 1))); }
.s1 { top: 12%; right: 6%;  font-size: 120px; color: var(--yellow); --depth: 1.6; }
.s2 { top: 30%; left: 8%;   font-size: 60px;  color: var(--teal);   --depth: 0.6;  animation-delay: -1.5s; }
.s3 { top: 62%; right: 12%; font-size: 90px;  color: var(--pink);   --depth: 1.1;  animation-delay: -3s;   animation-duration: 9s; }
.s4 { top: 78%; left: 15%;  font-size: 70px;  color: var(--blue);   --depth: 0.8;  animation-delay: -4.5s; animation-duration: 6s; }
.s5 { top: 45%; left: 45%;  font-size: 150px; color: var(--violet); --depth: 1.9;  animation-delay: -2.5s; animation-duration: 10s; }
.s6 { top: 8%;  left: 30%;  font-size: 50px;  color: var(--coral);  --depth: 0.5;  animation-delay: -5.5s; animation-duration: 5s; }
.s7 { top: 52%; right: 30%; font-size: 44px;  color: var(--teal);   --depth: 1.3;  animation-delay: -2s;   animation-duration: 7.5s; }
.s8 { top: 88%; right: 40%; font-size: 84px;  color: var(--yellow); --depth: 0.9;  animation-delay: -6.5s; animation-duration: 8.5s; }
@keyframes floaty {
  0%   { translate: 0 0;       rotate: -8deg; scale: 1; }
  25%  { translate: 14px -22px; rotate: 4deg;  scale: 1.05; }
  50%  { translate: -10px -34px; rotate: 9deg;  scale: 0.96; }
  75%  { translate: -18px -12px; rotate: -4deg; scale: 1.04; }
  100% { translate: 0 0;       rotate: -8deg; scale: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .bg-shapes .shape { animation: none; }
  .bg-shapes { transition: none; }
}

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 14px clamp(16px, 4vw, 48px);
  /* لا تُستخدم backdrop-filter هنا: شريط ثابت يعاد رسمه مع كل حركة تمرير
     عبر الصفحة الطويلة، وطمس الخلفية الحي كان أكبر سبب للّاج أثناء التمرير */
  background: rgba(14, 19, 42, 0.97);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  display: grid; place-items: center;
  flex-shrink: 0;
  width: 42px; height: 42px;
  font-family: var(--font-display); font-size: 26px; font-weight: 800; color: #10162f;
  background: linear-gradient(135deg, var(--yellow), #ff8a3d);
  border-radius: 14px;
  transform: rotate(-8deg);
  box-shadow: 0 4px 14px rgba(255, 176, 32, 0.4);
}
.brand-mark.small { width: 30px; height: 30px; font-size: 18px; border-radius: 9px; }
.brand-name { font-family: var(--font-display); font-size: 26px; font-weight: 800; }
.topnav { display: flex; gap: 4px; margin-inline-start: auto; min-width: 0; flex-shrink: 1; }
.nav-link {
  padding: 9px 16px; border-radius: 12px;
  color: var(--muted); font-size: 15px; font-weight: 600;
  transition: 0.2s;
}
.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.icon-btn {
  width: 42px; height: 42px; font-size: 18px;
  display: grid; place-items: center;
  flex-shrink: 0; /* لا تنكمش الأزرار عند ضيق الشريط فتفقد شكلها */
}
/* أزرار الأيقونات (إغلاق/إعدادات) صور جاهزة حقيقية بنفس طراز مرجعك —
   لا تعتمد الحلوى بالكود لأنها بلا نص متغيّر أصلًا، الصورة أدق وأقرب */
.icon-btn:not(.profile-btn) {
  background: url('/assets/icons/btn-close.png') center / contain no-repeat;
  border: none; box-shadow: none;
  font-size: 0; color: transparent;
}
.icon-btn:not(.profile-btn)::before { content: none; }
#settingsBtn { background-image: url('/assets/icons/btn-settings.png'); }
.icon-btn.off { opacity: 0.35; }

/* ---------- الشاشات ---------- */
.screen { display: none; position: relative; z-index: 1; }
.screen.active { display: block; }

/* ---------- البطل ---------- */
.hero { padding: clamp(40px, 8vw, 90px) clamp(16px, 4vw, 48px) 30px; text-align: center; }
.hero-inner { max-width: 760px; margin: 0 auto; }
.hero-badge {
  display: inline-block; padding: 8px 18px;
  background: rgba(255, 176, 32, 0.12);
  border: 1px solid rgba(255, 176, 32, 0.35);
  color: var(--yellow);
  border-radius: 999px; font-weight: 700; font-size: 14px;
  margin-bottom: 22px;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(38px, 7vw, 64px);
  font-weight: 800; line-height: 1.25;
}
.grad-text {
  background: linear-gradient(90deg, var(--yellow), var(--pink), var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { margin: 18px auto 30px; max-width: 520px; color: var(--muted); font-size: 18px; line-height: 1.8; }
.hero-ctas { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }

/* شعاع لامع مشترك لأزرار البطل الثلاثة — أول ما يراه الزائر فيستحق لمسة "واو" */
.btn-daily, .btn-play, .btn-friends {
  position: relative; overflow: hidden;
}
.btn-daily::after, .btn-play::after, .btn-friends::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.22) 50%, transparent 60%);
  transform: translateX(-130%); transition: transform 0.6s ease; pointer-events: none;
}
.btn-daily:hover::after, .btn-play:hover::after, .btn-friends:hover::after { transform: translateX(130%); }
.btn-glyph { font-size: 20px; }

.btn-daily {
  --candy-edge: #b8321f;
  display: flex; align-items: center; gap: 12px; text-align: start;
  padding: 12px 20px;
  background: linear-gradient(180deg, #ffcf9e 0%, #ff7a4d 55%, #e8432f 100%);
  border: 3px solid var(--candy-edge);
}
.btn-daily-icon {
  position: relative; width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
}
.btn-daily strong { display: block; font-family: var(--font-display); font-size: 19px; }
.btn-daily small { font-size: 12.5px; opacity: 0.9; }

.btn-play {
  --candy-edge: #0a685f;
  padding: 14px 26px;
  background: linear-gradient(180deg, #7ff0e0 0%, #16b8a6 55%, #0e8a7d 100%);
  border: 3px solid var(--candy-edge);
  font-family: var(--font-display); font-size: 17px; font-weight: 800;
}

/* ---------- شعلة حقيقية متحركة (لا إنجاز بعد) وعلامة صح هادئة (أُنجز) ---------- */
.daily-flame, .btn-daily-icon { position: relative; }
.daily-flame { width: 64px; height: 64px; display: grid; place-items: center; }
.flame-emoji { position: relative; z-index: 1; display: block; font-size: 44px; line-height: 1; transition: filter 0.3s; }
.btn-daily-icon .flame-emoji { font-size: 24px; }
.flame-fx { position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.blazing .flame-fx { opacity: 1; }
.blazing .flame-emoji { filter: drop-shadow(0 0 8px rgba(255, 138, 61, 0.85)); animation: flameEmojiBob 1s ease-in-out infinite; }
.flame-fx i {
  position: absolute; bottom: 2%;
  width: 46%; height: 66%;
  border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
  background: radial-gradient(circle at 50% 75%, #fff6b0 0%, #ffb020 38%, #ff5f2d 68%, transparent 84%);
  animation: flameFlicker 1s ease-in-out infinite;
}
.flame-fx i:nth-child(1) { inset-inline-start: 4%;  width: 40%; animation-delay: -0.35s; }
.flame-fx i:nth-child(2) { inset-inline-start: 27%; }
.flame-fx i:nth-child(3) { inset-inline-start: 56%; width: 40%; animation-delay: -0.65s; }
@keyframes flameFlicker {
  0%, 100% { transform: scaleY(1) scaleX(1) translateY(0); opacity: 0.85; }
  30%      { transform: scaleY(1.2) scaleX(0.88) translateY(-8%); opacity: 1; }
  60%      { transform: scaleY(0.9) scaleX(1.08) translateY(2%); opacity: 0.8; }
}
@keyframes flameEmojiBob { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) {
  .flame-fx i, .blazing .flame-emoji { animation: none; }
}

.hero-stats { display: flex; justify-content: center; gap: clamp(20px, 6vw, 60px); margin-top: 46px; }
.hstat { display: grid; gap: 2px; }
.hstat strong { font-family: var(--font-display); font-size: 30px; color: var(--yellow); }
.hstat span { color: var(--muted); font-size: 13.5px; }

/* ---------- بطاقة التحدي اليومي ---------- */
.daily-section { padding: 26px clamp(16px, 4vw, 48px); }
.daily-card {
  position: relative; overflow: hidden;
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 26px; flex-wrap: wrap;
  padding: 28px 32px;
  background: linear-gradient(135deg, #2b1f4d 0%, #14305c 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 26px;
  box-shadow: var(--shadow);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.daily-card:hover { transform: translateY(-4px); }
/* بقعة توهج برتقالية خلف الشعلة تمنح البطاقة إحساس "دفء" يوافق موضوعها */
.daily-card::before {
  content: ""; position: absolute; top: -50px; inset-inline-start: -30px;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 138, 61, 0.4), transparent 70%);
  opacity: 0.7; pointer-events: none;
}
.daily-right { position: relative; display: flex; align-items: center; gap: 20px; flex: 1; min-width: 260px; }
.daily-card h2 { font-family: var(--font-display); font-size: 24px; margin-bottom: 6px; }
.daily-num { color: var(--yellow); }
.daily-card p { color: var(--muted); line-height: 1.7; font-size: 15px; max-width: 420px; }
.daily-left { display: flex; align-items: center; gap: 18px; }
.streak-box {
  display: grid; place-items: center; gap: 2px;
  padding: 10px 18px;
  background: rgba(255, 176, 32, 0.1);
  border: 2px solid rgba(255, 176, 32, 0.4);
  border-radius: 14px;
}
.streak-count { font-family: var(--font-display); font-size: 26px; font-weight: 800; color: var(--yellow); }
.streak-label { font-size: 12px; color: var(--muted); }
.btn-cta {
  --candy-edge: #b85e00;
  padding: 13px 26px;
  background: linear-gradient(180deg, #ffe58a 0%, #ffb020 55%, #e8790a 100%);
  border: 3px solid var(--candy-edge);
  font-family: var(--font-display); font-size: 18px; font-weight: 800;
}

/* ---------- التصنيفات ---------- */
.cats-section { padding: 50px clamp(16px, 4vw, 48px); }
.section-title { font-family: var(--font-display); font-size: clamp(26px, 4vw, 34px); text-align: center; }
.section-sub { text-align: center; color: var(--muted); margin-top: 8px; }
.section-search { max-width: 380px; margin: 22px auto 0; }
.section-search-input {
  width: 100%; padding: 12px 18px;
  font-family: var(--font-body); font-size: 15px; color: var(--text);
  background: var(--card); border: 2px solid var(--line); border-radius: 999px;
  text-align: center; transition: border-color 0.2s, box-shadow 0.2s;
}
.section-search-input::placeholder { color: var(--muted); }
.section-search-input:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 176, 32, 0.18); }
.section-search-input::-webkit-search-cancel-button { cursor: pointer; }
.section-empty { text-align: center; color: var(--muted); padding: 30px 16px; font-size: 15px; }
.cats-grid {
  max-width: 1000px; margin: 34px auto 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px;
}

/* ---------- بطاقات النقر المشتركة (تصنيف + تحدٍّ): لمسة "استوديو ألعاب" ---------- */
/* كل بطاقة: بقعة ضوء ملونة كبروجكتور خلف الأيقونة + شعاع لامع يعبرها عند
   التحويم + ارتداد خفيف عند الضغط — بدل السطح المسطح ذي الشريط اللوني السابق */
.cat-card, .mode-card {
  position: relative; overflow: hidden;
  padding: 26px 20px 22px;
  background: var(--card);
  border: 2px solid color-mix(in srgb, var(--cat-color, var(--mode-color)) 30%, var(--line));
  border-radius: var(--radius);
  display: grid; gap: 8px;
  /* box-shadow ليس ضمن transition عمدًا: تحريكه بصريًا رخيص لكن حسابه
     مكلف على كل إطار، وبعشرات البطاقات يصبح السبب الأول للّاج عند اللمس/التحويم */
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.22s;
  will-change: transform;
}
.cat-card { text-align: start; }
.mode-card { text-align: center; justify-items: center; }
.cat-card::before, .mode-card::before {
  content: ""; position: absolute; top: -36px; inset-inline-start: -24px;
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--cat-color, var(--mode-color)) 60%, transparent), transparent 72%);
  opacity: 0.6; pointer-events: none;
}
.mode-card::before { inset-inline-start: auto; inset-inline-end: -24px; }
.cat-card::after, .mode-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.16) 50%, transparent 58%);
  transform: translateX(-130%); transition: transform 0.65s ease; pointer-events: none;
}
.cat-card:hover::after, .mode-card:hover::after { transform: translateX(130%); }
.cat-card:hover, .mode-card:hover {
  transform: translateY(-6px) scale(1.015);
  border-color: color-mix(in srgb, var(--cat-color, var(--mode-color)) 75%, var(--line));
  box-shadow: 0 16px 32px -6px color-mix(in srgb, var(--cat-color, var(--mode-color)) 38%, rgba(5, 9, 26, 0.5));
}
.cat-card:active, .mode-card:active { transform: translateY(-1px) scale(0.97); }
.card-play-hint {
  position: absolute; top: 16px; inset-inline-start: 16px;
  font-size: 11px; color: var(--cat-color, var(--mode-color));
  opacity: 0; transform: scaleX(-1) translateX(6px); transition: opacity 0.2s, transform 0.2s;
}
.cat-card:hover .card-play-hint, .mode-card:hover .card-play-hint { opacity: 0.85; transform: scaleX(-1) translateX(0); }
/* في بطاقة التصنيف تطفو الشارتان فوق الصورة نفسها — خلفية معتمة أكثر
   (لا شفافة) كي تبقى واضحة مهما كانت تفاصيل الصورة تحتها */
.cat-card .card-play-hint { background: rgba(10, 14, 34, 0.55); border-radius: 999px; padding: 5px; }
.cat-card .card-best { background: rgba(10, 14, 34, 0.65); }
/* شارة أفضل نتيجة سابقة — تظهر دائمًا (ليست عند التحويم فقط) لأنها معلومة مفيدة لا زخرفة */
.card-best {
  position: absolute; top: 14px; inset-inline-end: 14px;
  font-size: 11px; font-weight: 700; color: var(--yellow);
  background: rgba(255, 176, 32, 0.14); border: 1px solid rgba(255, 176, 32, 0.35);
  padding: 3px 9px; border-radius: 999px;
}

.mode-icon {
  display: grid; place-items: center; overflow: hidden;
  border-radius: 50%;
  box-shadow: 0 6px 16px -2px color-mix(in srgb, var(--mode-color) 55%, transparent);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mode-card:hover .mode-icon { transform: scale(1.08) rotate(-4deg); }
/* صورة أقرب للمربع لكل تصنيف بدل اللافتة العريضة السابقة (16:10) */
.cat-icon {
  width: 100%; aspect-ratio: 4 / 3; font-size: 28px;
  border-radius: 16px; overflow: hidden;
  background: color-mix(in srgb, var(--cat-color) 18%, transparent);
  box-shadow: 0 8px 20px -4px color-mix(in srgb, var(--cat-color) 45%, transparent);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cat-card:hover .cat-icon { transform: scale(1.03); }
.cat-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cat-name { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.cat-desc { color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.cat-count {
  font-size: 12px; font-weight: 700; color: var(--cat-color, var(--yellow));
  padding: 4px 12px; border-radius: 999px; width: fit-content;
  background: linear-gradient(120deg, color-mix(in srgb, var(--cat-color) 20%, transparent), color-mix(in srgb, var(--cat-color) 8%, transparent));
  border: 1px solid color-mix(in srgb, var(--cat-color) 30%, transparent);
}

/* ---------- التحديات الخاصة ---------- */
.modes-section { padding: 50px clamp(16px, 4vw, 48px) 10px; }
.modes-grid {
  max-width: 1000px; margin: 34px auto 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px;
}
.mode-icon {
  width: 72px; height: 72px; font-size: 32px;
  background: color-mix(in srgb, var(--mode-color) 26%, transparent);
  border: 1px solid color-mix(in srgb, var(--mode-color) 45%, transparent);
}
.mode-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mode-name { font-family: var(--font-display); font-size: 18px; font-weight: 800; }
.mode-desc { color: var(--muted); font-size: 12.5px; line-height: 1.6; min-height: 40px; }
.mode-count {
  font-size: 12px; font-weight: 700; color: var(--mode-color);
  padding: 4px 12px; border-radius: 999px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--mode-color) 22%, transparent), color-mix(in srgb, var(--mode-color) 8%, transparent));
  border: 1px solid color-mix(in srgb, var(--mode-color) 32%, transparent);
}

/* ---------- كيف تلعب ---------- */
.how-section { padding: 50px clamp(16px, 4vw, 48px); }
.how-grid {
  max-width: 1000px; margin: 34px auto 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px;
}
.how-card {
  padding: 26px 22px; text-align: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.how-num {
  width: 44px; height: 44px; margin: 0 auto 14px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 22px; font-weight: 800;
  color: #10162f;
  background: linear-gradient(135deg, var(--teal), #7ee7c0);
  border-radius: 50%;
}
.how-card h3 { font-family: var(--font-display); font-size: 18px; margin-bottom: 6px; }
.how-card p { color: var(--muted); font-size: 14px; line-height: 1.7; }

/* ---------- إنجازاتي ---------- */
.stats-section { padding: 50px clamp(16px, 4vw, 48px); }
.stats-grid {
  max-width: 640px; margin: 28px auto 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.stat-card {
  display: grid; place-items: center; gap: 3px;
  padding: 14px 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.stat-icon { font-size: clamp(16px, 4vw, 20px); }
.stat-card strong { font-family: var(--font-display); font-size: clamp(18px, 5vw, 24px); color: var(--yellow); }
.stat-card span:last-child { color: var(--muted); font-size: 10.5px; line-height: 1.3; text-align: center; }

/* ---------- قريبًا ---------- */
.soon-section { padding: 40px clamp(16px, 4vw, 48px) 60px; }
.soon-card {
  max-width: 900px; margin: 0 auto; text-align: center;
  padding: 34px 28px;
  background: linear-gradient(135deg, rgba(63, 131, 248, 0.12), rgba(144, 97, 249, 0.12));
  border: 1px solid rgba(144, 97, 249, 0.25);
  border-radius: 26px;
}
.soon-card h2 { font-family: var(--font-display); font-size: 24px; margin-bottom: 18px; }
.soon-items { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.soon-chip {
  padding: 9px 16px; font-size: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* ---------- التذييل ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 34px clamp(16px, 4vw, 48px);
  text-align: center; color: var(--muted);
  display: grid; gap: 8px;
}
.footer-brand { display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--text); }
.footer-copy { font-size: 12.5px; opacity: 0.7; }
.footer-links a { color: var(--muted); text-decoration: none; font-size: 13.5px; }
.footer-links a:hover { color: var(--yellow); text-decoration: underline; }

/* ---------- الصفحات الفرعية (من نحن / الخصوصية) ---------- */
.page-wrap {
  max-width: 760px; margin: 0 auto;
  padding: 40px clamp(16px, 5vw, 32px) 70px;
  position: relative; z-index: 1;
}
.page-title { font-family: var(--font-display); font-size: clamp(28px, 5vw, 38px); font-weight: 800; }
.page-updated { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.page-card {
  margin-top: 18px; padding: 22px 24px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.page-card h2 { font-family: var(--font-display); font-size: 20px; margin-bottom: 10px; color: var(--yellow); }
.page-card p { line-height: 1.9; color: #d8def5; margin-bottom: 10px; }
.page-card ul { padding-inline-start: 20px; display: grid; gap: 10px; }
.page-card li { line-height: 1.9; color: #d8def5; }
.page-card a { color: var(--teal); }
.contact-line { font-size: 15px; }
.page-links { margin-top: 20px; text-align: center; }
.page-links a { color: var(--muted); }
.btn-back {
  display: inline-block; margin-top: 26px;
  padding: 13px 26px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 14px; color: var(--text); text-decoration: none;
  font-family: var(--font-display); font-weight: 700;
}
.btn-back:hover { background: #33417a; }

/* ============================================================
   شاشة اللعب
   ============================================================ */
.quiz-wrap {
  max-width: 680px; margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 32px) 60px;
  display: grid; justify-items: center; gap: 18px;
  min-height: 100vh; align-content: start;
}
.quiz-top { display: flex; align-items: center; gap: 14px; width: 100%; padding-top: 6px; }
.profile-top { padding: 16px clamp(16px, 4vw, 48px) 0; }
.quiz-progress {
  flex: 1; height: 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); overflow: hidden;
}
.quiz-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--yellow));
  border-radius: 999px;
  transition: width 0.4s ease;
}
.quiz-score {
  min-width: 64px; text-align: center;
  font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--yellow);
  background: rgba(255, 176, 32, 0.1);
  border: 1px solid rgba(255, 176, 32, 0.3);
  padding: 6px 14px; border-radius: 12px;
}
.quiz-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.quiz-cat {
  padding: 6px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 700;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line);
}
.quiz-counter { color: var(--muted); font-size: 14px; }
.quiz-streak { color: var(--coral); font-weight: 700; font-size: 14px; min-height: 20px; }

/* مؤقت دائري */
.timer-ring { position: relative; width: 108px; height: 108px; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.08); stroke-width: 8; }
.ring-fg {
  fill: none; stroke: var(--teal); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 276.5; stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.timer-ring.warn .ring-fg { stroke: var(--yellow); }
.timer-ring.danger .ring-fg { stroke: var(--coral); }
.timer-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 36px; font-weight: 800;
}
.timer-ring.danger .timer-num { color: var(--coral); animation: tickPulse 1s infinite; }
@keyframes tickPulse { 50% { transform: scale(1.15); } }

.question-text {
  font-family: var(--font-display);
  font-size: clamp(21px, 4vw, 27px);
  font-weight: 700; text-align: center; line-height: 1.6;
  min-height: 96px; display: grid; place-items: center;
}

.answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; width: 100%; }
.answer-btn {
  position: relative;
  padding: 18px 16px; min-height: 72px;
  background: var(--card);
  border-radius: 14px;
  font-size: 17px; font-weight: 600; line-height: 1.5;
  display: grid; place-items: center; text-align: center;
}
.answer-btn:hover:not(:disabled) { background: var(--card-2); }
.answer-btn:disabled { cursor: default; }
.answer-btn.correct {
  background: rgba(49, 196, 141, 0.28);
  color: #d3fbea;
  animation: popIn 0.3s;
}
.answer-btn.wrong {
  background: rgba(240, 82, 82, 0.26);
  color: #ffd7d7;
  animation: shake 0.35s;
}
.answer-btn.faded { opacity: 0.45; }
@keyframes popIn { 0% { transform: scale(0.96); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* وسائط السؤال: علم أو إيموجي */
.q-media { display: grid; place-items: center; }
.q-media img.flag-img {
  width: min(320px, 78vw);
  border-radius: 14px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 28px rgba(5, 9, 26, 0.5);
}
.q-media .q-emoji {
  font-size: clamp(48px, 10vw, 72px);
  letter-spacing: 8px;
  direction: ltr;
}

/* صح أم خطأ */
.answers-grid.tf-grid { grid-template-columns: 1fr 1fr; max-width: 440px; margin: 0 auto; }
.answers-grid.tf-grid .answer-btn { font-size: 22px; font-family: var(--font-display); min-height: 86px; }

/* ترتيب الحروف */
.scramble-area { display: grid; gap: 18px; justify-items: center; width: 100%; }
.scramble-slots { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; direction: rtl; }
.scramble-slot {
  width: 52px; height: 58px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 26px; font-weight: 800;
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  transition: 0.15s;
}
.scramble-slot.filled {
  border-style: solid; border-color: var(--violet);
  background: rgba(144, 97, 249, 0.15);
  cursor: pointer;
}
.scramble-slot.good { border-color: var(--teal); background: rgba(49, 196, 141, 0.2); color: #b8f5dd; }
.scramble-slots.bad .scramble-slot { border-color: var(--coral); animation: shake 0.35s; }
.scramble-tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; direction: rtl; }
.scramble-tile {
  width: 54px; height: 58px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 26px; font-weight: 800;
  background: var(--card-2);
  border-radius: 12px;
}
.scramble-tile:hover:not(:disabled) { filter: brightness(1.12); }
.scramble-tile:disabled { opacity: 0.25; cursor: default; }
.scramble-clear { padding: 10px 22px; }
.scramble-hint { color: var(--muted); font-size: 15px; }

/* اكتب الإجابة */
.typed-area { display: flex; gap: 10px; width: 100%; max-width: 480px; flex-wrap: wrap; justify-content: center; }
.typed-input {
  flex: 1; min-width: 220px;
  padding: 16px 20px;
  font-family: var(--font-body); font-size: 18px; color: var(--text);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  outline: none;
  text-align: center;
  transition: border-color 0.15s;
}
.typed-input:focus { border-color: var(--yellow); }
.typed-input.bad { border-color: var(--coral); animation: shake 0.35s; }
.typed-input.good { border-color: var(--teal); background: rgba(49, 196, 141, 0.12); }
.typed-submit { padding: 14px 26px; font-size: 17px; border-radius: 14px; }

.speed-bonus {
  min-height: 26px;
  font-family: var(--font-display); font-weight: 800; font-size: 17px;
  color: var(--teal);
}
.speed-bonus.show { animation: riseFade 1s forwards; }
@keyframes riseFade {
  0% { opacity: 0; transform: translateY(8px); }
  25% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* ============================================================
   شاشة النتيجة
   ============================================================ */
.result-wrap {
  max-width: 560px; margin: 0 auto;
  padding: 50px clamp(16px, 4vw, 32px) 70px;
  display: grid; justify-items: center; gap: 16px; text-align: center;
}
.result-emoji { font-size: 74px; animation: popIn 0.5s; }
.result-title { font-family: var(--font-display); font-size: clamp(28px, 5vw, 38px); font-weight: 800; }
.result-sub { color: var(--muted); font-size: 17px; }
.result-score-card {
  display: flex; gap: 12px; width: 100%; justify-content: center; flex-wrap: wrap;
  margin-top: 10px;
}
.rs-item {
  flex: 1; min-width: 130px;
  display: grid; gap: 4px; place-items: center;
  padding: 20px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
}
.rs-item strong { font-family: var(--font-display); font-size: 32px; color: var(--yellow); }
.rs-item span { color: var(--muted); font-size: 13px; }
.result-squares { font-size: 26px; letter-spacing: 3px; direction: ltr; }
.new-record {
  padding: 10px 22px;
  background: rgba(255, 176, 32, 0.12);
  border: 1px solid rgba(255, 176, 32, 0.4);
  color: var(--yellow);
  font-family: var(--font-display); font-weight: 800;
  border-radius: 999px;
  animation: popIn 0.5s;
}
.result-actions { display: grid; gap: 18px; width: 100%; max-width: 380px; margin-top: 12px; justify-items: center; }
.btn-share {
  --candy-edge: #0d6b3c;
  padding: 14px 22px;
  background: linear-gradient(180deg, #7ee8a8 0%, #25d366 55%, #128c4e 100%);
  border: 3px solid var(--candy-edge);
  font-family: var(--font-display); font-size: 16px; font-weight: 800;
}
.btn-secondary {
  --candy-edge: #1f4f9e;
  padding: 12px 18px;
  background: linear-gradient(180deg, #bcd9ff 0%, #3f83f8 55%, #2f6ad0 100%);
  border: 3px solid var(--candy-edge);
  font-size: 16px; font-weight: 800;
}
.result-actions-row { display: flex; gap: 18px; justify-content: center; }

#confettiCanvas { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

/* ============================================================
   الملف الشخصي والصور الرمزية
   ============================================================ */
/* البروفايل يبقى إطارًا دائريًا بسيطًا حول صورة اللاعب — بلا خلفية حلوى
   ولا لمعان زجاجي فوقها، لأنها هي نفسها الصورة الشخصية لا زر عادي */
.profile-btn {
  padding: 0; position: relative;
  background: none !important; border: none !important; box-shadow: none !important;
  -webkit-text-stroke: 0; text-shadow: none;
}
.profile-btn::before { display: none; }
.profile-btn svg { width: 100%; height: 100%; display: block; }
/* حلقة نابضة بـ transform+opacity فقط (لا box-shadow) كي تبقى رخيصة حتى
   لو استمرت طويلًا بانتظار إنشاء اللاعب لملفه الشخصي */
.profile-btn.attention::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  border: 2px solid rgba(255, 176, 32, 0.65);
  animation: profilePulse 2s ease-out infinite;
  pointer-events: none;
}
@keyframes profilePulse {
  0%   { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.45); opacity: 0; }
}

.stats-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.btn-edit-profile { padding: 10px 18px; font-size: 14px; }
.stats-avatar { width: 52px; height: 52px; display: none; }
.stats-avatar.show { display: block; }
.stats-avatar svg { width: 100%; height: 100%; display: block; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: 18px;
  /* بلا backdrop-filter: طمس حي مكلف، ولون أغمق وأعتم يعطي نفس إحساس العزل بلا تكلفة */
  background: rgba(6, 10, 26, 0.88);
}
.modal-overlay[hidden] { display: none; }
.modal {
  position: relative; overflow-x: hidden; overflow-y: auto;
  width: 100%; max-width: 520px;
  max-height: 90vh;
  padding: 30px 26px;
  background: linear-gradient(160deg, #232e5c, #1a2348);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  display: grid; gap: 16px; justify-items: center;
  animation: modalIn 0.25s ease;
}
/* محتوى النافذة يمرر داخليًا بينما تبقى بقعة التوهج والحواف الدائرية غير مقصوصة */
.modal > * { position: relative; }
.modal::before {
  content: ""; position: absolute; top: -60px; inset-inline-start: 50%; translate: -50% 0;
  width: 260px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 176, 32, 0.22), transparent 70%);
  pointer-events: none;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
/* position تُعاد تأكيدها آخر الملف (بعد .icon-btn) لأن كلا القاعدتين بنفس
   التحديد وقاعدة الأزرار الموحّدة اللاحقة كانت تكسر تثبيت الزاوية هنا */
.modal-close { top: 14px; inset-inline-start: 14px; }
.modal-title { font-family: var(--font-display); font-size: 26px; font-weight: 800; }
.modal-sub { color: var(--muted); font-size: 14px; text-align: center; line-height: 1.7; max-width: 380px; }
.profile-name { width: 100%; max-width: 320px; }
.profile-name-error {
  color: var(--coral); font-size: 14px; font-weight: 700;
  margin: -6px auto 4px; max-width: 320px;
}

/* ---------- مصمّم الشخصية: بطاقة دائرية حقيقية + تبويب فئة واحد نشط ---------- */
.avatar-stage { position: relative; width: 152px; margin: 2px auto 4px; }
.avatar-preview { border-radius: 50%; overflow: hidden; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4); }
.avatar-preview svg { width: 100%; display: block; }
/* حركة خفيفة تُشعر الشخصية بالحياة — مجموعة غلاف مستقلة عن تحويل التكبير
   الذي يضبطه الكود، فلا يتعارضان. لا تُطبَّق على المعاينات المصغّرة في الشريط */
.avatar-preview .avatar-idle { animation: avatarIdle 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 90%; }
@keyframes avatarIdle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-1.5px) rotate(1deg); }
}
@media (prefers-reduced-motion: reduce) {
  .avatar-preview .avatar-idle { animation: none; }
}
.randomize-btn {
  position: absolute; bottom: -2px; inset-inline-end: -6px;
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(160deg, #9061f9, #6d3fd1);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
  font-size: 18px;
  display: grid; place-items: center;
  transition: transform 0.15s;
}
.randomize-btn:hover { transform: scale(1.08) rotate(-8deg); }
.zoom-controls {
  position: absolute; bottom: -2px; inset-inline-start: -6px;
  display: flex; flex-direction: column; gap: 4px;
}
.zoom-btn {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  font-size: 11px;
  display: grid; place-items: center;
}
.zoom-btn:hover { background: rgba(255, 255, 255, 0.18); }

.picker-tabs { display: flex; gap: 8px; width: 100%; justify-content: center; flex-wrap: wrap; }
.tab-btn {
  width: 44px; height: 44px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--line);
  color: inherit;
  display: grid; place-items: center;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.3); }
.tab-btn.active {
  border-color: var(--yellow);
  background: rgba(255, 176, 32, 0.14);
  box-shadow: 0 0 0 3px rgba(255, 176, 32, 0.22);
}

.picker-strip {
  display: flex; gap: 8px; width: 100%; max-width: 420px; margin: 0 auto;
  overflow-x: auto; padding: 4px 4px 8px;
  scroll-snap-type: x proximity;
}
.strip-swatch {
  flex-shrink: 0; scroll-snap-align: start;
  width: 50px; height: 50px; padding: 3px;
  border-radius: 50%; overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid var(--line);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.strip-swatch svg { width: 100%; height: 100%; display: block; }
.strip-swatch:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.3); }
.strip-swatch.selected {
  border-color: var(--yellow);
  background: rgba(255, 176, 32, 0.12);
  box-shadow: 0 0 0 3px rgba(255, 176, 32, 0.22);
}
.profile-save { width: 100%; max-width: 320px; }

@media (max-width: 480px) {
  .strip-swatch { width: 44px; height: 44px; }
}

/* ============================================================
   نظام الأزرار "الحلوى اللامعة" (Glossy 3D) — تدرّج عمودي فاتح لغامق،
   بقعة لمعان زجاجية أعلى الزر، وعمق حقيقي (ظل داخلي + خارجي)، بنفس
   طراز أزرار ألعاب الجوال الجاهزة — يناسب موقعًا سيتحول لتطبيق
   ============================================================ */
.btn-cta, .btn-secondary, .btn-play, .btn-daily, .btn-share, .btn-friends,
.diff-btn, .scramble-tile, .typed-submit, .answer-btn, .icon-btn {
  position: relative;
  overflow: hidden;
  font-family: var(--font-display);
  /* نص أبيض بمخطط داكن من نفس عائلة لون الزر عبر ظلال متعددة الاتجاهات
     (لا text-stroke) — الحروف العربية متصلة ودقيقة التفاصيل (نقاط، وصلات
     رفيعة) و-webkit-text-stroke يشوّهها أو يخفيها بدل رسم مخطط نظيف حولها */
  color: #fff;
  font-weight: 800;
  text-shadow:
    -1.5px -1.5px 0 var(--candy-edge, #000),
    1.5px -1.5px 0 var(--candy-edge, #000),
    -1.5px 1.5px 0 var(--candy-edge, #000),
    1.5px 1.5px 0 var(--candy-edge, #000),
    0 3px 0 var(--candy-edge, #000);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.5),
    inset 0 -9px 12px rgba(0, 0, 0, 0.18),
    0 6px 0 var(--candy-edge, rgba(0, 0, 0, 0.35)),
    0 10px 18px rgba(5, 9, 26, 0.35);
  transition: transform 0.13s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.13s ease,
              background 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}
/* بقعة لمعان بيضاوية أعلى يسار كل زر — التوقيع البصري لأسلوب "الحلوى" */
.btn-cta::before, .btn-secondary::before, .btn-play::before, .btn-daily::before,
.btn-share::before, .btn-friends::before, .diff-btn::before, .scramble-tile::before,
.typed-submit::before, .answer-btn::before, .icon-btn::before {
  content: ""; position: absolute; top: 8%; inset-inline-start: 10%;
  width: 55%; height: 32%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
  border-radius: 50%;
  pointer-events: none;
}
/* تفاوت الاستدارة حسب دور الزر — يوضع بعد القاعدة الموحّدة مباشرة كي
   يتغلّب عليها مهما كان موضع تعريف كل زر في الملف */
.btn-secondary, .typed-submit, .btn-share, .btn-cta, .btn-play, .btn-daily, .btn-friends { border-radius: 999px; }
.answer-btn, .diff-btn { border-radius: 16px; }
.scramble-tile { border-radius: 13px; }
.icon-btn { border-radius: 50%; }

/* التحويم: ارتفاع بسيط + سطوع أعلى بقليل — يوحي أن الزر نهض قليلًا */
.btn-cta:hover, .btn-secondary:hover, .btn-play:hover, .btn-daily:hover, .btn-share:hover,
.btn-friends:hover, .diff-btn:hover, .scramble-tile:hover:not(:disabled),
.typed-submit:hover, .answer-btn:hover:not(:disabled), .icon-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

/* أزرار الإجابات الملونة (لكل زر لون مبهج مختلف) */
.answers-grid:not(.tf-grid) .answer-btn {
  font-weight: 700;
  font-size: 17.5px;
}
.answers-grid:not(.tf-grid) .answer-btn:nth-child(1) { --candy-edge: #a12020; background: linear-gradient(180deg, #ffb0b0 0%, #f05252 55%, #d03030 100%); border-color: var(--candy-edge); }
.answers-grid:not(.tf-grid) .answer-btn:nth-child(2) { --candy-edge: #1f4f9e; background: linear-gradient(180deg, #a8cbff 0%, #3f83f8 55%, #2f6ad0 100%); border-color: var(--candy-edge); }
.answers-grid:not(.tf-grid) .answer-btn:nth-child(3) { --candy-edge: #a06800; background: linear-gradient(180deg, #ffd98a 0%, #e8a412 55%, #b87e0a 100%); border-color: var(--candy-edge); }
.answers-grid:not(.tf-grid) .answer-btn:nth-child(4) { --candy-edge: #157950; background: linear-gradient(180deg, #8ff0c0 0%, #23a873 55%, #157950 100%); border-color: var(--candy-edge); }

/* نمط الخريطة — أسلوب quiz.com: بلا إطار، مندمجة مع خلفية الموقع */
.quiz-wrap.wide { max-width: 1160px; }
.map-area { display: grid; gap: 14px; width: 100%; justify-items: center; }
.map-frame { position: relative; width: 100%; }
.map-wrap {
  width: 100%;
  background: #23b3c7; /* محيط فيروزي فاتح بأسلوب quiz.com */
  border-radius: 22px;
  overflow: hidden;
}
.map-wrap svg {
  width: 100%;
  height: auto;
  max-height: 62vh;
  display: block;
  touch-action: none;
}
.map-wrap svg path {
  fill: #ddf3e8; /* يابسة بلون النعناع الفاتح */
  stroke: #8fc9b4;
  stroke-width: 0.5;
  cursor: pointer;
  transition: fill 0.1s;
}
.map-wrap svg path:hover { fill: #b5e7d1; }
.map-wrap svg path.map-selected {
  fill: #ffb020 !important;
  stroke: #b45309 !important;
  stroke-width: 1 !important;
}
.map-wrap svg path.map-correct { fill: #22c55e !important; stroke: #14532d !important; }
.map-wrap svg path.map-wrong { fill: #ef4444 !important; stroke: #7f1d1d !important; }
/* الدول المدموجة (المغرب + صحراؤه، وفلسطين كاملة): تحتفظ بحدودها الطبيعية
   مثل بقية الدول حتى لا تندمج مع الجيران، وتتوحّد في اللون عند التفاعل
   لتُعامَل كقطعة واحدة (ضغطة واحدة تحدّدها كلها) */
.map-wrap svg path.map-merged.map-hovergroup { fill: #b5e7d1 !important; }
.map-wrap svg path.map-merged.map-selected { fill: #ffb020 !important; stroke: #b45309 !important; }
.map-wrap svg path.map-merged.map-correct { fill: #22c55e !important; stroke: #14532d !important; }
.map-wrap svg path.map-merged.map-wrong { fill: #ef4444 !important; stroke: #7f1d1d !important; }
.map-next {
  background: linear-gradient(135deg, #23b3c7, #0e8ca0);
  color: #fff;
}
.map-controls {
  position: absolute;
  top: 8px; inset-inline-end: 8px;
  display: grid; gap: 8px;
}
.map-zoom-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 18px;
  background: rgba(34, 45, 85, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  transition: 0.15s;
}
.map-zoom-btn:hover { background: rgba(53, 66, 116, 0.95); transform: scale(1.08); }
.map-confirm { padding: 13px 36px; }
.map-confirm:disabled { opacity: 0.45; cursor: default; }
.map-loading { padding: 60px 20px; color: var(--muted); font-weight: 700; font-size: 16px; text-align: center; }

/* من الأكبر؟ — خياران كبيران متقابلان */
.answers-grid.cmp-grid { grid-template-columns: 1fr 1fr; max-width: 560px; margin: 0 auto; }
.answers-grid.cmp-grid .answer-btn {
  min-height: 96px;
  font-size: 18px;
  font-family: var(--font-display);
  line-height: 1.5;
}

/* اكشف الكذبة: ثلاث عبارات طويلة بعمود واحد */
.answers-grid.lie-grid { grid-template-columns: 1fr; max-width: 560px; margin: 0 auto; }
.answers-grid.lie-grid .answer-btn {
  font-size: 15.5px;
  min-height: 62px;
  line-height: 1.7;
  padding: 14px 18px;
}

/* صح أم خطأ: أخضر وأحمر كبيران */
.answers-grid.tf-grid .answer-btn:nth-child(1) { --candy-edge: #157950; background: linear-gradient(180deg, #8ff0c0 0%, #23a873 55%, #157950 100%); border-color: var(--candy-edge); }
.answers-grid.tf-grid .answer-btn:nth-child(2) { --candy-edge: #a12020; background: linear-gradient(180deg, #ffb0b0 0%, #f05252 55%, #d03030 100%); border-color: var(--candy-edge); }

/* حالات الإجابة فوق الألوان الجديدة */
.answers-grid .answer-btn.correct {
  background: #31c48d !important;
  color: #06281c !important;
  text-shadow: none;
  box-shadow: 0 0 0 4px rgba(49, 196, 141, 0.35);
}
.answers-grid .answer-btn.wrong {
  background: #b91c1c !important;
  color: #fff !important;
}
.answers-grid .answer-btn.faded { opacity: 0.35; filter: grayscale(0.5); }

/* حروف الترتيب بطابع مكعبات اللعب */
.scramble-tile {
  --candy-edge: #5c33b8;
  background: linear-gradient(180deg, #cbb0ff 0%, #9061f9 55%, #7c4ce0 100%);
  border: 3px solid var(--candy-edge);
}
.scramble-tile:disabled { opacity: 0.2; }

/* بطاقات التحديات والتصنيفات: ميلان مرح عند التمرير */
.mode-card:hover { transform: translateY(-6px) rotate(-1.2deg) scale(1.03); }
.cat-card:hover { transform: translateY(-6px) rotate(1deg); }

/* ---------- المستوى والخبرة ---------- */
.level-card {
  max-width: 900px; margin: 30px auto 0;
  display: flex; align-items: center; gap: 20px;
  padding: 22px 26px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.level-icon {
  width: 76px; height: 76px;
  display: grid; place-items: center;
  background: rgba(255, 176, 32, 0.1);
  border-radius: 18px;
  flex-shrink: 0;
}
.level-icon img { width: 58px; height: 58px; object-fit: contain; }
.level-info { flex: 1; display: grid; gap: 8px; }
.level-name { font-family: var(--font-display); font-size: 21px; font-weight: 800; color: var(--yellow); }
.level-bar {
  height: 14px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.level-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--yellow), #ff8a3d);
  border-radius: 999px;
  transition: width 0.6s ease;
}
.level-xp { color: var(--muted); font-size: 13.5px; }

/* ---------- الشارات ---------- */
.badges-title {
  max-width: 900px; margin: 40px auto 0;
  font-family: var(--font-display); font-size: 22px; font-weight: 800;
  text-align: center;
}
.badge-count {
  color: var(--yellow); font-size: 14px; font-weight: 700;
  background: rgba(255, 176, 32, 0.12);
  padding: 3px 12px; border-radius: 999px;
}
.badges-progress {
  max-width: 520px; margin: 16px auto 0;
  height: 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); overflow: hidden;
}
.badges-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--yellow), #ff8a3d);
  border-radius: 999px; transition: width 0.7s ease;
}
.badges-grid {
  max-width: 940px; margin: 26px auto 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 16px;
}
.badges-more {
  display: block; margin: 20px auto 0; padding: 12px 28px;
  font-family: var(--font-body); font-size: 14px; font-weight: 700; color: var(--yellow);
  background: rgba(255, 176, 32, 0.1); border: 1px solid rgba(255, 176, 32, 0.3);
  border-radius: 999px;
}
.badges-more:hover { background: rgba(255, 176, 32, 0.18); }

/* ---------- الحساب السحابي ---------- */
.cloud-card {
  max-width: 460px; margin: 44px auto 36px;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(63, 131, 248, 0.09), rgba(144, 97, 249, 0.09));
  border: 1px solid var(--line);
  border-radius: 16px;
}
.cloud-card-icon { font-size: 30px; flex-shrink: 0; }
.cloud-card-body { flex: 1; min-width: 0; }
.account-state { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cloud-card-title { color: var(--muted); font-size: 13px; line-height: 1.6; flex: 1; min-width: 160px; }
.account-status { font-size: 14px; font-weight: 700; color: var(--teal); }
.cloud-modal { max-width: 340px; text-align: center; }
.cloud-modal-brand { font-size: 38px; }
.cloud-modal #googleBtnContainer { display: flex; justify-content: center; margin-top: 4px; }
.btn-guest {
  background: none; border: none; padding: 6px; cursor: pointer;
  font-family: var(--font-body); font-size: 14px; font-weight: 700;
  color: var(--muted); text-decoration: underline;
}
.btn-guest:hover { color: var(--text); }
.badge-medal {
  padding: 18px 12px 14px; text-align: center;
  border-radius: 18px;
  display: grid; gap: 8px; justify-items: center;
}
.badge-medal.earned { background: rgba(255, 176, 32, 0.07); border: 1px solid rgba(255, 176, 32, 0.28); }
.badge-medal.locked { background: rgba(255, 255, 255, 0.02); border: 1px solid var(--line); }
/* إطار مربّع مدوّر يحتضن صورة الشارة: توهّج ذهبي للمكتسبة، تعتيم للمقفلة */
.badge-disc {
  width: 68px; height: 68px; border-radius: 18px;
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
}
.badge-medal.earned .badge-disc {
  border: 2px solid #ffd76a;
}
.badge-medal.locked .badge-disc {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
}
.badge-glyph { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge-medal.earned .badge-glyph { filter: drop-shadow(0 1px 1px rgba(120, 60, 0, 0.4)); }
.badge-medal.locked .badge-glyph { opacity: 0.38; filter: grayscale(1); }
.badge-name { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; }
.badge-medal.earned .badge-name { color: var(--yellow); }
.badge-medal.locked .badge-name { color: var(--muted); }
.badge-desc { color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.badge-medal.locked .badge-desc { opacity: 0.75; }

/* ============================================================
   لوحة الصدارة
   ============================================================ */
.lb-section { padding: 50px clamp(16px, 4vw, 48px) 16px; }
.lb-list { max-width: 640px; margin: 30px auto 0; display: grid; gap: 10px; }
.lb-empty, .lb-guest-hint {
  max-width: 500px; margin: 30px auto 0; text-align: center;
  color: var(--muted); font-size: 14px; line-height: 1.8;
}
.lb-row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  opacity: 0; transform: translateY(10px);
  animation: lbIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes lbIn { to { opacity: 1; transform: none; } }
.lb-rank {
  width: 30px; flex-shrink: 0; text-align: center;
  font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--muted);
}
.lb-row.lb-top .lb-rank { font-size: 22px; }
.lb-avatar { width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; overflow: hidden; }
.lb-avatar svg { width: 100%; height: 100%; display: block; }
.lb-info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.lb-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-level { font-size: 11px; color: var(--muted); }
.lb-xp { font-family: var(--font-display); font-weight: 800; color: var(--yellow); font-size: 15px; flex-shrink: 0; white-space: nowrap; }
/* توهّج ذهبي/فضي/برونزي لأصحاب المراكز الثلاثة الأولى — لمسة احتفالية بلا
   ازدحام (تدرّج خفيف + إطار ملوّن فقط، بلا صور أو حركة إضافية) */
.lb-row.rank-1 { border-color: rgba(255, 215, 80, 0.55); background: linear-gradient(120deg, rgba(255, 215, 80, 0.14), var(--card) 65%); box-shadow: 0 4px 16px rgba(255, 215, 80, 0.16); }
.lb-row.rank-2 { border-color: rgba(205, 215, 230, 0.5); background: linear-gradient(120deg, rgba(205, 215, 230, 0.12), var(--card) 65%); }
.lb-row.rank-3 { border-color: rgba(222, 150, 90, 0.5); background: linear-gradient(120deg, rgba(222, 150, 90, 0.12), var(--card) 65%); }
/* بطاقتك مثبَّتة أسفل الشاشة دومًا أثناء تصفّح القائمة — تعرف مركزك فورًا
   بلا حاجة للتمرير حتى تجديها بين عشرات الأسماء */
.lb-me-dock {
  position: sticky; bottom: 0; z-index: 5;
  padding: 12px clamp(16px, 4vw, 48px) calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
}
/* بطاقتك أكبر بوضوح من باقي الصفوف — أول شي تلقاه عينك بأسفل الشاشة */
.lb-row.lb-me {
  max-width: 640px; margin: 0 auto;
  padding: 16px 20px; gap: 16px;
  border: 3px solid var(--yellow);
  background: linear-gradient(120deg, rgba(255, 176, 32, 0.18), var(--card) 70%);
  box-shadow: 0 10px 28px rgba(255, 176, 32, 0.32);
  opacity: 1; transform: none; animation: none;
}
.lb-row.lb-me .lb-avatar { width: 56px; height: 56px; }
.lb-row.lb-me .lb-rank { font-size: 24px; width: 36px; }
.lb-row.lb-me .lb-name { font-size: 17px; }
.lb-row.lb-me .lb-level { font-size: 12.5px; }
.lb-row.lb-me .lb-xp { font-size: 18px; }

/* مكافآت شاشة النتيجة */
.xp-gain {
  font-family: var(--font-display); font-weight: 800; font-size: 18px;
  color: var(--yellow);
  min-height: 24px;
}
.level-up {
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--yellow), #ff8a3d);
  color: #10162f;
  font-family: var(--font-display); font-weight: 800; font-size: 17px;
  border-radius: 999px;
  animation: popIn 0.5s;
  box-shadow: 0 8px 24px rgba(255, 176, 32, 0.4);
}
.new-badges { display: grid; gap: 8px; justify-items: center; }
.new-badge-chip {
  padding: 9px 20px;
  background: rgba(144, 97, 249, 0.15);
  border: 1px solid rgba(144, 97, 249, 0.45);
  border-radius: 999px;
  font-size: 15px;
  animation: popIn 0.45s;
}
.new-badge-chip strong { color: #c9adff; }
.new-badge-icon { width: 22px; height: 22px; border-radius: 6px; vertical-align: middle; margin-inline-end: 4px; }

/* ---------- قميص النادي ---------- */
.jersey-box {
  width: min(230px, 62vw);
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.jersey-svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45)); }

/* ---------- بوابة كرة القدم ---------- */
.fc-modal { max-width: 460px; }
.fc-grid { display: grid; gap: 14px; width: 100%; }
.fc-btn {
  padding: 20px 18px;
  border-radius: 20px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 20px; font-weight: 800;
  display: grid; gap: 6px; justify-items: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  border-bottom: 5px solid rgba(0, 0, 0, 0.35);
  transition: transform 0.15s, filter 0.15s;
}
.fc-btn:hover { transform: translateY(-3px) scale(1.02); filter: brightness(1.12); }
.fc-btn:active { transform: translateY(3px); border-bottom-width: 2px; }
.fc-btn small { font-size: 12.5px; opacity: 0.92; font-family: var(--font-body); font-weight: 600; }
.fc-jersey { background: linear-gradient(150deg, #16a34a, #0f7a37); }
.fc-player { background: linear-gradient(150deg, #f59e0b, #d97d06); }
.fc-quiz   { background: linear-gradient(150deg, #3b82f6, #2563c9); }

/* ---------- نافذة اختيار الصعوبة ---------- */
.diff-modal { max-width: 460px; }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; width: 100%; }
.diff-btn {
  padding: 18px 14px;
  font-size: 19px;
  font-weight: 800;
  display: grid; gap: 6px; justify-items: center;
}
.diff-btn small { font-size: 12px; opacity: 0.9; font-family: var(--font-body); font-weight: 600; }
.diff-easy { --candy-edge: #157950; background: linear-gradient(180deg, #8ff0c0 0%, #31c48d 55%, #1f9c6d 100%); border: 3px solid var(--candy-edge); }
.diff-mid  { --candy-edge: #1f4f9e; background: linear-gradient(180deg, #a8cbff 0%, #3f83f8 55%, #2f6ad0 100%); border: 3px solid var(--candy-edge); }
.diff-hard { --candy-edge: #a12020; background: linear-gradient(180deg, #ffb0b0 0%, #f05252 55%, #d03030 100%); border: 3px solid var(--candy-edge); }
.diff-mix  { --candy-edge: #5c33b8; background: linear-gradient(180deg, #cbb0ff 0%, #9061f9 55%, #7c4ce0 100%); border: 3px solid var(--candy-edge); }

@media (max-width: 420px) {
  .diff-grid { grid-template-columns: 1fr; }
}
.practice-toggle {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px; padding: 12px 16px; width: 100%;
  background: rgba(144, 97, 249, 0.1); border: 1px solid rgba(144, 97, 249, 0.3);
  border-radius: 14px; font-size: 13.5px; color: var(--text); cursor: pointer;
}
.practice-toggle input { width: 18px; height: 18px; accent-color: var(--violet); flex-shrink: 0; cursor: pointer; }

/* ============================================================
   استجابة الجوال
   ============================================================ */
@media (max-width: 640px) {
  .topnav { display: none; }
  /* التحديات الخاصة: شبكة عمودان بدل عمود طويل — تصفح أسرع وتمرير أقل */
  .modes-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  /* ساحة التحدي (التصنيفات العادية، أكثر عددًا): تمرير أفقي بدل عمود طويل —
     سحب جانبي واحد بدل عشرات الأسطر الرأسية، مع تلاشٍ خفيف عند الحافتين */
  .cats-grid {
    display: flex; flex-wrap: nowrap; gap: 14px;
    overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    padding: 4px 4px 10px; margin: 34px -4px 0;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, transparent, black 18px, black calc(100% - 18px), transparent);
  }
  .cats-grid::-webkit-scrollbar { display: none; }
  .cats-grid .cat-card { flex: 0 0 152px; scroll-snap-align: start; }
  .cat-card, .mode-card { padding: 16px 12px; }
  .mode-icon { width: 58px; height: 58px; }
  .cat-name, .mode-name { font-size: 16px; }
  .cat-desc, .mode-desc { font-size: 11.5px; min-height: 0; }
  .icon-btn { width: 44px; height: 44px; }
  /* الخريطة تمتد لكامل عرض الشاشة لتكبر مساحة اللمس */
  .map-wrap { border-radius: 14px; }
  .quiz-wrap.wide { padding-inline: 8px; }
  .map-zoom-btn { width: 46px; height: 46px; }
  .hero { padding-top: 34px; }
  .hero-ctas { flex-direction: column; align-items: stretch; }
  .btn-daily { justify-content: center; }
  .daily-card { flex-direction: column; text-align: center; }
  .daily-right { flex-direction: column; }
  .daily-left { width: 100%; justify-content: center; }
  .answers-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 26px; }

  /* ===== شاشة اللعب على الجوال: السؤال والإجابات في شاشة واحدة بلا تمرير ===== */
  /* رأس الصفحة نفسه، مصغّرًا: نفس عناصر الحاسوب بارتفاع أقل ثلثًا */
  .topbar { padding: 7px 12px; gap: 10px; }
  .brand-mark { width: 32px; height: 32px; font-size: 20px; border-radius: 10px; }
  .brand-name { font-size: 20px; }
  .icon-btn { width: 38px; height: 38px; font-size: 16px; }
  /* الأزرار تُدفع إلى الطرف المقابل للشعار (يسار الشاشة في العربية) */
  .profile-btn { padding: 0; margin-inline-start: auto; }
  .quiz-wrap { padding: 8px 12px 20px; gap: 8px; }
  .quiz-top { padding-top: 0; gap: 10px; }
  .quiz-meta { gap: 8px; font-size: 13px; }
  .quiz-cat { padding: 4px 10px; font-size: 12.5px; }
  .quiz-counter, .quiz-streak { font-size: 12.5px; }
  .timer-ring { width: 64px; height: 64px; }        /* بدل 108 */
  .timer-num { font-size: 24px; }
  .question-text { min-height: 0; font-size: 19px; line-height: 1.5; }
  .q-media img.flag-img { width: min(165px, 46vw); }
  .q-media .q-emoji { font-size: 42px; letter-spacing: 4px; }
  .answers-grid { gap: 9px; }
  .answer-btn { min-height: 48px; padding: 10px 14px; font-size: 16px; }
  .answers-grid.tf-grid .answer-btn { min-height: 62px; font-size: 19px; }
  .answers-grid.cmp-grid .answer-btn { min-height: 68px; font-size: 16px; }
  .answers-grid.lie-grid .answer-btn { min-height: 54px; font-size: 14px; padding: 10px 12px; }
  .speed-bonus { min-height: 20px; font-size: 15px; }
  .jersey-box { width: min(160px, 46vw); padding: 6px; }
  .scramble-slot, .scramble-tile { width: 46px; height: 50px; font-size: 22px; }
  .map-wrap svg { max-height: 46vh; }
}

/* ============================================================
   اللعب مع الأصدقاء — الغرف المباشرة
   ============================================================ */
.btn-friends {
  --candy-edge: #43158c;
  padding: 14px 26px;
  background: linear-gradient(180deg, #c9aaff 0%, #7c3aed 55%, #5b21b6 100%);
  border: 3px solid var(--candy-edge);
  color: #24063f;
  font-family: var(--font-display); font-size: 17px; font-weight: 800;
}

.room-wrap {
  position: relative;
  max-width: 620px; margin: 0 auto;
  padding: 20px clamp(14px, 4vw, 28px) 60px;
  display: grid; gap: 14px;
}
.room-wrap section { display: grid; gap: 14px; justify-items: center; }
.room-back { justify-self: start; background: none; color: var(--muted); font-size: 15px; padding: 6px 0; }
.room-title { font-family: var(--font-display); font-size: clamp(24px, 5vw, 32px); font-weight: 800; text-align: center; }
.room-sub { color: var(--muted); text-align: center; line-height: 1.8; max-width: 420px; }
.room-h3 { font-family: var(--font-display); font-size: 19px; }
.room-note { color: var(--muted); font-size: 14.5px; text-align: center; min-height: 20px; }
.room-big { width: 100%; max-width: 360px; }
.room-label { color: var(--muted); font-size: 14px; }

.room-or { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 360px; color: var(--muted); }
.room-or::before, .room-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.code-input {
  width: 100%; max-width: 300px;
  padding: 16px; text-align: center;
  font-family: var(--font-display); font-size: 34px; font-weight: 800;
  letter-spacing: 10px; direction: ltr;
  color: var(--text); background: var(--card);
  border: 2px solid var(--line); border-radius: 18px; outline: none;
}
.code-input:focus { border-color: var(--violet); }
.code-display {
  font-family: var(--font-display); font-size: clamp(40px, 11vw, 58px); font-weight: 800;
  letter-spacing: 6px; direction: ltr; color: var(--yellow);
  background: rgba(255,176,32,0.1);
  border: 2px dashed rgba(255,176,32,0.45);
  border-radius: 20px; padding: 12px 26px;
}
.room-share { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.room-share .btn-share, .room-share .btn-secondary { padding: 12px 22px; font-size: 15px; }

.lobby-players {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; width: 100%;
}
.lobby-player {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  animation: popIn 0.3s;
}
.lobby-player.host { border-color: rgba(255,176,32,0.5); background: rgba(255,176,32,0.08); }
.lp-avatar { width: 32px; height: 32px; flex-shrink: 0; }
.lp-avatar svg { width: 100%; height: 100%; display: block; }
.lp-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-crown { margin-inline-start: auto; }

.room-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-bottom: 12px; }
.room-settings label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; }
.room-settings select {
  padding: 11px; font-family: var(--font-body); font-size: 14.5px;
  color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}

.rp-top { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.rp-counter { color: var(--muted); font-size: 14.5px; }
.rp-timer {
  font-family: var(--font-display); font-size: 30px; font-weight: 800; color: var(--teal);
  min-width: 58px; text-align: center;
  background: rgba(49,196,141,0.12); border-radius: 12px; padding: 2px 12px;
}
.rp-timer.danger { color: var(--coral); background: rgba(240,82,82,0.14); animation: tickPulse 1s infinite; }
#rpAnswers { width: 100%; }
.answer-btn.chosen { outline: 3px solid var(--yellow); outline-offset: 2px; }

.rv-title { font-family: var(--font-display); font-size: 26px; font-weight: 800; text-align: center; }
.rv-points { font-family: var(--font-display); font-size: 19px; color: var(--yellow); text-align: center; }
.rv-explain { color: var(--muted); font-size: 14.5px; text-align: center; }
.rv-list { display: grid; gap: 7px; width: 100%; }
.rv-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px;
}
.rv-row.me { border-color: var(--yellow); background: rgba(255,176,32,0.1); }
.rv-rank { font-family: var(--font-display); font-weight: 800; min-width: 26px; }
.rv-avatar { width: 30px; height: 30px; flex-shrink: 0; }
.rv-avatar svg { width: 100%; height: 100%; display: block; }
.rv-name { font-weight: 700; font-size: 14.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-score { font-family: var(--font-display); font-weight: 800; color: var(--yellow); }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; width: 100%; }
.podium-slot {
  display: grid; justify-items: center; gap: 5px;
  padding: 14px 10px; border-radius: 16px; flex: 1; max-width: 150px;
  background: var(--card); border: 1px solid var(--line);
  animation: popIn 0.5s;
}
.podium-slot.p1 { background: linear-gradient(160deg, rgba(255,176,32,0.25), rgba(255,138,61,0.12)); border-color: rgba(255,176,32,0.6); padding-block: 24px; }
.pd-medal { font-size: 26px; }
.pd-avatar { width: 46px; height: 46px; }
.pd-avatar svg { width: 100%; height: 100%; display: block; }
.pd-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; text-align: center; }
.pd-score { font-family: var(--font-display); font-weight: 800; color: var(--yellow); font-size: 17px; }

.room-toast {
  position: fixed; bottom: 20px; inset-inline: 20px;
  margin: 0 auto; max-width: 380px;
  padding: 13px 18px; border-radius: 14px;
  background: rgba(49,196,141,0.95); color: #06281c;
  font-weight: 700; text-align: center;
  opacity: 0; pointer-events: none; transform: translateY(12px);
  transition: 0.25s; z-index: 300;
}
.room-toast.show { opacity: 1; transform: translateY(0); }
.room-toast.bad { background: rgba(240,82,82,0.95); color: #fff; }

@media (max-width: 640px) {
  .room-wrap { padding: 12px 12px 40px; gap: 11px; }
  .room-settings { grid-template-columns: 1fr; }
  .lobby-players { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .rp-timer { font-size: 24px; }
}

/* ---------- تأكيد المغادرة ---------- */
.leave-modal { max-width: 380px; text-align: center; }
.leave-actions { display: grid; gap: 16px; width: 100%; justify-items: center; }
/* زر ثانوي هادئ بصبغة حمراء بدل تعبئة صريحة صاخبة — التباين يأتي من درجة
   اللون نفسها (أحمر على أزرق) لا من حدة الإطار أو قوة التعبئة */
/* تعبئة صريحة: الإطار الأسود لا يُقرأ فوق تعبئة شبه شفافة داكنة */
.leave-danger {
  --candy-edge: #a12020;
  background: linear-gradient(180deg, #ffb0b0 0%, #f05252 55%, #d03030 100%);
  border-color: var(--candy-edge);
}

/* ---------- تحسين شاشة الكشف بعد كل سؤال ---------- */
.rv-head {
  display: grid; gap: 6px; justify-items: center; width: 100%;
  padding: 16px 14px; border-radius: 20px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line);
}
.rv-head.good { background: rgba(49,196,141,0.14); border-color: rgba(49,196,141,0.45); }
.rv-head.bad { background: rgba(240,82,82,0.12); border-color: rgba(240,82,82,0.4); }
.rv-correct { font-size: 15px; color: var(--muted); }
.rv-correct strong { color: var(--teal); font-family: var(--font-display); font-size: 18px; }
.rv-progress { color: var(--muted); font-size: 13.5px; }
.rv-row { transition: transform 0.2s; }
.rv-row .rv-delta {
  font-size: 12.5px; font-weight: 700; color: var(--teal);
  min-width: 44px; text-align: center;
}
.rv-row .rv-delta.zero { color: var(--muted); opacity: 0.6; }

/* ---------- تحسين الشاشة النهائية ---------- */
.end-head { display: grid; gap: 4px; justify-items: center; }
.end-crown { font-size: 44px; animation: popIn 0.6s; }
.end-summary {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  width: 100%; margin-top: 4px;
}
.end-stat {
  flex: 1; min-width: 96px; padding: 12px 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  display: grid; gap: 2px; justify-items: center;
}
.end-stat strong { font-family: var(--font-display); font-size: 22px; color: var(--yellow); }
.end-stat span { font-size: 11.5px; color: var(--muted); }

/* ---------- تحسينات الجوال للغرف ---------- */
@media (max-width: 640px) {
  .lobby-players { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .lobby-player { padding: 7px 9px; border-radius: 12px; }
  .lp-avatar { width: 28px; height: 28px; }
  .lp-name { font-size: 13px; }
  .code-display { font-size: 40px; letter-spacing: 4px; padding: 10px 18px; }
  .code-input { font-size: 28px; letter-spacing: 7px; padding: 13px; }
  .room-title { font-size: 22px; }
  .room-sub { font-size: 14px; }
  .podium-slot { padding: 10px 6px; }
  .podium-slot.p1 { padding-block: 18px; }
  .pd-avatar { width: 38px; height: 38px; }
  .pd-name { font-size: 12.5px; }
  .pd-score { font-size: 15px; }
  .pd-medal { font-size: 22px; }
  .rv-head { padding: 12px 10px; }
  .rv-row { padding: 7px 10px; gap: 7px; }
  .rv-name { font-size: 13.5px; }
  .rv-avatar { width: 26px; height: 26px; }
  .end-stat { padding: 10px 6px; }
}

/* ============================================================
   لوحة الإعدادات
   ============================================================ */
.settings-modal { max-width: 430px; }
.set-row { width: 100%; display: grid; gap: 8px; }
.set-inline { grid-template-columns: 1fr auto; align-items: center; }
.set-label { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.set-val { color: var(--yellow); }
.set-hint { color: var(--muted); font-size: 12.5px; }
.set-range {
  width: 100%; height: 30px; -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
.set-range::-webkit-slider-runnable-track {
  height: 10px; border-radius: 999px;
  background: linear-gradient(90deg, var(--yellow), #ff8a3d);
}
.set-range::-moz-range-track { height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--yellow), #ff8a3d); }
.set-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; margin-top: -8px;
  border-radius: 50%; background: #fff; border: 3px solid var(--yellow);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.set-range::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 3px solid var(--yellow); }
.set-toggle {
  width: 58px; height: 32px; border-radius: 999px;
  background: rgba(255,255,255,0.12); border: 1px solid var(--line);
  position: relative; transition: background 0.2s;
  flex-shrink: 0;
}
.set-toggle .knob {
  position: absolute; top: 3px; inset-inline-end: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #7b86ad; transition: 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.35);
}
.set-toggle:active .knob { transform: scale(0.88); }
.set-toggle.on { background: rgba(49,196,141,0.35); border-color: rgba(49,196,141,0.6); }
.set-toggle.on .knob { inset-inline-end: 29px; background: var(--teal); }
.set-row:has(.set-danger) { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 6px; }
.set-danger {
  --candy-edge: #a12020;
  width: 100%;
  background: linear-gradient(180deg, #ffb0b0 0%, #f05252 55%, #d03030 100%);
  border-color: var(--candy-edge);
}

/* ============================================================
   الوضع النهاري (الافتراضي ليلي)
   ============================================================ */
html.light {
  --bg: #eef1fb;
  --bg-2: #ffffff;
  --card: #ffffff;
  --card-2: #f2f5ff;
  --line: rgba(20, 30, 70, 0.12);
  --text: #16204a;
  --muted: #5b6690;
}
html.light body { background: radial-gradient(1200px 600px at 85% -10%, #dfe6ff 0%, var(--bg) 55%) fixed; color: var(--text); }
html.light .topbar { background: rgba(255,255,255,0.9); }
html.light .icon-btn { background: rgba(20,30,70,0.06); }
html.light .icon-btn:hover { background: rgba(20,30,70,0.12); }
html.light .bg-shapes .shape { opacity: 0.08; }
html.light .how-card { background: rgba(20,30,70,0.03); }
html.light .quiz-progress, html.light .level-bar, html.light .badges-progress { background: rgba(20,30,70,0.1); }
html.light .modal { background: linear-gradient(160deg, #ffffff, #f4f7ff); border-color: rgba(20,30,70,0.14); }
html.light .modal-overlay { background: rgba(120,132,180,0.45); }
html.light .page-card p, html.light .page-card li { color: #2c3866; }
html.light .set-toggle { background: rgba(20,30,70,0.12); }
html.light .answer-btn { color: #fff; }
html.light .scramble-slot { background: rgba(20,30,70,0.05); border-color: rgba(20,30,70,0.25); }
html.light .typed-input, html.light .code-input { background: #fff; color: var(--text); }
html.light .map-wrap { background: #cfe9f5; }
html.light .lobby-player, html.light .rv-row, html.light .end-stat { background: #fff; }

/* ---------- الحروف اللاتينية: اتجاه من اليسار لليمين ---------- */
.scramble-slots.latin, .scramble-tiles.latin { direction: ltr; }
.typed-input.latin { direction: ltr; text-align: center; font-family: "Rubik", sans-serif; letter-spacing: 1px; }

/* ---------- ألوان بوابة الإنجليزية ---------- */
.en-mean  { background: linear-gradient(150deg, #2563eb, #1d4ed8); }
.en-write { background: linear-gradient(150deg, #7c3aed, #5b21b6); }
.en-order { background: linear-gradient(150deg, #0891b2, #0e7490); }
.en-gram  { background: linear-gradient(150deg, #059669, #047857); }

/* زر إغلاق النوافذ يثبّت بزاوية البطاقة لا في المنتصف — .icon-btn الموحّد
   يضبط position:relative بنفس التحديد، فهذا التأكيد آخر الملف ضروري ليفوز */
.modal-close { position: absolute !important; }

/* ضغطة موحّدة لكل أزرار الموقع — مقصود وضعها هنا، آخر الملف، كي تتغلّب
   دائمًا على تأثير :hover الخاص بكل زر أثناء الضغط (الأولوية بترتيب
   الظهور بالملف عند تساوي التحديد، لا يكفي تعريفها قرب أول الملف) */
/* الضغط يبتلع الشريط الداكن الداخلي فيبدو السطح وقد انبسط تحت الإصبع —
   مكانه آخر الملف عمدًا كي يتغلّب على :hover أعلاه عند تساوي التحديد */
.btn-cta:active, .btn-secondary:active, .btn-play:active, .btn-daily:active, .btn-share:active,
.btn-friends:active, .diff-btn:active, .scramble-tile:active:not(:disabled), .typed-submit:active,
.answer-btn:active:not(:disabled), .icon-btn:active {
  transform: translateY(5px);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.35),
    inset 0 -3px 6px rgba(0, 0, 0, 0.22),
    0 1px 0 var(--candy-edge, rgba(0, 0, 0, 0.35)),
    0 3px 6px rgba(5, 9, 26, 0.25);
  transition-duration: 0.05s;
}
