/* =========================================================
   Kingdom Feud — الأنماط المشتركة (RTL / مملكة قوطية ليلية)
   ========================================================= */

:root {
  /* الاسم الافتراضي للملف الموجود في المجلد؛ app.js يجرّب بدائل أخرى تلقائياً */
  --bg-image: url("background.jpeg");
  --night-950: #03050c;
  --night-900: #060a16;
  --night-850: #0a1120;
  --night-800: #0e1830;
  --night-700: #152444;
  --ink: #e8f0ff;
  --ink-dim: #a9b8d6;
  --ink-faint: #6b7c9c;

  --glow: #4ea6ff;
  --glow-hi: #8fcaff;
  --glow-soft: rgba(78, 166, 255, 0.35);

  --gold: #ffd77a;
  --gold-deep: #c99b2e;
  --silver: #d5deee;
  --strike: #ff2b45;
  --ok: #3ddc97;
  --warn: #ffb347;

  --radius: 16px;
  --radius-sm: 10px;

  --panel-bg: rgba(9, 15, 30, 0.62);
  --panel-bg-2: rgba(12, 20, 40, 0.78);
  --panel-brd: rgba(122, 178, 255, 0.26);
  --panel-brd-hi: rgba(143, 202, 255, 0.55);

  --font-ar: "Cairo", "Tajawal", system-ui, "Segoe UI", sans-serif;
  --font-num: "Cinzel", "Cairo", "Times New Roman", serif;

  --shadow-panel: 0 24px 60px -28px #000, 0 0 40px -18px var(--glow-soft);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ar);
  color: var(--ink);
  background-color: var(--night-950);
  /* الصورة تُكتشف تلقائياً من app.js (يدعم png / jpeg / jpg / webp) */
  background-image: var(--bg-image), radial-gradient(120% 90% at 50% 0%, #16294c 0%, #070d1c 55%, #02040a 100%);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.is-bg-png  { --bg-image: url("background.png"); }
body.is-bg-jpg  { --bg-image: url("background.jpg"); }
body.is-bg-webp { --bg-image: url("background.webp"); }

/* طبقة تعتيم خفيفة فوق الخلفية */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(115% 85% at 50% 45%, rgba(3, 6, 14, 0.18) 0%, rgba(2, 4, 10, 0.62) 78%, rgba(1, 2, 6, 0.86) 100%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: 0; }

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

::selection { background: var(--glow); color: #04070f; }

/* ===================== لوحات زجاجية ===================== */

.panel {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--panel-brd);
  border-radius: var(--radius);
  backdrop-filter: blur(10px) saturate(125%);
  -webkit-backdrop-filter: blur(10px) saturate(125%);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(190, 220, 255, 0.16),
    var(--shadow-panel);
}

/* حافة معدنية داخلية */
.panel::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(140, 190, 255, 0.1);
  border-radius: calc(var(--radius) - 6px);
  pointer-events: none;
}

.panel--pad { padding: clamp(14px, 1.6vw, 24px); }

.panel__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(15px, 1.15vw, 19px);
  color: var(--silver);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(122, 178, 255, 0.18);
}

.panel__title .ico { color: var(--glow); font-size: 1.15em; line-height: 1; }

/* ===================== أزرار ===================== */

.btn {
  --btn-bg: linear-gradient(180deg, rgba(40, 82, 148, 0.9), rgba(15, 30, 60, 0.92));
  --btn-brd: rgba(140, 195, 255, 0.4);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--btn-brd);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0;
  white-space: nowrap;
  transition: transform 0.14s ease, box-shadow 0.2s ease, filter 0.2s ease, background 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(200, 225, 255, 0.2), 0 10px 24px -14px #000;
}

.btn:hover { transform: translateY(-1px); filter: brightness(1.12); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: 2px solid var(--glow-hi); outline-offset: 2px; }

.btn--glow {
  --btn-brd: var(--panel-brd-hi);
  box-shadow: inset 0 1px 0 rgba(200, 225, 255, 0.25), 0 0 26px -6px var(--glow-soft), 0 10px 24px -14px #000;
}

.btn--gold {
  --btn-bg: linear-gradient(180deg, rgba(190, 148, 46, 0.92), rgba(96, 68, 12, 0.94));
  --btn-brd: rgba(255, 215, 122, 0.55);
  color: #fff6dd;
}

.btn--danger {
  --btn-bg: linear-gradient(180deg, rgba(150, 32, 48, 0.92), rgba(70, 12, 22, 0.94));
  --btn-brd: rgba(255, 110, 130, 0.5);
  color: #ffe3e7;
}

.btn--ghost {
  --btn-bg: rgba(20, 32, 58, 0.5);
  --btn-brd: rgba(122, 178, 255, 0.28);
}

.btn--sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn--lg { padding: 14px 26px; font-size: clamp(15px, 1.2vw, 19px); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.5); transform: none; }

/* ===================== حقول الإدخال ===================== */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; color: var(--ink-dim); font-weight: 700; }

.input, .select, textarea.input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(122, 178, 255, 0.28);
  background: rgba(4, 8, 18, 0.72);
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.input::placeholder { color: var(--ink-faint); }

.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--glow);
  box-shadow: 0 0 0 3px rgba(78, 166, 255, 0.16), 0 0 18px -6px var(--glow-soft);
}

.input[type="number"] { -moz-appearance: textfield; }
.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.select { cursor: pointer; }
.select option { background: #0a1120; color: var(--ink); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 150px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }

.hint { font-size: 12px; color: var(--ink-faint); line-height: 1.7; }
.err { color: #ff8a9c; font-size: 12.5px; font-weight: 700; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  border: 1px solid rgba(122, 178, 255, 0.35);
  background: rgba(20, 34, 62, 0.7);
  color: var(--ink-dim);
}

.divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(122, 178, 255, 0.35), transparent); margin: 14px 0; border: 0; }

/* =========================================================
   الصفحة الأولى: العرض (index.html)
   ========================================================= */

.display-stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: clamp(14px, 1.8vw, 34px);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.3vw, 20px);
}

.display-stage.is-shaking { animation: shake 0.55s cubic-bezier(.36, .07, .19, .97); }

/* شريط السؤال */
.question-bar {
  padding: clamp(9px, 1vw, 16px) clamp(14px, 1.6vw, 26px);
  text-align: center;
  background: linear-gradient(180deg, rgba(10, 18, 38, 0.82), rgba(6, 11, 24, 0.6));
  border-color: var(--panel-brd-hi);
}

.question-bar__label {
  font-size: clamp(10px, 0.75vw, 12px);
  letter-spacing: 3px;
  color: var(--glow-hi);
  opacity: 0.85;
  font-weight: 800;
}

.question-bar__text {
  margin-top: 4px;
  font-size: clamp(19px, 2.3vw, 42px);
  font-weight: 900;
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 0 34px rgba(78, 166, 255, 0.45), 0 4px 18px rgba(0, 0, 0, 0.8);
}

.question-bar__text.is-empty { color: var(--ink-faint); font-weight: 700; }

/* مجموع نقاط الجولة */
.round-total {
  align-self: center;
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.4vw, 22px);
  padding: 8px clamp(16px, 2vw, 30px);
  border-radius: 999px;
  border: 1px solid rgba(255, 215, 122, 0.4);
  background: linear-gradient(180deg, rgba(60, 46, 12, 0.6), rgba(20, 16, 6, 0.66));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 30px -14px rgba(255, 215, 122, 0.5), inset 0 1px 0 rgba(255, 235, 180, 0.2);
}

.round-total__label { font-size: clamp(11px, 0.9vw, 15px); color: #e8cf94; font-weight: 800; }
.round-total__value {
  font-family: var(--font-num);
  font-size: clamp(22px, 2.4vw, 42px);
  font-weight: 900;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 22px rgba(255, 200, 90, 0.55);
}
.round-total__mult {
  font-family: var(--font-num);
  font-size: clamp(16px, 1.5vw, 28px);
  font-weight: 900;
  color: #ffe9b0;
  padding: 2px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 215, 122, 0.35);
  background: rgba(255, 215, 122, 0.1);
}
.round-total.is-bump { animation: bump 0.5s ease; }

/* منطقة اللعب */
.play-area {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(165px, 0.8fr) minmax(0, 3.4fr) minmax(165px, 0.8fr);
  grid-template-areas: "teamA board teamB";
  gap: clamp(10px, 1.2vw, 22px);
  align-items: center;
  padding-bottom: clamp(6px, 1vw, 16px);
}

.team-box--a { grid-area: teamA; }
.team-box--b { grid-area: teamB; }
.answers-grid { grid-area: board; }

/* ---- مربعات الفرق ---- */
.team-box {
  padding: clamp(9px, 1vw, 16px) clamp(8px, 0.8vw, 14px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 0.55vw, 8px);
  background: linear-gradient(180deg, rgba(12, 22, 46, 0.72), rgba(6, 11, 24, 0.55));
}

.team-box__crest {
  width: clamp(42px, 4.2vw, 68px);
  height: clamp(42px, 4.2vw, 68px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(20px, 2vw, 34px);
  line-height: 1;
  border: 2px solid rgba(143, 202, 255, 0.4);
  background: radial-gradient(circle at 50% 30%, rgba(40, 78, 140, 0.85), rgba(6, 12, 26, 0.9));
  box-shadow: 0 0 30px -10px var(--glow-soft), inset 0 2px 10px rgba(255, 255, 255, 0.14);
  overflow: hidden;
  flex: none;
}

.team-box__crest img { width: 100%; height: 100%; object-fit: cover; }

.team-box__name {
  font-size: clamp(12px, 1.1vw, 20px);
  font-weight: 900;
  color: var(--silver);
  line-height: 1.2;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.team-box__score {
  font-family: var(--font-num);
  font-size: clamp(30px, 4vw, 70px);
  font-weight: 900;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 30px rgba(120, 190, 255, 0.6), 0 6px 20px rgba(0, 0, 0, 0.8);
}

.team-box__score.is-up { animation: scorePop 0.75s cubic-bezier(.2, 1.4, .4, 1); }
.team-box__score.is-down { animation: scoreShake 0.6s ease; }

.team-box__strikes { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-height: 18px; }

.strike-mark {
  width: clamp(15px, 1.5vw, 24px);
  height: clamp(15px, 1.5vw, 24px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: clamp(9px, 0.9vw, 13px);
  font-weight: 900;
  color: #ffd9de;
  border: 1px solid rgba(255, 90, 110, 0.6);
  background: linear-gradient(180deg, rgba(190, 30, 48, 0.9), rgba(80, 10, 20, 0.9));
  box-shadow: 0 0 16px -4px rgba(255, 43, 69, 0.7);
  animation: strikeIn 0.35s cubic-bezier(.2, 1.5, .4, 1);
}

/* ---- بطاقات الإجابات: عمودان × ثلاثة صفوف (ترتيب رأسي) ---- */
.answers-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  grid-auto-flow: column;
  gap: clamp(7px, 0.85vw, 15px);
  align-self: stretch;
  width: 100%;
  max-width: 580px;
  max-height: 430px;
  margin-inline: auto;
}

.answer-card {
  perspective: 1100px;
  min-height: 52px;
}

.answer-card__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.62s cubic-bezier(.35, .05, .2, 1);
}

.answer-card.is-revealed .answer-card__inner { transform: rotateY(180deg); }

.answer-card__face {
  position: absolute;
  inset: 0;
  border-radius: clamp(10px, 1.1vw, 18px);
  border: 1px solid var(--panel-brd);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(6px, 0.8vw, 16px);
  overflow: hidden;
}

/* الوجه الأمامي: الرقم */
.answer-card__front {
  background:
    linear-gradient(180deg, rgba(28, 58, 108, 0.92), rgba(9, 18, 38, 0.95)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0 6px, transparent 6px 12px);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.55),
    inset 0 0 34px -6px rgba(78, 166, 255, 0.35),
    0 16px 34px -20px #000;
  font-family: var(--font-num);
  font-size: clamp(24px, 3.3vw, 58px);
  font-weight: 900;
  color: #eaf3ff;
  text-shadow: 0 0 26px rgba(120, 190, 255, 0.55), inset 0 3px 0 rgba(0, 0, 0, 0.5);
}

/* الوجه الخلفي: الإجابة */
.answer-card__back {
  transform: rotateY(180deg);
  flex-direction: column;
  gap: 2px;
  background: linear-gradient(180deg, rgba(58, 44, 12, 0.9), rgba(24, 18, 6, 0.94));
  border-color: rgba(255, 215, 122, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.5),
    inset 0 0 40px -8px rgba(255, 200, 90, 0.35),
    0 0 34px -10px rgba(255, 200, 90, 0.4),
    0 16px 34px -20px #000;
}

.answer-card__text {
  font-size: clamp(12px, 1.1vw, 23px);
  font-weight: 800;
  line-height: 1.22;
  color: #fff8e6;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  overflow-wrap: anywhere;
}

.answer-card__points {
  font-family: var(--font-num);
  font-size: clamp(10px, 0.92vw, 18px);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 200, 90, 0.6);
}

/* خانة فارغة */
.answer-card.is-empty .answer-card__front {
  background: linear-gradient(180deg, rgba(12, 18, 32, 0.6), rgba(6, 9, 18, 0.7));
  border-style: dashed;
  border-color: rgba(122, 178, 255, 0.16);
  box-shadow: none;
  color: rgba(140, 165, 200, 0.35);
  font-size: clamp(15px, 1.6vw, 30px);
  text-shadow: none;
}

/* زر ملء الشاشة */
.fs-btn {
  position: fixed;
  bottom: 10px;
  left: 10px;
  z-index: 40;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(122, 178, 255, 0.3);
  background: rgba(6, 11, 24, 0.6);
  color: var(--ink-dim);
  font-size: 17px;
  cursor: pointer;
  opacity: 0.18;
  transition: opacity 0.25s ease, transform 0.2s ease, color 0.2s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.fs-btn:hover { opacity: 1; color: var(--glow-hi); transform: scale(1.08); }

/* طبقة الستريك */
.strike-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 0, 40, 0.26) 0%, rgba(0, 0, 0, 0.82) 72%);
}

.strike-overlay.is-active { animation: strikeFlash 2s ease forwards; }

.strike-overlay__x {
  font-family: var(--font-num);
  font-size: min(48vw, 44vh);
  font-weight: 900;
  line-height: 1;
  color: #ff2438;
  text-shadow: 0 0 70px rgba(255, 0, 40, 0.95), 0 0 170px rgba(255, 0, 40, 0.6);
  transform: scale(0.4);
}

.strike-overlay.is-active .strike-overlay__x { animation: strikeX 2s cubic-bezier(.16, .9, .3, 1) forwards; }

/* ===================== أنيميشن ===================== */

@keyframes shake {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(6px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-9px, 0, 0); }
  40%, 60% { transform: translate3d(9px, 0, 0); }
}

@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.09); }
  100% { transform: scale(1); }
}

@keyframes scorePop {
  0% { transform: scale(1); color: #fff; }
  30% { transform: scale(1.28); color: var(--gold); text-shadow: 0 0 48px rgba(255, 210, 100, 0.95); }
  100% { transform: scale(1); color: #fff; }
}

@keyframes scoreShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); color: #ff8a9c; }
  75% { transform: translateX(7px); color: #ff8a9c; }
}

@keyframes strikeIn {
  0% { transform: scale(0) rotate(-40deg); opacity: 0; }
  70% { transform: scale(1.25) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes strikeFlash {
  0% { opacity: 0; }
  8% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes strikeX {
  0% { transform: scale(0.35) rotate(-18deg); opacity: 0; }
  18% { transform: scale(1.15) rotate(4deg); opacity: 1; }
  32% { transform: scale(1) rotate(0); opacity: 1; }
  80% { transform: scale(1) rotate(0); opacity: 1; }
  100% { transform: scale(1.35) rotate(0); opacity: 0; }
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes flashGold {
  0% { box-shadow: 0 0 0 0 rgba(255, 215, 122, 0); }
  40% { box-shadow: 0 0 26px 2px rgba(255, 215, 122, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(255, 215, 122, 0); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* =========================================================
   الصفحات الإدارية: admin.html / control.html
   ========================================================= */

.page {
  position: relative;
  z-index: 1;
  max-width: 1500px;
  margin: 0 auto;
  padding: clamp(12px, 1.6vw, 28px);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.4vw, 20px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: clamp(12px, 1.3vw, 20px) clamp(14px, 1.8vw, 28px);
}

.topbar__brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.topbar__logo {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 24px;
  border-radius: 12px;
  border: 1px solid var(--panel-brd-hi);
  background: radial-gradient(circle at 50% 30%, rgba(40, 78, 140, 0.9), rgba(6, 12, 26, 0.95));
  box-shadow: 0 0 22px -8px var(--glow-soft);
}

.topbar__title { font-size: clamp(17px, 1.6vw, 27px); font-weight: 900; }
.topbar__sub { font-size: 12.5px; color: var(--ink-faint); }
.topbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-brd-hi);
  background: linear-gradient(180deg, rgba(40, 82, 148, 0.9), rgba(15, 30, 60, 0.92));
  font-weight: 700;
  transition: filter 0.2s ease, transform 0.14s ease;
}

.link-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: clamp(12px, 1.4vw, 20px);
  align-items: start;
}

.stack { display: flex; flex-direction: column; gap: clamp(12px, 1.4vw, 20px); }

/* ---- قائمة الأسئلة ---- */
.q-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; padding: 2px; }

.q-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(122, 178, 255, 0.18);
  background: rgba(8, 14, 28, 0.6);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.14s ease;
  animation: popIn 0.25s ease;
}

.q-item:hover { border-color: var(--panel-brd-hi); background: rgba(16, 28, 54, 0.72); transform: translateX(3px); }

.q-item.is-active {
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(255, 215, 122, 0.16), rgba(14, 24, 48, 0.7));
  box-shadow: 0 0 20px -10px rgba(255, 215, 122, 0.6);
}

.q-item.is-live { border-inline-end: 3px solid var(--glow); }

.q-item__idx {
  font-family: var(--font-num);
  font-size: 13px;
  color: var(--ink-faint);
  flex: none;
  width: 26px;
}

.q-item__text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.q-item__meta { font-size: 11px; color: var(--ink-faint); flex: none; }
.q-item__live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); flex: none; }

.empty-note {
  padding: 18px 12px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
  border: 1px dashed rgba(122, 178, 255, 0.22);
  border-radius: var(--radius-sm);
}

/* ---- محرر السؤال ---- */
.editor__qtext { margin-bottom: 12px; }
.editor__answers { display: flex; flex-direction: column; gap: 8px; }

.ans-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 92px 34px;
  gap: 8px;
  align-items: center;
}

.ans-row__idx { font-family: var(--font-num); font-size: 13px; color: var(--ink-faint); text-align: center; }
.ans-row__del { padding: 7px 0; font-size: 14px; }
.icon-btn {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 110, 130, 0.35);
  background: rgba(90, 16, 28, 0.5);
  color: #ff9aa8;
  cursor: pointer;
  font-size: 13px;
  transition: filter 0.18s ease, transform 0.14s ease;
}
.icon-btn:hover { filter: brightness(1.25); transform: translateY(-1px); }
.icon-btn--ok { border-color: rgba(61, 220, 151, 0.4); background: rgba(14, 60, 42, 0.5); color: #86efc2; }

/* ---- إعدادات الفرق ---- */
.team-editor { display: flex; flex-direction: column; gap: 14px; }

.team-editor__card {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(122, 178, 255, 0.2);
  background: rgba(8, 14, 28, 0.5);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-editor__head { display: flex; align-items: center; gap: 10px; }

.team-editor__label { font-weight: 800; color: var(--silver); font-size: 14px; }
.team-editor__crest {
  width: 44px;
  height: 44px;
  flex: none;
  font-size: clamp(17px, 1.5vw, 24px);
  border-width: 1px;
}
.team-editor__score { font-family: var(--font-num); font-size: 22px; font-weight: 900; color: var(--gold); margin-inline-start: auto; }

.team-editor__tools { display: flex; gap: 8px; flex-wrap: wrap; }
.team-editor__emoji { display: flex; gap: 6px; flex-wrap: wrap; }
.emoji-pick {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(122, 178, 255, 0.22);
  background: rgba(6, 11, 24, 0.6);
  cursor: pointer;
  font-size: 18px;
  transition: transform 0.14s ease, border-color 0.18s ease;
}
.emoji-pick:hover { transform: translateY(-2px) scale(1.06); border-color: var(--panel-brd-hi); }
.emoji-pick.is-on { border-color: var(--gold); box-shadow: 0 0 16px -6px rgba(255, 215, 122, 0.8); }

.preview-thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--panel-brd-hi);
}

/* ---- المضاعف ---- */
.mult-picker { display: flex; gap: 8px; }
.mult-btn {
  flex: 1;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(122, 178, 255, 0.25);
  background: rgba(8, 14, 28, 0.6);
  font-family: var(--font-num);
  font-size: 19px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.18s ease;
}
.mult-btn:hover { border-color: var(--panel-brd-hi); transform: translateY(-1px); }
.mult-btn.is-on {
  border-color: var(--gold);
  color: var(--gold);
  background: linear-gradient(180deg, rgba(255, 215, 122, 0.22), rgba(40, 30, 8, 0.7));
  box-shadow: 0 0 24px -8px rgba(255, 215, 122, 0.8);
}

/* ---- نافذة اختيار الفريق للستريك ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(2, 4, 10, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal.is-open { display: grid; }
.modal__box { max-width: 560px; width: 100%; padding: 22px; animation: popIn 0.25s ease; }
.modal__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

/* =========================================================
   صفحة التحكم بالجولة (control.html)
   ========================================================= */

.control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(12px, 1.4vw, 20px);
  align-items: start;
}

.answer-toggle-list { display: flex; flex-direction: column; gap: 9px; }

.answer-toggle {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 76px 116px;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(122, 178, 255, 0.22);
  background: rgba(8, 14, 28, 0.58);
  text-align: start;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: all 0.2s ease;
  animation: popIn 0.24s ease;
}

.answer-toggle:hover { border-color: var(--panel-brd-hi); background: rgba(16, 28, 54, 0.7); }

.answer-toggle.is-on {
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(255, 215, 122, 0.18), rgba(14, 24, 48, 0.72));
  box-shadow: 0 0 24px -12px rgba(255, 215, 122, 0.8);
}

.answer-toggle__num {
  font-family: var(--font-num);
  font-size: 16px;
  font-weight: 900;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(122, 178, 255, 0.3);
  background: rgba(6, 12, 26, 0.7);
  color: #dbe8ff;
}
.answer-toggle.is-on .answer-toggle__num { border-color: var(--gold); color: var(--gold); }

.answer-toggle__text { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.answer-toggle__pts { font-family: var(--font-num); font-weight: 900; color: var(--gold); font-size: 15px; text-align: center; }
.answer-toggle__state { font-size: 12px; font-weight: 800; color: var(--ink-faint); text-align: center; }
.answer-toggle.is-on .answer-toggle__state { color: var(--ok); }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 9px; }

.award-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.award-btn { flex-direction: column; gap: 2px; padding: 14px 10px; }
.award-btn__team { font-size: 13px; font-weight: 800; }
.award-btn__pts { font-family: var(--font-num); font-size: 22px; font-weight: 900; color: var(--gold); }

.preview-mini {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(122, 178, 255, 0.2);
  background: rgba(4, 8, 18, 0.55);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-mini__q { font-size: 14px; font-weight: 800; color: #fff; line-height: 1.4; }

.preview-mini__teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.preview-mini__team {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(122, 178, 255, 0.2);
  background: rgba(10, 18, 36, 0.6);
  text-align: center;
}
.preview-mini__name { font-size: 12px; color: var(--ink-dim); font-weight: 700; }
.preview-mini__score { font-family: var(--font-num); font-size: 26px; font-weight: 900; color: #fff; }
.preview-mini__strikes { display: flex; gap: 5px; justify-content: center; margin-top: 5px; min-height: 16px; }
.preview-mini__strikes span { font-size: 12px; color: var(--strike); }

.preview-mini__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(122, 178, 255, 0.28);
  background: rgba(18, 32, 60, 0.6);
  color: var(--ink-dim);
}
.chip.is-on { border-color: var(--gold); color: var(--gold); background: rgba(255, 215, 122, 0.14); }

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

/* ===================== شريط الحالة ===================== */

.toast-host {
  position: fixed;
  inset-block-end: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  max-width: 92vw;
}

.toast {
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--panel-brd-hi);
  background: rgba(8, 14, 30, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 12px 30px -14px #000, 0 0 26px -12px var(--glow-soft);
  animation: popIn 0.25s ease;
}

.toast--err { border-color: rgba(255, 110, 130, 0.6); color: #ffb3bd; }
.toast--ok { border-color: rgba(61, 220, 151, 0.55); color: #9df0c9; }

/* ===================== استجابة الشاشات ===================== */

@media (max-width: 1200px) {
  .play-area { grid-template-columns: minmax(130px, 0.75fr) minmax(0, 3fr) minmax(130px, 0.75fr); }
  .answers-grid { max-width: 560px; }
}

@media (max-width: 1000px) {
  .admin-grid, .control-grid { grid-template-columns: minmax(0, 1fr); }
  .play-area {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "teamA teamB" "board board";
  }
  .team-box { flex-direction: row; justify-content: center; flex-wrap: wrap; gap: 12px; }
  .team-box__score { font-size: clamp(30px, 7vw, 52px); }
}

@media (max-width: 720px) {
  .answers-grid { max-width: 100%; max-height: 400px; }
  .answer-card { min-height: 54px; }
  .answer-toggle { grid-template-columns: 34px minmax(0, 1fr) 60px; }
  .answer-toggle__state { grid-column: 1 / -1; text-align: start; }
  .ans-row { grid-template-columns: 22px minmax(0, 1fr) 72px 32px; }
  .modal__actions, .award-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar__actions { justify-content: stretch; }
  .topbar__actions > * { flex: 1; }
}

/* ===================== قائمة التنقل (☰) ===================== */

.nav-shell {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}

.nav-hamburger {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  pointer-events: auto;
  cursor: pointer;
  background: rgba(6, 12, 26, 0.7);
  border: 1px solid var(--panel-brd-hi);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px -10px #000, 0 0 18px -8px var(--glow-soft);
  transition: transform 0.14s ease, filter 0.2s ease;
}
.nav-hamburger:hover { filter: brightness(1.15); }
.nav-hamburger:active { transform: scale(0.94); }

.nav-hamburger__line {
  display: block;
  width: 20px;
  height: 2.5px;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 6px var(--glow-soft);
}

.nav-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 12, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  pointer-events: none;
}

.nav-drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(280px, 82vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 14px;
  background: linear-gradient(180deg, rgba(14, 24, 48, 0.98), rgba(6, 12, 26, 0.99));
  border-right: 1px solid var(--panel-brd-hi);
  box-shadow: 18px 0 46px -22px #000;
  transform: translateX(-100%);
  transition: transform 0.28s ease;
  overflow-y: auto;
  pointer-events: auto;
}

body.nav-is-open .nav-backdrop { opacity: 1; visibility: visible; pointer-events: auto; }
body.nav-is-open .nav-drawer { transform: translateX(0); }

.nav-drawer__title {
  font-size: 20px;
  font-weight: 900;
  padding: 6px 8px 14px;
  border-bottom: 1px solid var(--panel-brd);
  background: linear-gradient(90deg, var(--gold), var(--silver));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-drawer__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.nav-drawer__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.nav-drawer__link:hover { background: rgba(78, 166, 255, 0.12); border-color: var(--panel-brd); }

.nav-drawer__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  border: 1px solid var(--panel-brd);
  background: rgba(255, 255, 255, 0.06);
}

.nav-drawer__link.is-current {
  background: linear-gradient(180deg, rgba(40, 82, 148, 0.8), rgba(15, 30, 60, 0.9));
  border-color: var(--panel-brd-hi);
  box-shadow: 0 8px 22px -14px #000, inset 0 0 14px -8px var(--glow-soft);
}
.nav-drawer__link.is-current .nav-drawer__icon { border-color: var(--panel-brd-hi); box-shadow: 0 0 12px -4px var(--glow-soft); }

/* إفساح مجال للزر ☰ أعلى شريط الصفحات الإدارية */
@media (min-width: 721px) {
  body[data-page="admin"] .topbar,
  body[data-page="control"] .topbar { padding-left: 64px; }
}
@media (max-width: 720px) {
  body[data-page="admin"] .topbar,
  body[data-page="control"] .topbar { padding-top: 54px; }
}
/* شاشة العرض: لا يزاحم الزر ☰ نص السؤال */
body[data-page="display"] .question-bar { padding-inline: 62px; }