/* Fortress design system: tokens, components, layouts. Dark is the default, light is a full peer. */
:root {
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-head: 'Barlow Semi Condensed', 'Inter', sans-serif;
  --font-num: 'JetBrains Mono', ui-monospace, monospace;

  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* dark */
  --bg: #0d0f12;
  --bg-tint: rgba(11, 13, 16, .86);
  --surface: rgba(22, 25, 30, .92);
  --surface-2: #1c2026;
  --surface-3: #252a31;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #eceef0;
  --text-2: #a7aeb6;
  --text-3: #6f7780;
  --accent: #e8a33d;
  --accent-2: #f3bd6a;
  --accent-ink: #1b1204;
  --accent-soft: rgba(232, 163, 61, .14);
  --danger: #e5574a;
  --danger-soft: rgba(229, 87, 74, .14);
  --ok: #4cb07a;
  --ok-soft: rgba(76, 176, 122, .14);
  --info: #72a7d8;
  --info-soft: rgba(114, 167, 216, .16);
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 32px rgba(0, 0, 0, .35);
  --focus: 0 0 0 3px rgba(232, 163, 61, .45);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ebe6de;
  --bg-tint: rgba(238, 234, 227, .84);
  --surface: rgba(252, 250, 247, .94);
  --surface-2: #f4f0ea;
  --surface-3: #e9e3da;
  --line: rgba(30, 24, 16, .10);
  --line-strong: rgba(30, 24, 16, .2);
  --text: #17191c;
  --text-2: #50565d;
  --text-3: #858a90;
  --accent: #b8741a;
  --accent-2: #d08b2c;
  --accent-ink: #fffaf2;
  --accent-soft: rgba(184, 116, 26, .12);
  --danger: #c23e31;
  --danger-soft: rgba(194, 62, 49, .1);
  --ok: #2e8a58;
  --ok-soft: rgba(46, 138, 88, .1);
  --info: #3c74a8;
  --info-soft: rgba(60, 116, 168, .12);
  --shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 10px 28px rgba(60, 45, 25, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 var(--font-ui);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
.app-bg {
  position: fixed; inset: 0; z-index: -1;
  background-image: linear-gradient(var(--bg-tint), var(--bg-tint)), var(--bg-img, none);
  background-size: auto, 640px;
  transition: background-image .3s;
}
:root[data-theme="light"] .app-bg { background-blend-mode: normal, luminosity; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; letter-spacing: .005em; line-height: 1.1; }
h1 { font-size: clamp(40px, 5vw, 68px); font-weight: 700; }
h2 { font-size: 30px; font-weight: 700; }
h3 { font-size: 20px; font-weight: 600; }
.eyebrow { font: 600 12px/1 var(--font-ui); letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
.muted { color: var(--text-2); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface-2);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-lg { height: 52px; padding: 0 24px; font-size: 16px; border-radius: 12px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 40px; padding: 0; }
.btn[disabled] { opacity: .38; pointer-events: none; }
.btn-block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px;
  font: 600 11px/1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase;
  background: var(--surface-3); color: var(--text-2);
}
.chip svg { width: 14px; height: 14px; }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.live-dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- surfaces ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); backdrop-filter: blur(14px);
}
.panel-pad { padding: var(--s5); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-title { font: 600 12px/1 var(--font-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.divider { height: 1px; background: var(--line); margin: var(--s4) 0; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, .select {
  height: 46px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font: inherit; width: 100%;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input.is-error { border-color: var(--danger); }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .err { font-size: 12px; color: var(--danger); }
.switch { position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); cursor: pointer; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform .2s var(--ease), background .2s; }
.switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: var(--accent-ink); }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-weight: 600; font-size: 13px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px; border-right: 1px solid var(--line); background: var(--surface);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font: 700 20px/1 var(--font-head); letter-spacing: .12em; }
.brand svg { width: 28px; height: 28px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: var(--r-md);
  color: var(--text-2); font-weight: 500; position: relative;
}
.nav-item svg { width: 19px; height: 19px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.nav-item[aria-current="page"]::before { content: ''; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--text-3); }
.rail-foot { margin-top: auto; display: grid; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r-md); background: var(--surface-2); }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  font: 700 15px/1 var(--font-head); background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong);
}
.avatar.lg { width: 48px; height: 48px; border-radius: 12px; font-size: 20px; }
.avatar.w { background: #efe8d9; color: #2a2620; border-color: #c9bda4; }
.avatar.b { background: #2b2f35; color: #eae5da; border-color: #0b0c0e; }
.main { min-width: 0; }
.page { padding: 28px 32px 56px; max-width: 1360px; margin: 0 auto; animation: pagein .28s var(--ease); }
@keyframes pagein { from { opacity: 0; transform: translateY(6px); } }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.tabbar { display: none; }

/* ---------- board ---------- */
.board-svg { width: 100%; height: 100%; display: block; user-select: none; -webkit-tap-highlight-color: transparent; }
.board-svg .tile { cursor: pointer; }
.board-svg .piece { cursor: pointer; transition: opacity .2s; }
.board-svg .piece { transition: opacity .2s; will-change: transform; }
.board-svg .tok-shadow { fill: rgba(0, 0, 0, .38); }
.board-svg.compact .tok-shadow { fill: rgba(0, 0, 0, .3); }
.board-svg .tok-ring { fill: none; stroke-width: 1.1; }
.board-svg .tok-bevel { fill: none; stroke-width: 1.6; }
.board-svg .tok-spec { fill: #fff; opacity: .22; pointer-events: none; }
.board-svg .side-w .tok-edge { fill: #a99b80; }
.board-svg .side-w .tok { stroke: #8f836c; stroke-width: 1; }
.board-svg .side-w .tok-bevel { stroke: rgba(255, 255, 255, .75); }
.board-svg .side-w .tok-ring { stroke: rgba(80, 64, 40, .25); }
.board-svg .side-w .emblem { fill: #2c2721; }
.board-svg .side-w .emblem-hi { fill: rgba(255, 255, 255, .8); }
.board-svg .side-b .tok-edge { fill: #0a0b0d; }
.board-svg .side-b .tok { stroke: #07080a; stroke-width: 1.2; }
.board-svg .side-b .tok-bevel { stroke: rgba(255, 255, 255, .16); }
.board-svg .side-b .tok-ring { stroke: rgba(255, 255, 255, .1); }
.board-svg .side-b .emblem { fill: #ebe5d8; }
.board-svg .side-b .emblem-hi { fill: rgba(0, 0, 0, .7); }
.board-svg .side-b .tok-spec { opacity: .1; }
.board-svg .board-shadow polygon { fill: rgba(0, 0, 0, .28); }
.board-svg.compact .board-shadow { display: none; }
.board-svg .tile .hov { fill: #fff; opacity: 0; transition: opacity .12s; pointer-events: none; }
@media (hover: hover) { .board-svg:not(.compact) .tile:hover .hov { opacity: .07; } .board-svg .piece:hover .tokg { transform: translateY(-2px); } }
.board-svg .tokg { transition: transform .15s var(--ease); }
.board-svg .is-selected .tokg { transform: translateY(-3px) scale(1.04); }
.board-svg .str rect { stroke-width: 1.4; }
.board-svg .side-w .str rect { fill: #1b1d21; stroke: #f5efe2; }
.board-svg .side-w .str text { fill: #fff; }
.board-svg .side-b .str rect { fill: #f3ecdd; stroke: #0b0c0e; }
.board-svg .side-b .str text { fill: #17191c; }
.board-svg .str text, .board-svg .moved-badge text, .board-svg .dmg text {
  font: 700 13px/1 var(--font-ui); text-anchor: middle; dominant-baseline: central; font-variant-numeric: tabular-nums; pointer-events: none;
}
.board-svg .hl-sel { fill: rgba(232, 163, 61, .22); stroke: #e8a33d; stroke-width: 3.5; animation: selpulse 1.6s ease-in-out infinite; }
@keyframes selpulse { 50% { stroke-opacity: .55; fill-opacity: .6; } }
.board-svg .mv { pointer-events: none; animation: pop .22s var(--ease) both; }
@keyframes pop { from { opacity: 0; } }
.board-svg .hl-fc { fill: rgba(20, 22, 26, .78); stroke: #e8a33d; stroke-width: 2.2; }
.board-svg .fc-t { font: 700 13px/1 var(--font-ui); fill: #f3bd6a; text-anchor: middle; dominant-baseline: central; font-variant-numeric: tabular-nums; }
.board-svg .mv.up .hl-fc { stroke: #4cb07a; } .board-svg .mv.up .fc-t { fill: #7fdca6; }
.board-svg .mv.risk-hit .hl-fc { stroke: #f0a04b; stroke-dasharray: 4 3; }
.board-svg .mv.risk-dies .hl-fc { fill: rgba(120, 20, 14, .85); stroke: #ff6a55; } .board-svg .mv.risk-dies .fc-t { fill: #fff; font-size: 12px; }
.board-svg.ink-light .hl-fc { fill: rgba(255, 252, 245, .92); stroke: #a86510; } .board-svg.ink-light .fc-t { fill: #7a4a0c; }
.board-svg.ink-light .mv.up .hl-fc { stroke: #2e8a58; } .board-svg.ink-light .mv.up .fc-t { fill: #1f6b42; }
.board-svg.ink-light .mv.risk-dies .hl-fc { fill: #b3261e; } .board-svg.ink-light .mv.risk-dies .fc-t { fill: #fff; }
.board-svg .arrow line { stroke-width: 5; stroke-linecap: round; }
.board-svg .arrow-last line { stroke: rgba(114, 167, 216, .85); }
.board-svg .arrow-hint line { stroke: #e8a33d; stroke-dasharray: 9 7; animation: march .8s linear infinite; }
@keyframes march { to { stroke-dashoffset: -16; } }
.board-svg .hint-target { fill: rgba(232, 163, 61, .16); stroke: #e8a33d; stroke-width: 2; animation: selpulse 1.2s infinite; }
.board-svg .contact-glow { stroke: rgba(255, 70, 50, .35); stroke-width: 12; stroke-linecap: round; }
.board-svg .burst-ring { fill: none; stroke: #ffb199; stroke-width: 3; }
.board-svg .hl-move { fill: #e8a33d; stroke: rgba(0, 0, 0, .45); stroke-width: 1.5; }
.board-svg .hl-vault { fill: none; stroke: #e8a33d; stroke-width: 3.5; }
.board-svg .hl-last { fill: rgba(114, 167, 216, .26); stroke: rgba(114, 167, 216, .8); stroke-width: 2; }
.board-svg .hl-promo { fill: rgba(232, 163, 61, .14); stroke: #e8a33d; stroke-width: 3; stroke-dasharray: 6 5; }
.board-svg.ink-light .hl-promo { fill: rgba(168, 101, 16, .16); stroke: #a86510; }
.board-svg .contact { stroke: #ff5a4a; stroke-width: 5; stroke-linecap: round; animation: contact 1.4s ease-in-out infinite; }
@keyframes contact { 50% { stroke: #ff8c7a; } }
.board-svg .dmg rect { fill: #e5574a; stroke: rgba(0, 0, 0, .35); }
.board-svg .dmg text { fill: #fff; font-size: 12px; }
.board-svg .dmg.dies rect { fill: #9e1d14; stroke: #ff8a7f; stroke-width: 1.5; }
.board-svg .is-dying .tok { stroke: #ff5a4a !important; stroke-width: 3 !important; stroke-dasharray: 5 4; }
.board-svg .is-dying { opacity: .72; }
.board-svg .moved-badge circle { fill: #e8a33d; stroke: rgba(0, 0, 0, .5); }
.board-svg .moved-badge text { fill: #1b1204; font-size: 11px; }
.board-svg.ink-light .hl-move { fill: #b8741a; stroke: rgba(255, 255, 255, .7); }
.board-svg.ink-light .hl-vault, .board-svg.ink-light .hl-sel { stroke: #a86510; }

/* ---------- game screen ---------- */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; height: calc(100vh - 40px); min-height: 620px; }
.game-stage { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px; min-width: 0; }
.board-wrap { position: relative; display: grid; place-items: center; min-height: 0; }
.board-wrap > .board-svg { position: absolute; inset: 0; }
.player {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 10px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line);
}
.player .name { font-weight: 600; }
.player .meta { font-size: 12px; color: var(--text-3); display: flex; gap: 8px; align-items: center; }
.player .force { display: flex; gap: 4px; align-items: center; font-size: 12px; color: var(--text-2); }
.clock {
  margin-left: auto; min-width: 116px; padding: 8px 14px; border-radius: 10px; text-align: right;
  font: 600 26px/1 var(--font-num); font-variant-numeric: tabular-nums; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2);
}
.player.is-active { border-color: var(--line-strong); }
.player.is-active .clock { background: var(--text); color: var(--bg); border-color: transparent; }
.player.is-low .clock { background: var(--danger); color: #fff; }
.side-rail { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.turn-banner { padding: 16px 18px; border-radius: var(--r-lg); display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; }
.turn-banner.mine { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface); }
.turn-banner .big { font: 700 22px/1.1 var(--font-head); }
.turn-banner .sub { font-size: 13px; color: var(--text-2); }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.step { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.step .bar { height: 4px; border-radius: 4px; background: var(--surface-3); }
.step.done { color: var(--text-2); }
.step.done .bar { background: color-mix(in srgb, var(--accent) 55%, var(--surface-3)); }
.step.now { color: var(--text); }
.step.now .bar { background: var(--accent); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); font-size: 13px; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.alert-danger b { color: var(--text); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.inspector { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; padding: 16px 18px; }
.inspector svg.token { width: 64px; height: 64px; }
.inspector .t { font: 700 20px/1 var(--font-head); display: flex; align-items: baseline; gap: 8px; }
.inspector .t .num { font-size: 26px; color: var(--accent); }
.breakdown { grid-column: 1 / -1; display: grid; gap: 6px; font-size: 13px; }
.breakdown .li { display: flex; justify-content: space-between; color: var(--text-2); }
.breakdown .li b { color: var(--text); font-family: var(--font-num); font-weight: 600; }
.movelist { overflow: auto; min-height: 0; flex: 1; font-size: 13px; }
.movelist table { width: 100%; border-collapse: collapse; }
.movelist .panel-head { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.movelist td { padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.movelist td:first-child { color: var(--text-3); width: 42px; font-family: var(--font-num); }
.movelist .mv { font-family: var(--font-num); }
.movelist tr.cur td { background: var(--accent-soft); }
.actions-bar { display: grid; gap: 8px; }
.actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.7fr); gap: 8px; }
.actions .btn { min-width: 0; padding: 0 12px; }
.side-rail { min-width: 0; }
.actions-sub { display: grid; grid-template-columns: repeat(4, auto); gap: 2px; justify-content: space-between; }
.actions-sub .btn { padding: 0 8px; gap: 6px; }
.actions-sub .btn svg { width: 15px; height: 15px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); justify-content: center; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.legend .lg-fc { width: 18px; height: 18px; border: 2px solid #e8a33d; background: rgba(20,22,26,.8); color: #f3bd6a; font: 700 10px/14px var(--font-ui); text-align: center; font-style: normal; }
.kbd-hint { color: var(--text-3); }
kbd { font: 600 11px/1 var(--font-num); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text-2); }
.btn-xs { width: 30px; height: 30px; border-radius: 8px; }
.btn-xs svg { width: 17px; height: 17px; }
.balance { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.balance span:last-child { text-align: right; }
.bal-bar { height: 6px; border-radius: 6px; background: #2a2e35; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
:root[data-theme="light"] .bal-bar { background: #3a3d42; }
.bal-bar i { display: block; height: 100%; background: #efe8d9; transition: width .6s var(--ease); }
.alerts { display: grid; gap: 8px; }
.alerts:empty { display: none; }
.outcome { padding: 12px 16px; display: flex; justify-content: space-between; font-size: 13px; }
.inspector.empty { display: flex; gap: 12px; align-items: flex-start; color: var(--text-2); font-size: 13px; }
.inspector.empty svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.result-stats div { padding: 12px; border-radius: 10px; background: var(--surface-2); display: grid; gap: 2px; }
.result-stats b { font-size: 22px; } .result-stats span { font-size: 12px; color: var(--text-3); }
#accept.ready { animation: ready 1.8s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 0 5px var(--accent-soft); } }
.lg-sel { border: 2.5px solid #e8a33d; }
.lg-move { background: #e8a33d; transform: scale(.7); }
.lg-hit { width: 16px !important; height: 4px !important; border-radius: 3px !important; background: #ff5a4a; }
.lg-last { background: rgba(114, 167, 216, .5); border: 1.5px solid #72a7d8; border-radius: 3px !important; }

/* ---------- landing ---------- */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; padding: 20px 0 40px; }
.hero p.lead { font-size: 18px; color: var(--text-2); max-width: 520px; margin: 18px 0 28px; }
.hero .board-card { aspect-ratio: 1 / 1; max-height: 620px; padding: 12px 12px 48px; position: relative; }
.demo-cap { position: absolute; left: 16px; right: 16px; bottom: 14px; display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; }
.demo-cap #demoTxt { overflow: hidden; text-overflow: ellipsis; font-family: var(--font-num); font-size: 12px; }
.stats { display: flex; gap: 28px; margin-top: 30px; }
.stats b { display: block; font: 700 26px/1 var(--font-head); }
.stats span { font-size: 13px; color: var(--text-3); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.mode { padding: 20px; display: grid; gap: 10px; transition: border-color .15s, transform .15s; cursor: pointer; }
.mode:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.mode .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--accent); }
.mode .ic svg { width: 22px; height: 22px; }
.section { margin-top: 44px; }
.section-head { display: flex; align-items: end; justify-content: space-between; margin-bottom: 16px; gap: 16px; }
.bots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; }
.bot { padding: 16px 14px; display: grid; gap: 10px; justify-items: start; cursor: pointer; transition: border-color .15s; }
.bot:hover { border-color: var(--accent); }
.bot .elo { font: 600 22px/1 var(--font-num); }
.rules3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.rule { padding: 20px; display: grid; gap: 8px; }
.rule .n { font: 700 13px/1 var(--font-num); color: var(--accent); }

/* ---------- lobby ---------- */
.lobby { display: grid; grid-template-columns: 1fr 380px; gap: 20px; }
.tc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tc { padding: 14px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface-2); cursor: pointer; text-align: left; }
.tc b { display: block; font: 700 20px/1.1 var(--font-num); }
.tc span { font-size: 12px; color: var(--text-3); }
.tc[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.bar-meter { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.bar-meter i { display: block; height: 100%; background: var(--accent); }

/* ---------- ranks ---------- */
table.rank { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rank th { text-align: left; font: 600 11px/1 var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); padding: 14px 18px; border-bottom: 1px solid var(--line); }
table.rank td { padding: 12px 18px; border-bottom: 1px solid var(--line); }
table.rank tr.me td { background: var(--accent-soft); }
.pos { font: 700 15px/1 var(--font-num); color: var(--text-3); }
.up { color: var(--ok); } .down { color: var(--danger); }

/* ---------- watch ---------- */
.featured { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; padding: 20px; }
.featured .board-card { aspect-ratio: 1; position: relative; padding: 4px 4px 44px; }
.feat-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.feat-player { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.feat-player .clock { min-width: 88px; font-size: 20px; padding: 6px 10px; }
.feat-player .clock.on { background: var(--text); color: var(--bg); }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; flex: 1; align-content: start; min-height: 220px; }
.feed li { display: flex; gap: 10px; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); font: 500 13px/1.4 var(--font-num); color: var(--text-2); animation: pagein .3s var(--ease); }
.feed li:first-child { color: var(--text); background: var(--accent-soft); }
.feed li .num { color: var(--text-3); min-width: 26px; }
.watch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.watch-card { overflow: hidden; cursor: pointer; }
.watch-card .mini { aspect-ratio: 1.15; padding: 10px; border-bottom: 1px solid var(--line); }

/* ---------- appearance ---------- */
.appearance { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.swatch { display: grid; gap: 8px; cursor: pointer; border: 0; padding: 0; background: none; text-align: left; }
.swatch .sw { aspect-ratio: 1; border-radius: 12px; background-size: cover; border: 2px solid transparent; box-shadow: inset 0 0 0 1px var(--line-strong); position: relative; overflow: hidden; }
.swatch .sw.board { background: var(--surface-2); display: grid; place-items: center; padding: 6px; }
.swatch .sw .modes2 { position: absolute; inset: auto 0 0 0; display: grid; grid-template-columns: 1fr 1fr; height: 30%; }
.swatch[aria-pressed="true"] .sw { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.swatch .nm { font-size: 13px; font-weight: 600; }
.swatch .nt { font-size: 11px; color: var(--text-3); margin-top: -6px; }
.sticky { position: sticky; top: 20px; }
.preview-board { aspect-ratio: 1.08; padding: 14px; }
.pairing { display: grid; grid-template-columns: 76px 1fr; gap: 16px; align-items: center; }
.pairing .pv { width: 76px; height: 76px; border-radius: 12px; background-size: cover; border: 1px solid var(--line-strong); }

/* ---------- design system page ---------- */
.ds-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.tok-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.tok-sw { display: grid; gap: 6px; font-size: 12px; }
.tok-sw i { height: 56px; border-radius: 10px; border: 1px solid var(--line-strong); }
.tok-sw code { font: 500 11px/1 var(--font-num); color: var(--text-3); }
.type-scale > div { display: flex; align-items: baseline; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.type-scale code { width: 120px; flex: none; font: 500 11px/1 var(--font-num); color: var(--text-3); }
.principles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.principle { padding: 18px; }
.principle .q { font: 700 17px/1.2 var(--font-head); margin: 8px 0 6px; }

/* ---------- modal / toast ---------- */
.scrim { position: fixed; inset: 0; background: rgba(5, 6, 8, .6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .2s; }
.modal { width: min(440px, 100%); padding: 28px; display: grid; gap: 16px; animation: rise .25s var(--ease); background: var(--surface-2); backdrop-filter: none; }
.toast { background: var(--surface-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; padding: 12px 16px; display: flex; gap: 10px; align-items: center; font-size: 14px; animation: rise .25s var(--ease); }
.result { text-align: center; justify-items: center; }
.result h2 { font-size: 38px; }

/* ---------- tablet ---------- */
@media (max-width: 1180px) {
  .shell { grid-template-columns: 76px 1fr; }
  .rail { padding: 18px 10px; align-items: center; }
  .rail .label, .brand span, .rail-foot .me div, .nav-item .count { display: none; }
  .brand { padding: 4px 0 18px; }
  .nav-item { width: 52px; justify-content: center; padding: 0; }
  .nav-item[aria-current="page"]::before { left: -10px; }
  .rail-foot .btn { width: 52px; padding: 0; }
  .rail-foot .btn span { display: none; }
  .rail-foot .me { padding: 8px; }
  .game { grid-template-columns: minmax(0, 1fr) 320px; }
  .bots { grid-template-columns: repeat(4, 1fr); }
  .appearance { grid-template-columns: 1fr; }
  .appearance .sticky { position: static; }
  .lobby { grid-template-columns: 1fr; }
  .watch-grid { grid-template-columns: repeat(2, 1fr); }
  .featured { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .rule-view { grid-template-columns: 1fr; padding: 20px; gap: 20px; min-height: 0; }
  .rule-fig { order: -1; }
  .rule-text h2 { font-size: 30px; }
  .game { grid-template-columns: 1fr; height: auto; }
  .game .board-wrap { aspect-ratio: 1.02; }
  .game .board-wrap > .board-svg { position: absolute; }
  .hero { grid-template-columns: 1fr; }
  .ds-grid { grid-template-columns: 1fr; }
  .principles { grid-template-columns: 1fr 1fr; }
}

/* ---------- mobile: designed for thumbs, not shrunk ---------- */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .page { padding: 16px 16px 96px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); backdrop-filter: blur(16px);
  }
  .tabbar a { display: grid; justify-items: center; gap: 3px; padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--text-3); border-radius: 10px; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .mtop { display: flex !important; }
  h1 { font-size: 40px; }
  .hero { padding-top: 4px; gap: 22px; }
  .hero p.lead { font-size: 16px; margin: 12px 0 20px; }
  .hero .cta .btn { flex: 1; }
  .stats { gap: 18px; }
  .modes, .rules3 { grid-template-columns: 1fr; }
  .mode { grid-template-columns: 42px 1fr; align-items: center; padding: 14px; }
  .mode p { display: none; }
  .bots { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 132px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 6px; scroll-snap-type: x mandatory; }
  .bot { scroll-snap-align: start; }
  .watch-grid { grid-template-columns: 1fr; }
  .tc-grid { grid-template-columns: repeat(2, 1fr); }
  .swatches { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .principles { grid-template-columns: 1fr; }
  .tok-row { grid-template-columns: repeat(3, 1fr); }
  .hide-m { display: none !important; }

  /* game: board edge to edge, info on top, actions in the thumb zone */
  .game-page .page { padding: 0 0 0; }
  .game { gap: 0; min-height: 0; }
  .game-stage { gap: 0; grid-template-rows: auto auto auto; }
  .game .player { border-radius: 0; border-width: 0 0 1px; padding: 8px 12px; background: var(--surface); }
  .game .player .clock { font-size: 22px; min-width: 96px; padding: 7px 10px; }
  .game .board-wrap { aspect-ratio: 548 / 552; margin: 4px 2px; }
  .game .turn-banner .sub { font-size: 12px; }
  .game .steps { margin-top: 6px; }
  .game #inspector { order: 5; }
  .game .side-rail { gap: 0; display: flex; flex-direction: column; }
  .game .turn-banner { border-radius: 0; border-width: 0 0 1px; padding: 12px 16px; }
  .game .turn-banner .big { font-size: 18px; }
  .game .panel { border-radius: 0; border-width: 0 0 1px; box-shadow: none; }
  .game .movelist { display: none; }
  .game .actions-bar {
    position: sticky; bottom: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface);
    border-top: 1px solid var(--line); display: grid; gap: 8px; z-index: 30;
  }
  .game .actions .btn { height: 54px; font-size: 16px; }
  .legend { display: none; }
  .tabbar.in-game { display: none; }
}
.mtop .brand span { display: inline; font-size: 18px; }
.ds-grid > * { min-width: 0; }
.table-wrap { overflow-x: auto; }
.rules-tabs { margin-bottom: 16px; overflow-x: auto; max-width: 100%; }
.rules-tabs button { flex: none; }
.rule-view { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 32px; padding: 32px; align-items: stretch; min-height: 520px; }
.rule-text { display: flex; flex-direction: column; gap: 16px; }
.rule-text h2 { font-size: 40px; }
.rule-fig { margin: 0; display: grid; gap: 12px; align-content: center; }
.rule-fig #ruleBoard { aspect-ratio: 548 / 552; }
.rule-fig figcaption { font-size: 14px; color: var(--text-2); text-align: center; }
.move-list { display: grid; gap: 10px; }
.move-list .row { gap: 12px; }
.mtop { display: none; align-items: center; justify-content: space-between; margin-bottom: 14px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Mobile performance: no live blur, and a background that never resizes with the URL bar. */
.app-bg { height: 100lvh; bottom: auto; transform: translateZ(0); }
@media (max-width: 960px), (hover: none) {
  .panel, .rail, .tabbar, .game .actions-bar { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .panel { background: var(--surface-2); }
  :root[data-theme="light"] .panel { background: #fbf9f6; }
  .tabbar, .game .actions-bar { background: var(--surface-2); }
  :root[data-theme="light"] .tabbar, :root[data-theme="light"] .game .actions-bar { background: #fbf9f6; }
  .board-svg { touch-action: manipulation; }
}
@media (max-width: 640px) {
  .actions .btn span { display: none; }
  .actions #accept span { display: inline; }
  .actions { grid-template-columns: 56px 56px 1fr; }
  .actions-sub .btn { font-size: 12px; }
  .game .balance { margin-top: 8px; }
  .kbd-hint { display: none; }
}
