/* =====================================================================
   برا السالفة — الأنماط
   طابع ليلي: كحلي داكن + ذهبي + تركواز، RTL، Mobile-First
   ===================================================================== */

:root {
  --navy: #0f172a;
  --navy-2: #0b1220;
  --navy-3: #111c33;
  --gold: #f59e0b;
  --gold-light: #fcd34d;
  --teal: #14b8a6;
  --teal-dark: #0d9488;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --danger: #f87171;
  --success: #34d399;
  --line: rgba(148, 163, 184, 0.18);
  --card: rgba(255, 255, 255, 0.045);
  --card-strong: rgba(255, 255, 255, 0.07);
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 24px 60px -32px rgba(0, 0, 0, 0.85);
  --font: 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background-color: var(--navy);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 800; }
p { margin: 0; }
button, input { font-family: inherit; }
button { cursor: pointer; }
a { color: var(--gold-light); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.row.center { justify-content: center; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }

/* ------------------------------ الخلفية ------------------------------ */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(1100px 600px at 88% -10%, rgba(20, 184, 166, 0.16), transparent 60%),
    radial-gradient(900px 520px at 8% 0%, rgba(245, 158, 11, 0.12), transparent 55%),
    linear-gradient(180deg, #0f172a 0%, #0b1220 100%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
}
.blob-gold {
  width: 340px; height: 340px;
  background: rgba(245, 158, 11, 0.28);
  top: 18%; inset-inline-end: -140px;
  animation: floaty 14s ease-in-out infinite alternate;
}
.blob-teal {
  width: 380px; height: 380px;
  background: rgba(20, 184, 166, 0.22);
  bottom: -160px; inset-inline-start: -140px;
  animation: floaty 18s ease-in-out infinite alternate-reverse;
}
.grain {
  position: absolute; inset: 0;
  opacity: 0.035;
  background-image: radial-gradient(#ffffff 0.5px, transparent 0.5px);
  background-size: 4px 4px;
}

@keyframes floaty {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-30px, 40px, 0) scale(1.12); }
}

/* ------------------------------ الشريط العلوي ------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(11, 18, 32, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.mini-code {
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--gold-light);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 0.95rem;
  direction: ltr;
}

.phase-pill {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--teal);
  background: rgba(20, 184, 166, 0.1);
  border: 1px solid rgba(20, 184, 166, 0.25);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.voice-strip {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}
.voice-strip::-webkit-scrollbar { display: none; }

.voice-empty {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 5px 10px;
}

.voice-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.voice-avatar.speaking {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.22);
  animation: pulseRing 1.4s ease-out infinite;
  transform: translateY(-1px);
}
.voice-avatar.muted { opacity: 0.62; }
.voice-avatar .muted-icon {
  position: absolute;
  bottom: -4px;
  inset-inline-start: -4px;
  font-size: 0.62rem;
  background: var(--navy-2);
  border-radius: 50%;
  padding: 1px;
  font-style: normal;
}

.wave {
  position: absolute;
  bottom: -2px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 10px;
  background: var(--navy-2);
  border-radius: 6px;
  padding: 1px 3px;
}
.wave b {
  width: 2px;
  background: var(--teal);
  border-radius: 2px;
  animation: wave 0.8s ease-in-out infinite;
}
.wave b:nth-child(1) { height: 4px; animation-delay: 0s; }
.wave b:nth-child(2) { height: 8px; animation-delay: 0.15s; }
.wave b:nth-child(3) { height: 5px; animation-delay: 0.3s; }

.topbar-left { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 13px;
  transition: background 0.2s, border-color 0.2s, transform 0.12s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.09); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn.active {
  border-color: rgba(20, 184, 166, 0.55);
  background: rgba(20, 184, 166, 0.16);
}
.icon-btn.muted {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.14);
}
.icon-btn.off { opacity: 0.6; }

.badge {
  position: absolute;
  top: -5px;
  inset-inline-end: -5px;
  min-width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  font-size: 0.66rem;
  font-weight: 800;
  color: #1b1300;
  background: var(--gold);
  border-radius: 999px;
  padding: 0 5px;
  box-shadow: 0 0 0 3px var(--navy-2);
}

/* ------------------------------ التخطيط العام ------------------------------ */
.wrap {
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: 18px 16px calc(100px + env(safe-area-inset-bottom));
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeUp 0.4s ease both;
}

.screen-head { display: flex; flex-direction: column; gap: 4px; }
.screen-head.center { align-items: center; text-align: center; }
.screen-head h2 { font-size: clamp(1.3rem, 5vw, 1.8rem); }

.eyebrow {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: var(--teal);
  text-transform: uppercase;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-head h3 { font-size: 1.05rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.chip.gold {
  color: var(--gold-light);
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.28);
}
.chip.teal {
  color: #5eead4;
  background: rgba(20, 184, 166, 0.1);
  border-color: rgba(20, 184, 166, 0.28);
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.8;
}

/* ------------------------------ الأزرار ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  transition: transform 0.12s ease, filter 0.2s ease, box-shadow 0.2s ease, opacity 0.2s;
  min-height: 44px;
}
.btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; filter: none; }
.btn:focus-visible, .icon-btn:focus-visible, .pill:focus-visible,
.role-card:focus-visible, .vote-card:focus-visible, .player-chip:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.btn-gold {
  color: #1b1300;
  background: linear-gradient(135deg, #fcd34d 0%, #f59e0b 55%, #d97706 100%);
  box-shadow: 0 12px 26px -14px rgba(245, 158, 11, 0.85);
}
.btn-teal {
  color: #022c26;
  background: linear-gradient(135deg, #5eead4 0%, #14b8a6 55%, #0d9488 100%);
  box-shadow: 0 12px 26px -14px rgba(20, 184, 166, 0.8);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--text);
}
.btn-lg { width: 100%; padding: 15px 20px; font-size: 1.02rem; margin-top: 6px; }

/* ------------------------------ الحقول ------------------------------ */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.field > span {
  font-size: 0.85rem;
  font-weight: 700;
  color: #cbd5e1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.field > span b { color: var(--gold-light); font-weight: 800; }

input[type="text"] {
  width: 100%;
  padding: 13px 15px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(8, 13, 25, 0.65);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]::placeholder { color: #64748b; font-weight: 500; }
input[type="text"]:focus {
  outline: none;
  border-color: rgba(20, 184, 166, 0.7);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
}

.code-input {
  text-align: center;
  font-size: 2rem !important;
  font-weight: 900 !important;
  letter-spacing: 14px;
  direction: ltr;
  padding-inline-start: 14px !important;
  margin: 14px 0 12px;
  color: var(--gold-light) !important;
  background: rgba(8, 13, 25, 0.75) !important;
}
.code-input::placeholder { letter-spacing: 10px; color: #475569 !important; }

.range {
  width: 100%;
  accent-color: var(--gold);
  height: 26px;
  cursor: pointer;
}

/* ------------------------------ الشاشة الرئيسية ------------------------------ */
.hero {
  position: relative;
  text-align: center;
  padding: 26px 6px 10px;
}

.hero-orbs {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}
.orb {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  font-size: 1.6rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  box-shadow: 0 16px 30px -20px #000;
  animation: floatCard 5s ease-in-out infinite;
}
.orb-1 { transform: rotate(-7deg); animation-delay: 0s; }
.orb-2 { transform: rotate(5deg) translateY(6px); animation-delay: 0.6s; }
.orb-3 { transform: rotate(9deg); animation-delay: 1.2s; }

.logo {
  font-size: clamp(2.9rem, 12vw, 4.8rem);
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1.12;
  background: linear-gradient(180deg, #fef3c7 0%, #fcd34d 30%, #f59e0b 65%, #b45309 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 16px 40px rgba(245, 158, 11, 0.25));
  margin: 4px 0 2px;
}

.tagline {
  max-width: 540px;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.95;
}
.tagline b { color: var(--gold-light); }

.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.create-card h2, .join-card h2 { font-size: 1.2rem; }
.join-card .muted { margin-bottom: 4px; font-size: 0.88rem; }

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
@media (max-width: 420px) {
  .avatar-picker { grid-template-columns: repeat(8, 1fr); gap: 4px; }
}
.avatar-opt {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
}
.avatar-opt:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.08); }
.avatar-opt.selected {
  border-color: var(--gold);
  background: rgba(245, 158, 11, 0.16);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
  transform: translateY(-2px);
}

.rules {
  list-style: none;
  margin: 20px 0 0;
  padding: 16px 0 0;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 9px;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-foot {
  text-align: center;
  font-size: 0.76rem;
  color: #64748b;
  padding: 8px 0 4px;
}

/* ------------------------------ صالة الانتظار ------------------------------ */
.wait-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.wait-head h2 { font-size: 1.5rem; }

.room-code-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background:
    linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(20, 184, 166, 0.08)),
    rgba(255, 255, 255, 0.03);
  border-color: rgba(245, 158, 11, 0.22);
}
.room-code-info { display: flex; flex-direction: column; gap: 2px; }
.code-display {
  font-size: clamp(2rem, 9vw, 2.8rem);
  font-weight: 900;
  letter-spacing: 10px;
  direction: ltr;
  color: var(--gold-light);
  line-height: 1.2;
  text-shadow: 0 10px 30px rgba(245, 158, 11, 0.28);
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.player-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 8px;
  text-align: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  animation: fadeUp 0.3s ease both;
}
.player-tile.speaking {
  border-color: rgba(20, 184, 166, 0.55);
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.18);
}
.player-tile.offline { opacity: 0.45; }
.player-tile.offline .tile-meta { color: var(--danger); }

.tile-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}
.player-tile.speaking .tile-avatar {
  border-color: var(--teal);
  animation: pulseRing 1.4s ease-out infinite;
}
.crown {
  position: absolute;
  top: -10px;
  inset-inline-end: -8px;
  font-size: 0.9rem;
  filter: drop-shadow(0 2px 4px #000);
}
.tile-name {
  font-size: 0.8rem;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-meta { font-size: 0.64rem; color: var(--muted); }

.pills { display: flex; flex-wrap: wrap; gap: 7px; }
.pill {
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: all 0.2s;
}
.pill:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.pill.active {
  color: #1b1300;
  background: linear-gradient(135deg, #fcd34d, #f59e0b);
  border-color: transparent;
  box-shadow: 0 8px 18px -10px rgba(245, 158, 11, 0.9);
}

.settings-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
  padding: 12px 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
}
.summary-item span { font-size: 0.68rem; color: var(--muted); }
.summary-item b { font-size: 0.86rem; }

/* ------------------------------ بطاقة الدور ------------------------------ */
.timer-line {
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 700;
}
.timer-line span {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--gold-light);
  font-variant-numeric: tabular-nums;
}

.role-card {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 340px;
  margin: 0 auto;
  perspective: 1400px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.role-card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 26px 22px;
  text-align: center;
  border-radius: 24px;
  border: 1px solid var(--line);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.55s cubic-bezier(0.22, 0.8, 0.3, 1);
  overflow: hidden;
}

.role-card-front {
  background:
    radial-gradient(circle at 50% 0%, rgba(245, 158, 11, 0.14), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow);
}
.role-card-front::before,
.role-card-back::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(148, 163, 184, 0.22);
  border-radius: 18px;
  pointer-events: none;
}

.role-card-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 0%, rgba(20, 184, 166, 0.22), transparent 65%),
    linear-gradient(180deg, #122036, #0c1526);
  border-color: rgba(20, 184, 166, 0.3);
}
.role-card-back.outsider {
  background:
    radial-gradient(circle at 50% 0%, rgba(245, 158, 11, 0.26), transparent 65%),
    linear-gradient(180deg, #1b1626, #150f1c);
  border-color: rgba(245, 158, 11, 0.38);
  box-shadow: 0 0 60px -20px rgba(245, 158, 11, 0.4);
}

.role-card.flipped .role-card-front { transform: rotateY(180deg); }
.role-card.flipped .role-card-back { transform: rotateY(0deg); }

.big-emoji { font-size: 3.4rem; line-height: 1; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.5)); }

.role-card h3 { font-size: 1.2rem; }
.role-card .muted { max-width: 290px; font-size: 0.85rem; }

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  border: 1px solid;
}
.role-badge.teal {
  color: #5eead4;
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.35);
}
.role-badge.danger {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.4);
}
.secret-big {
  font-size: clamp(2rem, 9vw, 2.8rem);
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 12px 34px rgba(245, 158, 11, 0.3);
}

/* ------------------------------ مرحلة الأسئلة ------------------------------ */
.timer-bar {
  position: relative;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
}
.timer-fill {
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.4), rgba(245, 158, 11, 0.34));
  transition: width 0.25s linear, background 0.3s;
}
.timer-bar.urgent .timer-fill {
  background: linear-gradient(90deg, rgba(248, 113, 113, 0.55), rgba(245, 158, 11, 0.45));
}
.timer-bar > span {
  position: relative;
  font-weight: 900;
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.versus {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}
.vs-badge {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--gold-light);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.player-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
  padding: 16px 10px;
  min-height: 148px;
  justify-content: center;
}
.player-spot.speaking { border-color: rgba(20, 184, 166, 0.5); }
.spot-avatar {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid var(--line);
}
.player-spot.speaking .spot-avatar {
  border-color: var(--teal);
  animation: pulseRing 1.4s ease-out infinite;
}
.spot-role {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.spot-role.gold { color: var(--gold-light); }
.spot-role.teal { color: var(--teal); }
.player-spot h3 {
  font-size: 0.94rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spot-meta { font-size: 0.66rem; color: var(--muted); }

.secret-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  text-align: center;
  font-size: 0.86rem;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px dashed rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.07);
  color: #e2e8f0;
}
.secret-chip b { color: var(--gold-light); font-size: 1rem; }

.players-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: all 0.2s;
}
.player-chip:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.player-chip.active {
  color: #022c26;
  background: linear-gradient(135deg, #5eead4, #14b8a6);
  border-color: transparent;
}
.player-chip.asker {
  color: var(--gold-light);
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
}
.player-chip.target {
  color: #5eead4;
  border-color: rgba(20, 184, 166, 0.45);
  background: rgba(20, 184, 166, 0.1);
}
.player-chip.speaking { box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.4); }

/* ------------------------------ التصويت ------------------------------ */
.vote-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.vote-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  transition: all 0.2s;
  min-height: 118px;
}
.vote-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(20, 184, 166, 0.4);
  background: rgba(255, 255, 255, 0.07);
}
.vote-card.selected {
  border-color: var(--gold);
  background: rgba(245, 158, 11, 0.12);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}
.vote-card:disabled { opacity: 0.42; cursor: not-allowed; }
.vote-avatar { font-size: 2rem; line-height: 1; }
.vote-name { font-size: 0.86rem; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vote-check {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 900;
  color: #1b1300;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.2s;
}
.vote-card.selected .vote-check { opacity: 1; transform: scale(1); }
.mini-crown { position: absolute; top: 8px; inset-inline-start: 8px; font-size: 0.8rem; }
.vote-card.offline { text-decoration: line-through; }

/* ------------------------------ النتائج ------------------------------ */
.guess-box {
  border-color: rgba(245, 158, 11, 0.35);
  background:
    radial-gradient(circle at 50% 0%, rgba(245, 158, 11, 0.14), transparent 70%),
    rgba(255, 255, 255, 0.03);
  text-align: center;
  animation: pop 0.45s ease both;
}
.guess-box h3 { margin: 6px 0 10px; font-size: 1.05rem; }
.guess-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.guess-grid .muted { grid-column: 1 / -1; }
.guess-btn {
  padding: 12px 10px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 13px;
  transition: all 0.18s;
}
.guess-btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(245, 158, 11, 0.14);
  transform: translateY(-1px);
}
.guess-btn:disabled { opacity: 0.4; }

.reveal-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: pop 0.5s ease both;
}
.outsider-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  padding: 24px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(245, 158, 11, 0.35);
  background:
    radial-gradient(circle at 50% 0%, rgba(245, 158, 11, 0.2), transparent 70%),
    rgba(255, 255, 255, 0.03);
  box-shadow: 0 0 70px -30px rgba(245, 158, 11, 0.6);
}
.outsider-card .big-emoji { font-size: 4rem; animation: floatCard 4s ease-in-out infinite; }
.outsider-card h2 { font-size: 1.8rem; color: var(--gold-light); }

.verdict {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 15px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}
.verdict.win { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.1); }
.verdict.lose { color: #fca5a5; border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.1); }
.verdict.gold { color: var(--gold-light); border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.1); }

.word-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  padding: 18px;
}
.word-card h2 {
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  color: var(--gold-light);
  text-shadow: 0 10px 30px rgba(245, 158, 11, 0.25);
}

#resultsDetails { display: flex; flex-direction: column; gap: 14px; }

.breakdown { display: flex; flex-direction: column; gap: 12px; }
.breakdown-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.breakdown-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
}
.breakdown-top b { font-weight: 700; }
.breakdown-top .count { margin-inline-start: auto; color: var(--gold-light); font-weight: 800; }
.breakdown-bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.breakdown-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width 0.6s ease;
}
.breakdown-voters { font-size: 0.68rem; color: #64748b; }
.breakdown-empty { color: var(--muted); font-size: 0.84rem; }

.leaderboard { display: flex; flex-direction: column; gap: 8px; }
.leader-row {
  display: grid;
  grid-template-columns: 30px 38px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
}
.leader-row.top {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}
.rank {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--muted);
  text-align: center;
}
.leader-avatar { font-size: 1.35rem; }
.leader-name { font-size: 0.88rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-score { font-weight: 900; color: var(--gold-light); font-variant-numeric: tabular-nums; }
.delta {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--success);
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.28);
}
.delta.zero { color: var(--muted); background: rgba(255, 255, 255, 0.04); border-color: var(--line); }

/* ------------------------------ درج الدردشة ------------------------------ */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(2, 6, 15, 0.6);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.25s ease;
}

.chat-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  width: min(380px, 92vw);
  display: flex;
  flex-direction: column;
  background: #0a1322;
  border-inline-end: 1px solid var(--line);
  box-shadow: 30px 0 80px -30px #000;
  transform: translateX(-105%);
  transition: transform 0.32s cubic-bezier(0.22, 0.8, 0.3, 1);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.chat-drawer.open { transform: translateX(0); }

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.chat-head h3 { font-size: 1rem; }

.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}
.chat-empty { color: #64748b; font-size: 0.84rem; text-align: center; margin-top: 30px; }

.msg { display: flex; gap: 8px; align-items: flex-start; animation: fadeUp 0.25s ease both; }
.msg.mine { flex-direction: row-reverse; }
.msg-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
}
.msg-body {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 14px 14px 4px 14px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
}
.msg.mine .msg-body {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.28);
  border-radius: 14px 14px 14px 4px;
}
.msg-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-top b { font-size: 0.74rem; color: var(--gold-light); }
.msg-top span { font-size: 0.62rem; color: #64748b; }
.msg-body p { font-size: 0.86rem; line-height: 1.65; word-break: break-word; }

.msg-system {
  align-self: center;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  max-width: 92%;
}

.quick-chips {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: none;
}
.quick-chips::-webkit-scrollbar { display: none; }
.quick-chip {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.08);
  border: 1px solid rgba(20, 184, 166, 0.22);
  color: #99f6e4;
  transition: background 0.2s;
  white-space: nowrap;
}
.quick-chip:hover { background: rgba(20, 184, 166, 0.18); }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.chat-form input { flex: 1 1 auto; padding: 11px 13px; font-size: 0.9rem; }
.chat-form .btn { padding: 10px 16px; }

/* ------------------------------ التنبيهات والاتصال ------------------------------ */
.toasts {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  padding: 11px 16px;
  font-size: 0.84rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  background: rgba(13, 22, 38, 0.96);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 18px 40px -20px #000;
  animation: toastIn 0.3s ease both;
}
.toast.success { border-color: rgba(52, 211, 153, 0.4); }
.toast.error { border-color: rgba(248, 113, 113, 0.45); color: #fecaca; }
.toast.out { animation: toastOut 0.3s ease both; }

.conn-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgba(5, 10, 20, 0.8);
  backdrop-filter: blur(6px);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}

#audioSink { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ------------------------------ حركات ------------------------------ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pop {
  0% { opacity: 0; transform: scale(0.94); }
  70% { transform: scale(1.01); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.5); }
  100% { box-shadow: 0 0 0 10px rgba(20, 184, 166, 0); }
}
@keyframes wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}
@keyframes floatCard {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -6px; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px); }
}

/* ------------------------------ استجابة الشاشات ------------------------------ */
@media (min-width: 700px) {
  .wrap { padding: 26px 24px 120px; }
  .home-grid { grid-template-columns: 1.05fr 0.95fr; align-items: start; }
  .vote-grid { grid-template-columns: repeat(3, 1fr); }
  .guess-grid { grid-template-columns: repeat(3, 1fr); }
  .role-card { min-height: 370px; }
  .player-spot { min-height: 160px; }
}

@media (min-width: 1000px) {
  .topbar { padding-inline: 24px; }
  .hero { padding-top: 40px; }
  .screen { gap: 18px; }
}

@media (max-width: 380px) {
  .phase-pill { display: none; }
  .icon-btn { width: 38px; height: 38px; border-radius: 11px; }
  .mini-code { font-size: 0.85rem; padding: 4px 8px; }
  .players-grid { grid-template-columns: repeat(3, 1fr); }
}

/* تقليل الحركة لمن يفضل ذلك */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
