/* ── عرش ورماد — نظام التصميم ─────────────────────────────────────────── */
:root {
  --bg: #0B0A09;
  --bg2: #121010;
  --panel: rgba(255, 255, 255, .045);
  --panel2: rgba(255, 255, 255, .075);
  --border: rgba(255, 255, 255, .09);
  --border-gold: rgba(201, 162, 39, .28);
  --text: #F0E6D3;
  --muted: #9E9384;
  --gold: #C9A227;
  --gold2: #E8C870;
  --gold-deep: #A16207;
  --crimson: #B03A3A;
  --emerald: #4FA97A;
  --amber: #D9A441;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 4px 30px rgba(0, 0, 0, .5);
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, .6);
  --font-display: 'Reem Kufi', 'Noto Naskh Arabic', serif;
  --font-head: 'Noto Naskh Arabic', serif;
  --font-body: 'Noto Sans Arabic', system-ui, sans-serif;
  --icon-sm: 16px; --icon-md: 20px; --icon-lg: 24px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100dvh; background: var(--bg); color: var(--text);
  font-family: var(--font-body); line-height: 1.85; font-size: 16px;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
body::before {
  content: ''; position: fixed; inset: -30% -20% auto -20%; height: 72vh;
  pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(201, 162, 39, .17), transparent 62%);
}
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background:
    radial-gradient(circle at 12% 84%, rgba(176, 58, 58, .09), transparent 45%),
    radial-gradient(circle at 88% 22%, rgba(201, 162, 39, .07), transparent 45%);
}
#root { position: relative; z-index: 1; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.35; }
h4, h5 { font-family: var(--font-head); font-weight: 700; }
p { max-width: 74ch; }
::selection { background: rgba(201, 162, 39, .32); }

/* ── الغلاف العام ── */
.shell { max-width: 1180px; margin: 0 auto; padding: 1.25rem clamp(.9rem, 3vw, 2rem) 5rem; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; padding: .7rem 0; margin-bottom: 1.2rem;
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, rgba(11, 10, 9, .94), rgba(11, 10, 9, .78));
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px;
  display: grid; place-items: center; font-family: var(--font-display);
  font-size: 1.15rem; color: #14110C; background: linear-gradient(140deg, var(--gold2), var(--gold-deep));
  box-shadow: 0 6px 22px rgba(201, 162, 39, .3);
}
.brand-txt b { display: block; font-family: var(--font-display); font-size: 1.02rem; }
.brand-txt span { font-size: .72rem; color: var(--muted); letter-spacing: .04em; }
.top-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── أزرار ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .6rem 1.25rem; border-radius: 999px; cursor: pointer;
  font-family: var(--font-body); font-size: .88rem; font-weight: 600;
  border: 1px solid transparent; background: transparent; color: var(--text);
  transition: transform .16s ease, box-shadow .16s ease, background .2s ease, border-color .2s ease;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-gold { background: linear-gradient(140deg, var(--gold2), var(--gold-deep)); color: #14110C; box-shadow: 0 8px 26px rgba(201, 162, 39, .26); }
.btn-gold:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 38px rgba(201, 162, 39, .38); }
.btn-ghost { border-color: var(--border); background: var(--panel); }
.btn-ghost:hover:not(:disabled) { background: var(--panel2); border-color: var(--border-gold); transform: translateY(-1px); }
.btn-danger { border-color: rgba(176, 58, 58, .5); color: #E7A6A6; background: rgba(176, 58, 58, .12); }
.btn-sm { min-height: 36px; padding: .35rem .85rem; font-size: .78rem; }
.btn:focus-visible, .card-pick:focus-visible, .choice:focus-visible,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold2); outline-offset: 2px;
}

/* ── لوح ── */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  backdrop-filter: blur(12px); box-shadow: var(--shadow); padding: clamp(1.1rem, 2.4vw, 1.9rem);
}
.panel.gold { border-color: var(--border-gold); }
.hr { border: none; border-top: 1px solid var(--border); margin: 1.4rem 0; }
.tag {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .7rem; font-weight: 700;
  padding: .22rem .62rem; border-radius: 999px; letter-spacing: .04em;
  background: rgba(201, 162, 39, .13); color: var(--gold2); border: 1px solid var(--border-gold);
}
.tag.green { background: rgba(79, 169, 122, .12); color: var(--emerald); border-color: rgba(79, 169, 122, .3); }
.tag.red { background: rgba(176, 58, 58, .14); color: #E7A6A6; border-color: rgba(176, 58, 58, .34); }
.tag.grey { background: rgba(255, 255, 255, .06); color: var(--muted); border-color: var(--border); }

/* ── الشاشة الأولى ── */
.hero { text-align: center; padding: clamp(2.4rem, 7vw, 5rem) .5rem 2rem; }
.hero h1 {
  font-size: clamp(2.4rem, 8vw, 4.6rem); letter-spacing: -.01em; margin-bottom: .6rem;
  background: linear-gradient(160deg, #FFF6E2 10%, var(--gold2) 45%, var(--gold-deep) 95%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero .sub { color: var(--muted); font-size: clamp(.95rem, 2.2vw, 1.15rem); max-width: 60ch; margin: 0 auto 1.6rem; }
.rule-gold {
  width: 120px; height: 2px; margin: 1.4rem auto; border: none;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* ── بطاقات الاختيار ── */
.card-pick {
  text-align: right; cursor: pointer; color: inherit; font-family: var(--font-body);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.05rem 1.15rem; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.card-pick:hover { transform: translateY(-3px); border-color: var(--border-gold); background: var(--panel2); box-shadow: var(--shadow); }
.card-pick.on { border-color: var(--gold); background: rgba(201, 162, 39, .1); box-shadow: 0 0 0 1px var(--gold) inset, 0 12px 34px rgba(201, 162, 39, .16); }
.card-pick h4 { font-size: 1rem; margin-bottom: .25rem; }
.card-pick p { font-size: .82rem; color: var(--muted); line-height: 1.7; margin: 0; }
.card-pick .meta { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .6rem; }

/* ── الحقول ── */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.field > span { font-size: .76rem; font-weight: 700; color: var(--muted); letter-spacing: .03em; }
.field em { font-size: .72rem; color: var(--gold); font-style: normal; }
input, textarea, select {
  width: 100%; padding: .68rem .95rem; background: rgba(255, 255, 255, .05);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font-body); font-size: .92rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; min-height: 72px; line-height: 1.8; }
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 39, .16); }
input.err { border-color: var(--crimson); }
.field-error { color: #E7A6A6; font-size: .76rem; }
.steps { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.step-dot {
  font-size: .76rem; padding: .3rem .8rem; border-radius: 999px; color: var(--muted);
  border: 1px solid var(--border); background: rgba(255, 255, 255, .03);
}
.step-dot.on { color: #14110C; background: linear-gradient(140deg, var(--gold2), var(--gold-deep)); border-color: transparent; font-weight: 700; }
.step-dot.done { color: var(--gold2); border-color: var(--border-gold); }

/* ── شاشة اللعب: تخطيط ── */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.2rem; align-items: start; }
@media (max-width: 1024px) { .game-layout { grid-template-columns: 1fr; } .sidebar { position: static !important; } }
.sidebar { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 1rem; }

/* ── المشهد ── */
.scene { padding: clamp(1.1rem, 2.6vw, 2.1rem); }
.blk { animation: fadeUp .6s cubic-bezier(.16, 1, .3, 1) both; }
.blk-time {
  font-family: var(--font-head); font-size: 1.05rem; color: var(--gold2);
  display: flex; align-items: center; gap: .6rem; padding-bottom: .7rem;
}
.blk-time::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border-gold), transparent); }
.blk-place { font-size: .76rem; color: var(--muted); letter-spacing: .06em; margin-bottom: 1rem; }
.blk-head {
  font-family: var(--font-display); font-size: clamp(1.05rem, 2.4vw, 1.35rem); color: var(--gold2);
  margin: 1.5rem 0 .7rem; padding-right: .8rem; border-right: 3px solid var(--gold);
}
.blk p { margin-bottom: .85rem; font-size: clamp(.95rem, 1.6vw, 1.03rem); color: #E7DCC8; }
.blk-quote {
  border-right: 3px solid var(--border-gold); background: rgba(201, 162, 39, .07);
  padding: .85rem 1.1rem; border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--font-head); font-size: 1.02rem; color: var(--gold2); margin: .4rem 0 1rem;
}
.blk-faction, .blk-media, .blk-private, .blk-surprise, .blk-delayed, .blk-arc {
  border-radius: var(--radius); padding: .95rem 1.1rem; margin: .9rem 0;
  background: rgba(255, 255, 255, .035); border: 1px solid var(--border);
  border-right: 3px solid var(--muted);
}
.blk-faction .who { font-size: .74rem; font-weight: 700; color: var(--muted); letter-spacing: .05em; display: block; margin-bottom: .3rem; }
.blk-faction.pos { border-right-color: var(--emerald); background: rgba(79, 169, 122, .06); }
.blk-faction.neg { border-right-color: var(--crimson); background: rgba(176, 58, 58, .07); }
.blk-faction.neu { border-right-color: var(--amber); background: rgba(217, 164, 65, .05); }
.blk-media { border-right-color: #6E86B8; background: rgba(110, 134, 184, .07); }
.blk-media::before { content: 'نبض الإعلام'; display: block; font-size: .72rem; color: #9DB0D8; font-weight: 700; margin-bottom: .3rem; }
.blk-private { border-right-color: #A97BB8; background: rgba(169, 123, 184, .07); font-family: var(--font-head); }
.blk-private::before { content: 'ما لا يراه أحد'; display: block; font-size: .72rem; color: #C9A6D6; font-weight: 700; margin-bottom: .3rem; font-family: var(--font-body); }
.blk-surprise { border-right-color: var(--crimson); background: rgba(176, 58, 58, .1); }
.blk-surprise .t { display: flex; align-items: center; gap: .4rem; font-size: .76rem; font-weight: 700; color: #E7A6A6; margin-bottom: .35rem; }
.blk-delayed { border-right-color: var(--amber); background: rgba(217, 164, 65, .07); }
.blk-delayed .t { font-size: .76rem; font-weight: 700; color: var(--amber); margin-bottom: .35rem; }
.blk-arc { border-right-color: var(--gold); background: linear-gradient(140deg, rgba(201, 162, 39, .12), rgba(201, 162, 39, .03)); }
.blk-arc .t { font-family: var(--font-display); font-size: 1rem; color: var(--gold2); margin-bottom: .4rem; }

/* ── الخيارات ── */
.choices { display: grid; gap: .65rem; margin-top: 1.1rem; }
.choice {
  display: grid; grid-template-columns: 34px 1fr auto; gap: .7rem; align-items: start;
  text-align: right; cursor: pointer; color: inherit; width: 100%;
  font-family: var(--font-body); font-size: .9rem; line-height: 1.75;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .85rem 1rem; transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.choice:hover { transform: translateY(-2px); border-color: var(--border-gold); background: var(--panel2); box-shadow: var(--shadow); }
.choice .num {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: rgba(201, 162, 39, .12); border: 1px solid var(--border-gold);
  color: var(--gold2); font-weight: 700; font-size: .82rem;
}
.choice .mode { font-size: .68rem; color: var(--muted); letter-spacing: .05em; display: block; margin-bottom: .18rem; }
.choice .txt { color: #EADFC9; }
.choice.wild { border-color: rgba(176, 58, 58, .34); background: rgba(176, 58, 58, .06); }
.choice.wild .num { background: rgba(176, 58, 58, .16); border-color: rgba(176, 58, 58, .4); color: #E7A6A6; }
.free-row { display: flex; gap: .6rem; margin-top: .9rem; }
.free-row input { flex: 1; }

/* ── لوحة المؤشرات ── */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .9rem; }
.panel-head h3 { font-size: 1rem; }
.meter { margin-bottom: .72rem; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; font-size: .78rem; margin-bottom: .28rem; }
.meter-top b { font-size: .84rem; font-variant-numeric: tabular-nums; }
.meter-top .dl { font-size: .7rem; font-weight: 700; }
.dl.up { color: var(--emerald); } .dl.down { color: #E7A6A6; } .dl.flat { color: var(--muted); }
.bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold-deep), var(--gold2)); transition: width .7s cubic-bezier(.16, 1, .3, 1); }
.bar.warn > i { background: linear-gradient(90deg, #8A5A16, var(--amber)); }
.bar.bad > i { background: linear-gradient(90deg, #6E2323, var(--crimson)); }
.risk-row { display: flex; justify-content: space-between; font-size: .8rem; padding: .34rem 0; border-bottom: 1px dashed var(--border); }
.fac-row { display: flex; align-items: center; gap: .5rem; font-size: .78rem; padding: .3rem 0; }
.fac-row span { flex: 1; color: var(--muted); }
.fac-row .mini { width: 74px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.fac-row .mini > i { display: block; height: 100%; background: var(--muted); }

/* ── النافذة والسجل ── */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(6, 5, 4, .74);
  backdrop-filter: blur(5px); display: grid; place-items: center; padding: 1rem; animation: fadeUp .25s ease;
}
.modal {
  background: #100E0C; border: 1px solid var(--border-gold); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: min(760px, 100%); max-height: 86dvh; overflow: auto;
  padding: clamp(1.1rem, 3vw, 1.9rem);
}
.entry { display: grid; grid-template-columns: 108px 1fr; gap: .8rem; padding: .8rem 0; border-bottom: 1px solid var(--border); font-size: .86rem; }
.entry .when { color: var(--muted); font-size: .74rem; }
.entry .kind { font-size: .68rem; font-weight: 700; letter-spacing: .04em; }
.entry.k-choice .kind { color: var(--gold2); } .entry.k-surprise .kind { color: #E7A6A6; }
.entry.k-delayed .kind { color: var(--amber); } .entry.k-open .kind { color: var(--emerald); }
.empty { text-align: center; color: var(--muted); padding: 2rem 0; font-size: .88rem; }
.qline { display: flex; align-items: flex-start; gap: .6rem; padding: .5rem 0; border-top: 1px dashed var(--border); font-size: .82rem; }
.qline .in { color: var(--gold2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── النهاية ── */
.ending { text-align: center; padding: clamp(1.6rem, 5vw, 3rem) clamp(1rem, 4vw, 2.6rem); }
.ending h2 { font-size: clamp(1.7rem, 5vw, 2.8rem); margin-bottom: .5rem; }
.ending .tone { font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; }
.ending.win h2 { color: var(--gold2); } .ending.legend h2 { color: var(--gold2); }
.ending.lose h2 { color: #E7A6A6; } .ending.bitter h2 { color: var(--amber); }
.ending p { font-size: clamp(.95rem, 2vw, 1.06rem); color: #E7DCC8; max-width: 64ch; margin: .6rem auto; text-align: right; }

/* ── تنبيهات ── */
.toasts { position: fixed; bottom: 1.2rem; left: 1.2rem; z-index: 90; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  padding: .6rem 1.05rem; border-radius: var(--radius-sm); font-size: .84rem; font-weight: 600;
  background: rgba(79, 169, 122, .14); border: 1px solid rgba(79, 169, 122, .34); color: #BFE7D2;
  animation: fadeUp .3s ease; box-shadow: var(--shadow);
}
.toast.error { background: rgba(176, 58, 58, .16); border-color: rgba(176, 58, 58, .4); color: #E7A6A6; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.muted { color: var(--muted); font-size: .84rem; }
.center { text-align: center; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.between { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: space-between; align-items: center; }

/* ── استجابة الشاشات ── */
@media (max-width: 720px) {
  body { font-size: 15px; line-height: 1.8; }
  .shell { padding: .8rem .8rem 4rem; }
  .topbar { padding: .55rem 0; }
  .brand-txt span { display: none; }
  .choice { grid-template-columns: 28px 1fr; }
  .choice .num { width: 26px; height: 26px; font-size: .76rem; }
  .entry { grid-template-columns: 1fr; gap: .25rem; }
  .free-row { flex-direction: column; }
  .toasts { left: .7rem; right: .7rem; bottom: .7rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}
.mono { font-variant-numeric: tabular-nums; }
.pad0 { padding: 0; }
.nowrap { white-space: nowrap; }
