/* ⚔️ تحدي (طلب علي 2026-11-15): شكل عينة daisyUI «synthwave» اللي اختارها علي.
   مكتوب يدوي (بدون Tailwind ولا daisyUI كاملة)، وكل شي داخل .ch عشان ما يلمس neon-theme.css.
   نفس الملف لكل الألعاب: تركيب الصور أول، وبعدها الكلمات والاختلافات وصياد السمك. */
.ch {
  --ch-b1: #120b33;
  --ch-b2: #1c1248;
  --ch-b3: #281b60;
  --ch-tx: #f3effe;
  --ch-dim: rgba(243, 239, 254, .68);
  --ch-pri: #f471b5;   /* وردي */
  --ch-sec: #5fd4fb;   /* سماوي */
  --ch-acc: #fb9a3c;   /* برتقالي */
  --ch-warn: #fcd34d;  /* ذهبي */
  --ch-ok: #4ade80;    /* أخضر */
  --ch-wa: #25d366;    /* واتساب */
  color: var(--ch-tx);
  font-family: inherit;
  box-sizing: border-box;
}
.ch *, .ch *::before, .ch *::after { box-sizing: border-box; }
.ch[hidden], .ch [hidden] { display: none !important; }

/* البطاقة المضيئة */
.ch-card {
  background: var(--ch-b2);
  border-radius: 20px;
  padding: 18px 16px;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--ch-sec) 60%, transparent), 0 0 28px color-mix(in oklab, var(--ch-sec) 35%, transparent);
}
.ch-center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.ch-big-ic { font-size: 50px; line-height: 1; }
.ch-title { margin: 0; font-size: 25px; font-weight: 900; text-shadow: 0 0 12px color-mix(in oklab, var(--ch-pri) 80%, transparent); }
.ch-sub { margin: -4px 0 0; color: var(--ch-dim); font-size: 14px; }
.ch-small { margin: 0; color: var(--ch-dim); font-size: 13px; }

/* الخطوات: ادعُ · يدخلون · ابدأ */
.ch-steps { position: relative; list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; margin: 6px 0; padding: 0; font-size: 12px; }
/* الخط بين الخطوات: من نص أول خطوة لنص آخر خطوة، ويصير سماوي لمن يدخل لاعب */
.ch-steps::before { content: ''; position: absolute; top: 13px; left: 16.66%; right: 16.66%; height: 4px; border-radius: 4px; background: var(--ch-b3); }
.ch-steps.ch-full-line::before { background: var(--ch-sec); }
.ch-steps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ch-dim); }
.ch-steps li::before {
  content: attr(data-n); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--ch-b3); color: var(--ch-tx); font-weight: 900; position: relative; z-index: 1;
}
.ch-steps li.ch-sel { color: var(--ch-tx); }
.ch-steps li.ch-sel::before { background: var(--ch-sec); color: #062433; content: '✓'; }

/* مستوى الصعوبة */
.ch-sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; }
.ch-sizes button {
  min-height: 38px; border-radius: 999px; border: 1px solid color-mix(in oklab, var(--ch-tx) 25%, transparent);
  background: transparent; color: var(--ch-tx); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer;
}
.ch-sizes button.ch-sel { background: var(--ch-pri); border-color: var(--ch-pri); color: #2a0619; }
.ch-sizes button:disabled:not(.ch-sel) { opacity: .45; cursor: default; }

/* المربعات الأربعة */
.ch-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.ch-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-height: 124px; padding: 10px; border-radius: 16px;
  border: 2px dashed color-mix(in oklab, var(--ch-tx) 25%, transparent);
}
.ch-slot.ch-full { background: var(--ch-b3); border: 1px solid color-mix(in oklab, var(--ch-sec) 60%, transparent); }
.ch-slot.ch-off { opacity: .5; }
.ch-slot b { font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-slot .ch-wait { font-size: 12px; color: var(--ch-dim); }
.ch-ava {
  position: relative; display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%;
  background: var(--ch-b1); font-size: 30px; overflow: visible;
  box-shadow: 0 0 0 2px var(--ch-b2), 0 0 0 4px var(--ch-sec);
}
.ch-ava.ch-sm { width: 40px; height: 40px; font-size: 20px; flex: none; }
.ch-ava .rank-avatar { width: 100% !important; height: 100% !important; margin: 0 !important; border-radius: 50% !important; overflow: hidden; }
.ch-ava .rank-avatar img, .ch-ava .rank-avatar svg { width: 100% !important; height: 100% !important; object-fit: cover; border-radius: 50% !important; display: block; }
/* اللاعب عنده إطار مستوى أو مركز (frames.js): إطاره يكفي، ونشيل حلقتنا عشان ما تصير حلقتين */
.ch-ava:has(.lvf), .ch-ava:has(.fr) { box-shadow: none; background: transparent; }
.ch-ava.ch-empty { box-shadow: none; background: transparent; color: var(--ch-dim); }
.ch-ava.ch-on::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--ch-ok); box-shadow: 0 0 0 2px var(--ch-b3);
}

/* شارات */
.ch-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.ch-badge.ch-lead { background: var(--ch-warn); color: #3a2a00; }
.ch-badge.ch-ok { background: var(--ch-ok); color: #052e14; }
.ch-badge.ch-me { background: var(--ch-pri); color: #2a0619; }
.ch-badge.ch-big { font-size: 14px; padding: 4px 14px; }

/* النقاط اللي تتحرك (ينتظر) */
.ch-dots { display: inline-flex; gap: 4px; margin-top: 6px; }
.ch-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ch-dim); animation: ch-dot 1.2s infinite ease-in-out; }
.ch-dots i:nth-child(2) { animation-delay: .15s; }
.ch-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ch-dot { 0%, 80%, 100% { opacity: .25; transform: scale(.7); } 40% { opacity: 1; transform: scale(1); } }

/* الأزرار */
.ch-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.ch-row.ch-three { grid-template-columns: 1fr 1fr 1fr; }
/* 🟢 «المتصلين» جنب «أصدقائي»: 4 أزرار بنفس السطر (2026-11-16) */
.ch-row.ch-four { grid-template-columns: repeat(4, 1fr); }
.ch-row.ch-four .ch-btn { padding-inline: 4px; font-size: 13px; }
.ch-btn.ch-onl { color: var(--ch-ok); }
.ch-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 14px;
  border-radius: 12px; border: 1.5px solid currentColor; background: transparent; color: var(--ch-tx);
  font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; text-decoration: none;
  transition: transform .12s, background .15s, opacity .15s;
}
.ch-btn:active { transform: scale(.97); }
.ch-btn:disabled { opacity: .4; cursor: default; }
.ch-btn.ch-wa { color: var(--ch-wa); }
.ch-btn.ch-fr { color: var(--ch-acc); }
.ch-btn.ch-cp { color: var(--ch-sec); }
.ch-btn.ch-ghost { border-color: transparent; color: var(--ch-dim); }
.ch-btn.ch-sec { background: var(--ch-sec); border-color: var(--ch-sec); color: #062433; }
.ch-btn.ch-go {
  width: 100%; min-height: 58px; border-radius: 999px; border: 0; font-size: 21px; font-weight: 900;
  background: var(--ch-pri); color: #2a0619; box-shadow: 0 0 22px color-mix(in oklab, var(--ch-pri) 55%, transparent);
}
.ch-btn.ch-go:disabled { background: var(--ch-b3); color: var(--ch-dim); box-shadow: none; opacity: 1; }
.ch-ic { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* شاشة الانتظار */
.ch-lobby { max-width: 460px; margin: 0 auto; padding: 4px 0 24px; }
.ch-code { font-size: 13px; color: var(--ch-dim); }
.ch-code b { color: var(--ch-tx); letter-spacing: 2px; }

/* العد 3-2-1 */
.ch-count {
  position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; text-align: center;
  background: radial-gradient(circle at 50% 30%, rgba(80, 30, 160, .85), rgba(10, 6, 30, .94) 70%);
}
.ch-count-n {
  display: block; font-size: 150px; line-height: 1; font-weight: 900; color: var(--ch-sec);
  text-shadow: 0 0 22px color-mix(in oklab, var(--ch-pri) 85%, transparent);
}
.ch-count p { margin: 14px 0 0; font-size: 22px; font-weight: 800; }

/* أشرطة السباق فوق اللوحة */
.ch-race { display: flex; flex-direction: column; gap: 9px; margin: 0 auto 12px; width: 100%; max-width: 520px; justify-self: center; padding: 12px 14px; }
/* الصورة دايماً بمقاسها حتى لو الصفحة عندها قواعد عامة للـ span */
.ch .ch-ava { padding: 0 !important; margin: 0; border: 0; }
.ch-lane { display: flex; align-items: center; gap: 10px; }
.ch-lane-body { flex: 1; min-width: 0; }
.ch-lane-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.ch-lane-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-track { height: 12px; margin-top: 4px; border-radius: 999px; background: var(--ch-b1); overflow: hidden; }
.ch-fill { height: 100%; width: 0; border-radius: inherit; background: var(--ch-sec); transition: width .45s cubic-bezier(.2, .8, .2, 1); }
.ch-lane.ch-me .ch-fill { background: var(--ch-warn); }
.ch-lane.ch-done .ch-fill { background: var(--ch-ok); }
.ch-lane.ch-off { opacity: .45; }

/* شاشة الفايز */
.ch-modal {
  position: fixed; inset: 0; z-index: 8800; display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background: rgba(8, 4, 26, .78); backdrop-filter: blur(4px);
}
.ch-modal > .ch-card { width: 100%; max-width: 420px; }
.ch-cup { font-size: 84px; line-height: 1; }
.ch-cup img, .ch-big-ic img { width: 1em !important; height: 1em !important; }
.ch-modal .ch-row { grid-template-columns: 1fr; }
.ch-winner { margin: 0; font-size: 28px; font-weight: 900; color: var(--ch-warn); text-shadow: 0 0 14px color-mix(in oklab, var(--ch-warn) 70%, transparent); }
.ch-list { list-style: none; width: 100%; margin: 8px 0 4px; padding: 6px; border-radius: 14px; background: var(--ch-b1); }
.ch-list li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; }
.ch-list li.ch-first { background: color-mix(in oklab, var(--ch-warn) 12%, transparent); }
.ch-list li .ch-medal { width: 28px; text-align: center; font-size: 20px; }
.ch-list li .ch-name { flex: 1; min-width: 0; text-align: right; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-list li .ch-how { font-size: 12px; color: var(--ch-dim); }

/* لوحة الأصدقاء من تحت */
.ch-sheet { position: fixed; inset: 0; z-index: 8900; display: flex; align-items: flex-end; justify-content: center; background: rgba(8, 4, 26, .6); }
.ch-sheet > .ch-card { width: 100%; max-width: 480px; max-height: 80vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding-bottom: 22px; }
.ch-sheet h3 { margin: 0; font-size: 19px; font-weight: 900; }
.ch-people { list-style: none; width: 100%; margin: 6px 0; padding: 0; }
.ch-people li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid color-mix(in oklab, var(--ch-tx) 10%, transparent); }
.ch-people li > div { flex: 1; min-width: 0; text-align: right; }
.ch-people li b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-people li small { font-size: 12px; color: var(--ch-dim); }
.ch-people li small.ch-on { color: var(--ch-ok); }
.ch-people .ch-btn { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 999px; }

/* التنبيهات الصغيرة */
.ch-toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 9100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.ch-toast { padding: 11px 18px; border-radius: 12px; background: var(--ch-b3); color: var(--ch-tx); font-weight: 800; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .4); }
.ch-toast.ch-ok { background: var(--ch-ok); color: #052e14; }

/* الورق الملون */
.ch-confetti { position: fixed; inset: 0; z-index: 9200; pointer-events: none; width: 100%; height: 100%; }

@media (max-width: 380px) {
  .ch-slot { min-height: 110px; }
  .ch-count-n { font-size: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  .ch-dots i { animation: none; }
  .ch-fill { transition: none; }
}

/* ✅ زر «جاهز» تحت اسم اللاعب بشاشة الدعوة (علي 25/11) */
.ch-ready { font: inherit; font-weight: 800; font-size: .9rem; color: #fff; border: 2px solid #facc15; background: rgba(250, 204, 21, .18); border-radius: 99px; padding: 5px 14px; cursor: pointer; animation: chReadyPulse 1.2s ease-in-out infinite; }
.ch-ready.ch-on { border-color: #4ade80; background: rgba(74, 222, 128, .22); animation: none; }
.ch-ready:disabled { opacity: .6; }
.ch-wait-badge { background: rgba(255, 255, 255, .08); color: #fcd34d; }
@keyframes chReadyPulse { 50% { box-shadow: 0 0 14px #facc15; transform: scale(1.06); } }
