/* Snake Battle: same neutral, grid-based system as Aux Battle, green accent. */
:root {
  --bg: #efeee9;
  --panel: #f8f7f4;
  --field: #ffffff;
  --ink: #161615;
  --ink-2: #4b4a46;
  --ink-3: #87857f;
  --rule: #dad8d1;
  --rule-2: #c5c2ba;
  --hover: rgba(22, 22, 21, 0.04);
  --accent: #0f9f4b;
  --accent-soft: rgba(15, 159, 75, 0.11);
  --ok: #147a45;
  --bad: #c0281f;
  --on-ink: #f8f7f4;
  --board: #f4f3ef;
  --board-dot: #d6d4cc;
  --sans: 'IBM Plex Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --pixel: 'Pixelify Sans', var(--mono);
  --r: 3px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #121211; --panel: #1a1a18; --field: #20201e; --ink: #ecebe6; --ink-2: #b4b2ab; --ink-3: #7d7b75;
    --rule: #2c2b28; --rule-2: #3c3b37; --hover: rgba(236, 235, 230, 0.05);
    --accent: #2fd472; --accent-soft: rgba(47, 212, 114, 0.13); --ok: #3dbb78; --bad: #ff6a5f; --on-ink: #121211;
    --board: #151514; --board-dot: #2a2926;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #121211; --panel: #1a1a18; --field: #20201e; --ink: #ecebe6; --ink-2: #b4b2ab; --ink-3: #7d7b75;
  --rule: #2c2b28; --rule-2: #3c3b37; --hover: rgba(236, 235, 230, 0.05);
  --accent: #2fd472; --accent-soft: rgba(47, 212, 114, 0.13); --ok: #3dbb78; --bad: #ff6a5f; --on-ink: #121211;
  --board: #151514; --board-dot: #2a2926;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; min-height: 100vh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- type ---------- */
.label { font: 500 11px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-3); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-weight: 500; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
em { font-style: normal; color: var(--accent); }

/* ---------- layout ---------- */
.shell { width: min(1200px, 100%); margin: 0 auto; padding: 0 24px; }
.topbar { border-bottom: 1px solid var(--rule); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.topbar .shell { display: flex; align-items: center; gap: 20px; height: 56px; }
.wordmark {
  font: 600 19px/1 var(--pixel); letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; color: var(--ink);
  text-shadow: 0 0 1px var(--accent), 0 0 8px color-mix(in srgb, var(--accent) 70%, transparent), 0 0 22px color-mix(in srgb, var(--accent) 38%, transparent);
  -webkit-font-smoothing: none;
}
.wordmark b { color: var(--accent); font-weight: inherit; }
.topbar .spacer { flex: 1; }
.topbar .meta { display: flex; align-items: center; gap: 14px; }
.topbar .sep { width: 1px; height: 20px; background: var(--rule); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.live { background: var(--accent); animation: blink 1.6s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--rule); min-height: 42px; }
.panel-body { padding: 16px; }
.panel-foot { padding: 12px 16px; border-top: 1px solid var(--rule); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--rule-2); background: var(--field); font-weight: 500; font-size: 14px; white-space: nowrap; transition: background 0.12s, border-color 0.12s, color 0.12s; }
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn.block { width: 100%; }

.field { width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--rule-2); background: var(--field); outline: none; transition: border-color 0.12s, box-shadow 0.12s; }
.field:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder { color: var(--ink-3); }
.field.code { font: 500 18px var(--mono); letter-spacing: 0.3em; text-transform: uppercase; text-align: center; }
.field.code::placeholder { letter-spacing: 0.2em; font-size: 14px; }
.fieldset { display: flex; flex-direction: column; gap: 7px; }

.seg { display: inline-flex; border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--field); overflow: hidden; }
.seg button { height: 30px; min-width: 44px; padding: 0 10px; font: 500 12px var(--mono); color: var(--ink-2); border-left: 1px solid var(--rule); }
.seg button:first-child { border-left: 0; }
.seg button:hover:not(:disabled):not(.on) { background: var(--hover); }
.seg button.on { background: var(--ink); color: var(--on-ink); }
.seg button:disabled { cursor: default; }

.toggle { width: 38px; height: 20px; border-radius: 2px; border: 1px solid var(--rule-2); background: var(--field); position: relative; flex: none; transition: background 0.15s, border-color 0.15s; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 1px; background: var(--ink-3); transition: transform 0.15s, background 0.15s; }
.toggle.on { background: var(--ink); border-color: var(--ink); }
.toggle.on::after { transform: translateX(18px); background: var(--on-ink); }
.toggle:disabled { opacity: 0.55; cursor: default; }

.tag { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 7px; border: 1px solid var(--rule-2); border-radius: 2px; font: 500 10.5px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.tag.solid { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.tag.accent { border-color: var(--accent); color: var(--accent); }
.tag.ok { border-color: var(--ok); color: var(--ok); }
.tag.bad { border-color: var(--bad); color: var(--bad); }

.av { --c: #888; width: 26px; height: 26px; flex: none; border-radius: 2px; background: var(--c); color: #fff; display: inline-grid; place-items: center; font: 600 12px var(--mono); text-transform: uppercase; }
.av.lg { width: 40px; height: 40px; font-size: 16px; }
.av.xl { width: 56px; height: 56px; font-size: 22px; }
.swatches { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.swatches button { width: 100%; aspect-ratio: 1; max-width: 34px; border-radius: 2px; background: var(--c); position: relative; }
.swatches button.on::after { content: ''; position: absolute; inset: -4px; border: 1.5px solid var(--ink); border-radius: 3px; }
.swatches button.taken { opacity: 0.25; cursor: not-allowed; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font: 500 10.5px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); padding: 9px 16px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--hover); }
.table .r { text-align: right; }

/* ---------- home ---------- */
#app:has(> .home-main) { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.home-main { flex: 1 0 auto; display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); grid-template-areas: 'intro join' 'more join'; grid-template-rows: auto 1fr; gap: 0 56px; padding-block: 64px 56px; align-content: start; }
.home-main > .hero { grid-area: intro; }
.home-main > .hero-more { grid-area: more; }
.home-main > aside { grid-area: join; align-self: start; }
.hero-title { font-size: clamp(40px, 5.2vw, 64px); line-height: 1.02; letter-spacing: -0.04em; font-weight: 600; margin: 14px 0 18px; }
.hero-title .px { font-family: var(--pixel); letter-spacing: 0; color: var(--accent); text-shadow: 0 0 2px var(--accent), 0 0 18px color-mix(in srgb, var(--accent) 50%, transparent); }
.hero .lede { font-size: 17px; color: var(--ink-2); max-width: 480px; margin: 0 0 26px; }
.how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; max-width: 520px; padding-top: 22px; border-top: 1px solid var(--rule); }
.how b { display: block; font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.how b::before { content: ''; display: inline-block; width: 6px; height: 6px; background: var(--accent); margin: 0 7px 2px 0; vertical-align: middle; }
.how span { font-size: 13.5px; color: var(--ink-2); line-height: 1.4; }
.demo-board { margin-top: 28px; max-width: 520px; overflow: hidden; }
.demo-board canvas { display: block; width: 100%; height: auto; }
.keys { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
kbd { font: 500 11px var(--mono); color: var(--ink-2); border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 3px; padding: 1px 6px; background: var(--field); }
.invite { padding: 10px 12px; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--r); font-size: 14px; }
.or { display: flex; align-items: center; gap: 12px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--rule); }
.footer { border-top: 1px solid var(--rule); margin-top: auto; }
.footer .shell { display: flex; justify-content: space-between; gap: 16px; padding: 18px 24px; flex-wrap: wrap; }

/* ---------- lobby ---------- */
.page { padding-block: 28px 80px; }
.cols { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.room-code { font: 500 44px/1 var(--mono); letter-spacing: 0.22em; margin: 6px 0 16px; }
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mode { text-align: left; padding: 14px 14px 16px 16px; border-bottom: 1px solid var(--rule); border-right: 1px solid var(--rule); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; transition: background 0.12s; }
.mode:nth-child(2n) { border-right: 0; }
.mode:hover:not(:disabled) { background: var(--hover); }
.mode:disabled { cursor: default; }
.mode-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mode .t { font-weight: 600; font-size: 15px; }
.mode .d { font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.mode.on { background: var(--field); box-shadow: inset 3px 0 0 var(--accent); }
.mode .pips { display: inline-flex; gap: 2px; align-items: flex-end; height: 18px; margin-top: 2px; flex: none; }
.mode .pips i { width: 4px; background: var(--rule-2); border-radius: 1px; }
.mode.on .pips i.f { background: var(--accent); }
.mode .pips i.f { background: var(--ink-3); }
.prefs .pref { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 16px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.prefs .pref:last-child { border-bottom: 0; }
.prefs .pref .t { font-weight: 500; font-size: 14px; }
.prefs .pref .s { font-size: 13px; color: var(--ink-3); }
.status-list { display: flex; flex-direction: column; }
.status-list .s { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--rule); font-size: 14px; }
.status-list .s:last-child { border-bottom: 0; }

/* ---------- game ---------- */
.game-cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 20px; }
.board-panel { overflow: hidden; }
.board-wrap { position: relative; background: var(--board); touch-action: none; user-select: none; -webkit-user-select: none; }
.board-wrap canvas { display: block; margin: 0 auto; max-width: 100%; }
.speed { display: flex; align-items: center; gap: 10px; }
.speed-bar { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.speed-bar i { width: 4px; height: 100%; background: var(--rule-2); border-radius: 1px; transition: background 0.2s; }
.speed-bar i.f { background: var(--accent); }
.speed-bar i.f.hot { background: var(--bad); }
.speed-mult { font: 600 13px var(--mono); min-width: 44px; text-align: right; }
.speed-mult.bump { animation: bump 0.4s ease; }
@keyframes bump { 30% { transform: scale(1.35); color: var(--accent); } }

.board-over { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center; padding: 20px; }
.board-over > div { pointer-events: auto; }
.count { font: 600 clamp(64px, 12vw, 132px)/1 var(--pixel); color: var(--ink); text-shadow: 0 0 2px var(--accent), 0 0 26px color-mix(in srgb, var(--accent) 55%, transparent); animation: pop 0.35s ease; }
.count.go { color: var(--accent); }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } }
.over-label { font: 500 12px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 10px; }
.card { background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--rule-2); border-radius: var(--r); padding: 20px 24px; min-width: min(340px, 100%); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.4); backdrop-filter: blur(6px); animation: drop 0.25s ease; }
.card h2 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.03em; line-height: 1.1; margin: 10px 0 6px; }
.card .who { display: flex; align-items: center; justify-content: center; gap: 12px; }
.card .sub { color: var(--ink-2); font-size: 14px; }
.dead-note { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); pointer-events: none; }

.pips-row { display: inline-flex; gap: 3px; }
.pips-row i { width: 8px; height: 8px; border-radius: 1px; background: var(--rule-2); }
.pips-row i.f { background: var(--accent); }

.st-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; column-gap: 10px; min-height: 48px; padding: 6px 16px; border-bottom: 1px solid var(--rule); transition: opacity 0.3s; }
.st-row:last-child { border-bottom: 0; }
.st-row.out { opacity: 0.45; }
.st-row.me { background: var(--hover); }
.st-name { display: flex; align-items: baseline; gap: 6px; min-width: 0; font-size: 14px; font-weight: 500; }
.st-sub { display: flex; align-items: center; gap: 8px; font: 500 10.5px var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); margin-top: 3px; }
.st-sub .alive { color: var(--ok); }
.st-sub .dead { color: var(--bad); }
.st-wins { font: 600 15px var(--mono); text-align: right; }

.dpad { display: none; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 54px); gap: 6px; justify-content: center; padding: 12px; border-top: 1px solid var(--rule); }
.dpad button { border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--field); font: 600 18px var(--mono); color: var(--ink-2); }
.dpad button:active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.dpad .u { grid-column: 2; grid-row: 1; }
.dpad .l { grid-column: 1; grid-row: 2; }
.dpad .d { grid-column: 2; grid-row: 2; }
.dpad .r { grid-column: 3; grid-row: 2; }
@media (pointer: coarse) { .dpad { display: grid; } }

.final-title { font-size: clamp(32px, 4.5vw, 52px); letter-spacing: -0.035em; line-height: 1.05; margin: 10px 0 20px; }
.champ { display: flex; align-items: center; gap: 18px; padding: 22px; }
.champ .label { margin-bottom: 4px; }

/* ---------- chat ---------- */
.chat-log { height: 260px; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; overscroll-behavior: contain; }
.chat-log .empty { padding: 12px 16px; color: var(--ink-3); font-size: 14px; }
.msg { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 9px; padding: 5px 16px; }
.msg .av { width: 22px; height: 22px; font-size: 10.5px; margin-top: 1px; }
.msg .who { font-size: 13px; font-weight: 600; }
.msg .body { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.msg.cont { padding-top: 0; }
.msg.cont .av { visibility: hidden; height: 0; }
.msg.cont .who { display: none; }
.sysmsg { padding: 3px 16px; font: 400 11.5px var(--mono); color: var(--ink-3); }
.chat-input { display: flex; gap: 6px; align-items: center; padding: 10px; border-top: 1px solid var(--rule); }
.chat-input .field { height: 36px; font-size: 14px; }

/* ---------- toasts / modal ---------- */
#toasts { position: fixed; top: 68px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: calc(100% - 32px); }
.toast { padding: 9px 14px; background: var(--ink); color: var(--on-ink); border-radius: var(--r); font-size: 13.5px; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.4); animation: drop 0.2s ease; max-width: 100%; }
.toast.err { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transition: opacity 0.3s; }
@keyframes drop { from { transform: translateY(-6px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.modal-bg { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(4px); animation: fade 0.15s ease; }
.modal { width: min(400px, 100%); box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.45); animation: drop 0.18s ease; }
.modal h3 { font-size: 18px; font-weight: 600; }
.modal-text { margin-top: 8px; font-size: 14px; color: var(--ink-2); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .home-main { grid-template-columns: 1fr; grid-template-areas: 'intro' 'join' 'more'; grid-template-rows: auto; row-gap: 28px; padding-block: 36px; }
  .hero .lede { margin-bottom: 0; }
  .cols, .game-cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .shell { padding-inline: 16px; }
  .topbar .shell { gap: 12px; }
  .hide-sm { display: none !important; }
  .how { grid-template-columns: 1fr; gap: 12px; }
  .modes { grid-template-columns: 1fr; }
  .mode { border-right: 0 !important; }
  .room-code { font-size: 36px; }
  .table th, .table td { padding-left: 12px; padding-right: 12px; }
  .page { padding-block: 16px 60px; }
  .chat-log { height: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- survival: rival boards ---------- */
.rivals { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 12px; }
.rival { border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; background: var(--field); transition: opacity 0.3s; }
.rival.out { opacity: 0.45; }
.rival-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 13px; font-weight: 500; border-bottom: 1px solid var(--rule); }
.rival-head .av { width: 18px; height: 18px; font-size: 9.5px; }
.watch-note { position: absolute; left: 12px; top: 12px; pointer-events: none; }
.watch-note .tag { background: color-mix(in srgb, var(--panel) 85%, transparent); }
.places { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; text-align: left; }
.place { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 2px; font-size: 14px; }
.place .av { width: 20px; height: 20px; font-size: 10px; }
.place.me { background: var(--hover); }
.place > .num:first-child { width: 14px; text-align: right; font-size: 12px; }
#gameModes .mode svg { color: var(--ink-3); margin-top: 2px; }

/* ---------- hunger ---------- */
.hunger { display: inline-flex; align-items: center; gap: 7px; margin-left: 6px; }
.hbar { width: 74px; height: 6px; border-radius: 1px; background: var(--rule-2); overflow: hidden; display: inline-block; }
.hbar i { display: block; height: 100%; width: 100%; background: var(--accent); transition: width 0.15s linear, background 0.2s; }
.hunger.low .hbar i { background: #d9a400; }
.hunger.starving .hbar i { background: var(--bad); }
.hunger.starving { animation: blink 0.5s steps(2) infinite; }
.hunger.starving .label { color: var(--bad); }
.mini-h { width: 34px; height: 4px; background: var(--rule-2); border-radius: 1px; overflow: hidden; display: inline-block; }
.mini-h i { display: block; height: 100%; background: var(--ok); }
.mini-h.low i { background: var(--bad); }

/* ---------- home: demo with both modes, solo button ---------- */
.demo-boards { position: relative; display: grid; gap: 8px; padding: 8px; background: var(--panel); }
.demo-boards.survival { grid-template-columns: 1fr 1fr; }
.demo-boards.battle { grid-template-columns: 1fr; }
.demo-boards canvas { display: block; margin: 0 auto; max-width: 100%; }
.demo-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.demo-caption { padding: 10px 16px 12px; font-size: 13.5px; color: var(--ink-2); border-top: 1px solid var(--rule); min-height: 44px; }
#demoTabs button { height: 24px; min-width: 0; font-size: 11px; }

/* ---------- speed-up warning, banners ---------- */
.next-speed { width: 44px; height: 3px; background: var(--rule-2); border-radius: 1px; overflow: hidden; display: inline-block; }
.next-speed i { display: block; height: 100%; width: 0; background: var(--ink-3); }
.next-speed.soon i { background: var(--bad); }
.next-speed.soon { animation: blink 0.5s steps(2) infinite; }
.banner { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); pointer-events: none; z-index: 2; }
.banner > div { font: 600 13px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; padding: 6px 12px; border-radius: var(--r); white-space: nowrap; }
.banner-warn { color: var(--bad); border: 1px solid var(--bad); background: color-mix(in srgb, var(--panel) 85%, transparent); }
.banner-in { color: #fff; background: var(--bad); animation: pop 0.3s ease; }
.banner-in b { font-weight: 700; }
.banner-starve { color: #fff; background: var(--bad); animation: blink 0.4s steps(2) infinite; }

/* ---------- header status (speed, quota) and rules ---------- */
.speed-status { font: 600 11px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); min-width: 92px; text-align: right; white-space: nowrap; }
.speed-status.soon { color: var(--bad); animation: blink 0.5s steps(2) infinite; }
.speed-status.bump { color: var(--accent); }
.quota { margin-left: 4px; }
.quota.done { color: var(--ok); }
.quota.danger { color: var(--bad); animation: blink 0.5s steps(2) infinite; }
.rules-head { border-top: 1px solid var(--rule); }
#growth button { min-width: 0; }
@media (max-width: 640px) { .speed-status { min-width: 0; } }

/* ---------- sandbox ---------- */
.sandbox { max-height: 70vh; display: flex; flex-direction: column; }
.sb-actions { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.sb-groups { overflow-y: auto; padding: 4px 0 8px; }
.sb-gl { padding: 10px 14px 4px; color: var(--accent); }
.sb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 14px; font-size: 13px; }
.sb-l { display: flex; flex-direction: column; min-width: 0; }
.sb-l small { font-size: 11px; color: var(--ink-3); line-height: 1.3; }
.sb-v { display: inline-flex; align-items: center; gap: 5px; flex: none; }
.sb-v em { font: 500 10.5px var(--mono); color: var(--ink-3); width: 30px; }
.sb-in { width: 84px; height: 30px; padding: 0 8px; font-size: 13px; text-align: right; }
select.sb-in { width: 110px; text-align: left; }
.sb-in:disabled { opacity: 0.6; }

/* ---------- design picker ---------- */
.designs { display: flex; flex-direction: column; }
.design { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 9px 14px; border-bottom: 1px solid var(--rule); transition: background 0.12s; }
.design:hover:not(:disabled) { background: var(--hover); }
.design.on { background: var(--field); box-shadow: inset 3px 0 0 var(--accent); }
.design:disabled { cursor: default; }
.design .dn { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.design .dn b { font: 600 10.5px var(--mono); color: var(--ink-3); border: 1px solid var(--rule-2); border-radius: 2px; padding: 0 5px; }
.design.on .dn b { color: var(--accent); border-color: var(--accent); }
.design .dr { font-size: 12.5px; color: var(--ink-2); line-height: 1.35; }
.design .dw { font-size: 11.5px; color: var(--ink-3); font-style: italic; line-height: 1.35; }
.sb-fine summary { cursor: pointer; padding: 10px 14px; list-style-position: inside; }
.sb-fine summary span { text-transform: none; letter-spacing: 0; }
.design-rule { padding: 8px 16px; font-size: 13px; color: var(--ink-2); border-bottom: 1px solid var(--rule); background: var(--field); }
.design-rule:empty { display: none; }
.sandbox { max-height: none; }
