:root {
  color-scheme: dark;
  --bg: #0d0e17;
  --panel: rgba(24, 25, 40, .82);
  --panel-strong: #1a1b2b;
  --text: #f8f8ff;
  --muted: #aeb0c4;
  --purple: #8b5cf6;
  --pink: #ec4899;
  --cyan: #22d3ee;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #fb7185;
  --line: rgba(255,255,255,.10);
  --shadow: 0 24px 80px rgba(0,0,0,.38);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(139,92,246,.22), transparent 34rem),
    linear-gradient(160deg, #0b0c14, #10111c 48%, #0b0c14);
  font-family: "Vazirmatn", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.ambient {
  position: fixed;
  width: 30rem;
  height: 30rem;
  filter: blur(90px);
  opacity: .12;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
}
.ambient-one { background: var(--pink); left: -15rem; top: 30%; }
.ambient-two { background: var(--cyan); right: -18rem; bottom: -8rem; }

.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  box-shadow: 0 12px 30px rgba(139,92,246,.3);
  font-weight: 900; font-size: 1.55rem;
  transform: rotate(-4deg);
}
.brand strong { display: block; font-size: 1.12rem; }
.brand small { display: block; color: var(--muted); margin-top: 1px; }
.room-badge {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); background: rgba(255,255,255,.06);
  padding: 9px 13px; border-radius: 999px; color: var(--muted); cursor: pointer;
}
.room-badge b { letter-spacing: 2px; color: var(--text); direction: ltr; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto 60px;
  min-height: calc(100vh - 180px);
}

.hero-grid { display: grid; grid-template-columns: 1.08fr .92fr; gap: 24px; align-items: stretch; }
.hero, .panel, .question-card, .loading-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--radius);
}
.hero { padding: clamp(30px, 5vw, 64px); position: relative; overflow: hidden; }
.hero::after {
  content: "؟"; position: absolute; inset: auto auto -78px -20px;
  font-size: 17rem; font-weight: 900; color: rgba(255,255,255,.035); transform: rotate(9deg);
}
.eyebrow {
  display: inline-flex; gap: 8px; align-items: center;
  color: #d8c9ff; background: rgba(139,92,246,.14); border: 1px solid rgba(139,92,246,.3);
  border-radius: 999px; padding: 8px 12px; font-weight: 700; font-size: .9rem;
}
.hero h1 { font-size: clamp(2.4rem, 6vw, 5.4rem); line-height: .98; letter-spacing: -3px; margin: 24px 0 18px; }
.hero h1 span { color: transparent; background: linear-gradient(90deg, #a78bfa, #f472b6, #67e8f9); background-clip: text; -webkit-background-clip: text; }
.hero p { color: var(--muted); line-height: 2; font-size: 1.05rem; max-width: 50ch; }
.mini-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 30px; }
.mini-step { border: 1px solid var(--line); background: rgba(255,255,255,.045); padding: 14px; border-radius: 18px; }
.mini-step b { display: block; color: var(--cyan); font-size: .82rem; margin-bottom: 5px; }
.mini-step span { font-weight: 700; }

.join-panel { padding: clamp(22px, 4vw, 38px); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 5px; border-radius: 16px; background: rgba(255,255,255,.05); margin-bottom: 26px; }
.tab { border: 0; background: transparent; padding: 12px; border-radius: 12px; cursor: pointer; color: var(--muted); font-weight: 800; }
.tab.active { background: var(--panel-strong); color: var(--text); box-shadow: 0 8px 18px rgba(0,0,0,.18); }
.form-pane { display: none; }
.form-pane.active { display: block; animation: rise .3s ease; }
.form-pane h2 { margin: 0 0 6px; font-size: 1.45rem; }
.form-pane > p { color: var(--muted); margin: 0 0 24px; }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field label { font-weight: 700; color: #d9daea; }
.input, .select {
  width: 100%; outline: 0; border: 1px solid var(--line); border-radius: 15px;
  color: var(--text); background: rgba(7,8,14,.55); padding: 14px 16px;
  transition: .2s border, .2s box-shadow, .2s transform;
}
.input:focus, .select:focus { border-color: rgba(139,92,246,.8); box-shadow: 0 0 0 4px rgba(139,92,246,.13); }
.code-input { direction: ltr; text-align: center; letter-spacing: 6px; font-weight: 900; text-transform: uppercase; font-size: 1.25rem; }

.btn {
  border: 0; border-radius: 15px; padding: 13px 18px; cursor: pointer;
  display: inline-flex; justify-content: center; align-items: center; gap: 8px;
  font-weight: 900; transition: .18s transform, .18s filter, .18s opacity;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.07); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { cursor: not-allowed; opacity: .48; transform: none; filter: none; }
.btn-primary { background: linear-gradient(135deg, var(--purple), var(--pink)); box-shadow: 0 12px 30px rgba(139,92,246,.25); }
.btn-secondary { background: rgba(255,255,255,.075); border: 1px solid var(--line); }
.btn-danger { background: rgba(251,113,133,.12); color: #fecdd3; border: 1px solid rgba(251,113,133,.22); }
.btn-block { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; }
.game-main, .sidebar { min-width: 0; }
.panel { padding: clamp(20px, 4vw, 34px); }
.sidebar { display: grid; align-content: start; gap: 16px; }
.sidebar .panel { padding: 20px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-title h2, .panel-title h3 { margin: 0; }
.muted { color: var(--muted); }

.lobby-code {
  display: grid; place-items: center; text-align: center;
  border: 1px dashed rgba(103,232,249,.35); background: rgba(34,211,238,.06);
  padding: 24px; border-radius: 20px; margin: 20px 0;
}
.lobby-code small { color: var(--muted); }
.lobby-code strong { direction: ltr; letter-spacing: 10px; font-size: clamp(2rem, 7vw, 4rem); margin: 6px 0; }
.share-link { font-size: .9rem; color: var(--cyan); overflow-wrap: anywhere; }

.player-list { display: grid; gap: 9px; }
.player-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); background: rgba(255,255,255,.04); border-radius: 15px; padding: 11px 13px;
}
.player-ident { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 12px; background: linear-gradient(135deg, rgba(139,92,246,.45), rgba(34,211,238,.3)); font-weight: 900; }
.player-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 800; }
.host-tag, .me-tag { font-size: .72rem; padding: 3px 7px; border-radius: 999px; }
.host-tag { color: #fde68a; background: rgba(251,191,36,.12); }
.me-tag { color: #bae6fd; background: rgba(34,211,238,.12); }
.offline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(251,113,133,.1); }
.score-pill { direction: ltr; color: #ddd6fe; font-weight: 900; }

.phase-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.round-pill { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; color: var(--muted); white-space: nowrap; }
.timer {
  width: 58px; height: 58px; display: grid; place-items: center; flex: 0 0 58px;
  border-radius: 50%; border: 4px solid rgba(139,92,246,.26); background: rgba(139,92,246,.1);
  font-size: 1.2rem; font-weight: 900; direction: ltr;
}
.timer.danger { border-color: rgba(251,113,133,.5); color: #fecdd3; animation: pulse 1s infinite; }
.question-card { padding: clamp(24px, 5vw, 44px); background: linear-gradient(145deg, rgba(139,92,246,.16), rgba(236,72,153,.07)); position: relative; overflow: hidden; }
.question-card::after { content: "؟"; position: absolute; left: -8px; bottom: -70px; font-size: 14rem; font-weight: 900; color: rgba(255,255,255,.045); }
.category { display: inline-flex; color: #e9d5ff; font-weight: 800; font-size: .84rem; border-radius: 999px; background: rgba(139,92,246,.16); padding: 7px 10px; }
.question-card h1 { position: relative; z-index: 1; font-size: clamp(1.55rem, 4vw, 2.65rem); line-height: 1.65; margin: 20px 0 0; }
.instruction { color: var(--muted); line-height: 1.9; margin: 18px 0; }
.answer-input { min-height: 58px; font-size: 1.05rem; }

.progress-wrap { margin: 18px 0; }
.progress-label { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.progress { height: 9px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.07); }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple), var(--cyan)); transition: width .35s ease; }
.waiting-box { text-align: center; border: 1px solid var(--line); border-radius: 18px; padding: 24px; background: rgba(255,255,255,.035); }
.waiting-box .big-icon { font-size: 2.3rem; display: block; margin-bottom: 8px; }

.answers-grid { display: grid; gap: 12px; margin-top: 18px; }
.answer-option {
  width: 100%; border: 1px solid var(--line); background: rgba(255,255,255,.045); color: var(--text);
  padding: 17px; border-radius: 17px; text-align: right; cursor: pointer; line-height: 1.8;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; transition: .18s;
}
.answer-option:hover:not(:disabled) { border-color: rgba(139,92,246,.65); background: rgba(139,92,246,.1); transform: translateY(-2px); }
.answer-option.selected { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,.1); }
.answer-option.own { opacity: .48; cursor: not-allowed; }
.answer-number { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.08); direction: ltr; font-weight: 900; }

.reveal-card { border: 1px solid var(--line); background: rgba(255,255,255,.04); border-radius: 18px; padding: 17px; }
.reveal-card.truth { border-color: rgba(52,211,153,.55); background: rgba(52,211,153,.08); }
.reveal-card.fake { border-color: rgba(236,72,153,.2); }
.reveal-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 8px; }
.truth-label, .fake-label { font-size: .78rem; font-weight: 900; padding: 5px 9px; border-radius: 999px; }
.truth-label { background: rgba(52,211,153,.16); color: #a7f3d0; }
.fake-label { background: rgba(236,72,153,.14); color: #fbcfe8; }
.answer-owner { color: var(--muted); font-size: .87rem; }
.reveal-text { font-size: 1.04rem; line-height: 1.8; font-weight: 700; }
.voters { margin-top: 12px; color: var(--muted); font-size: .88rem; }

.points-list { display: grid; gap: 8px; margin-top: 18px; }
.points-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding: 10px 0; }
.points-row:last-child { border-bottom: 0; }
.points-chip { font-size: .78rem; border-radius: 999px; padding: 4px 8px; background: rgba(255,255,255,.06); color: var(--muted); }
.points-total { color: #fde68a; font-weight: 900; direction: ltr; }

.winner { text-align: center; padding: 20px 0 30px; }
.trophy { font-size: 5rem; filter: drop-shadow(0 16px 28px rgba(251,191,36,.22)); }
.winner h1 { margin: 10px 0 6px; font-size: clamp(2rem, 6vw, 4rem); }
.winner p { color: var(--muted); }
.leaderboard { display: grid; gap: 10px; max-width: 620px; margin: 0 auto 26px; }
.leader-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.045); border-radius: 16px; padding: 12px; }
.leader-row:first-child { border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.07); }
.rank { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: rgba(255,255,255,.07); font-weight: 900; }

.notice { border-radius: 15px; padding: 13px 15px; line-height: 1.8; }
.notice-info { color: #bae6fd; background: rgba(34,211,238,.08); border: 1px solid rgba(34,211,238,.18); }
.notice-warn { color: #fde68a; background: rgba(251,191,36,.07); border: 1px solid rgba(251,191,36,.17); }

.loading-card { min-height: 300px; display: grid; place-content: center; place-items: center; gap: 16px; color: var(--muted); }
.spinner { width: 46px; height: 46px; border: 4px solid rgba(255,255,255,.1); border-top-color: var(--purple); border-radius: 50%; animation: spin .9s linear infinite; }
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: 28px; transform: translate(-50%, 30px);
  min-width: min(390px, calc(100% - 32px)); max-width: 560px; padding: 13px 17px; border-radius: 14px;
  background: #24263a; border: 1px solid var(--line); box-shadow: 0 18px 60px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; transition: .25s; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(251,113,133,.38); color: #fecdd3; }

footer { width: min(1180px, calc(100% - 32px)); margin: 0 auto 24px; display: flex; justify-content: space-between; gap: 14px; color: #777a91; font-size: .82rem; }

#confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 80; }
.confetti-piece { position: absolute; width: 10px; height: 16px; top: -20px; border-radius: 3px; animation: confetti-fall 3.5s linear forwards; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes confetti-fall { to { transform: translate3d(var(--drift), 110vh, 0) rotate(760deg); opacity: .9; } }

@media (max-width: 900px) {
  .hero-grid, .game-layout { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .topbar { min-height: 74px; }
  .brand small { display: none; }
  .brand-mark { width: 42px; height: 42px; border-radius: 14px; }
  .app-shell { width: min(100% - 20px, 1180px); margin-top: 10px; }
  .hero { padding: 28px 22px; }
  .hero h1 { letter-spacing: -2px; }
  .mini-steps { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: 1fr; }
  .panel, .question-card { border-radius: 20px; }
  .phase-head { align-items: flex-start; }
  .lobby-code strong { letter-spacing: 7px; }
  footer { width: calc(100% - 20px); flex-direction: column; align-items: center; text-align: center; }
  .points-row { grid-template-columns: 1fr auto; }
  .points-chip { display: none; }
}
