/* =============================================================================
   words.css — «كلمة السر». نفس القاعدة الداكنة وأسلوب أزرار قائد الشحنات
   (عائلة واحدة في البوابة) بلون بنفسجي مميّز، وخط Baloo Bhaijaan 2 المستدير.

   بنية اللوحة: .board > #grid (البلاطات + الحروف) + svg#bands (أشرطة الكلمات).
   الـ svg فوق خلفيات البلاطات وتحت الحروف (z-index 1 مقابل 2 للحرف) — فيبدو
   الشريط «تحت» الحرف كما في ألغاز الورق.
   ========================================================================== */

:root {
  --panel: #1f1a45;
  --panel-2: #2b2460;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #a78bfa;
  --accent-2: #7c3aed;
  --text: #f3efff;
  --dim: #a89fd1;
  --good: #34d399;
  --bad: #ff4d5e;
  --gold: #ffd166;
  --tint: #a78bfa;
  --cell: 42px;
  --font: "Baloo Bhaijaan 2", "Segoe UI", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; font-family: var(--font); color: var(--text); overflow: hidden; }
body {
  background:
    radial-gradient(90% 60% at 50% -10%, color-mix(in srgb, var(--tint) 38%, transparent) 0%, transparent 60%),
    radial-gradient(130% 100% at 50% 110%, #1a1345 0%, #0c0a22 60%);
  user-select: none;
  transition: background .6s ease;
}

#app { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px; }
.screen.hidden { display: none; }

/* ---------- أزرار ---------- */
.btn {
  font-family: inherit; font-size: 18px; font-weight: 800; color: var(--text);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 18px; padding: 14px 22px; cursor: pointer;
  transition: transform .07s ease, filter .15s ease; box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,.08);
}
@media (hover: hover) and (pointer: fine) { .btn:hover { filter: brightness(1.12); } }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.btn-primary { background: linear-gradient(180deg, #b79bff, var(--accent-2)); color: #fff; box-shadow: 0 5px 0 #4c1d95, inset 0 1px 0 rgba(255,255,255,.25); }
.btn-primary:active { box-shadow: 0 2px 0 #4c1d95; }
.btn.big { font-size: 22px; padding: 17px 30px; }
.btn-ghost { background: rgba(255, 255, 255, 0.06); box-shadow: none; }
.btn.small { font-size: 15px; padding: 8px 14px; border-radius: 13px; }
.btn.small .cost { color: var(--gold); font-weight: 800; margin-inline-start: 4px; }
.btn.danger { background: linear-gradient(180deg, #e0453a, #b5342b); box-shadow: 0 5px 0 #7c231c; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  font-size: 26px; font-weight: 800; background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line); color: var(--text); width: 46px; height: 46px;
  border-radius: 15px; cursor: pointer; line-height: 1; flex: none; font-family: inherit;
}
.icon-btn:active { transform: translateY(2px); }

/* ---------- القائمة ---------- */
.menu-card { position: relative; z-index: 2; text-align: center; max-width: 460px; width: 100%; animation: pop .4s cubic-bezier(.2, 1.3, .4, 1); }
.menu-fx { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.menu-fx .tile {
  position: absolute; bottom: -80px; width: 54px; height: 54px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.05));
  border: 1px solid rgba(255,255,255,.14); box-shadow: 0 10px 30px rgba(0,0,0,.35);
  opacity: 0; animation: rise linear infinite;
}
.menu-fx .t1 { left: 6%;  animation-duration: 19s; }
.menu-fx .t2 { left: 18%; animation-duration: 23s; animation-delay: -7s; }
.menu-fx .t3 { left: 31%; animation-duration: 17s; animation-delay: -12s; }
.menu-fx .t4 { left: 47%; animation-duration: 25s; animation-delay: -4s; }
.menu-fx .t5 { left: 62%; animation-duration: 21s; animation-delay: -15s; }
.menu-fx .t6 { left: 76%; animation-duration: 27s; animation-delay: -9s; }
.menu-fx .t7 { left: 88%; animation-duration: 20s; animation-delay: -18s; }
.menu-fx .t8 { left: 40%; animation-duration: 29s; animation-delay: -22s; }
@keyframes rise { 0% { transform: translateY(0) rotate(-8deg); opacity: 0; } 12% { opacity: .35; } 88% { opacity: .35; } 100% { transform: translateY(-92vh) rotate(16deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .menu-fx { display: none; } }

.hub-link {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 3;
  color: var(--dim); text-decoration: none; font-weight: 800; font-size: 15px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 13px; padding: 8px 14px;
}
@media (hover: hover) and (pointer: fine) { .hub-link:hover { color: var(--text); } }

.emblem-wrap { position: relative; width: clamp(120px, 26vw, 176px); margin: 0 auto 4px; }
.emblem-wrap::before {
  content: ""; position: absolute; inset: -18%; border-radius: 50%;
  background: radial-gradient(circle, rgba(167,139,250,.45), transparent 62%);
  animation: glow 3.8s ease-in-out infinite;
}
.logo-emblem { position: relative; width: 100%; height: auto; display: block; animation: logofloat 3.8s ease-in-out infinite; filter: drop-shadow(0 14px 26px rgba(0, 0, 0, .5)); }
@keyframes logofloat { 50% { transform: translateY(-7px); } }
@keyframes glow { 50% { transform: scale(1.12); opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .logo-emblem, .emblem-wrap::before { animation: none; } }
/* لون صلب بلا تباعد حروف: letter-spacing يقطع وصل الحروف العربية */
.title {
  font-size: clamp(44px, 10vw, 74px); font-weight: 800; line-height: 1.15; color: #f1ebff;
  text-shadow: 0 4px 0 #1d1546, 0 10px 26px rgba(0, 0, 0, .45);
}
.tagline { color: var(--dim); font-size: clamp(15px, 3.6vw, 19px); margin: 2px 0 22px; }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; }
.menu-stats { display: flex; justify-content: center; gap: 22px; margin-top: 20px; color: var(--gold); font-weight: 800; font-size: 18px; }

/* ---------- الأشرطة العلوية ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 820px; margin-bottom: 12px; gap: 12px; }
.bar h2 { font-size: 26px; font-weight: 800; }
.bar-right { min-width: 46px; text-align: left; color: var(--gold); font-weight: 800; }
.hint-line { color: var(--dim); margin-bottom: 12px; font-size: 15px; }
.tier-legend { display: flex; gap: 8px; margin-bottom: 12px; font-size: 12px; font-weight: 800; }
.tl { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); }
.tl.easy   { --tier: #34d399; } .tl.medium { --tier: #60a5fa; } .tl.hard { --tier: #fb923c; } .tl.expert { --tier: #f472b6; }
.tl::before { content: "●"; color: var(--tier); margin-inline-end: 5px; }

/* ---------- شبكة المراحل ---------- */
.levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px; width: 100%; max-width: 820px; overflow-y: auto; padding: 6px; align-content: start; max-height: 74vh; }
.lvl {
  --tier: #34d399;
  aspect-ratio: 1; border-radius: 20px; cursor: pointer; color: var(--text); font-family: inherit;
  border: 1px solid color-mix(in srgb, var(--tier) 35%, var(--line));
  background: linear-gradient(180deg, color-mix(in srgb, var(--tier) 16%, var(--panel-2)), var(--panel));
  box-shadow: 0 4px 0 rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255,255,255,.07);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; position: relative;
  transition: transform .07s;
}
.lvl.medium { --tier: #60a5fa; } .lvl.hard { --tier: #fb923c; } .lvl.expert { --tier: #f472b6; }
.lvl:active { transform: translateY(3px); }
.lvl .num { font-size: 27px; font-weight: 800; line-height: 1.1; }
.lvl .ico { font-size: 16px; }
.lvl .lvl-stars { display: flex; gap: 2px; height: 14px; color: rgba(255, 255, 255, .18); }
.lvl .lvl-stars svg { width: 13px; height: 13px; }
.lvl .lvl-stars svg.on { color: var(--gold); }
.lvl.locked { filter: grayscale(.8) brightness(.55); cursor: not-allowed; }
.lvl.locked::after { content: ""; position: absolute; top: 50%; left: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; opacity: .85;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='4.5' y='10.5' width='15' height='11' rx='3' fill='%23d6cdf5'/%3E%3Cpath d='M8 10.5V8a4 4 0 0 1 8 0v2.5' fill='none' stroke='%23d6cdf5' stroke-width='2.4'/%3E%3Ccircle cx='12' cy='16' r='1.7' fill='%232a2156'/%3E%3C/svg%3E") center/contain no-repeat; }
.lvl.locked .num, .lvl.locked .lvl-stars, .lvl.locked .ico { opacity: 0; }
.lvl.current { outline: 3px solid var(--tier); outline-offset: 1px; }

/* ---------- شبكة المواضيع ---------- */
.themes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; width: 100%; max-width: 760px; overflow-y: auto; max-height: 72vh; padding: 6px; align-content: start; }
.theme {
  border-radius: 20px; border: 1px solid var(--line); cursor: pointer; color: var(--text); font-family: inherit;
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); box-shadow: 0 4px 0 rgba(0, 0, 0, .3);
  padding: 16px 10px 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: transform .07s;
}
.theme:active { transform: translateY(3px); }
.theme .ico { font-size: 34px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); }
.theme .nm { font-weight: 800; font-size: 15px; }

/* ---------- الإعدادات ---------- */
.settings-body { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 14px; }
.settings-body .row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line);
  border-radius: 18px; padding: 15px 18px; font-weight: 700; cursor: pointer;
}
/* مفاتيح تبديل بدل مربّعات الاختيار — نفس شكل إعدادات قائد الشحنات */
.settings-body input[type=checkbox] {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; cursor: pointer;
  width: 52px; height: 30px; border-radius: 20px; background: rgba(255, 255, 255, .14); transition: background .2s;
}
.settings-body input[type=checkbox]::before {
  content: ""; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); transition: transform .2s cubic-bezier(.22, 1, .36, 1);
}
.settings-body input[type=checkbox]:checked { background: var(--accent); }
.settings-body input[type=checkbox]:checked::before { transform: translateX(-22px); }
.settings-body input[type=checkbox]:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.row-label { display: inline-flex; align-items: center; gap: 9px; }
.note { color: var(--dim); font-size: 13px; text-align: center; }

/* ---------- شاشة اللعب ---------- */
#game { justify-content: flex-start; gap: 10px; padding: 10px 10px 12px; }
.watermark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 60vmin; opacity: .035; pointer-events: none; filter: grayscale(.4) blur(2px); z-index: 0; }
#game > *:not(.watermark) { position: relative; z-index: 1; }

.game-bar { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 720px; padding-top: env(safe-area-inset-top); }
.game-title { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.game-title span { font-weight: 800; font-size: 19px; }
.game-title small { color: var(--dim); font-size: 12.5px; font-weight: 700; }
.pills { display: flex; flex-direction: column; gap: 4px; align-items: stretch; min-width: 74px; }
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font-weight: 800; font-size: 13.5px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.07); border: 1px solid var(--line); color: var(--text);
}
.pill.gold { color: var(--gold); }

.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.board { position: relative; }

.grid {
  display: grid; direction: rtl; gap: 4px; padding: 10px; border-radius: 22px; position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(0, 0, 0, .22));
  border: 1px solid color-mix(in srgb, var(--tint) 30%, var(--line));
  box-shadow: 0 18px 44px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255,255,255,.08), 0 0 0 6px color-mix(in srgb, var(--tint) 10%, transparent);
  touch-action: none;
}
.cell {
  width: var(--cell); height: var(--cell); border-radius: calc(var(--cell) * .24); position: relative;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.035));
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.10), 0 2px 0 rgba(0,0,0,.22);
  transition: transform .12s, background .15s;
}
.cell span { position: relative; z-index: 2; font-size: calc(var(--cell) * 0.56); font-weight: 800; color: var(--text); line-height: 1; transition: color .15s; }
.cell.sel { transform: scale(1.06); background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,.08)); }
.cell.found span { color: #17122e; }
.cell.hinted { animation: hintpulse 1.1s ease-in-out 3; }
.cell.reveal { transform: scale(1.08); background: var(--gold); }
.cell.reveal span { color: #2a1d00; }
.cell.flown { opacity: .35; }
@keyframes hintpulse { 50% { background: var(--gold); transform: scale(1.12); } }
.grid.shake { animation: shake .28s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* أشرطة الكلمات: فوق البلاطات، تحت الحروف */
.bands { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.bands line { stroke-linecap: round; }
.bands .band-sel { stroke: var(--accent); opacity: .55; }
.bands .band-found { opacity: .92; animation: bandin .28s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes bandin { from { opacity: 0; } }

/* ---------- شريط كلمة السر ---------- */
.secret { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.secret-label { color: var(--dim); font-weight: 800; font-size: 14px; }
.secret-slots { display: flex; gap: 5px; direction: rtl; }
.slot {
  width: 32px; height: 38px; border-radius: 10px; border: 2px dashed rgba(255, 255, 255, .2);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 21px; color: transparent;
}
.slot.on {
  color: #2a1d00; background: linear-gradient(180deg, #ffe08a, #f2b634); border-style: solid; border-color: #ffd166;
  box-shadow: 0 4px 0 #a86f00; animation: pop .3s cubic-bezier(.2, 1.4, .4, 1);
}
.flyer {
  position: fixed; z-index: 70; pointer-events: none; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--gold); color: #2a1d00; font-weight: 800; font-family: var(--font);
  box-shadow: 0 8px 20px rgba(0,0,0,.4); transition: transform .55s cubic-bezier(.3, 1.2, .4, 1), opacity .55s;
}

/* ---------- قائمة الكلمات ---------- */
.words-panel { width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; }
.words-head { display: flex; align-items: center; justify-content: space-between; }
.words-list { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; overflow-y: auto; padding: 2px; }
.wchip {
  padding: 6px 13px; border-radius: 999px; font-weight: 800; font-size: 15.5px; color: var(--text);
  background: rgba(255, 255, 255, .07); border: 1px solid var(--line); transition: all .2s;
}
.wchip.done { text-decoration: line-through; text-decoration-thickness: 2px; color: #17122e; border-color: transparent; opacity: .8; }
.wchip.flash { animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }

/* ---------- تنبيه عائم ---------- */
.toast {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: rgba(14, 10, 36, .94); border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 15px; font-weight: 800; font-size: 15px; z-index: 40; white-space: nowrap;
  animation: pop .25s cubic-bezier(.2, 1.4, .4, 1);
}

/* ---------- طبقة النتيجة ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(6, 5, 20, .8); padding: 16px; }
.overlay.hidden { display: none; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.overlay-card {
  position: relative; width: 100%; max-width: 400px; text-align: center; border-radius: 28px; padding: 26px 22px 22px;
  background: linear-gradient(160deg, #3b2c7a, #1c1a44 70%); border: 1px solid rgba(203, 184, 255, .35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255,255,255,.1); animation: pop .4s cubic-bezier(.2, 1.3, .4, 1);
}
.overlay-card h2 { font-size: 32px; font-weight: 800; margin-bottom: 4px; }
.result-stars { display: flex; justify-content: center; gap: 6px; margin-bottom: 4px; height: 58px; color: var(--gold); }
.rs-ic { width: 48px; height: 48px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35)); }
.result-stars i { font-style: normal; display: inline-block; opacity: .18; filter: grayscale(1); transform: scale(.6); transition: transform .35s cubic-bezier(.2, 1.6, .4, 1), opacity .3s, filter .3s; }
.result-stars i.on { opacity: 1; filter: none; transform: scale(1); }
.result-secret { color: var(--dim); margin-bottom: 16px; }
.result-secret b { color: var(--gold); font-size: 22px; }
.result-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.result-rows div { display: flex; justify-content: space-between; background: rgba(255, 255, 255, .06); border-radius: 13px; padding: 10px 14px; font-weight: 700; }
.result-rows span { color: var(--dim); }
.overlay-buttons { display: flex; flex-direction: column; gap: 10px; }

@keyframes pop { from { transform: scale(.86); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* أرقام معزولة: تمنع الـ bidi من قلب «⭐ 0 / 90» و«+8» */
.menu-stats span, .bar-right, .pill, .result-rows b { direction: ltr; unicode-bidi: isolate; }

/* ---------- شاشات ---------- */
@media (max-height: 700px) {
  .game-bar { padding-top: 2px; }
  .slot { width: 27px; height: 33px; font-size: 18px; }
  .wchip { font-size: 14px; padding: 5px 10px; }
}
@media (min-height: 860px) { #game { justify-content: center; } }
@media (min-width: 900px) { .words-list { max-height: 30vh; } }

/* ---------- الجوال: إحساس التطبيق (مشترك مع البوابة) ----------
   لا انتظار لنقرة مزدوجة، ولا تحديد لنص الأزرار بالضغط المطوّل، ولا سحب-للتحديث
   يقاطع اللعب. */
html { -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button, a, [role="button"] { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.hub-link{ display:inline-flex; align-items:center; gap:7px; }
.hub-mark{ width:20px; height:20px; flex:none; }

/* ---------- أيقونات مرسومة (بدل الإيموجي) ---------- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.ui-ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn.small .ui-ic { width: 18px; height: 18px; color: var(--gold); }
.btn.small .cost { margin-inline-start: 0; }
.st-ic { width: 19px; height: 19px; flex: none; }
.menu-stats span, .bar-right { display: inline-flex; align-items: center; gap: 6px; }
.menu-stats b, .bar-right b, .pill b { font-weight: 800; font-variant-numeric: tabular-nums; }
.pill-ic { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- تحدٍّ مع الأصدقاء ---------- */
.party-body { width: 100%; max-width: 460px; }
.party-card {
  display: flex; flex-direction: column; gap: 14px; align-items: stretch; text-align: center;
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line);
  border-radius: 22px; padding: 20px 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; text-align: start; font-weight: 800; font-size: 14px; color: var(--dim); }
.field input, .field select, .join-row input {
  font-family: inherit; font-size: 18px; font-weight: 700; color: var(--text);
  background: rgba(0, 0, 0, .28); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0;
}
.field input:focus-visible, .field select:focus-visible, .join-row input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.field select option { color: #111; }
.or { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 13px; font-weight: 700; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; text-align: center; letter-spacing: .3em; font-variant-numeric: tabular-nums; direction: ltr; font-size: 22px; }
.code-label { color: var(--dim); font-weight: 800; font-size: 14px; }
.room-code { font-size: 54px; font-weight: 800; line-height: 1; letter-spacing: .12em; direction: ltr; font-variant-numeric: tabular-nums; color: #f1ebff; }
.btn.small { align-self: center; }
.players { list-style: none; display: flex; flex-direction: column; gap: 6px; text-align: start; }
.players li { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); font-weight: 800; }
.players li small { color: var(--dim); font-weight: 700; }
.players li.away { opacity: .45; }
.players .crown { width: 18px; height: 18px; color: var(--gold); flex: none; }
.players .dot { width: 9px; height: 9px; margin: 0 4.5px; border-radius: 50%; background: #34d399; flex: none; }
.players li.away .dot { background: var(--dim); }

.race { width: 100%; max-width: 720px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.race.hidden { display: none; }
.racer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 800;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 11px; padding: 5px 9px; }
.racer.me { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.racer.away { opacity: .45; }
.racer .rn { max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.racer .rb { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.racer .rb i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.racer.done .rb i { background: var(--gold); }
.racer b { font-variant-numeric: tabular-nums; direction: ltr; }

.ranking { list-style: none; counter-reset: rk; display: flex; flex-direction: column; gap: 6px; margin: 6px 0 14px; text-align: start; }
.ranking li { counter-increment: rk; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .06); font-weight: 800; }
.ranking li::before { content: counter(rk); width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .1); font-size: 13px; }
.ranking li:first-child::before { background: var(--gold); color: #3a2a00; }
.ranking li.me { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); }
.ranking li span { flex: 1; }
.ranking li b { font-variant-numeric: tabular-nums; color: var(--dim); }

/* سمة hidden تغلب أي display في الأنماط (بدونها تبقى الأزرار والحقول ظاهرة) */
[hidden], .party-card.hidden { display: none !important; }
/* شاشة التحدّي قد تطول على الجوال: تبدأ من الأعلى وتُمرَّر بدل أن تُقصّ */
#party { justify-content: flex-start; overflow-y: auto; overscroll-behavior: contain; padding-top: max(16px, env(safe-area-inset-top)); }
