/* =====================================================================
   شيفرة | أوراق الأنماط
   الهوية: أزرق بترولي + رمل + ذهبي، أشكال هندسية فقط (بلا ذوات أرواح).
   ===================================================================== */

:root {
  --petrol:   #0F2C35;
  --petrol-2: #163A45;
  --petrol-3: #1E4A57;
  --sand:     #EFE4CB;
  --sand-2:   #E2D3B1;
  --ink:      #1E2A30;
  --gold:     #D8B35A;
  --muted:    #8FA7AE;
  --line:     rgba(239, 228, 203, .14);
  --neutral:  #7E7563;
  --trap:     #232B31;
  --danger:   #F08A7E;
  --ok:       #6FC08A;

  --t0: #D2463C;
  --t1: #3B6FD8;
  --t2: #3F9B5A;
  --t3: #E39B2D;
  --t4: #8A55C8;
  --t5: #1FA3A3;

  --ui:      "IBM Plex Sans Arabic", system-ui, "Segoe UI", sans-serif;
  --display: "Reem Kufi", "IBM Plex Sans Arabic", system-ui, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
}

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

html, body { height: 100%; }

body {
  background: var(--petrol);
  color: var(--sand);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23EFE4CB' stroke-opacity='.035' stroke-width='1.2'%3E%3Cpath d='M48 8l11 29 29 11-29 11-11 29-11-29L8 48l29-11z'/%3E%3Crect x='30' y='30' width='36' height='36' transform='rotate(45 48 48)'/%3E%3C/g%3E%3C/svg%3E");
}

/* الأرقام إنجليزية دائمًا */
body, input, button, select, textarea { font-variant-numeric: lining-nums; }

a { color: var(--gold); }

button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }

/* اللمس: منع تحديد النص وتكبير النقر المزدوج على ما يُضغط.
   كان سحب الإصبع قليلًا على كلمة البطاقة يبدأ تحديد نص فتضيع الضغطة. */
button, summary, label.chk, .card, .board {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* =====================================================================
   شريط السدو والترويسة
   ===================================================================== */

.sadu {
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='168' height='14'%3E%3Cpath d='M0 14L14 0L28 14Z' fill='%23D2463C'/%3E%3Cpath d='M28 14L42 0L56 14Z' fill='%23EFE4CB'/%3E%3Cpath d='M56 14L70 0L84 14Z' fill='%233B6FD8'/%3E%3Cpath d='M84 14L98 0L112 14Z' fill='%23E39B2D'/%3E%3Cpath d='M112 14L126 0L140 14Z' fill='%233F9B5A'/%3E%3Cpath d='M140 14L154 0L168 14Z' fill='%238A55C8'/%3E%3C/svg%3E");
  background-size: auto 100%;
  opacity: .9;
  flex: none;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 700;
  color: var(--sand);
  text-decoration: none;
  line-height: 1.2;
}

.topbar .meta { color: var(--muted); font-size: 15px; }
.topbar .meta b { color: var(--sand); font-weight: 600; }
.topbar .spacer { margin-inline-start: auto; }

.roomcode {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 2px;
  background: var(--petrol-2);
  border-radius: var(--r-md);
  padding: 4px 14px;
}

/* =====================================================================
   عناصر عامة
   ===================================================================== */

.panel {
  background: var(--petrol-2);
  border-radius: var(--r-lg);
  padding: 18px;
}

.panel h2,
.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}

.btn {
  border: 0;
  border-radius: var(--r-md);
  padding: 13px 18px;
  font-size: 16px;
  font-weight: 700;
  background: var(--petrol-3);
  color: var(--sand);
  transition: filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:disabled { opacity: .4; cursor: default; }

.btn.primary { background: var(--gold); color: var(--ink); }
.btn.ghost {
  background: none;
  color: var(--sand);
  border: 1.5px solid var(--line);
  font-weight: 600;
}
.btn.danger { background: none; border: 1.5px solid var(--danger); color: var(--danger); font-weight: 600; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: var(--r-sm); }

.inp, select.inp {
  width: 100%;
  background: var(--petrol);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  color: var(--sand);
  padding: 12px 14px;
  font-weight: 600;
}
.inp::placeholder { color: var(--muted); font-weight: 400; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.7; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.msg {
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 12px;
  background: rgba(240, 138, 126, .14);
  color: var(--danger);
  border: 1px solid rgba(240, 138, 126, .3);
}
.msg.ok {
  background: rgba(111, 192, 138, .14);
  color: var(--ok);
  border-color: rgba(111, 192, 138, .3);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--petrol-3);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
}

table.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.tbl th {
  text-align: start; color: var(--muted); font-weight: 600;
  font-size: 13px; padding: 8px 6px; border-bottom: 1px solid var(--line);
}
table.tbl td { padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl code { font-family: var(--display); letter-spacing: 1px; font-size: 16px; }
table.tbl input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gold); }
td.rowacts { white-space: nowrap; display: flex; gap: 6px; justify-content: flex-end; }

/* شريط العمليات الجماعية فوق الجداول */
.bulkbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md, 12px);
  background: rgba(255, 255, 255, .03);
}
.bulkbar .spacer { flex: 1 1 auto; }

/* خيار بمربع اختيار */
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--gold); flex: none; }

/* شبكة خيارات الافتراضيات */
.optgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px 18px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.bulkbar .idle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
}
.bulkbar .idle .inp { width: 72px; padding: 6px 8px; text-align: center; }

@media (max-width: 600px) {
  .bulkbar { flex-direction: column; align-items: stretch; }
  .bulkbar .spacer { display: none; }
  .bulkbar .btn { width: 100%; }
  .bulkbar .idle { justify-content: space-between; }
  td.rowacts { flex-direction: column; }
}

/* =====================================================================
   الصفحة الرئيسية ولوحة المالك
   ===================================================================== */

.wrap { max-width: 980px; margin: 0 auto; padding: 24px 18px 60px; }
.wrap.narrow { max-width: 560px; }

.hero { text-align: center; padding: 28px 0 22px; }
.hero h1 { font-family: var(--display); font-size: clamp(38px, 8vw, 62px); font-weight: 700; line-height: 1.1; }
.hero p { color: var(--muted); margin-top: 10px; font-size: 17px; }

.cards2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }

.codeinput {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 8px;
  text-align: center;
  text-transform: uppercase;
}

/* =====================================================================
   الشبكة والبطاقات
   ===================================================================== */

/* minmax(0,1fr) ضروري كي تنكمش الأعمدة دون أن تدفعها الكلمات الطويلة */
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  gap: 9px;
}

.card {
  position: relative;
  aspect-ratio: 1.5;
  border-radius: 10px;
  background: var(--sand);
  color: var(--ink);
  border: 0;
  padding: 2px;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 700;
  /* الخط يتبع عرض العمود المتاح لا عرض الشاشة كاملة */
  font-size: clamp(9.5px, calc((100vw - 44px) / var(--cols, 5) / 4.2), 22px);
  line-height: 1.15;
  overflow: hidden;
  word-break: break-word;
  box-shadow: 0 3px 0 var(--sand-2);
}

.card::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(30, 42, 48, .14);
  border-radius: 6px;
  pointer-events: none;
}

.card .w { position: relative; z-index: 1; padding: 0 3px; }

.card .mark {
  position: absolute;
  inset-inline-end: -10%;
  bottom: -22%;
  width: 62%;
  opacity: .22;
  pointer-events: none;
  line-height: 0;
}
.card .mark svg { width: 100%; height: auto; }

button.card { cursor: pointer; }
button.card:disabled { cursor: default; }

/* مكشوفة */
.card.rev { color: #fff; box-shadow: none; }
.card.rev::before { border-color: rgba(255, 255, 255, .22); }
.card.rev.neutral { background: var(--neutral); color: rgba(255, 255, 255, .78); }
.card.rev.trap { background: var(--trap); color: var(--gold); }
.card.rev.trap .mark { opacity: .55; width: 44%; bottom: -8%; }

/* خريطة القائد (غير مكشوفة) */
.card.key { box-shadow: none; }
.card.key .strip { position: absolute; inset-block: 0; inset-inline-start: 0; width: 6px; z-index: 2; }
.card.key.trap { background: #3A4247; color: var(--gold); }
.card.key.neutral { background: #D7CCB2; color: #6D6553; }
.card.key.own { box-shadow: inset 0 0 0 2px rgba(30, 42, 48, .25); }

/* رؤية القائد المحدودة: بطاقة بلا لون معروف */
.card.key.unknown::before { border-style: dashed; border-color: rgba(30, 42, 48, .28); }

/* الكلمات التي قصدها القائد بتلميحه */
.card.intent { box-shadow: inset 0 0 0 2.5px var(--gold); }
.intent-dot {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 1px rgba(30, 42, 48, .35);
  z-index: 3;
}

/* =====================================================================
   شريط الفرق: المتبقي لكل فريق أمام اللاعب على جواله
   ===================================================================== */

.tstrip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 12px 8px;
  scrollbar-width: none;
}
.tstrip::-webkit-scrollbar { display: none; }

.ts {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  background: var(--petrol-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 13px;
  white-space: nowrap;
}
.ts svg { width: 15px; height: 15px; display: block; }
.ts .nm { color: var(--muted); }
.ts .n  { font-family: var(--display); font-size: 16px; line-height: 1; }

.ts.me .nm   { color: var(--sand); }
.ts.now      { border-color: var(--gold); background: var(--petrol-3); }
.ts.now .nm  { color: var(--sand); }
.ts.done .n  { color: var(--ok); }
.ts.gone     { opacity: .5; }
.ts.gone .n  { color: var(--danger); }

/* =====================================================================
   تلميحات سابقة في الجولة («فتح الماضي»)
   ===================================================================== */

.clues {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 2px;
  min-width: 0;
}
.clues .lbl { font-size: 12px; color: var(--muted); flex: none; }
.ckrow {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  min-width: 0;
  scrollbar-width: none;
}
.ckrow::-webkit-scrollbar { display: none; }

.ck {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 4px 9px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
  opacity: .72;
}
.ck svg { width: 12px; height: 12px; display: block; }
.ck b  { font-weight: 600; }
.ck i  { font-style: normal; font-family: var(--display); color: var(--gold); }
.ck em { font-style: normal; font-size: 11px; color: var(--ok); }

/* تلميحات فريقك أوضح، وما بقيت كلماته عليه نقطة ذهبية */
.ck.me   { opacity: 1; background: var(--petrol-2); }
.ck.me.open { border-color: var(--gold); }
.ck.me.open::after {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
}

/* =====================================================================
   ما بين الجولات
   ===================================================================== */

.between .subhead {
  font-family: var(--display);
  font-size: 17px;
  margin: 8px 14px 4px;
}
.between > .hint { padding: 0 14px; }
.between .lobby { padding-top: 4px; padding-bottom: 10px; }

details.lastboard {
  margin: 10px 12px 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
details.lastboard .play-board { padding: 0 0 12px; }
details.lastboard > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 10px;
}
details.lastboard[open] > summary { color: var(--sand); }

/* خلية تحوي بطاقة وزر اعتمادها؛ تأخذ حجم البطاقة نفسه داخل الشبكة */
.board > .cell { position: relative; display: grid; min-width: 0; }
.board > .cell > .card { width: 100%; }

/* زر ✓ في زاوية البطاقة المختارة: يختصر النزول إلى شريط الأسفل */
.okbtn {
  position: absolute;
  bottom: 3px;
  inset-inline-end: 3px;
  z-index: 4;
  width: clamp(22px, 38%, 30px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .6), 0 2px 4px rgba(30, 42, 48, .35);
  animation: pop .18s ease;
}
.okbtn svg { width: 66%; height: auto; display: block; }
.okbtn:active { transform: scale(.9); }
.okbtn:disabled { opacity: .55; cursor: default; }

/* الأغلبية غير مكتملة: الشارة تعرض الأصوات المطلوبة بدل ✓ */
.okbtn.short {
  background: var(--sand-2);
  color: var(--ink);
  font-size: clamp(9px, 1.6vw, 12px);
  font-weight: 700;
  cursor: default;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .45);
}

@keyframes pop {
  from { transform: scale(.4); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .okbtn { animation: none; }
}

/* تصويت وتحديد */
.card.mine { outline: 3px solid var(--gold); outline-offset: 1px; }
.votes {
  position: absolute; top: 4px; inset-inline-start: 4px;
  display: flex; gap: 2px; z-index: 3;
}
.votes i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 1px rgba(30, 42, 48, .35);
}

.card.anim { animation: flip .5s ease; }
@keyframes flip {
  0%   { transform: rotateX(0); }
  50%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .card.anim { animation: none; }
}

/* =====================================================================
   شريط التلميح
   ===================================================================== */

.cluebar {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--petrol-2);
  border-radius: var(--r-lg);
  padding: 14px 20px;
  flex-wrap: wrap;
}
.cluebar .who { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 17px; }
.cluebar .who svg { flex: none; }

.clue {
  font-family: var(--display);
  font-size: clamp(26px, 3.4vw, 46px);
  font-weight: 700;
  line-height: 1.15;
  color: var(--sand);
  display: flex;
  align-items: center;
  gap: 12px;
}
.clue .n {
  display: grid; place-items: center;
  width: 1.3em; height: 1.3em;
  border-radius: 14px;
  background: var(--gold);
  color: var(--ink);
  font-size: .78em;
}
.clue.waiting { font-size: clamp(17px, 2vw, 24px); color: var(--muted); font-family: var(--ui); font-weight: 600; }

.guesses { color: var(--muted); font-size: 14px; }
.guesses b { color: var(--sand); font-size: 20px; }

/* =====================================================================
   المؤقت (المرحلة الثالثة) — العد يُزامن من الخادم
   ===================================================================== */

.timer {
  position: relative;
  width: 74px;
  height: 74px;
  flex: none;
  margin-inline-start: auto;
}
.timer svg { transform: rotate(-90deg); display: block; }
.timer > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
}
.timer .pz {
  position: absolute;
  inset-inline: 0;
  bottom: -13px;
  text-align: center;
  font-size: 10px;
  font-style: normal;
  color: var(--muted);
}
.timer.sm { width: 46px; height: 46px; margin: 0; }
.timer.sm > span { font-size: 13px; }

/* زر كتم الصوت */
.btn.snd { font-size: 12px; padding: 6px 10px; white-space: nowrap; }
.btn.snd[aria-pressed="true"] { color: var(--gold); border-color: rgba(216, 179, 90, .5); }

/* مربع القائمة المخصصة */
textarea.inp { min-height: 120px; line-height: 1.8; resize: vertical; font-weight: 500; }

/* =====================================================================
   الشاشة المشتركة
   ===================================================================== */

.screen-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 330px;
  gap: 20px;
  padding: 16px 22px 26px;
  align-items: start;
}
.screen-center { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.team {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  border-radius: var(--r-md);
}
.team + .team { margin-top: 4px; }
.team.now { background: var(--petrol-3); box-shadow: inset -4px 0 0 var(--gold); }
.team .nm { font-weight: 600; font-size: 17px; }
.team .st { font-size: 13px; color: var(--muted); margin-top: 1px; }
.team.now .st { color: var(--gold); }
.team.gone .nm, .team.gone .pips { opacity: .45; }
.team .pts { font-family: var(--display); font-size: 24px; font-weight: 700; text-align: center; min-width: 42px; }
.team .pts small { display: block; font-family: var(--ui); font-size: 11px; color: var(--muted); font-weight: 500; }

.pips { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.pip { width: 10px; height: 10px; border-radius: 3px; border: 1.5px solid currentColor; }
.pip.on { background: currentColor; }

.standing {
  display: grid;
  grid-template-columns: 20px 22px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  padding: 5px 0;
}
.standing .rk { color: var(--muted); font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--petrol-3); margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; }

.log { list-style: none; padding: 0; margin: 4px 0 0; max-height: 46vh; overflow: auto; }
.log li {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.55;
}
.log time { color: var(--muted); font-size: 12px; padding-top: 2px; white-space: nowrap; }
.log .q { font-weight: 700; }
.log .bad { color: var(--danger); }
.log .good { color: var(--ok); }
.split { margin-top: 20px; }

.banner {
  background: var(--petrol-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 22px;
  text-align: center;
}
.banner b { font-family: var(--display); font-size: 26px; display: block; margin-bottom: 4px; }

/* =====================================================================
   صفحة اللاعب والقائد (الجوال أولًا)
   ===================================================================== */

.play {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
}
.play-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 8px;
}
.play-head .t { font-weight: 700; font-size: 16px; }
.play-head .s { font-size: 13px; color: var(--gold); }
.play-head .spacer { margin-inline-start: auto; }

.play-clue {
  margin: 0 12px;
  background: var(--petrol-2);
  border-radius: var(--r-lg);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.play-clue .clue { font-size: 30px; }
.play-clue .clue .n { border-radius: 11px; }
.play-clue .guesses { margin-inline-start: auto; text-align: center; line-height: 1.3; }

.play-board { padding: 12px; }
.play-board .board { gap: 4px; }
.play-board .card {
  border-radius: 7px;
  box-shadow: 0 2px 0 var(--sand-2);
  font-weight: 600;
  aspect-ratio: 1.3;
}
.play-board .card::before { inset: 3px; border-radius: 4px; }
.play-board .card .w { padding: 0 1px; }

.play-foot {
  margin-top: auto;
  position: sticky;
  bottom: 0;
  background: var(--petrol-2);
  border-radius: 22px 22px 0 0;
  padding: 12px 14px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .25);
}
.voters { font-size: 13px; color: var(--muted); min-height: 20px; margin-bottom: 9px; text-align: center; }
.voters b { color: var(--sand); }

.idle { margin: auto; padding: 30px 24px; text-align: center; color: var(--muted); line-height: 1.8; }
.idle b { display: block; color: var(--sand); font-size: 20px; margin-bottom: 6px; font-family: var(--display); }

.nums {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 4px;
  margin: 10px 0;
}
.nums button {
  border: 0;
  border-radius: var(--r-sm);
  background: var(--petrol);
  color: var(--sand);
  padding: 10px 0;
  font-weight: 700;
  font-size: 15px;
}
.nums button[aria-pressed="true"] { background: var(--gold); color: var(--ink); }

/* فلترة خريطة القائد */
.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 12px 0;
}
.filters button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--petrol-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}
.filters button i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.filters button[aria-pressed="true"] {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
}
.card.dim { opacity: .26; filter: grayscale(.7); }

.legend { display: flex; gap: 12px; flex-wrap: wrap; padding: 0 14px 4px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* =====================================================================
   الردهة (قبل بدء الجولة)
   ===================================================================== */

.lobby { padding: 12px 14px 30px; }
.lobby .teamcard {
  background: var(--petrol-2);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.lobby .teamcard header { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.lobby .teamcard header .nm { font-weight: 700; font-size: 17px; }
.lobby .teamcard header .cnt { margin-inline-start: auto; color: var(--muted); font-size: 13px; }
.members { display: flex; flex-wrap: wrap; gap: 6px; }
.member {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--petrol-3); border-radius: 999px;
  padding: 5px 11px; font-size: 14px;
}
.member.lead { box-shadow: inset 0 0 0 1.5px var(--gold); }
.member .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.member .dot.on { background: var(--ok); }
.member .crown { color: var(--gold); font-size: 12px; font-weight: 700; }

/* =====================================================================
   لوحة المنظِّم
   ===================================================================== */

/* عمودان مستقلان: كل عمود يرصّ لوحاته دون أن تتركا فجوة بينهما */
.host-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.host-grid .col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

@media (max-width: 980px) { .host-grid { grid-template-columns: 1fr; } }
.qrbox {
  background: #fff;
  border-radius: var(--r-md);
  padding: 8px;
  width: fit-content;
  line-height: 0;
}

/* الدعوة: الباركود يسار والروابط بجانبه */
.invite-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.invite-row .qrbox { flex: none; }
.invite-links { flex: 1 1 260px; min-width: 0; }
.invite-links .panel-title { margin-bottom: 6px; }
.invite-links .panel-title:not(:first-child) { margin-top: 14px; }

.linkrow { display: flex; gap: 8px; align-items: stretch; }
.linkrow .linkbox { flex: 1 1 auto; margin: 0; display: flex; align-items: center; }
.linkrow .btn { flex: none; }

@media (max-width: 560px) {
  .invite-row { flex-direction: column; }
  .invite-row .qrbox { align-self: center; }
}
.linkbox {
  background: var(--petrol);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 13.5px;
  word-break: break-all;
  color: var(--sand);
  margin-bottom: 8px;
}
.sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0 14px;
}

/* شريط التحكم في لوحة المنظِّم */
.control-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.control-head h2 { color: var(--muted); font-size: 15px; }
.control-actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.quicklinks { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.ql {
  display: block;
  background: var(--petrol);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  text-decoration: none;
  color: var(--sand);
  transition: border-color .15s;
}
.ql:hover { border-color: var(--gold); }
.ql b { display: block; font-size: 16px; margin-bottom: 3px; }
.ql span { font-size: 13px; color: var(--muted); line-height: 1.6; }
.ql-main { border-color: rgba(216, 179, 90, .55); background: var(--petrol-3); }
.ql-main b { color: var(--gold); }

/* مجموعات الإعدادات القابلة للطي */
details.group {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-bottom: 10px;
}
details.group > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--sand);
  font-size: 15px;
  padding: 2px 0;
  list-style: none;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before { content: "▸ "; color: var(--gold); }
details.group[open] > summary::before { content: "▾ "; }
details.group[open] > summary { margin-bottom: 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sand);
  font-size: 14.5px;
  line-height: 1.5;
}

.points-row { display: flex; gap: 8px; flex-wrap: wrap; }
.points-row .pt { flex: 1 1 74px; }
.points-row .pt span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.points-row .pt input { padding: 8px 6px; text-align: center; }

/* لوحة الجلسة */
.session-line { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 14.5px; }
.session-line b { color: var(--sand); }

/* الشاشة الختامية */
.final { text-align: center; }
.final .crown { font-family: var(--display); font-size: clamp(30px, 4vw, 52px); font-weight: 700; margin: 6px 0 2px; }
.final-table { margin: 18px auto 0; max-width: 620px; }
.final-row {
  display: grid;
  grid-template-columns: 44px 26px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--petrol);
  margin-bottom: 7px;
  font-size: 17px;
}
.final-row.top { background: var(--petrol-3); box-shadow: inset -4px 0 0 var(--gold); }
.final-row .rk { font-family: var(--display); font-size: 22px; color: var(--gold); text-align: center; }
.final-row .sc { font-family: var(--display); font-size: 24px; font-weight: 700; }
.final-row .sc small { font-family: var(--ui); font-size: 11px; color: var(--muted); font-weight: 500; display: block; }
.final-note { color: var(--muted); font-size: 14px; margin-top: 12px; }

.assign-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.assign-row select { padding: 7px 10px; font-size: 14px; }

/* =====================================================================
   تكيّف الشاشات
   ===================================================================== */

@media (max-width: 1100px) {
  .screen-grid { grid-template-columns: 1fr; }
  .log { max-height: 320px; }
}

@media (min-width: 720px) {
  .play { max-width: 680px; }
  .play-board .board { gap: 8px; }
  .play-board .card {
    aspect-ratio: 1.45;
    font-size: clamp(12px, calc(640px / var(--cols, 5) / 4.2), 20px);
  }
}

@media (max-width: 400px) {
  .topbar { gap: 10px; padding: 10px 12px; }
  .brand { font-size: 24px; }
  .play-clue .clue { font-size: 26px; }
}
