@font-face { font-family: 'Vazirmatn'; src: url('/fonts/Vazirmatn.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root, html[data-theme='neon'] {
  --bg: #090b12; --bg2: #090b12; --ink: #eef0ff; --sub: #8b93b8; --panel: #10142a; --panel-2: #0a0d1c; --line: #1d2447;
  --accent: #22d3ee; --accent-ink: #061018; --good: #34d399; --bad: #f87171; --warn: #fbbf24;
  --glow: 0 0 0 2px #22d3ee66, 0 0 22px #22d3ee40; --radius: 20px; --blur: none; --shadow: none;
}
html[data-theme='glass'] {
  --bg: linear-gradient(165deg, #1a1050 0%, #0e2a66 55%, #0a4a6a 100%); --bg2: #0e2a66; --ink: #ffffff; --sub: #cfd8ff;
  --panel: rgba(255,255,255,.11); --panel-2: rgba(10,10,40,.36); --line: rgba(255,255,255,.22);
  --accent: #ffffff; --accent-ink: #1a1050; --good: #86efac; --bad: #fca5a5; --warn: #fde047;
  --glow: 0 0 0 2px rgba(255,255,255,.6), 0 0 24px rgba(255,255,255,.25); --radius: 24px; --blur: blur(18px); --shadow: none;
}
html[data-theme='light'] {
  --bg: #f3f5fa; --bg2: #f3f5fa; --ink: #0f172a; --sub: #5b6478; --panel: #ffffff; --panel-2: #eef1f8; --line: #e1e5ef;
  --accent: #0f172a; --accent-ink: #ffffff; --good: #047857; --bad: #b91c1c; --warn: #b45309;
  --glow: 0 0 0 2px #0f172a55, 0 4px 14px rgba(15,23,42,.14); --radius: 20px; --blur: none; --shadow: 0 1px 2px rgba(15,23,42,.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); background-attachment: fixed; background-color: var(--bg2); color: var(--ink); font-family: 'Vazirmatn', system-ui, sans-serif; font-size: 15px; line-height: 1.6; overflow-x: hidden; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

#app { max-width: 480px; margin: 0 auto; padding: 14px 14px 90px; min-height: 100vh; display: flex; flex-direction: column; gap: 14px; }

/* ---- primitives */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.center { display: flex; align-items: center; justify-content: center; text-align: center; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--sub); }
.title { font-weight: 800; font-size: 18px; }
.small { font-size: 13px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12px; font-weight: 700; background: var(--panel-2); color: var(--sub); border: 1px solid var(--line); }
.badge.acc { color: var(--accent); border-color: currentColor; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; padding: 2px 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.timer.low { color: var(--bad); border-color: var(--bad); }
.banner { text-align: center; font-weight: 800; padding: 10px 12px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.banner.me { color: var(--accent); box-shadow: var(--glow); }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; background: var(--panel-2); border: 2px solid var(--line); color: var(--ink); overflow: hidden; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar.off { opacity: .45; }

.btn { white-space: nowrap; min-height: 44px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .08s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 800; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 44px; padding: 0; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--panel); color: var(--sub); font-weight: 600; font-size: 13px; }
.chip.on { color: var(--accent); border-color: var(--accent); background: var(--panel-2); font-weight: 800; }
input[type=text], input[type=search], input:not([type]), select, textarea { min-height: 44px; width: 100%; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select option { color: #111; }

.seg { display: flex; gap: 4px; padding: 4px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.seg > button { flex: 1; min-height: 44px; border: 0; border-radius: 14px; background: transparent; color: var(--sub); font-weight: 600; }
.seg > button.on { background: var(--accent); color: var(--accent-ink); font-weight: 800; }
html[data-theme='neon'] .seg > button.on { background: #0e2a3a; color: var(--accent); box-shadow: inset 0 0 0 1px #22d3ee66; }

.switch { width: 52px; height: 30px; border-radius: 15px; border: 0; padding: 3px; display: flex; justify-content: flex-end; background: var(--line); flex: none; }
.switch i { width: 24px; height: 24px; border-radius: 50%; background: var(--sub); display: block; }
.switch.on { justify-content: flex-start; background: var(--accent); }
.switch.on i { background: var(--accent-ink); }
.switch:disabled { opacity: .5; }

/* ---- header */
.top { display: flex; align-items: center; gap: 10px; }
.top .name { font-size: 21px; font-weight: 800; color: var(--accent); }
html[data-theme='light'] .top .name { color: var(--ink); }
html[data-theme='glass'] .top .name { color: #fff; }
.top .sub { font-size: 13px; color: var(--sub); }
.scope-pill { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 12px; border: 1px solid var(--line); color: var(--sub); }

/* ---- game cards */
.gcard { border-radius: var(--radius); padding: 14px; background: var(--panel); border: 1px solid color-mix(in srgb, var(--gc) 35%, var(--line)); display: flex; flex-direction: column; gap: 10px; backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); }
html[data-theme='neon'] .gcard { box-shadow: 0 0 26px color-mix(in srgb, var(--gc) 14%, transparent); }
.gicon { width: 52px; height: 52px; border-radius: 16px; flex: none; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--gc) 22%, transparent); color: var(--gc); }
html[data-theme='light'] .gicon { color: color-mix(in srgb, var(--gc) 70%, #000); }
.gname { font-size: 18px; font-weight: 800; }
.gpl { font-size: 13px; font-weight: 700; color: var(--gc); }
html[data-theme='light'] .gpl { color: color-mix(in srgb, var(--gc) 65%, #000); }
.gdesc { font-size: 13.5px; color: var(--sub); }
.gcard .tag { padding: 3px 11px; border-radius: 12px; font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--gc) 20%, transparent); color: var(--gc); }
html[data-theme='light'] .gcard .tag { color: color-mix(in srgb, var(--gc) 65%, #000); }
.gplay { min-height: 48px; border: 0; border-radius: 16px; background: var(--gc); color: #0b0d16; font-weight: 800; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px; }
html[data-theme='glass'] .gplay { background: #fff; color: #1a1050; }
html[data-theme='light'] .gplay { background: #0f172a; color: #fff; border-radius: 24px; }

/* ---- rooms / lobby */
.room-item { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line); }
.plist { display: flex; flex-direction: column; gap: 8px; }
.pitem { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.code { font-size: 22px; font-weight: 800; letter-spacing: 3px; direction: ltr; unicode-bidi: isolate; }

/* ---- game screen */
.gbar { display: flex; align-items: center; gap: 8px; }
.gbar .t { flex: 1; font-weight: 800; font-size: 17px; }
.game { display: flex; flex-direction: column; gap: 10px; }
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 38vh; }
.chat .msgs { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; max-height: 24vh; padding: 4px 2px; }
.chat .m b { color: var(--accent); }
html[data-theme='light'] .chat .m b { color: var(--ink); }
.chat .sys { color: var(--sub); font-size: 12.5px; }

/* ---- overlays */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(4,6,14,.66); display: flex; align-items: center; justify-content: center; padding: 18px; }
.overlay .box { width: 100%; max-width: 400px; max-height: 88vh; overflow-y: auto; background: var(--panel); background-color: color-mix(in srgb, var(--bg2) 92%, #000); border: 1px solid var(--line); border-radius: 26px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
html[data-theme='light'] .overlay .box { background-color: #fff; }
.toast { position: fixed; z-index: 80; bottom: 22px; left: 50%; transform: translateX(-50%); max-width: 88vw; padding: 10px 18px; border-radius: 16px; background: var(--ink); color: var(--bg2); font-weight: 700; font-size: 14px; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--panel-2); }
.rank-row .n { width: 26px; text-align: center; font-weight: 800; color: var(--sub); }
.rank-row.me { box-shadow: var(--glow); }
.xpbar { height: 10px; border-radius: 6px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--line); }
.xpbar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.stat { flex: 1; text-align: center; padding: 10px 6px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.stat b { display: block; font-size: 20px; }
.empty { text-align: center; color: var(--sub); padding: 18px 8px; }

/* ---- wheel / voice */
.wheel-cv { width: min(100%, 340px); height: auto; aspect-ratio: 1; }
textarea { width: 100%; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); outline: none; }
.speaking { box-shadow: 0 0 0 3px var(--good); }
.pitem .tools { display: flex; gap: 6px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper b { min-width: 36px; text-align: center; font-size: 18px; }
.vchat { max-height: 26vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
