/* ═══════════ كمين ═══════════ */
:root {
  --navy-0: #0a0e22;
  --navy-1: #111631;
  --navy-2: #1b2247;
  --gold: #f2b134;
  --gold-soft: #ffd57a;
  --gold-deep: #c98a12;
  --cream: #fdf6e3;
  --clay: #e0603c;
  --clay-deep: #a53a1d;
  --ok: #34d399;
  --muted: #8b96b8;
  --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  font-family: "Tajawal", system-ui, sans-serif;
  background: radial-gradient(ellipse at 50% -20%, var(--navy-2), var(--navy-0) 70%);
  color: var(--cream);
  min-height: 100dvh;
  display: flex; flex-direction: column;
  overflow-x: hidden;
}

.screen { display: none; flex: 1; position: relative; padding: 16px; }
.screen.active { display: flex; flex-direction: column; }

/* نجوم الخلفية */
.stars { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.stars::before, .stars::after {
  content: "✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦ ✧ ✦";
  position: absolute; inset: 0;
  color: rgba(242, 177, 52, 0.12);
  font-size: 22px; letter-spacing: 48px; line-height: 120px;
  white-space: pre-wrap;
}
.stars::after { transform: translate(60px, 60px) scale(1.4); opacity: 0.5; }

/* ═══════════ البداية ═══════════ */
.start-inner {
  margin: auto; width: min(620px, 100%);
  display: flex; flex-direction: column; align-items: center;
  text-align: center; position: relative; z-index: 1;
}
.hero-art {
  width: min(620px, 92vw); border-radius: 22px; overflow: hidden;
  border: 4px solid var(--gold);
  box-shadow: 0 0 60px rgba(242, 177, 52, 0.3), 0 18px 50px rgba(0,0,0,0.5);
  animation: bob 4s ease-in-out infinite;
}
.hero-art img { display: block; width: 100%; height: auto; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-0.4deg);} 50% { transform: translateY(-8px) rotate(0.4deg);} }

.logo { margin-top: 18px; font-size: clamp(42px, 9vw, 68px); font-weight: 900; line-height: 1.1; }
.logo-kameen { color: var(--clay); text-shadow: 0 0 26px rgba(224, 96, 60, 0.5), 0 4px 0 var(--clay-deep); }
.tagline { margin-top: 6px; font-size: clamp(15px, 3.6vw, 19px); color: #b9c3e0; font-weight: 500; }

.setup-card {
  margin-top: 24px; width: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 1px solid rgba(242,177,52,0.25);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(6px);
}
.how-row { display: flex; gap: 10px; }
.how-step {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--navy-1); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px; padding: 14px 8px;
  font-size: 14px; font-weight: 700; color: #b9c3e0; line-height: 1.4;
}
.how-step span { font-size: 30px; }

.btn-big {
  margin-top: 22px; width: 100%;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold) 55%, var(--gold-deep));
  color: var(--navy-0);
  border: none; border-radius: 14px;
  padding: 16px; font-family: inherit; font-size: 22px; font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--gold-deep), 0 14px 30px rgba(242,177,52,0.35);
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn-big:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--gold-deep); }
.btn-big:disabled { filter: grayscale(0.75) brightness(0.7); cursor: default; box-shadow: none; }
.hint { margin-top: 12px; font-size: 13px; color: var(--muted); }

/* ═══════════ الصالة ═══════════ */
.lobby-inner {
  margin: auto; width: min(980px, 100%);
  position: relative; z-index: 1; text-align: center;
}
.lobby-title { font-size: clamp(24px, 5vw, 36px); font-weight: 900; margin-bottom: 18px; }
.lobby-cols { display: flex; gap: 22px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.qr-col { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.join-cue { font-size: 2rem; display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 18px 8px; animation: cue 1.6s infinite; text-align: center; }
.join-cue div { font-size: 1.05rem; font-weight: 800; line-height: 1.7; color: #b9c3e0; }
.join-cue small { font-weight: 700; font-size: .8rem; opacity: .75; }
.join-cue b { color: var(--gold-soft); }
@keyframes cue { 50% { transform: translateY(5px); } }

.roster-col { flex: 1; min-width: 300px; max-width: 460px; text-align: right; }
.roster-head { font-size: 18px; font-weight: 900; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.count-pill { background: var(--gold); color: var(--navy-0); border-radius: 999px; padding: 1px 12px; font-size: 15px; }

.roster { display: flex; flex-wrap: wrap; gap: 8px; }
.p-chip {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,0.06); border: 2px solid rgba(255,255,255,0.16);
  border-radius: 999px; padding: 6px 12px;
  font-size: 15px; font-weight: 800;
  animation: pop-in 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.p-chip .av { font-size: 20px; }
.p-chip.off { opacity: 0.45; border-style: dashed; }
.p-chip .kick {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 13px; font-family: inherit; padding: 0 2px;
}
.p-chip .kick:hover { color: var(--clay); }
@keyframes pop-in { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* شرح الأدوار في الصالة */
.roles-brief {
  margin-top: 18px;
  background: var(--navy-1); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px; padding: 8px 14px;
}
.rb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px dashed rgba(255,255,255,0.1);
  font-size: 15px; font-weight: 800; text-align: right;
}
.rb-row:last-child { border-bottom: none; }
.rb-ico {
  width: 52px; height: 52px; border-radius: 12px; object-fit: cover; object-position: top;
  border: 2px solid rgba(242,177,52,0.45); flex-shrink: 0;
}
.rb-name { color: var(--gold-soft); white-space: nowrap; }
.rb-hint { display: block; font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.55); line-height: 1.5; }
.cfg-warn {
  margin-top: 10px; font-size: 14px; font-weight: 800; color: var(--clay);
  background: rgba(224, 96, 60, 0.1); border: 1px dashed var(--clay);
  border-radius: 10px; padding: 8px 12px;
}
.roster-col .btn-big { margin-top: 14px; font-size: 19px; }

/* ═══════════ الطاولة ═══════════ */
.game-top {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  width: min(1200px, 100%); margin: 0 auto;
}
.phase-chip {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: var(--navy-0); font-weight: 900; font-size: clamp(15px, 2.6vw, 20px);
  border-radius: 999px; padding: 8px 20px;
  box-shadow: 0 0 24px rgba(242,177,52,0.35);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw;
}
.deck-info { flex: 1; font-size: clamp(12px, 2vw, 15px); font-weight: 700; color: #b9c3e0; }
.btn-mini {
  background: none; border: 1px solid rgba(255,255,255,0.25); color: var(--muted);
  border-radius: 10px; padding: 6px 12px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.btn-mini:hover { color: var(--clay); border-color: var(--clay); }

.narration {
  position: relative; z-index: 1;
  text-align: center; margin: 12px auto 4px;
  font-size: clamp(17px, 3.4vw, 27px); font-weight: 900;
  width: min(1000px, 100%); line-height: 1.5;
  min-height: 1.5em;
}
.narration b { color: var(--gold-soft); }

.seats {
  position: relative; z-index: 1;
  flex: 1; display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  width: min(1200px, 100%); margin: 0 auto; gap: 14px;
}
.seat {
  position: relative;
  width: clamp(128px, 16vw, 180px);
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  border: 2px solid rgba(255,255,255,0.16);
  border-radius: var(--radius);
  padding: 14px 8px 10px;
  text-align: center;
  transition: opacity 0.4s, filter 0.4s, border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}
.seat .av { font-size: clamp(34px, 5vw, 50px); display: block; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.45)); }
.seat .nm { margin-top: 4px; font-size: clamp(13px, 1.9vw, 16px); font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.turn {
  border-color: var(--gold); box-shadow: 0 0 26px rgba(242,177,52,0.35);
  transform: translateY(-4px);
}
.seat.turn::before {
  content: "🎴 دوره"; position: absolute; top: -12px; right: 50%; transform: translateX(50%);
  background: var(--gold); color: var(--navy-0); font-weight: 900; font-size: 12px;
  border-radius: 999px; padding: 2px 12px; white-space: nowrap;
}
.seat.awaited { border-color: var(--clay); box-shadow: 0 0 26px rgba(224,96,60,0.4); animation: throb 1.1s ease-in-out infinite; }
.seat.awaited::before {
  content: "⏳ ننتظره"; position: absolute; top: -12px; right: 50%; transform: translateX(50%);
  background: var(--clay); color: #fff; font-weight: 900; font-size: 12px;
  border-radius: 999px; padding: 2px 12px; white-space: nowrap;
}
@keyframes throb { 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }
.seat.dead { opacity: 0.5; filter: grayscale(1); }
.seat.dead::after { content: "☠️"; position: absolute; top: 6px; left: 8px; font-size: 22px; filter: none; }
.seat.off { border-style: dashed; }

/* الأرواح: قلوب ممتلئة + فاضية، والرقم جنبها (ما نعتمد على اللون وحده) */
.hearts { margin-top: 4px; font-size: clamp(12px, 1.8vw, 15px); font-weight: 900; letter-spacing: 1px; }
.hearts .full { color: var(--clay); }
.hearts .lost { color: rgba(255,255,255,0.22); }
.hearts .num { color: var(--muted); font-size: 0.85em; margin-right: 4px; }

.seat .role-badge {
  margin-top: 4px; display: inline-block;
  font-size: clamp(10px, 1.5vw, 12px); font-weight: 900;
  border-radius: 999px; padding: 2px 10px;
  background: rgba(242,177,52,0.16); color: var(--gold-soft);
  border: 1px solid rgba(242,177,52,0.4);
}
.seat .role-badge.threat { background: rgba(224,96,60,0.16); color: #ff9a7a; border-color: rgba(224,96,60,0.5); }
.seat .gear {
  margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center;
  min-height: 18px;
}
.gear .g {
  font-size: 10px; font-weight: 900; border-radius: 6px; padding: 1px 6px;
  background: var(--navy-1); border: 1px solid rgba(255,255,255,0.18); color: #b9c3e0;
}
.gear .g.w { color: var(--gold-soft); border-color: rgba(242,177,52,0.45); }
.gear .g.j { color: #ff9a7a; border-color: rgba(224,96,60,0.5); }
.seat .handcount { margin-top: 4px; font-size: clamp(11px, 1.6vw, 13px); color: var(--muted); font-weight: 800; }
.seat .kick {
  position: absolute; top: 4px; right: 6px;
  background: none; border: none; color: rgba(255,255,255,0.25);
  font-size: 13px; cursor: pointer; font-family: inherit;
}
.seat .kick:hover { color: var(--clay); }

/* سجل الطاولة */
.table-log {
  position: relative; z-index: 1;
  width: min(900px, 100%); margin: 8px auto 0;
  background: rgba(10, 14, 34, 0.55); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px; padding: 10px 16px;
  font-size: clamp(12px, 1.9vw, 15px); font-weight: 700; color: #b9c3e0;
  display: flex; flex-direction: column; gap: 3px;
  max-height: 20dvh; overflow: hidden; justify-content: flex-end;
}
.table-log div:last-child { color: var(--cream); font-weight: 900; }

/* ═══════════ الإعلانات ═══════════ */
.announce-overlay {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(27,34,71,0.55), rgba(5,6,15,0.94) 75%);
  animation: pop-in 0.3s;
  padding: 20px;
}
.announce-box {
  width: min(680px, 100%);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  border: 1px solid rgba(242,177,52,0.35);
  border-radius: 24px;
  padding: 30px 26px;
  text-align: center;
  animation: an-zoom 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
  max-height: 92dvh; overflow-y: auto;
}
@keyframes an-zoom { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.an-art {
  display: block; width: 100%; max-width: 420px; margin: 0 auto;
  border-radius: 16px; border: 2px solid rgba(242,177,52,0.4);
  box-shadow: 0 14px 40px rgba(0,0,0,0.5);
}
.an-art.portrait { max-width: 240px; }
.an-art.wide { max-width: 560px; }
.an-title { margin-top: 10px; font-size: clamp(24px, 6vw, 40px); font-weight: 900; line-height: 1.4; }
.an-title b { color: var(--gold-soft); }
.an-title .bad { color: var(--clay); }
.an-title .good { color: var(--ok); }
.an-sub { margin-top: 8px; font-size: clamp(15px, 3.4vw, 20px); color: #b9c3e0; font-weight: 700; }

.reveal-list { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.rv-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--navy-1); border-radius: 12px; padding: 8px 14px;
  font-size: 16px; font-weight: 800; text-align: right;
}
.rv-row .av { font-size: 22px; }
.rv-ico { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; object-position: top; border: 2px solid rgba(242,177,52,0.4); }
.rv-row .who { flex: 1; }
.rv-row .role-tag { font-size: 14px; font-weight: 900; color: var(--gold-soft); }
.rv-row.is-threat .role-tag { color: #ff9a7a; }
.rv-row .out { font-size: 13px; color: var(--muted); }

.sc-head { margin: 18px 0 6px; font-size: 13px; font-weight: 900; letter-spacing: 2px; color: var(--muted); }
.sc-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 14px; font-size: 16px; font-weight: 800;
}
.sc-row b { color: var(--gold-soft); }

.an-actions { display: flex; gap: 12px; margin-top: 20px; }
.an-actions .btn-big { margin-top: 0; flex: 2; font-size: 19px; }
.btn-ghost {
  flex: 1; background: none; border: 2px solid rgba(255,255,255,0.3);
  color: var(--cream); border-radius: 14px; font-family: inherit;
  font-size: 16px; font-weight: 700; cursor: pointer; padding: 12px;
}

.site-footer {
  text-align: center; font-size: 12px; color: #6b7694;
  padding: 10px 16px 14px; position: relative; z-index: 1;
}
.site-footer a { color: var(--gold-soft); text-decoration: none; font-weight: 800; }
.site-footer b { color: var(--gold-soft); letter-spacing: 2px; }

@media (max-width: 640px) {
  .how-row { flex-direction: column; }
  .lobby-cols { flex-direction: column; align-items: center; }
  .roster-col { width: 100%; max-width: 420px; }
}
