:root {
  --bg: #080d13;
  --bg-2: #0b121b;
  --panel: rgba(17, 26, 37, 0.86);
  --panel-solid: #111a25;
  --panel-2: #0e1721;
  --line: rgba(130, 160, 190, 0.14);
  --line-strong: rgba(130, 160, 190, 0.28);
  --text: #e9f0f8;
  --muted: #8da2b8;
  --dim: #5f748a;
  --amber: #f0b35b;
  --amber-2: #ffcd83;
  --jade: #58c9a6;
  --violet: #a98cf2;
  --red: #e0737d;
  --blue: #6ba8ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-y: scroll;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--amber-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.92em; background: rgba(120, 160, 200, 0.12); padding: 1px 5px; border-radius: 5px; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: 0.01em; }
p { margin: 0; }
ul { margin: 0; padding-left: 18px; }

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 600px at 15% -10%, rgba(240, 179, 91, 0.10), transparent 60%),
    radial-gradient(800px 500px at 95% 0%, rgba(88, 201, 166, 0.08), transparent 60%),
    radial-gradient(700px 700px at 50% 120%, rgba(70, 120, 210, 0.08), transparent 60%),
    linear-gradient(180deg, #080d13 0%, #0a1119 50%, #080d13 100%);
}
.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(140, 170, 200, 0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(140, 170, 200, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 30%, transparent 80%);
}

/* --------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px clamp(16px, 4vw, 44px);
  background: rgba(8, 13, 19, 0.78);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { position: relative; width: 38px; height: 34px; flex: none; }
.stone {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  position: relative;
  box-shadow: inset -3px -4px 7px rgba(0, 0, 0, 0.35), inset 2px 2px 4px rgba(255, 255, 255, 0.14), 0 3px 8px rgba(0, 0, 0, 0.45);
}
.stone.black { background: radial-gradient(circle at 32% 28%, #4a5563, #1b222b 55%, #090c10); }
.stone.white { background: radial-gradient(circle at 32% 28%, #ffffff, #efe8d8 55%, #c8bfae); }
.brand-mark .stone { position: absolute; top: 4px; left: 10px; }
.brand-mark .stone.black { left: 0; top: 0; z-index: 2; }
.brand-mark .stone.white { left: 15px; top: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-size: 17px; letter-spacing: 0.08em; }
.brand-text small { font-size: 9px; letter-spacing: 0.34em; color: var(--dim); margin-top: 3px; }
.tabs { display: flex; gap: 4px; margin-left: 8px; flex: 1; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  transition: 0.18s ease;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab.active { color: #17120a; background: linear-gradient(180deg, var(--amber-2), var(--amber)); box-shadow: 0 4px 18px rgba(240, 179, 91, 0.28); }
.top-right { display: flex; align-items: center; gap: 12px; }
.conn { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.conn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); box-shadow: 0 0 0 3px rgba(95, 116, 138, 0.12); }
.conn.online { color: var(--jade); }
.conn.online .dot { background: var(--jade); box-shadow: 0 0 10px rgba(88, 201, 166, 0.8); }
.conn.offline { color: var(--red); }
.conn.offline .dot { background: var(--red); }
.server-chip { border: 1px solid var(--line); color: var(--dim); padding: 3px 9px; border-radius: 999px; font-size: 11px; font-family: var(--mono); }

/* ---------------------------------------------------------------- page */
.page { max-width: 1360px; margin: 0 auto; padding: 30px clamp(16px, 4vw, 44px) 80px; }
.view { display: none; animation: fade-up 0.28s ease; }
.view.active { display: block; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; flex-wrap: wrap; }
.view-head h2 { font-size: clamp(22px, 2.6vw, 30px); letter-spacing: 0.03em; }
.view-head p { color: var(--muted); margin-top: 5px; max-width: 720px; }
.muted { color: var(--muted); }
.fineprint { color: var(--dim); font-size: 12px; line-height: 1.5; margin-top: 10px; }

/* ---------------------------------------------------------------- cards */
.card {
  background: linear-gradient(180deg, rgba(21, 32, 45, 0.9), rgba(14, 22, 32, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-head h3 { font-size: 16px; }
.card-head .muted { font-size: 12px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr); gap: 18px; margin-bottom: 18px; }
.arena-top { grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.85fr); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--dim); font-size: 12px; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.empty { color: var(--dim); text-align: center; padding: 26px 10px; font-size: 13px; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 13px; }
.field > label { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
input, select, textarea {
  width: 100%;
  background: rgba(7, 12, 18, 0.65);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  transition: 0.16s ease;
}
input::placeholder { color: var(--dim); }
input:focus, select:focus, textarea:focus { border-color: rgba(240, 179, 91, 0.65); box-shadow: 0 0 0 3px rgba(240, 179, 91, 0.12); }
select { cursor: pointer; }
select option { background: #0e1721; }
input[type="checkbox"] { accent-color: var(--amber); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: rgba(120, 160, 200, 0.08);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: 0.16s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: rgba(240, 179, 91, 0.45); background: rgba(240, 179, 91, 0.08); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(180deg, var(--amber-2), var(--amber)); border-color: transparent; color: #17120a; box-shadow: 0 6px 20px rgba(240, 179, 91, 0.22); }
.btn.primary:hover { filter: brightness(1.04); background: linear-gradient(180deg, #ffd692, #f4b963); }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; border-color: rgba(224, 115, 125, 0.4); color: var(--red); }
.btn.danger-ghost:hover { background: rgba(224, 115, 125, 0.1); border-color: var(--red); }
.btn.wide { width: 100%; }
.btn.tiny { padding: 5px 10px; font-size: 12px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

.segmented { display: flex; background: rgba(7, 12, 18, 0.6); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; }
.segmented button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; transition: 0.16s ease; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: rgba(240, 179, 91, 0.16); color: var(--amber-2); box-shadow: inset 0 0 0 1px rgba(240, 179, 91, 0.25); }
.segmented.small button { padding: 7px 6px; font-size: 12px; }

/* ---------------------------------------------------------------- play */
.play-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.board-panel {
  background: linear-gradient(180deg, rgba(21, 32, 45, 0.94), rgba(12, 19, 27, 0.94));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 86px;
}
.board-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.board-head h2 { font-size: 19px; }
.board-head p { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.board-head-right { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { border: 1px solid var(--line); background: rgba(7, 12, 18, 0.45); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 11.5px; white-space: nowrap; }
.board-stage { position: relative; width: 100%; max-width: min(100%, calc(100vh - 260px)); margin: 0 auto; border-radius: 16px; overflow: hidden; background: #0a1118; aspect-ratio: 1 / 1; }
#board { display: block; width: 100%; height: 100%; cursor: default; touch-action: none; }
#board.interactive { cursor: crosshair; }
.board-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(5, 9, 14, 0.75); border: 1px solid var(--line); color: var(--muted); font-size: 12px; padding: 5px 12px; border-radius: 999px; pointer-events: none; backdrop-filter: blur(6px); opacity: 0; transition: 0.25s; }
.board-stage:hover .board-hint { opacity: 1; }
.board-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.players { display: flex; gap: 8px; flex-wrap: wrap; }
.player-pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 5px; border-radius: 999px; border: 1px solid var(--line); background: rgba(7, 12, 18, 0.45); font-size: 12px; color: var(--muted); }
.player-pill.active { border-color: rgba(240, 179, 91, 0.5); color: var(--text); box-shadow: 0 0 0 1px rgba(240, 179, 91, 0.12); }
.stone.mini { width: 18px; height: 18px; }
.board-tools { display: flex; align-items: center; gap: 14px; }
.switch { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; cursor: pointer; user-select: none; }
.switch input { width: auto; }
.turn-badge { font-size: 12px; color: var(--amber-2); border: 1px solid rgba(240, 179, 91, 0.28); background: rgba(240, 179, 91, 0.08); border-radius: 999px; padding: 4px 11px; white-space: nowrap; }
.turn-badge.their { color: var(--muted); border-color: var(--line); background: rgba(7, 12, 18, 0.45); }

.side-panel {
  background: linear-gradient(180deg, rgba(21, 32, 45, 0.9), rgba(12, 19, 27, 0.92));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  min-height: 420px;
  position: sticky;
  top: 86px;
}
.mode-tabs { margin-bottom: 18px; }
.mode-body.hidden, .hidden { display: none !important; }
.online-create { margin-top: 4px; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; }
.live-list { display: flex; flex-direction: column; gap: 8px; }
.live-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); background: rgba(7, 12, 18, 0.4); border-radius: 11px; padding: 10px 12px; cursor: pointer; transition: 0.16s; }
.live-item:hover { border-color: rgba(240, 179, 91, 0.4); background: rgba(240, 179, 91, 0.05); }
.live-item .names { font-size: 12.5px; }
.live-item .meta { color: var(--dim); font-size: 11.5px; margin-top: 2px; }
.live-item .badge-live { color: var(--jade); font-size: 11px; border: 1px solid rgba(88, 201, 166, 0.35); border-radius: 999px; padding: 2px 8px; }

.game-banner { display: flex; gap: 11px; align-items: flex-start; border: 1px solid rgba(240, 179, 91, 0.25); background: linear-gradient(180deg, rgba(240, 179, 91, 0.09), rgba(240, 179, 91, 0.03)); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.banner-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.game-banner strong { display: block; font-size: 13.5px; }
.game-banner p { color: var(--muted); font-size: 12px; margin-top: 3px; }
.room-card { border: 1px dashed var(--line-strong); border-radius: 12px; padding: 12px; margin-bottom: 13px; background: rgba(7, 12, 18, 0.35); }
.room-code-row { display: flex; align-items: center; gap: 9px; }
.room-code-row > span { color: var(--muted); font-size: 12px; }
.room-code-row strong { font-family: var(--mono); font-size: 19px; letter-spacing: 0.18em; color: var(--amber-2); }
.room-code-row .btn { margin-left: auto; }
.room-players { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; font-size: 12.5px; }
.room-player { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.room-player .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.room-player .dot.on { background: var(--jade); box-shadow: 0 0 8px rgba(88, 201, 166, 0.7); }
.room-player strong { color: var(--text); font-weight: 600; }
.room-actions { display: flex; gap: 8px; }
.active-actions { display: flex; gap: 8px; margin-bottom: 13px; flex-wrap: wrap; }
.active-actions .btn { flex: 1; }
.result-banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 13px; border: 1px solid rgba(240, 179, 91, 0.35); background: linear-gradient(180deg, rgba(240, 179, 91, 0.12), rgba(240, 179, 91, 0.04)); display: flex; flex-direction: column; gap: 2px; }
.result-banner strong { font-size: 14px; }
.result-banner span { color: var(--muted); font-size: 12px; }
.result-banner.lose { border-color: rgba(224, 115, 125, 0.35); background: linear-gradient(180deg, rgba(224, 115, 125, 0.1), rgba(224, 115, 125, 0.03)); }
.list-title { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.move-list-wrap { margin-top: 4px; }
.move-list { list-style: none; margin: 0; padding: 0; max-height: 210px; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-family: var(--mono); font-size: 12px; }
.move-list li { display: flex; gap: 7px; align-items: center; color: var(--muted); padding: 2px 4px; border-radius: 5px; }
.move-list li:nth-child(4n+1), .move-list li:nth-child(4n+2) { background: rgba(255, 255, 255, 0.018); }
.move-list .mv-no { color: var(--dim); width: 26px; text-align: right; }
.move-list .mv-stone { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.move-list .mv-stone.black { background: radial-gradient(circle at 32% 28%, #58646f, #161b22); }
.move-list .mv-stone.white { background: radial-gradient(circle at 32% 28%, #fff, #cec5b4); }
.move-list .mv-coord { color: var(--text); }
.move-list .mv-flag { color: var(--amber); font-size: 10px; margin-left: auto; }

/* --------------------------------------------------------------- tables */
.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--line); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 560px; }
.data-table th { text-align: left; font-weight: 600; color: var(--dim); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; padding: 10px 12px; background: rgba(7, 12, 18, 0.5); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid rgba(130, 160, 190, 0.08); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(240, 179, 91, 0.035); }
.data-table .name-cell { display: flex; flex-direction: column; gap: 1px; }
.data-table .name-cell strong { font-weight: 600; }
.data-table .name-cell small { color: var(--dim); font-size: 11px; }
.num { font-variant-numeric: tabular-nums; font-family: var(--mono); }
.rank { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); background: rgba(255, 255, 255, 0.04); }
.rank.r1 { color: #1a1408; background: linear-gradient(180deg, #ffd98f, #e8ae4f); font-weight: 700; }
.rank.r2 { color: #121820; background: linear-gradient(180deg, #dbe6f0, #aebdcb); font-weight: 700; }
.rank.r3 { color: #1a120c; background: linear-gradient(180deg, #e5b28c, #c58a63); font-weight: 700; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 10.5px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.local { color: var(--amber-2); border-color: rgba(240, 179, 91, 0.3); background: rgba(240, 179, 91, 0.08); }
.badge.remote { color: var(--jade); border-color: rgba(88, 201, 166, 0.3); background: rgba(88, 201, 166, 0.08); }
.badge.source { color: var(--violet); border-color: rgba(169, 140, 242, 0.3); background: rgba(169, 140, 242, 0.08); }
.badge.on { color: var(--jade); border-color: rgba(88, 201, 166, 0.35); }
.badge.off { color: var(--dim); }
.badge.busy { color: var(--amber-2); border-color: rgba(240, 179, 91, 0.3); }
.status-cell { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.status-cell .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.status-cell.online .dot { background: var(--jade); box-shadow: 0 0 7px rgba(88, 201, 166, 0.8); }
.status-cell.busy .dot { background: var(--amber); }

/* ---------------------------------------------------------------- arena */
.stat-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { min-width: 96px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(17, 26, 37, 0.7); }
.stat span { display: block; font-size: 19px; font-weight: 650; font-family: var(--mono); color: var(--amber-2); }
.stat small { color: var(--dim); font-size: 11px; }
.vs-row { display: flex; align-items: center; justify-content: space-between; color: var(--dim); font-size: 11px; letter-spacing: 0.2em; margin: -4px 0 9px; }
.match-list { display: flex; flex-direction: column; gap: 8px; max-height: 380px; overflow: auto; }
.match-item { border: 1px solid var(--line); background: rgba(7, 12, 18, 0.35); border-radius: 11px; padding: 10px 12px; }
.match-item .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.match-item .names { font-size: 12.5px; }
.match-item .score { font-family: var(--mono); color: var(--amber-2); font-size: 13px; }
.match-item .meta { color: var(--dim); font-size: 11px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.match-item .bar { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.06); margin-top: 8px; overflow: hidden; }
.match-item .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--jade)); }
.match-item.finished { opacity: 0.82; }
.match-item .game-links { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.game-link { border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); background: transparent; cursor: pointer; }
.game-link:hover { color: var(--amber-2); border-color: rgba(240, 179, 91, 0.4); }
.bot-table-wrap { margin-top: 18px; }
.register-form h4, .register-side h4 { font-size: 14px; margin-bottom: 12px; }
.register-side { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 6px 4px 0 14px; border-left: 1px solid var(--line); }
.callout { display: flex; flex-direction: column; gap: 4px; width: 100%; margin-top: 6px; border: 1px solid var(--line); background: rgba(7, 12, 18, 0.45); border-radius: 10px; padding: 10px 12px; font-size: 12px; color: var(--muted); }
.callout strong { color: var(--text); font-size: 12.5px; margin-bottom: 3px; }
.callout code { word-break: break-all; }

/* ------------------------------------------------------------------ lab */
.file-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 92px; border: 1px dashed var(--line-strong); border-radius: 12px; background: rgba(7, 12, 18, 0.35); cursor: pointer; color: var(--muted); font-size: 12.5px; transition: 0.16s; text-align: center; padding: 14px; }
.file-drop:hover, .file-drop.dragging { border-color: rgba(240, 179, 91, 0.5); background: rgba(240, 179, 91, 0.04); }
.file-drop input { display: none; }
.file-drop .file-name { color: var(--amber-2); font-family: var(--mono); font-size: 12px; }
.template-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.job-list { display: flex; flex-direction: column; gap: 9px; }
.job-item { border: 1px solid var(--line); background: rgba(7, 12, 18, 0.35); border-radius: 11px; padding: 12px 14px; }
.job-item .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.job-item .names { font-size: 13px; }
.job-item .meta { color: var(--dim); font-size: 11.5px; margin-top: 3px; }
.progress { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.07); overflow: hidden; margin-top: 9px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--jade)); transition: width 0.4s ease; }
.job-report { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 9px; font-size: 12px; color: var(--muted); }
.job-report strong { color: var(--text); font-family: var(--mono); }

/* ----------------------------------------------------------------- docs */
.docs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.doc-card h3 { margin-bottom: 9px; font-size: 16px; }
.doc-card p { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.code-block { background: rgba(5, 9, 14, 0.75); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-family: var(--mono); font-size: 11.5px; line-height: 1.6; color: #c9d8e8; white-space: pre-wrap; word-break: break-word; }
.doc-list { color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 5px; }

/* ---------------------------------------------------------------- toast */
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 36px)); }
.toast { background: rgba(18, 28, 40, 0.96); border: 1px solid var(--line-strong); border-left: 3px solid var(--amber); color: var(--text); border-radius: 10px; padding: 10px 13px; font-size: 12.5px; box-shadow: var(--shadow); animation: toast-in 0.22s ease; }
.toast.error { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--jade); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(4, 7, 11, 0.72); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; }
.modal { width: min(680px, 100%); max-height: min(86vh, 900px); overflow: auto; background: linear-gradient(180deg, #15202d, #0e1721); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6); animation: fade-up 0.22s ease; }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); background: rgba(14, 23, 33, 0.96); backdrop-filter: blur(8px); }
.modal-head h3 { font-size: 15.5px; }
.modal-body { padding: 18px; }
.token-box { font-family: var(--mono); font-size: 12px; background: rgba(5, 9, 14, 0.8); border: 1px solid rgba(240, 179, 91, 0.3); color: var(--amber-2); border-radius: 10px; padding: 12px; word-break: break-all; margin: 10px 0; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.report-stat { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: rgba(7, 12, 18, 0.4); }
.report-stat span { display: block; font-family: var(--mono); font-size: 18px; color: var(--amber-2); }
.report-stat small { color: var(--dim); font-size: 11px; }
.replay-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 14px; }
.replay-board { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #0a1118; }
.replay-board canvas { width: 100%; height: 100%; display: block; }
.replay-side { display: flex; flex-direction: column; gap: 8px; }
.replay-side .btn { width: 100%; }
.replay-move { font-family: var(--mono); font-size: 12px; color: var(--muted); min-height: 20px; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 1120px) {
  .play-grid { grid-template-columns: minmax(0, 1fr) 340px; }
  .two-col, .arena-top { grid-template-columns: 1fr; }
  .register-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 14px; }
}
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; margin-left: 0; }
  .play-grid { grid-template-columns: 1fr; }
  .board-panel, .side-panel { position: static; }
  .docs-grid { grid-template-columns: 1fr; }
  .view-head { align-items: flex-start; }
  .stat-strip { width: 100%; }
  .stat { flex: 1; }
}
@media (max-width: 620px) {
  .page { padding-top: 18px; }
  .board-panel { padding: 12px; }
  .board-head-right { display: none; }
  .split { grid-template-columns: 1fr; }
  .replay-wrap { grid-template-columns: 1fr; }
  .move-list { grid-template-columns: 1fr; }
  .server-chip { display: none; }
  .toast-stack { left: 12px; right: 12px; max-width: none; }
}

/* ---------------------------------------------------------------- remote */
.relay-mini {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(88, 201, 166, 0.3);
  background: rgba(88, 201, 166, 0.06);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12px;
  color: var(--muted);
}
.relay-mini .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--jade); box-shadow: 0 0 8px rgba(88, 201, 166, 0.8); }
.relay-mini a { margin-left: auto; white-space: nowrap; }
.relay-status { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.status-line { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12.5px; }
.status-line .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.status-line.on { color: var(--jade); }
.status-line.on .dot { background: var(--jade); box-shadow: 0 0 10px rgba(88, 201, 166, 0.8); }
.status-line.wait { color: var(--amber-2); }
.status-line.wait .dot { background: var(--amber); animation: pulse 1.4s infinite; }
.status-line.bad { color: var(--red); }
.status-line.bad .dot { background: var(--red); }
.relay-url { font-family: var(--mono); font-size: 12px; color: var(--amber-2); word-break: break-all; line-height: 1.5; }
#relay-invite-box { gap: 7px; }
#replay-board canvas, .replay-board canvas { width: 100%; height: 100%; }
.steps { color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 9px; padding-left: 20px; }
.steps li { padding-left: 3px; line-height: 1.6; }
.steps strong { color: var(--text); }

.role-chip { border: 1px solid var(--line); background: rgba(7, 12, 18, 0.5); color: var(--muted); border-radius: 999px; padding: 3px 9px; font-size: 10.5px; white-space: nowrap; }
.role-chip.local { color: var(--amber-2); border-color: rgba(240, 179, 91, 0.35); background: rgba(240, 179, 91, 0.08); }
.role-chip.admin { color: var(--violet); border-color: rgba(169, 140, 242, 0.35); background: rgba(169, 140, 242, 0.08); }
.role-chip.user { color: var(--jade); border-color: rgba(88, 201, 166, 0.35); background: rgba(88, 201, 166, 0.08); }

/* --------------------------------------------------------------- invites */
.invite-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0; color: var(--muted); font-size: 12px; }
.invite-toolbar input[type="number"] { width: 72px; margin-left: 6px; }
.invite-toolbar input:not([type="number"]) { width: 200px; }
.invite-list { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; }
.invite-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: rgba(7, 12, 18, 0.35); border-radius: 9px; padding: 8px 10px; font-size: 12px; }
.invite-row .label { min-width: 92px; color: var(--text); }
.invite-row .url { flex: 1; font-family: var(--mono); font-size: 11px; color: var(--muted); word-break: break-all; }
.invite-row .actions { display: flex; gap: 5px; flex-shrink: 0; }
