/* ═══════════════════════════════════════════════════════════
   مسابقة فوز — التنسيقات
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg:        #0a091c;
  --bg-2:      #12102e;
  --ink:       #f4f2ff;
  --ink-soft:  #a9a4cf;
  --glass:     rgba(255, 255, 255, .055);
  --glass-2:   rgba(255, 255, 255, .085);
  --stroke:    rgba(255, 255, 255, .12);
  --gold:      #ffc86b;
  --gold-2:    #ff9a3c;
  --violet:    #7c5cff;
  --violet-2:  #b06bff;
  --green:     #2fd18b;
  --red:       #ff5d6c;
  --r-lg: 28px;
  --r-md: 18px;
  --shadow: 0 30px 80px -20px rgba(0, 0, 0, .75);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: 'Tajawal', 'Segoe UI', 'Noto Naskh Arabic', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── الخلفية المتحركة ─────────────────────────────────────── */
.aurora {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, #221a4d 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 70%);
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5;
  will-change: transform;
}
.b1 { width: 52vmax; height: 52vmax; top: -22vmax; right: -14vmax;
      background: radial-gradient(circle, #7c5cff, transparent 68%);
      animation: drift1 22s var(--ease) infinite alternate; }
.b2 { width: 44vmax; height: 44vmax; bottom: -20vmax; left: -12vmax;
      background: radial-gradient(circle, #ff9a3c, transparent 68%); opacity: .32;
      animation: drift2 27s var(--ease) infinite alternate; }
.b3 { width: 36vmax; height: 36vmax; top: 38%; left: 46%;
      background: radial-gradient(circle, #2fd18b, transparent 70%); opacity: .18;
      animation: drift3 31s var(--ease) infinite alternate; }

@keyframes drift1 { to { transform: translate(-12vmax, 10vmax) scale(1.18); } }
@keyframes drift2 { to { transform: translate(10vmax, -8vmax)  scale(1.12); } }
@keyframes drift3 { to { transform: translate(-14vmax, -12vmax) scale(.85); } }

.grain {
  position: absolute; inset: 0; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#confetti { position: fixed; inset: 0; z-index: 40; pointer-events: none; }

/* ── المسرح والشاشات ──────────────────────────────────────── */
.stage {
  position: relative; z-index: 2;
  min-height: 100dvh; display: grid; place-items: center;
  padding: 20px clamp(14px, 4vw, 28px);
}

.screen { display: none; width: 100%; max-width: 560px; }
.screen.is-active { display: block; animation: screenIn .55s var(--ease) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(22px) scale(.97); } }

.card {
  position: relative;
  background: linear-gradient(155deg, var(--glass-2), var(--glass));
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  padding: clamp(26px, 5.5vw, 40px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .12);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  text-align: center;
  overflow: hidden;
}
/* لمعة علوية */
.card::before {
  content: ''; position: absolute; inset: -1px -1px auto; height: 130px;
  background: radial-gradient(60% 100% at 50% 0, rgba(255, 200, 107, .16), transparent 70%);
  pointer-events: none;
}

/* ── النصوص ───────────────────────────────────────────────── */
.crest {
  width: 84px; height: 84px; margin: 0 auto 18px;
  display: grid; place-items: center; font-size: 40px; line-height: 1;
  border-radius: 26px;
  background: linear-gradient(150deg, rgba(255, 200, 107, .25), rgba(124, 92, 255, .25));
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 14px 40px -10px rgba(255, 154, 60, .5);
  animation: float 5s ease-in-out infinite;
}
.crest.sm { width: 68px; height: 68px; font-size: 32px; border-radius: 22px; margin-bottom: 14px; }
@keyframes float { 50% { transform: translateY(-9px) rotate(-4deg); } }

.title { font-size: clamp(30px, 7.5vw, 42px); font-weight: 900; letter-spacing: -.5px; line-height: 1.25; }
.title.sm { font-size: clamp(24px, 6vw, 30px); }
.grad {
  background: linear-gradient(100deg, var(--gold), var(--gold-2) 45%, var(--violet-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle { margin-top: 10px; color: var(--ink-soft); font-size: clamp(14px, 3.6vw, 16.5px); line-height: 1.75; }
.note { margin-top: 16px; font-size: 12.5px; color: rgba(169, 164, 207, .72); line-height: 1.7; }

/* ── الشرائح ──────────────────────────────────────────────── */
.chips { list-style: none; display: flex; gap: 10px; justify-content: center; margin: 22px 0 4px; }
.chip {
  flex: 1; max-width: 118px; padding: 12px 6px; border-radius: var(--r-md);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--stroke);
  display: grid; gap: 2px;
}
.chip b { font-size: 25px; font-weight: 900; line-height: 1; }
.chip span { font-size: 11.5px; color: var(--ink-soft); }
.chip.accent { background: linear-gradient(160deg, rgba(255, 200, 107, .18), rgba(255, 154, 60, .06));
               border-color: rgba(255, 200, 107, .4); }
.chip.accent b { color: var(--gold); }

/* ── القواعد ──────────────────────────────────────────────── */
.rules { list-style: none; text-align: right; margin: 22px 0 26px; display: grid; gap: 11px; }
.rules li { display: flex; gap: 11px; align-items: center; font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.rules i {
  flex: none; width: 25px; height: 25px; border-radius: 9px; display: grid; place-items: center;
  font-style: normal; font-size: 12px; font-weight: 700; color: var(--gold);
  background: rgba(255, 200, 107, .13); border: 1px solid rgba(255, 200, 107, .28);
}

/* ── الأزرار ──────────────────────────────────────────────── */
.btn {
  width: 100%; border: 0; cursor: pointer; font-family: inherit; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border-radius: 16px; transition: transform .2s var(--ease), box-shadow .25s var(--ease), filter .2s;
}
.btn-lg { padding: 17px 22px; font-size: 17px; }
.btn-primary {
  color: #1a1005;
  background: linear-gradient(100deg, var(--gold), var(--gold-2));
  box-shadow: 0 14px 34px -10px rgba(255, 154, 60, .65), inset 0 1px 0 rgba(255, 255, 255, .5);
  position: relative; overflow: hidden;
}
.btn-primary::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-130%) skewX(-20deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent);
  animation: sheen 3.4s ease-in-out infinite; animation-delay: 1s;
}
@keyframes sheen { 0%, 62% { transform: translateX(-130%) skewX(-20deg); } 100% { transform: translateX(130%) skewX(-20deg); } }
.btn:hover  { transform: translateY(-2px); filter: brightness(1.04); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-ghost {
  margin-top: 18px; padding: 13px 18px; font-size: 14px; color: var(--ink);
  background: rgba(255, 255, 255, .07); border: 1px solid var(--stroke);
}

/* ── رأس المسابقة والمؤقت ─────────────────────────────────── */
.quiz { text-align: right; padding-top: clamp(20px, 4vw, 28px); }

.quiz-head { display: flex; align-items: center; gap: 15px; margin-bottom: 18px; }

.timer { position: relative; width: 66px; height: 66px; flex: none; }
.timer .ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, .1); stroke-width: 6; }
.ring-fg {
  fill: none; stroke: var(--gold); stroke-width: 6; stroke-linecap: round;
  stroke-dasharray: 194.8; stroke-dashoffset: 0;
  filter: drop-shadow(0 0 7px rgba(255, 200, 107, .7));
  transition: stroke .4s linear;
}
.timer-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums;
}
.timer.warn  .ring-fg { stroke: var(--gold-2); filter: drop-shadow(0 0 8px rgba(255, 154, 60, .8)); }
.timer.warn  .timer-num { color: var(--gold-2); }
.timer.danger .ring-fg { stroke: var(--red); filter: drop-shadow(0 0 10px rgba(255, 93, 108, .9)); }
.timer.danger .timer-num { color: var(--red); }
.timer.danger { animation: pulse .85s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.09); } }

.head-meta { flex: 1; min-width: 0; }
.qcount { font-size: 13px; color: var(--ink-soft); }
.qcount b { color: var(--ink); font-weight: 800; }

.dots { display: flex; gap: 6px; margin-top: 9px; }
.dots span {
  height: 5px; flex: 1; border-radius: 99px; background: rgba(255, 255, 255, .13);
  transition: background .35s var(--ease), box-shadow .35s;
}
.dots span.done { background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.dots span.now  { background: rgba(255, 255, 255, .45); box-shadow: 0 0 10px rgba(255, 255, 255, .4); }
.dots span.good { background: var(--green); }
.dots span.bad  { background: var(--red); }

.progress { height: 3px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-bottom: 22px; }
.progress span {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--gold), var(--red));
  transform-origin: right; transform: scaleX(1);
}

/* ── السؤال والخيارات ─────────────────────────────────────── */
.q-wrap.swap { animation: qIn .42s var(--ease) both; }
@keyframes qIn { from { opacity: 0; transform: translateX(28px); } }

.question {
  font-size: clamp(19px, 4.8vw, 24px); font-weight: 800; line-height: 1.55;
  margin-bottom: 20px; min-height: 2.4em; display: flex; align-items: center;
}

.options { display: grid; gap: 10px; }

.opt {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 15px 16px; border-radius: var(--r-md); cursor: pointer;
  background: rgba(255, 255, 255, .05); border: 1.5px solid var(--stroke);
  color: var(--ink); font-family: inherit; font-size: 15.5px; font-weight: 600;
  text-align: right; line-height: 1.5;
  transition: transform .18s var(--ease), background .2s, border-color .2s, box-shadow .25s;
}
.opt .lt {
  flex: none; width: 32px; height: 32px; border-radius: 11px; display: grid; place-items: center;
  font-size: 14px; font-weight: 900; color: var(--gold);
  background: rgba(255, 200, 107, .13); border: 1px solid rgba(255, 200, 107, .26);
  transition: all .2s;
}
.opt .tx { flex: 1; }
.opt:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .3); transform: translateX(-4px); }
.opt:active { transform: scale(.985); }

.opt.picked { border-color: var(--violet); background: rgba(124, 92, 255, .18); }
.opt.correct {
  border-color: var(--green); background: rgba(47, 209, 139, .18);
  box-shadow: 0 0 0 3px rgba(47, 209, 139, .13);
}
.opt.correct .lt { color: var(--green); background: rgba(47, 209, 139, .2); border-color: rgba(47, 209, 139, .4); }
.opt.wrong {
  border-color: var(--red); background: rgba(255, 93, 108, .16);
  animation: shake .38s var(--ease);
}
.opt.wrong .lt { color: var(--red); background: rgba(255, 93, 108, .2); border-color: rgba(255, 93, 108, .4); }
@keyframes shake { 25% { transform: translateX(-7px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }

.options.locked .opt { pointer-events: none; }
.options.locked .opt:not(.correct):not(.wrong) { opacity: .42; }

/* ── شاشة الجوال ──────────────────────────────────────────── */
.phone-card { padding-top: 34px; }
.timer.mini { position: absolute; top: 18px; left: 18px; width: 48px; height: 48px; }
.timer.mini .timer-num { font-size: 16px; }

/* أرقام الجوال تُقرأ من اليسار لليمين، فيأتي مفتاح الدولة أولاً ثم الرقم */
.field {
  direction: ltr;
  display: flex; align-items: center; gap: 10px; margin-top: 22px;
  background: rgba(255, 255, 255, .06); border: 1.5px solid var(--stroke);
  border-radius: var(--r-md); padding: 6px 16px 6px 8px;
  transition: border-color .2s, box-shadow .25s, background .2s;
}
.field:focus-within {
  border-color: var(--gold); background: rgba(255, 255, 255, .09);
  box-shadow: 0 0 0 4px rgba(255, 200, 107, .13);
}
.field.bad { border-color: var(--red); box-shadow: 0 0 0 4px rgba(255, 93, 108, .13); }
.cc {
  flex: none; font-weight: 800; font-size: 15px; color: var(--gold); direction: ltr;
  padding: 12px 12px; border-radius: 12px; background: rgba(255, 200, 107, .1);
}
#phone {
  flex: 1; min-width: 0; background: none; border: 0; outline: 0;
  color: var(--ink); font-family: inherit; font-size: 21px; font-weight: 700;
  letter-spacing: 1.5px; padding: 12px 4px;
}
#phone::placeholder { color: rgba(169, 164, 207, .4); letter-spacing: 1px; font-weight: 500; }

.err { min-height: 20px; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--red); }
#phone-form .btn { margin-top: 6px; }

/* ── النتيجة ──────────────────────────────────────────────── */
.seal {
  width: 88px; height: 88px; margin: 0 auto 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 42px; font-weight: 900; color: #08210f;
  background: linear-gradient(150deg, var(--green), #1fb673);
  box-shadow: 0 16px 44px -12px rgba(47, 209, 139, .7);
  animation: pop .6s var(--ease) both;
}
.seal.red {
  color: #2b0a0e; background: linear-gradient(150deg, #ff8a94, var(--red));
  box-shadow: 0 16px 44px -12px rgba(255, 93, 108, .6);
}
@keyframes pop { from { transform: scale(.4) rotate(-25deg); opacity: 0; } }

.score-box {
  margin: 22px auto 4px; padding: 18px; max-width: 260px; border-radius: var(--r-md);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--stroke);
}
.score-num { display: flex; align-items: baseline; justify-content: center; gap: 4px; direction: ltr; }
.score-num b  { font-size: 44px; font-weight: 900; line-height: 1;
                background: linear-gradient(100deg, var(--gold), var(--gold-2));
                -webkit-background-clip: text; background-clip: text; color: transparent; }
.score-num i  { font-size: 26px; color: var(--ink-soft); font-style: normal; }
.score-num em { font-size: 26px; color: var(--ink-soft); font-style: normal; font-weight: 700; }
.score-lbl { display: block; margin-top: 7px; font-size: 13px; color: var(--ink-soft); }

/* ── شارة إغلاق المسابقة ──────────────────────────────────── */
.ended-badge {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 22px;
  padding: 11px 20px; border-radius: 99px; font-size: 13.5px; font-weight: 800;
  color: var(--gold); background: rgba(255, 200, 107, .12);
  border: 1px solid rgba(255, 200, 107, .35);
}
.ended-badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ── تفاصيل ───────────────────────────────────────────────── */
@media (max-width: 380px) {
  .chip b { font-size: 21px; }
  .opt { padding: 13px 13px; font-size: 14.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .05ms !important; }
}
