/* موزّع المافيا — الهوية البصرية (Noir / Casino / Tarot) */
:root {
  --bg: #0a0d14;
  --bg-2: #0f1420;
  --panel: #121824;
  --panel-2: #0c1018;
  --line: #2c3440;
  --line-2: #1f2633;
  --gold: #c9a55a;
  --gold-2: #d9b25f;
  --gold-3: #f0d18a;
  --gold-soft: rgba(201, 165, 90, .35);
  --ink: #f3ead8;
  --ink-2: #cfc6b2;
  --muted: #a3acbb;
  --mafia: #b8434f;
  --mafia-2: #8e2433;
  --mafia-ink: #f5a3ad;
  --mafia-bg: #2a1215;
  --ok: #8fe0b5;
  --ok-bg: #13261c;
  --warn: #f0c36a;
  --dot-random: #3dd68c;
  --dot-pick: #e5484d;
  --radius: 16px;
  --font: 'Cairo', system-ui, sans-serif;
  --display: 'Reem Kufi', 'Cairo', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--font); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(ellipse at 50% -10%, rgba(201, 165, 90, .14), transparent 55%);
  background-attachment: fixed; line-height: 1.6; -webkit-tap-highlight-color: transparent;
}
a { color: var(--gold-2); }
a:hover { color: var(--gold-3); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--gold-3); outline-offset: 2px; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.gold { color: var(--gold-2); }
.mafia-ink { color: var(--mafia-ink); }
.ok { color: var(--ok); }
.bad { color: var(--mafia-ink); }
.warn { color: var(--warn); }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: 14px; border: 1px solid transparent; font-weight: 800; font-size: 15px; text-decoration: none;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn-gold { background: var(--gold); color: #14110a; }
.btn-gold:hover { background: var(--gold-2); color: #14110a; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--gold-soft); color: var(--ink); }
.btn-mafia { background: var(--mafia-2); color: #fbe9eb; }
.btn-danger { background: transparent; border-color: var(--mafia); color: var(--mafia-ink); }
.btn-wa { background: var(--ok-bg); border-color: #2f6b46; color: var(--ok); }
.btn-wa:hover { color: #c8f5dc; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-xl { min-height: 58px; font-size: 17px; border-radius: 18px; }
.btn-block { display: flex; width: 100%; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px 0; font-size: 13px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.row-btns > * { flex: 1 1 140px; }

.icon-btn {
  width: 52px; height: 52px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); font-size: 22px;
}
.icon-btn.ghost { width: 44px; height: 44px; background: transparent; border-color: transparent; color: var(--muted); }

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: rgba(10, 13, 20, .85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-2);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand-ico { width: 32px; height: 32px; color: var(--gold); display: inline-flex; }
.brand-ico svg { width: 32px; height: 32px; }
.topbar-links { display: flex; gap: 6px; }
.topbar-link { padding: 8px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 700; }
.topbar-link:hover { background: var(--panel); color: var(--ink); }

/* ---------- الصور الرمزية ---------- */
.avatar {
  --av: var(--gold); flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px;
  background: var(--av); color: #14110a; font-weight: 800; overflow: hidden; box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3px var(--av);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 28px; height: 28px; font-size: 11px; }
.avatar-sm { width: 34px; height: 34px; font-size: 12px; }
.avatar-md { width: 46px; height: 46px; font-size: 15px; }
.avatar-lg { width: 60px; height: 60px; font-size: 20px; }
.avatar-xl { width: 104px; height: 104px; font-size: 34px; font-family: var(--display); }

.stars { font-size: 22px; letter-spacing: 3px; }
.stars .on { color: var(--gold); }
.stars .off { color: var(--line); }

/* ---------- العناصر العامة ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { font-size: 16px; color: var(--gold-2); }
.flash { padding: 12px 16px; border-radius: 14px; font-weight: 700; font-size: 14px; margin-bottom: 14px; }
.flash-ok { background: var(--ok-bg); border: 1px solid #2f6b46; color: var(--ok); }
.flash-err { background: var(--mafia-bg); border: 1px solid var(--mafia); color: #f5c2c8; }
.empty { padding: 20px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }
.pill { padding: 7px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 800; color: var(--gold-2); white-space: nowrap; }

.form { display: flex; flex-direction: column; gap: 8px; }
.form label, .label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.form input:not([type=checkbox]):not([type=radio]), .form select, .search input, .copy-row input {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid #3a4456; background: var(--bg); color: var(--ink); font-size: 15px;
}
.form input[type=file] { padding: 10px 12px; }
.form input:focus, .search input:focus { border-color: var(--gold); outline: none; }
.form button[type=submit] { margin-top: 8px; align-self: flex-start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid > div { display: flex; flex-direction: column; gap: 6px; }
.span-2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
.code-input { font-size: 22px !important; font-weight: 800; letter-spacing: 6px; text-align: center; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; width: 36px; height: 36px; border-radius: 999px; background: var(--sw); border: 3px solid transparent; cursor: pointer; }
.swatch input:checked + span { border-color: var(--ink); }
.swatch input:focus-visible + span { outline: 2px solid var(--gold-3); outline-offset: 2px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { direction: ltr; font-size: 13px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpis-sm { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin: 0; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi b { font-family: var(--display); font-size: 30px; line-height: 1.1; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi-mafia { border-color: rgba(184, 67, 79, .45); }
.kpi-mafia b { color: var(--mafia-ink); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line-2); color: var(--ink); text-decoration: none; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-row .grow small { font-size: 12px; }
.rank { width: 24px; text-align: center; font-family: var(--display); color: var(--gold-2); }
.res { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.res.win { background: var(--ok-bg); color: var(--ok); }
.res.lose { background: var(--mafia-bg); color: var(--mafia-ink); }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--panel-2); }
.badge-town { background: rgba(201, 165, 90, .15); color: var(--gold-3); }
.badge-mafia { background: var(--mafia-bg); color: var(--mafia-ink); }
.badge-none { color: var(--muted); }

.log { display: flex; flex-direction: column; gap: 6px; }
.log div { display: flex; gap: 10px; font-size: 13px; }
.log span { flex-shrink: 0; color: var(--muted); font-weight: 700; min-width: 64px; }
.log p { margin: 0; }

.table-wrap { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.table th { color: var(--muted); font-size: 12px; font-weight: 700; }

/* ---------- صفحات الدخول ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 400px; padding: 28px 24px; border-radius: 24px; background: var(--bg-2); border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 7px var(--bg-2), inset 0 0 0 8px var(--gold-soft), 0 30px 70px rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.auth-card h1 { font-family: var(--display); font-size: 28px; }
.auth-card .form { text-align: right; }
.brand-mark { color: var(--gold); display: flex; justify-content: center; }
.brand-mark svg { width: 72px; height: 72px; }

/* ---------- لوحة الإدارة ---------- */
.admin-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; max-width: 1240px; margin: 0 auto; padding: 20px; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 76px; align-self: start; }
.admin-nav a { padding: 12px 14px; border-radius: 12px; color: var(--ink-2); text-decoration: none; font-weight: 700; }
.admin-nav a:hover { background: var(--panel); color: var(--ink); }
.admin-nav a.is-on { background: var(--panel); color: var(--gold-2); box-shadow: inset -3px 0 0 var(--gold); }
.admin-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.page-title { font-family: var(--display); font-size: 28px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.search input { width: 240px; }
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.player-card { background: var(--bg-2); border: 1px solid var(--gold-soft); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.player-card.is-off { opacity: .55; }
.pc-head { display: flex; align-items: center; gap: 12px; }
.pc-head div { display: flex; flex-direction: column; }
.pc-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: center; font-size: 11px; color: var(--muted); }
.pc-stats span { display: flex; flex-direction: column; background: var(--panel); border-radius: 10px; padding: 6px 2px; }
.pc-stats b { font-size: 15px; color: var(--ink); }
.pc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pc-actions form { display: contents; }

/* ---------- الصفحة العامة للاعب ---------- */
.profile { max-width: 560px; margin: 0 auto; padding: 24px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.profile-hero { align-items: center; text-align: center; gap: 10px; padding: 28px 18px; }
.profile-hero h1 { font-family: var(--display); font-size: 32px; }
.tier { padding: 4px 14px; border-radius: 999px; background: #221d12; border: 1px solid var(--gold); color: var(--gold-3); font-size: 13px; font-weight: 800; }
.team-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.team-card { padding: 16px; border-radius: 18px; background: var(--panel); border: 1px solid var(--gold-soft); display: flex; flex-direction: column; gap: 6px; }
.team-card span { font-size: 13px; font-weight: 800; color: var(--gold-2); }
.team-card b { font-family: var(--display); font-size: 38px; line-height: 1; }
.team-card small { color: var(--ink-2); }
.team-card.mafia { background: #161018; border-color: rgba(184, 67, 79, .45); }
.team-card.mafia span { color: var(--mafia-ink); }
.meter { display: block; height: 7px; border-radius: 999px; background: var(--line-2); overflow: hidden; flex: 1; }
.meter span { display: block; height: 100%; background: var(--gold); border-radius: inherit; }
.team-card.mafia .meter span, .meter.mafia span { background: var(--mafia); }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-row > span { width: 110px; font-weight: 700; }
.bar-row b { width: 24px; text-align: left; color: var(--muted); }

/* ================================================================ */
/* طاولة اللعب                                                       */
/* ================================================================ */
.app { max-width: 1240px; margin: 0 auto; padding: 18px 16px 48px; }
.screen { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.screen-play { max-width: none; }
.screen-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.screen-head h1 { font-family: var(--display); font-size: 30px; }
.eyebrow { font-size: 12px; font-weight: 700; color: var(--gold-2); }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.section-head h2 { font-size: 16px; color: var(--gold-2); }

.calc-wrap { position: relative; }
.mode-dot { position: absolute; top: -8px; left: -8px; width: 26px; height: 26px; padding: 0; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; }
.mode-dot span { width: 9px; height: 9px; border-radius: 999px; box-shadow: 0 0 0 2px var(--bg); }

.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.roster-chip { min-height: 56px; padding: 6px 10px; border-radius: 14px; display: flex; align-items: center; gap: 10px; background: var(--panel-2); border: 1px solid #222936; opacity: .55; text-align: right; }
.roster-chip.is-on { background: var(--panel); border-color: var(--gold-soft); opacity: 1; }
.roster-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.roster-name b, .roster-name small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-name small { color: var(--muted); font-size: 11px; }

.stepper-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); }
.stepper-card > div:first-child { display: flex; flex-direction: column; }
.stepper-card small { color: var(--muted); font-size: 12px; }
.mafia-tone { background: #161018; border-color: rgba(184, 67, 79, .4); }
.mafia-tone b { color: #ee9aa4; }
.stepper { display: flex; align-items: center; gap: 10px; }
.step-btn { width: 46px; height: 46px; border-radius: 12px; border: 1px solid #4a3236; background: var(--bg); font-size: 22px; font-weight: 800; }
.step-mafia { background: var(--mafia-2); border-color: var(--mafia-2); color: #fbe9eb; }
.step-val { width: 36px; text-align: center; font-family: var(--display); font-size: 32px; font-weight: 700; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.role-chip { min-height: 44px; padding: 0 12px; border-radius: 12px; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; background: var(--panel-2); border: 1px solid #222936; color: #7d8597; }
.role-chip .glyph { font-family: var(--display); font-size: 16px; }
.role-chip.is-on.is-town { background: #1a1f2a; border-color: var(--gold); color: var(--ink); }
.role-chip.is-on.is-mafia { background: #2a1519; border-color: var(--mafia); color: var(--ink); }
.fill-row { display: flex; gap: 8px; font-size: 13px; font-weight: 700; }
.fill-row span { flex: 1; padding: 10px 12px; border-radius: 12px; border: 1px dashed #3a4456; color: var(--gold-2); }
.fill-row span.mafia-ink { border-color: #4a3236; }
.alert { padding: 12px 14px; border-radius: 14px; background: var(--mafia-bg); border: 1px solid var(--mafia); color: #f5c2c8; font-size: 13px; font-weight: 700; line-height: 1.8; }

/* النوافذ المنبثقة */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(5, 7, 11, .9); display: flex; align-items: flex-start; justify-content: center; padding: 80px 16px 16px; overflow-y: auto; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 420px; padding: 18px; border-radius: 26px; background: #151a24; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; box-shadow: 0 30px 60px rgba(0, 0, 0, .6); animation: rise .18s ease; }
.sheet-mafia { border-color: var(--mafia); }
.sheet-ok { border-color: #2f6b46; }
.sheet-head, .sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet-foot { font-size: 13px; font-weight: 800; }
.calc-disp { min-height: 76px; padding: 10px 16px; border-radius: 16px; background: var(--bg); display: flex; align-items: flex-end; justify-content: flex-end; font-size: 40px; font-weight: 700; overflow: hidden; word-break: break-all; }
.calc-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.calc-keys button { height: 62px; border-radius: 16px; border: 0; background: #0f131b; font-size: 22px; font-weight: 800; }
.calc-keys button:active { filter: brightness(1.3); }
.calc-keys .k-op { background: #232a38; color: var(--gold-2); }
.calc-keys .k-fn { background: #1c2230; }
.calc-keys .k-eq { background: var(--gold); color: #14110a; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.pick-chip { min-height: 54px; padding: 6px 10px; border-radius: 14px; display: flex; align-items: center; gap: 8px; background: #0f131b; border: 1px solid var(--line); text-align: right; }
.pick-chip span { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pick-chip b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-chip small { font-size: 11px; color: var(--mafia-ink); font-weight: 700; }
.pick-chip.is-on { background: #3a1119; border-color: var(--dot-pick); }
.pick-chip:disabled { opacity: 1; cursor: default; }

/* بطاقات التاروت */
.tarot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.tarot-back {
  position: relative; aspect-ratio: 5 / 8; padding: 0; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 5px var(--bg-2), inset 0 0 0 6px var(--gold-soft), 0 10px 24px rgba(0, 0, 0, .4);
  display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; color: var(--ink);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tarot-back:hover:not(:disabled) { transform: translateY(-3px); box-shadow: inset 0 0 0 5px var(--bg-2), inset 0 0 0 6px var(--gold), 0 16px 30px rgba(0, 0, 0, .5); }
.tarot-back .tarot-star { width: 56%; stroke: var(--gold-soft); }
.tarot-back .tag { position: absolute; top: 12px; font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--gold-2); }
.tarot-back .ribbon { position: absolute; bottom: 10px; right: 8px; left: 8px; padding: 4px 2px; border-radius: 6px; background: var(--bg); border: 1px solid var(--gold-soft); display: flex; flex-direction: column; line-height: 1.25; }
.tarot-back .ribbon b { font-size: 13px; }
.tarot-back .ribbon small { font-size: 10px; color: var(--muted); }
.tarot-back.is-done { border-color: #222936; opacity: .4; box-shadow: none; }
.tarot-star { fill: none; stroke-width: 1.4; }

.tarot-face {
  width: 100%; max-width: 360px; margin: 0 auto; padding: 22px 20px; border-radius: 22px; background: var(--bg-2); border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 7px var(--bg-2), inset 0 0 0 8px var(--gold-soft), 0 30px 70px rgba(0, 0, 0, .7), 0 0 60px rgba(201, 165, 90, .14);
  display: flex; flex-direction: column; gap: 12px;
}
.reveal-stage { display: flex; flex-direction: column; gap: 14px; animation: flip .45s cubic-bezier(.2, .8, .2, 1); }
.tarot-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--ink-2); padding: 0 6px; }
.medallion-wrap { position: relative; height: 150px; display: flex; align-items: center; justify-content: center; }
.medallion-wrap .tarot-star { position: absolute; width: 150px; height: 150px; stroke: var(--gold-soft); stroke-width: .8; }
.medallion { position: relative; width: 88px; height: 88px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 44px; font-weight: 700; background: var(--gold); color: #14110a; box-shadow: 0 0 0 4px var(--bg-2), 0 0 0 5px var(--gold); }
.role-title { font-family: var(--display); font-size: 28px; text-align: center; }
.role-desc { margin: 0; font-size: 13px; color: var(--ink-2); text-align: center; }
.ornament { display: flex; align-items: center; gap: 8px; }
.ornament span { flex: 1; height: 1px; background: var(--gold-soft); }
.ornament i { width: 6px; height: 6px; transform: rotate(45deg); background: var(--gold); }
.secret-box { height: 156px; overflow-y: auto; padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.secret-box b { color: var(--gold-2); font-size: 12px; }
.secret-box p { margin: 0; color: var(--ink-2); line-height: 1.8; }
.mate { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 8px; background: var(--panel); }
.mate span:first-child { font-weight: 800; }
.mate span:last-child { color: var(--ink-2); }
.countdown { display: flex; flex-direction: column; gap: 6px; text-align: center; }
.countdown .bar { height: 3px; border-radius: 999px; background: #1c2230; overflow: hidden; }
.countdown .bar span { display: block; height: 100%; background: var(--gold); transition: width 1s linear; }
.countdown small { color: var(--muted); }
.done-card { padding: 20px; border-radius: 20px; background: var(--panel); border: 1px solid var(--gold); display: flex; flex-direction: column; gap: 10px; }
.done-card b { font-size: 17px; color: var(--gold-2); }
.done-card p { margin: 0; color: var(--ink-2); }

/* شاشة اللعب */
.screen-play.is-day { --panel: #17150f; }
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.play-main, .play-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel { padding: 16px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.panel p { margin: 0; }
.panel-gold { border-color: var(--gold); background: #221d12; }
.panel-amber { border-color: #6b5520; background: #221d12; }
.panel-amber b { color: var(--gold-3); }
.win-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-radius: 18px; font-weight: 800; flex-wrap: wrap; }
.win-banner.town { background: var(--ok-bg); border: 1px solid #2f6b46; }
.win-banner.mafia { background: var(--mafia-bg); border: 1px solid var(--mafia); }
.steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.step { min-height: 62px; padding: 8px 12px; border-radius: 14px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: right; background: var(--panel); border: 1px solid var(--line); }
.step small { font-size: 12px; font-weight: 800; color: var(--gold-2); }
.step b { font-size: 13px; }
.step.is-cur { border-color: var(--gold); background: #1a2130; }
.step.is-off { opacity: .5; }
.target-chip, .voter-chip { min-height: 44px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 800; background: var(--bg); border: 1px solid var(--line); }
.target-chip.is-on { background: var(--gold); border-color: var(--gold); color: #14110a; }
.target-chip:disabled { opacity: .35; }
.voter-chip.is-on { background: var(--ink); border-color: var(--ink); color: #14110a; }
.timer-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); flex-wrap: wrap; }
.timer-card > div:first-child { display: flex; flex-direction: column; }
.timer { font-family: var(--display); font-size: 38px; font-weight: 700; line-height: 1.1; }
.timer.is-low { color: var(--mafia-ink); animation: pulse 1s ease infinite; }
.timer-card .row-btns > * { flex: 0 0 auto; }
.sheikh-btn { min-height: 56px; padding: 0 16px; border-radius: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; font-weight: 800; text-align: right; }
.sheikh-btn small { color: var(--gold-2); white-space: nowrap; }
.sheikh-btn.is-on { background: #2a2412; border-color: var(--gold); }
.cand-list { display: flex; flex-direction: column; gap: 8px; }
.cand { padding: 8px 12px; border-radius: 14px; background: #0f131b; border: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.cand.is-focus { border-color: var(--gold); background: #1a2130; }
.cand-row { display: flex; align-items: center; gap: 8px; }
.cand-name { flex: 1; min-height: 40px; background: transparent; border: 0; padding: 0; text-align: right; font-size: 14px; font-weight: 800; }
.count { min-width: 42px; padding: 4px 10px; border-radius: 999px; background: var(--line-2); font-family: var(--display); font-size: 17px; text-align: center; }
.count.has { background: var(--mafia-2); }
.mini-btn { width: 42px; height: 42px; flex-shrink: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 18px; font-weight: 800; }
.mini-btn.mafia { background: var(--mafia-2); border-color: var(--mafia-2); color: #fbe9eb; }
.mini-btn.gold { background: var(--gold); border-color: var(--gold); color: #14110a; }

/* بطاقات اللاعبين للحكم */
.pcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.pcard {
  position: relative; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 4px var(--bg-2), inset 0 0 0 5px var(--gold-soft); display: flex; flex-direction: column; overflow: hidden;
}
.pcard.is-open { border-color: var(--gold-3); box-shadow: inset 0 0 0 4px var(--bg-2), inset 0 0 0 5px var(--gold-3), 0 0 24px rgba(240, 209, 138, .2); }
.pcard.is-dead { border-color: var(--line); box-shadow: none; opacity: .6; }
.pcard-main { padding: 14px 8px 8px; background: transparent; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.pcard-main b { font-size: 14px; margin-top: 4px; }
.pcard.is-dead .pcard-main b { text-decoration: line-through; }
.pcard-main .last { font-size: 11px; color: var(--muted); line-height: 1.2; }
.pcard-main .role { font-size: 11px; font-weight: 700; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pcard.is-mafia .pcard-main .role { color: var(--mafia-ink); }
.pcard.is-mafia:not(.is-dead) .avatar { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3px var(--mafia); }
.status { margin-top: 2px; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.st-alive { background: var(--ok-bg); color: var(--ok); }
.st-dead { background: var(--mafia-bg); color: var(--mafia-ink); }
.st-muted { background: #2a2412; color: var(--gold-3); }
.pcard-counters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--gold-soft); margin: 0 5px 5px; }
.pcard-counters button { min-height: 46px; padding: 4px 0; background: transparent; border: 0; display: flex; flex-direction: column; align-items: center; line-height: 1.2; border-radius: 8px; }
.pcard-counters button:hover { background: rgba(201, 165, 90, .1); }
.pcard-counters button:active { background: rgba(201, 165, 90, .25); }
.pcard-counters b { font-size: 15px; }
.pcard-counters small { font-size: 10px; color: var(--muted); }

.control {
  padding: 18px 16px; border-radius: 20px; background: var(--bg-2); border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 6px var(--bg-2), inset 0 0 0 7px var(--gold-soft), 0 20px 50px rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; gap: 10px; animation: rise .18s ease;
}
.control-head { display: flex; align-items: center; gap: 12px; }
.control-head > div { flex: 1; display: flex; flex-direction: column; }
.control-head b { font-family: var(--display); font-size: 22px; }
.control-head small { font-size: 12px; font-weight: 700; }
.control .label { color: var(--gold-2); font-weight: 800; font-size: 12px; margin-top: 4px; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.status-btn { min-height: 44px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 800; background: var(--bg); border: 1px solid var(--line); }
.status-btn.is-on { background: var(--gold); border-color: var(--gold); color: #14110a; }
.status-btn.wide { width: 100%; }
.status-btn.is-muted { background: var(--mafia-bg); border-color: var(--mafia); }
.counter-row { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line-2); flex-wrap: wrap; }
.counter-row.round { background: var(--mafia-bg); border-color: var(--mafia); }
.c-label { flex: 1 1 110px; font-size: 13px; font-weight: 700; padding-inline-start: 6px; }
.c-input { width: 58px; min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); text-align: center; font-family: var(--display); font-size: 18px; font-weight: 700; -moz-appearance: textfield; }
.c-input::-webkit-outer-spin-button, .c-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.c-val { width: 42px; text-align: center; font-family: var(--display); font-size: 20px; }
.quick { display: flex; gap: 4px; }
.quick button { min-width: 42px; min-height: 42px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--gold-soft); background: transparent; color: var(--gold-2); font-size: 13px; font-weight: 800; }
.quick button:last-child { color: var(--muted); border-color: var(--line); }

.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.seg button { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-weight: 800; }
.seg button.is-on.town { background: var(--gold); border-color: var(--gold); color: #14110a; }
.seg button.is-on.mafia { background: var(--mafia-2); border-color: var(--mafia-2); color: #fbe9eb; }
.seg button.is-on.none { border-color: var(--ink); }
.summary { display: flex; flex-direction: column; gap: 6px; }
.sum-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line-2); flex-wrap: wrap; }
.sum-row > div { flex: 1 1 140px; display: flex; flex-direction: column; min-width: 0; }
.sum-row small { font-size: 12px; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes flip { from { opacity: 0; transform: perspective(900px) rotateY(-80deg); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- الشاشات الكبيرة ---------- */
@media (min-width: 980px) {
  .play-layout { grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); align-items: start; }
  .play-side { position: sticky; top: 76px; }
  .pcard-grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); }
}

/* ---------- الجوال ---------- */
@media (max-width: 820px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); padding: 14px; gap: 12px; }
  .admin-nav { position: static; flex-direction: row; overflow-x: auto; gap: 6px; }
  .admin-nav a { white-space: nowrap; padding: 10px 14px; background: var(--panel); }
  .admin-nav a.is-on { box-shadow: inset 0 -3px 0 var(--gold); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .search input { width: 100%; }
  .page-head .search { width: 100%; }
  .screen-head h1 { font-size: 26px; }
  .pcard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tarot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .roster { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick { width: 100%; justify-content: flex-end; }
  .topbar .brand { font-size: 16px; }
}
