/* ═══════════ مافيا ═══════════ */
:root {
  --navy-0: #0a0e22;
  --navy-1: #111631;
  --navy-2: #1b2247;
  --gold: #f2b134;
  --gold-soft: #ffd57a;
  --gold-deep: #c98a12;
  --cream: #fdf6e3;
  --blood: #e5484d;
  --blood-deep: #a92328;
  --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;
  transition: background 1.2s;
}
body.night { background: radial-gradient(ellipse at 50% -20%, #131a3d, #05060f 75%); }

.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; }

.moon {
  position: absolute; top: 26px; left: 40px; font-size: 64px;
  opacity: 0; transform: translateY(20px); transition: all 1.2s;
  filter: drop-shadow(0 0 30px rgba(253, 246, 227, 0.5));
  pointer-events: none;
}
body.night .moon { opacity: 1; transform: translateY(0); }

/* ═══════════ البداية ═══════════ */
.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-badge {
  width: min(200px, 46vw); aspect-ratio: 1; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 32%, #2a3568, var(--navy-1) 75%);
  border: 4px solid var(--gold);
  box-shadow: 0 0 60px rgba(242, 177, 52, 0.35), 0 18px 50px rgba(0,0,0,0.5);
  animation: bob 3.2s ease-in-out infinite;
}
.hero-emoji { font-size: clamp(72px, 20vw, 110px); filter: drop-shadow(0 8px 18px rgba(0,0,0,0.5)); }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-1.5deg);} 50% { transform: translateY(-10px) rotate(1.5deg);} }

.logo { margin-top: 18px; font-size: clamp(42px, 9vw, 68px); font-weight: 900; line-height: 1.1; }
.logo-mafia { color: var(--blood); text-shadow: 0 0 26px rgba(229, 72, 77, 0.5), 0 4px 0 var(--blood-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; }
.qr-box {
  background: #fff; border-radius: 18px; padding: 10px;
  border: 4px solid var(--gold);
  box-shadow: 0 0 40px rgba(242, 177, 52, 0.3);
  min-width: 200px; min-height: 120px;
  display: flex; align-items: center; justify-content: center;
}
.qr-box svg { display: block; width: min(52vw, 280px); height: auto; }
.qr-fallback { color: var(--navy-0); font-size: 13px; font-weight: 700; word-break: break-all; padding: 8px; max-width: 280px; }
.qr-code-text { font-size: 16px; color: #b9c3e0; line-height: 1.9; }
.qr-code-text b { color: var(--gold-soft); }
.qr-code-text #room-code { font-size: 26px; letter-spacing: 6px; }

.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(--blood); }
@keyframes pop-in { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.cfg {
  margin-top: 18px;
  background: var(--navy-1); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px; padding: 6px 14px;
}
.cfg-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px dashed rgba(255,255,255,0.1);
}
.cfg-row:last-child { border-bottom: none; }
.cfg-label { font-size: 16px; font-weight: 800; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--navy-2); color: var(--cream);
  border: 1px solid rgba(255,255,255,0.18);
  font-family: inherit; font-size: 18px; font-weight: 900; cursor: pointer;
}
.stepper button:active { background: var(--gold); color: var(--navy-0); }
.st-count { font-size: 19px; font-weight: 900; color: var(--gold-soft); min-width: 22px; text-align: center; }
.cfg-row.civ .cfg-label { color: var(--muted); }

.cfg-warn {
  margin-top: 10px; font-size: 14px; font-weight: 800; color: var(--blood);
  background: rgba(229, 72, 77, 0.1); border: 1px dashed var(--blood);
  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(1100px, 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(16px, 3vw, 22px);
  border-radius: 999px; padding: 8px 22px;
  box-shadow: 0 0 24px rgba(242,177,52,0.35);
}
body.night .phase-chip { background: linear-gradient(180deg, #43509a, #2a3568); color: var(--cream); }
.phase-info { flex: 1; font-size: clamp(13px, 2.4vw, 17px); 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(--blood); border-color: var(--blood); }

.narration {
  position: relative; z-index: 1;
  text-align: center; margin: 18px auto 6px;
  font-size: clamp(20px, 4.4vw, 34px); font-weight: 900;
  width: min(900px, 100%); line-height: 1.5;
  min-height: 1.5em;
}
.narration b { color: var(--gold-soft); }

.game-roster {
  position: relative; z-index: 1;
  flex: 1; align-content: center; justify-content: center;
  width: min(1100px, 100%); margin: 0 auto; gap: 14px;
}
.p-card {
  position: relative;
  width: clamp(120px, 15vw, 168px);
  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: 16px 8px 12px;
  text-align: center;
  transition: opacity 0.4s, filter 0.4s, border-color 0.25s, box-shadow 0.25s;
}
.p-card .av { font-size: clamp(38px, 6vw, 56px); display: block; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.45)); }
.p-card .nm { margin-top: 6px; font-size: clamp(13px, 2vw, 17px); font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-card .st { margin-top: 4px; font-size: clamp(11px, 1.6vw, 14px); font-weight: 800; color: var(--muted); min-height: 1.4em; }
.p-card.voted { border-color: var(--ok); }
.p-card.voted .st { color: var(--ok); }
.p-card.dead { opacity: 0.5; filter: grayscale(1); }
.p-card.dead::after {
  content: "☠️"; position: absolute; top: 6px; left: 8px; font-size: 22px; filter: none;
}
.p-card.off { border-style: dashed; }
.p-card .votes-badge {
  position: absolute; top: -10px; right: 50%; transform: translateX(50%);
  background: var(--blood); color: #fff; font-weight: 900; font-size: 14px;
  border-radius: 999px; padding: 2px 12px;
  box-shadow: 0 4px 14px rgba(229,72,77,0.45);
  animation: pop-in 0.25s;
}
.p-card .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;
}
.p-card .kick:hover { color: var(--blood); }

/* ═══════════ الإعلانات ═══════════ */
.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-emoji { font-size: clamp(54px, 12vw, 90px); display: block; filter: drop-shadow(0 10px 24px rgba(0,0,0,0.5)); }
.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(--blood); }
.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-row .who { flex: 1; }
.rv-row .role-tag { font-size: 14px; font-weight: 900; color: var(--gold-soft); }
.rv-row.is-mafia .role-tag { color: var(--blood); }
.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; }
}
