/* ===================================================================
   Arcade Admin — design system
   =================================================================== */
:root {
  --font: 'Inter', 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --info: #60a5fa;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar: 252px;
  --topbar: 64px;
  --row-h: 52px;
  --t: .18s cubic-bezier(.2,.8,.2,1);
}
:root, [data-theme="dark"] {
  --bg: #0b1020;
  --bg-grad: radial-gradient(1200px 600px at 80% -20%, rgba(124, 92, 255, .18), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(34, 211, 238, .10), transparent 60%);
  --panel: #0e1527;
  --surface: #121a30;
  --surface-2: #182136;
  --surface-3: #1f2a44;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #e6e9f2;
  --text-2: #b7bfd1;
  --muted: #8b93a7;
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, .7);
  --shadow-sm: 0 6px 18px -10px rgba(0, 0, 0, .6);
  --glass: rgba(14, 21, 39, .75);
  --chart-grid: rgba(255, 255, 255, .06);
  --input: #0c1222;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f3f5fb;
  --bg-grad: radial-gradient(1200px 600px at 80% -20%, rgba(124, 92, 255, .12), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(34, 211, 238, .10), transparent 60%);
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --surface-3: #e9edf7;
  --border: rgba(15, 23, 42, .08);
  --border-strong: rgba(15, 23, 42, .16);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --shadow: 0 18px 40px -24px rgba(15, 23, 42, .35);
  --shadow-sm: 0 6px 18px -12px rgba(15, 23, 42, .3);
  --glass: rgba(255, 255, 255, .8);
  --chart-grid: rgba(15, 23, 42, .06);
  --input: #ffffff;
  color-scheme: light;
}
html[lang="fa"] { --font: 'Vazirmatn', 'Inter', system-ui, sans-serif; }
[data-density="compact"] { --row-h: 42px; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); background-image: var(--bg-grad); background-attachment: fixed; color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
.num, .mono, td.num, .tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
@media (max-width: 1280px) { .cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .cols-3, .cols-2 { grid-template-columns: 1fr; } .span-2, .span-3, .span-4 { grid-column: span 1; } }
@media (max-width: 640px) { .cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-4 { grid-template-columns: 1fr; } }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; transition: grid-template-columns var(--t); }
.shell.collapsed { --sidebar: 76px; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--panel); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; gap: 10px; overflow: hidden; z-index: 30; }
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 14px; }
.brand .logo { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 20px; box-shadow: 0 10px 24px -10px var(--accent); flex: none; }
.brand .name { font-weight: 800; font-size: 16px; letter-spacing: .3px; white-space: nowrap; }
.brand .sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; overflow-x: hidden; }
.nav .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); padding: 14px 12px 6px; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text-2); font-weight: 600; white-space: nowrap; transition: background var(--t), color var(--t); position: relative; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); }
.nav a.active::before { content: ''; position: absolute; inset-inline-start: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav a svg { width: 20px; height: 20px; flex: none; opacity: .9; }
.nav a .badge { margin-inline-start: auto; }
.shell.collapsed .brand .text, .shell.collapsed .nav a span, .shell.collapsed .nav .group, .shell.collapsed .nav .badge, .shell.collapsed .sidebar-foot .text { display: none; }
.shell.collapsed .nav a { justify-content: center; padding: 12px; }
.shell.collapsed .nav a.active::before { display: none; }
.shell.collapsed .brand { justify-content: center; padding-inline: 0; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.sidebar-foot .avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--accent-2), var(--accent)); display: grid; place-items: center; color: #fff; font-weight: 800; flex: none; }
.sidebar-foot .text { flex: 1; min-width: 0; }
.sidebar-foot .text b { display: block; font-size: 13px; }
.sidebar-foot .text span { font-size: 11.5px; color: var(--muted); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar); display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 800; }
.topbar .crumb { color: var(--muted); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.search-btn { display: flex; align-items: center; gap: 10px; min-width: 260px; height: 38px; padding: 0 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 13px; transition: border var(--t); }
.search-btn:hover { border-color: var(--border-strong); }
.search-btn kbd { margin-inline-start: auto; font: 600 11px var(--font); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; }
.live-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.live-pill.on .dot { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--good) 8%, transparent); } }
.content { padding: 24px; display: flex; flex-direction: column; gap: 20px; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.2px; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.burger { display: none; }
@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; width: 272px; transform: translateX(calc(var(--dir, 1) * -100%)); transition: transform var(--t); box-shadow: var(--shadow); }
  [dir="rtl"] .sidebar { --dir: -1; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.collapsed .brand .text, .shell.collapsed .nav a span, .shell.collapsed .nav .group, .shell.collapsed .nav .badge, .shell.collapsed .sidebar-foot .text { display: initial; }
  .shell.collapsed .nav a { justify-content: flex-start; padding: 10px 12px; }
  .burger { display: grid; }
  .topbar { padding: 0 14px; }
  .content { padding: 14px; gap: 14px; }
  .search-btn { min-width: 0; width: 38px; padding: 0; justify-content: center; }
  .search-btn span, .search-btn kbd { display: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 25; }
}

/* ---------- buttons / inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: 13.5px; transition: all var(--t); white-space: nowrap; }
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2))); color: #fff; border: 0; box-shadow: 0 10px 24px -12px var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 10px; }
.btn.icon { width: 38px; padding: 0; }
.btn.icon.sm { width: 32px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.input, select.input, textarea.input { width: 100%; height: 40px; padding: 0 12px; border-radius: 12px; background: var(--input); border: 1px solid var(--border); color: var(--text); outline: none; transition: border var(--t), box-shadow var(--t); }
textarea.input { height: auto; min-height: 110px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input::placeholder { color: var(--muted); }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-inline-end: 32px; }
[dir="rtl"] select.input { background-position: left 12px center; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.search-input { position: relative; }
.search-input svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search-input .input { padding-inline-start: 36px; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); transition: background var(--t); flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); transition: transform var(--t); }
.switch.on { background: var(--accent); border-color: transparent; }
.switch.on::after { transform: translateX(18px); }
[dir="rtl"] .switch.on::after { transform: translateX(-18px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: 0; }
.switch-row b { display: block; font-size: 13.5px; }
.switch-row span { font-size: 12px; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 12px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: var(--muted); transition: all var(--t); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tabs button { padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--t); display: inline-flex; align-items: center; gap: 8px; }
.tabs button.on { color: var(--text); border-color: var(--accent); }
.tabs button:hover { color: var(--text); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.card-head .sub { font-size: 12px; color: var(--muted); }
.card-body { padding: 16px 18px 18px; flex: 1; min-width: 0; }
.card-body.flush { padding: 0; }
.card.pad { padding: 18px; }
.kpi { position: relative; overflow: hidden; padding: 16px 18px; gap: 12px; }
.kpi .ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; background: color-mix(in srgb, var(--c, var(--accent)) 18%, transparent); color: var(--c, var(--accent)); }
.kpi .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 26px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; margin-top: 2px; }
.kpi .delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; }
.kpi .delta.up { color: var(--good); }
.kpi .delta.down { color: var(--bad); }
.kpi .delta.flat { color: var(--muted); }
.kpi .spark { position: absolute; inset-inline-end: 12px; bottom: 12px; width: 84px; height: 32px; opacity: .9; }
.kpi::after { content: ''; position: absolute; inset-inline-end: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--c, var(--accent)) 22%, transparent), transparent 70%); pointer-events: none; }
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.sm { height: 200px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }

/* ---------- badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.badge.info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.badge.accent { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; font-weight: 600; transition: all var(--t); }
.chip.on { background: var(--accent); color: #fff; border-color: transparent; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 13px; flex: none; background: var(--c, var(--accent)); }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.game-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: color-mix(in srgb, var(--c, var(--accent)) 18%, transparent); flex: none; }
.game-ic.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 28px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 0 14px; height: var(--row-h); text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th.sorted { color: var(--accent); }
.tbl tbody tr { transition: background var(--t); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td .sub { font-size: 11.5px; color: var(--muted); }
.tbl .cell-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tbl .cell-user .n { font-weight: 600; max-width: 180px; }
.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; min-width: 70px; }
.progress i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; }
.pager .pages button { min-width: 32px; height: 32px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.pager .pages button.on { background: var(--accent); color: #fff; }
.pager .pages button:hover:not(.on) { background: var(--surface-2); color: var(--text); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .e { font-size: 40px; margin-bottom: 8px; opacity: .8; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; color: transparent !important; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- feed ---------- */
.feed { display: flex; flex-direction: column; max-height: 420px; overflow-y: auto; }
.feed .item { display: flex; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--border); animation: slidein .3s ease; align-items: flex-start; }
.feed .item:last-child { border-bottom: 0; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); background: color-mix(in srgb, var(--accent) 12%, transparent); } }
.feed .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 14px; flex: none; background: var(--surface-2); }
.feed .ic.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.feed .ic.error { background: color-mix(in srgb, var(--bad) 18%, transparent); }
.feed .txt { flex: 1; min-width: 0; font-size: 13px; }
.feed .txt b { font-weight: 600; }
.feed .txt .m { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .time { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- live session cards ---------- */
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.live-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: all var(--t); }
.live-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.live-card .vs { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12.5px; font-weight: 600; }
.live-card .vs .p { display: flex; align-items: center; gap: 6px; min-width: 0; }
.live-card .vs .p.turn .avatar { box-shadow: 0 0 0 2px var(--accent); }
.live-card .vs .p span { max-width: 70px; }
.live-card .vs .sep { color: var(--muted); font-size: 11px; }
.live-card .foot { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--muted); }
.board { display: grid; gap: 3px; width: 100%; aspect-ratio: 1; background: var(--surface-3); border-radius: 10px; padding: 6px; }
.board.ttt { grid-template-columns: repeat(3, 1fr); }
.board.ttt div { border-radius: 6px; background: var(--surface); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.board.ttt div.x { color: #7c5cff; }
.board.ttt div.o { color: #22d3ee; }
.board.ttt div.w { background: color-mix(in srgb, var(--good) 25%, transparent); }
.board.c4 { grid-template-columns: repeat(7, 1fr); aspect-ratio: 7/6; background: #1f2a4a; }
[data-theme="light"] .board.c4 { background: #334155; }
.board.c4 div { border-radius: 50%; background: var(--bg); aspect-ratio: 1; }
.board.c4 div.p0 { background: #7c5cff; }
.board.c4 div.p1 { background: #22d3ee; }
.board.c4 div.w { box-shadow: inset 0 0 0 2px #fff; }
.board.lg { max-width: 300px; }
.board.none { display: grid; place-items: center; aspect-ratio: 16/7; color: var(--muted); font-size: 12px; }

/* ---------- drawer / modal ---------- */
.drawer-bg, .modal-bg { position: fixed; inset: 0; background: rgba(3, 6, 16, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 60; display: flex; justify-content: flex-end; opacity: 0; transition: opacity .2s; }
.drawer-bg.show, .modal-bg.show { opacity: 1; }
.drawer { width: min(560px, 100%); height: 100%; background: var(--panel); border-inline-start: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; transform: translateX(calc(var(--dir, 1) * 40px)); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
[dir="rtl"] .drawer { --dir: -1; }
.drawer-bg.show .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; font-size: 16px; flex: 1; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal-bg { align-items: center; justify-content: center; padding: 20px; }
.modal { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); transform: translateY(12px) scale(.98); transition: transform .25s cubic-bezier(.2,.8,.2,1); max-height: 90vh; display: flex; flex-direction: column; }
.modal.wide { width: min(760px, 100%); }
.modal-bg.show .modal { transform: none; }
.modal-head { padding: 18px 22px 0; display: flex; align-items: center; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.modal-foot { padding: 0 22px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.section-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin: 4px 0 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.stat-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-mini div { background: var(--surface-2); border-radius: 12px; padding: 10px; text-align: center; }
.stat-mini b { display: block; font-size: 18px; }
.stat-mini span { font-size: 11px; color: var(--muted); }

/* ---------- toast ---------- */
.toasts { position: fixed; bottom: 20px; inset-inline-end: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 13.5px; font-weight: 600; animation: toastin .25s cubic-bezier(.2,.8,.2,1); max-width: 360px; }
.toast.good { border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.toast.out { animation: toastout .2s forwards; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes toastout { to { opacity: 0; transform: translateY(10px); } }

/* ---------- command palette ---------- */
.cmdk { position: fixed; inset: 0; z-index: 90; background: rgba(3, 6, 16, .55); backdrop-filter: blur(6px); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.cmdk .box { width: min(600px, 92vw); background: var(--panel); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; animation: toastin .2s; }
.cmdk input { width: 100%; height: 54px; padding: 0 18px; background: transparent; border: 0; border-bottom: 1px solid var(--border); outline: none; font-size: 15px; }
.cmdk .list { max-height: 50vh; overflow-y: auto; padding: 8px; }
.cmdk .grp { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 8px 10px 4px; }
.cmdk .it { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.cmdk .it.on, .cmdk .it:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.cmdk .it svg { width: 16px; height: 16px; opacity: .8; }
.cmdk .foot { padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 32px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; animation: fadein .35s; }
.login .logo { width: 60px; height: 60px; border-radius: 18px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-size: 30px; margin: 0 auto 4px; box-shadow: 0 14px 30px -12px var(--accent); }
.login h1 { margin: 0; text-align: center; font-size: 22px; }
.login p { margin: -8px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.login .err { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 600; text-align: center; }
.login .foot { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }
.demo-banner { background: linear-gradient(90deg, color-mix(in srgb, var(--warn) 22%, transparent), color-mix(in srgb, var(--accent) 18%, transparent)); border-bottom: 1px solid var(--border); font-size: 12.5px; font-weight: 600; text-align: center; padding: 6px 12px; }
.maint-banner { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: color-mix(in srgb, var(--warn) 16%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); font-weight: 600; font-size: 13px; }

/* ---------- game cards ---------- */
.game-card .head { display: flex; align-items: center; gap: 14px; }
.game-card .head h3 { margin: 0; font-size: 16px; }
.game-card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.game-card .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.game-card .stats div { background: var(--surface-2); border-radius: 12px; padding: 10px 8px; text-align: center; }
.game-card .stats b { display: block; font-size: 17px; }
.game-card .stats span { font-size: 11px; color: var(--muted); }
.steps { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.steps div { display: flex; gap: 10px; align-items: flex-start; }
.steps i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 800; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); flex: none; }
.copybox { display: flex; align-items: center; gap: 8px; background: var(--input); border: 1px dashed var(--border-strong); border-radius: 12px; padding: 8px 8px 8px 14px; }
.copybox code { flex: 1; font-family: ui-monospace, monospace; font-size: 13px; }

/* ---------- broadcast ---------- */
.tg-preview { background: #17212b; border-radius: 16px; padding: 16px; min-height: 120px; display: flex; flex-direction: column; gap: 8px; }
.tg-bubble { align-self: flex-start; max-width: 85%; background: #182533; color: #f5f5f5; border-radius: 14px 14px 14px 4px; padding: 8px 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
[dir="rtl"] .tg-bubble { border-radius: 14px 14px 4px 14px; align-self: flex-end; }
.tg-bubble a { color: #6ab3f3; }
.tg-bubble .tm { display: block; text-align: end; font-size: 11px; color: #7f91a4; margin-top: 4px; }
.tg-btn { align-self: flex-start; max-width: 85%; width: 100%; background: rgba(255,255,255,.08); color: #6ab3f3; border-radius: 8px; text-align: center; padding: 7px; font-size: 13px; font-weight: 600; }
[dir="rtl"] .tg-btn { align-self: flex-end; }
.toolbar { display: flex; gap: 4px; }
.toolbar button { width: 32px; height: 30px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 700; font-size: 12.5px; }
.bc-item { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.bc-item:last-child { border-bottom: 0; }
.bc-item .txt { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bc-item .meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

/* ---------- locales ---------- */
.loc-row { display: grid; grid-template-columns: 220px 1fr 1fr; gap: 12px; align-items: start; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.loc-row:last-child { border-bottom: 0; }
.loc-row .k { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); word-break: break-all; padding-top: 10px; }
.loc-row .ref { font-size: 13px; color: var(--text-2); padding-top: 9px; white-space: pre-wrap; }
.loc-row textarea { min-height: 40px; height: 40px; }
.loc-row.changed .input { border-color: var(--warn); }
.loc-row.missing .k::before { content: '•'; color: var(--bad); margin-inline-end: 6px; }
@media (max-width: 900px) { .loc-row { grid-template-columns: 1fr; gap: 4px; } }
.savebar { position: sticky; bottom: 0; background: var(--glass); backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- logs ---------- */
.lvl { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--info); }
.lvl.warn { background: var(--warn); }
.lvl.error { background: var(--bad); }
pre.json { margin: 0; background: var(--input); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 12px; overflow-x: auto; max-height: 240px; direction: ltr; text-align: left; }
tr.expand td { height: auto; padding: 10px 14px 14px; background: var(--surface-2); white-space: normal; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .settings-grid { grid-template-columns: 1fr; } }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; transition: transform var(--t); }
.swatches button.on { border-color: var(--text); transform: scale(1.1); }
.info-list { display: flex; flex-direction: column; }
.info-list .r { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-list .r:last-child { border-bottom: 0; }
.info-list .r span:first-child { color: var(--muted); }
.info-list .r span:last-child { font-weight: 600; text-align: end; overflow-wrap: anywhere; }

/* ---------- late overrides (specificity) ---------- */
.search-btn svg { width: 16px; height: 16px; flex: none; }
.search-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .burger { display: none; }
@media (max-width: 1024px) {
  .topbar .burger { display: inline-flex; }
  .topbar #collapse-btn { display: none !important; }
  .topbar .crumb { display: none; }
  .topbar h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
}

.board.summary { display: flex; flex-direction: column; gap: 4px; aspect-ratio: auto; padding: 8px; }
.board.summary .srow { display: flex; align-items: center; gap: 8px; font-size: 11.5px; padding: 3px 6px; border-radius: 6px; background: var(--surface); }
.board.summary .srow i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.board.summary .srow span:last-child { margin-inline-start: auto; }
.board.summary .dots { display: flex; gap: 3px; margin-inline-start: auto; }
.board.summary .dots i { width: 9px; height: 9px; border-radius: 50%; }
