/* Chess of the Hundred Guardians — interface styles.
 * Visual language follows the Amaravati Cyber design system: limestone by day, neutral graphite at
 * night, the rust accent for what can be pressed or is selected; opaque surfaces, hairlines and soft
 * shadows; serif headings, a clean sans body, tabular numbers. Fonts are the system fallbacks of that
 * system's stacks (no font files are loaded). Nothing animates behind reading text: the arena canvas
 * shows only on the home screen and during play. */

:root {
  color-scheme: light;
  --canvas: #f3eee5;
  --canvas-2: #e9e2d4;
  --card: #fffdf8;
  --card-2: #f8f4ec;
  --ink: #221a14;
  --ink-2: #40342b;
  --ink-3: #5a4c41;
  --line: rgba(70, 45, 20, 0.10);
  --line-2: rgba(70, 45, 20, 0.20);
  --accent: #b8430f;
  --accent-2: #933210;
  --accent-solid: #b8430f;
  --accent-ink: #ffffff;
  --accent-bg: rgba(184, 67, 15, 0.10);
  --brand: #a4461c;
  --ok: #137035; --ok-bg: rgba(19, 112, 53, 0.12);
  --warn: #8a5f06; --warn-bg: rgba(138, 95, 6, 0.14);
  --danger: #c42727; --danger-bg: rgba(196, 39, 39, 0.11);
  --info: #0d7383;
  --band: #111214; --band-ink: #f5eee5; --band-ink-2: #c7b8a9;
  --shadow-card: 0 1px 2px rgba(60, 38, 18, 0.05);
  --shadow-card-hover: 0 6px 18px -8px rgba(60, 38, 18, 0.16), 0 1px 2px rgba(60, 38, 18, 0.05);
  --shadow-pop: 0 24px 56px -20px rgba(45, 30, 12, 0.3), 0 0 0 1px rgba(45, 30, 12, 0.07);
  --radius-card: 10px;
  --radius-control: 8px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font-sans: "Segoe UI Variable Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #101113;
  --canvas-2: #191b1e;
  --card: #17191c;
  --card-2: #1e2125;
  --ink: #edeef0;
  --ink-2: #cdd1d6;
  --ink-3: #a9aeb6;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);
  --accent: #ee8450;
  --accent-2: #9c4418;
  --accent-solid: #b9501d;
  --accent-bg: rgba(238, 132, 80, 0.15);
  --brand: #ad5630;
  --ok: #22c55e; --ok-bg: rgba(34, 197, 94, 0.14);
  --warn: #e0a526; --warn-bg: rgba(224, 165, 38, 0.14);
  --danger: #f87171; --danger-bg: rgba(248, 113, 113, 0.14);
  --info: #2bb5c7;
  --band: #0b0c0e;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-card-hover: 0 10px 28px -12px rgba(0, 0, 0, 0.7);
  --shadow-pop: 0 24px 60px -20px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.07);
}

/* Aliases used by the view code. */
:root {
  --text: var(--ink); --muted: var(--ink-3); --faint: var(--ink-3);
  --gold: var(--accent); --gold-2: var(--accent); --bad: var(--danger);
  --panel: var(--card); --panel-solid: var(--card); --line-strong: var(--line-2);
  --serif: var(--font-display); --sans: var(--font-sans); --mono: var(--font-mono);
  --radius: var(--radius-card); --shadow: var(--shadow-card);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); color: var(--ink); font: 450 0.9375rem/1.55 var(--font-sans); font-variant-numeric: tabular-nums;
  overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.005em; }

#arena { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; display: none; }
body.with-arena #arena { display: block; }
body.with-arena { background: #101113; }
#app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }
#view { flex: 1; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: var(--card); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-card); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.125rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand .mark { width: 28px; height: 28px; border-radius: 7px; background: var(--brand); display: grid; place-items: center; color: #fff; font-size: 15px; }
.brand b { color: var(--brand); font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .meter { font-size: 0.8125rem; color: var(--ink-3); white-space: nowrap; margin-right: 6px; }
.topbar .meter b { color: var(--ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 7px 14px; border-radius: var(--radius-control);
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 550; font-size: 0.875rem;
  box-shadow: var(--shadow-card); transition: border-color .15s var(--ease-out), background .15s var(--ease-out), transform .1s; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--accent-bg); color: var(--ink); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 0.8125rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 38px; padding: 0; }
select.btn { padding-right: 28px; }

/* ---------- Home ---------- */
.home { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 32px 16px; text-align: center; color: #edeef0; }
.home .hero-card { max-width: 720px; padding: 36px 32px; border-radius: 16px; background: rgba(16, 17, 19, 0.78); border: 1px solid rgba(255,255,255,.1); box-shadow: 0 24px 60px -20px rgba(0,0,0,.85); }
.home h1 { font-size: clamp(2rem, 6vw, 3.5rem); line-height: 1.08; margin: 0 0 12px; }
.home h1 b { color: #ee8450; font-weight: 600; display: block; }
.home p.lead { max-width: 600px; margin: 0 auto 24px; color: #cdd1d6; font-size: 1.0625rem; }
.home .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.home .note { margin: 22px auto 0; color: #a9aeb6; font-size: 0.8125rem; max-width: 560px; }
.home .btn:not(.primary) { background: #17191c; color: #edeef0; border-color: rgba(255,255,255,.16); }

/* ---------- Map ---------- */
.map { max-width: 880px; margin: 0 auto; padding: 20px 16px 100px; position: relative; }
.map-head { text-align: center; padding: 12px 0 4px; }
.map-head h2 { font-size: 2rem; margin: 0; }
.map-head p { color: var(--ink-3); margin: 6px 0 0; }
.band { margin: 16px 0 6px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--band); border-radius: var(--radius-card); overflow: hidden; }
.band > div { background: var(--band); padding: 14px 16px; color: #e8eaed; }
.band b { display: block; font-family: var(--font-display); font-size: 1.5rem; font-weight: 500; color: #fff; }
.band span { font-size: 0.75rem; color: #b0b5bc; text-transform: uppercase; letter-spacing: .08em; }
.tier { margin: 36px 0 10px; text-align: center; }
.tier span { display: inline-block; padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card);
  font-size: 0.75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); }
.tier small { display: block; margin-top: 6px; color: var(--ink-3); font-size: 0.75rem; }
.path { position: relative; }
.path svg.trail { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.node { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; width: min(100%, 470px); margin: 12px 0; padding: 10px 14px 10px 10px;
  border-radius: var(--radius-card); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow-card); cursor: pointer; text-decoration: none; color: inherit;
  transition: box-shadow .18s var(--ease-out), border-color .18s var(--ease-out); }
.node:hover { box-shadow: var(--shadow-card-hover); border-color: var(--line-2); }
.node.right { margin-left: auto; flex-direction: row-reverse; text-align: right; padding: 10px 10px 10px 14px; }
.node .portrait { width: 72px; height: 72px; flex: none; }
.node .lv { font-size: 0.75rem; font-weight: 700; letter-spacing: .1em; color: var(--brand); text-transform: uppercase; }
.node .nm { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.2; }
.node .tt { color: var(--ink-3); font-size: 0.8125rem; }
.node .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; align-items: center; }
.node.right .row { justify-content: flex-end; }
.node.locked { background: var(--card-2); }
.node.locked .portrait { filter: grayscale(.85) opacity(.7); }
.node.locked .nm { color: var(--ink-2); }
.node.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg), var(--shadow-card); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--ink-2); background: var(--card); white-space: nowrap; }
.badge.completed { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge.unlocked { color: var(--accent); background: var(--accent-bg); border-color: transparent; }
.badge.locked { color: var(--ink-3); background: var(--card-2); }
.badge.reward { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.stars { color: var(--accent); letter-spacing: 1px; font-size: 0.75rem; white-space: nowrap; }
.stars i { font-style: normal; color: var(--line-2); }

/* Portraits */
.portrait { border-radius: 50%; overflow: hidden; background: var(--card-2); border: 2px solid var(--line-2); box-shadow: var(--shadow-card);
  display: grid; place-items: center; position: relative; }
.portrait img { width: 100%; height: 100%; display: block; }
.portrait .lock { position: absolute; inset: auto 0 4px 0; margin: auto; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.7);
  display: grid; place-items: center; font-size: 11px; }

/* ---------- Profile ---------- */
.profile { max-width: 1000px; margin: 0 auto; padding: 22px 16px 80px; }
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-card); overflow: hidden; }
.hero { display: grid; grid-template-columns: 180px 1fr; gap: 26px; padding: 26px; align-items: center; background: var(--card-2); border-bottom: 1px solid var(--line); }
.hero .portrait { width: 180px; height: 180px; border-width: 3px; }
.hero h1 { font-size: clamp(2rem, 5vw, 2.75rem); margin: 2px 0 0; line-height: 1.05; }
.hero .title { color: var(--brand); font-family: var(--font-display); font-size: 1.1875rem; font-style: italic; }
.hero .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.hero .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.cols { display: grid; grid-template-columns: 1.25fr 1fr; }
.cols > div { padding: 22px 26px; }
.cols > div + div { border-left: 1px solid var(--line); }
.k { font-size: 0.75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 20px 0 6px; font-weight: 700; }
.k:first-child { margin-top: 0; }
.bio { font-family: var(--font-display); font-size: 1.0625rem; line-height: 1.65; color: var(--ink); }
.quote { font-family: var(--font-display); font-style: italic; color: var(--ink-2); border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; margin: 10px 0; }
.sources li { color: var(--ink-2); }
ul.plain { margin: 0; padding-left: 18px; }
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 8px; text-align: center; }
.stat b { display: block; font-size: 1.5rem; font-family: var(--font-display); font-weight: 500; }
.stat span { font-size: 0.75rem; color: var(--ink-3); }
.history { display: grid; gap: 6px; }
.history .h { display: flex; gap: 10px; align-items: center; font-size: 0.8125rem; background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 6px 10px; }
.history .h .res { font-weight: 700; width: 46px; }
.history .h .res.win { color: var(--ok); } .history .h .res.loss { color: var(--danger); } .history .h .res.draw { color: var(--ink-3); }
.history .h .meta { color: var(--ink-3); flex: 1; }
.colorpick { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.colorpick .btn.on { border-color: var(--accent); background: var(--accent-bg); color: var(--ink); }

/* ---------- Match ---------- */
.match { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; max-width: 1240px; margin: 0 auto; padding: 14px 16px 30px; align-items: start; }
.board-col { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.board-wrap { position: relative; width: min(100%, calc(100vh - 210px), 760px); min-width: 280px; aspect-ratio: 1; }
.board-wrap canvas { width: 100%; height: 100%; display: block; border-radius: 8px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.85); touch-action: none; }
.seat { width: min(100%, calc(100vh - 210px), 760px); min-width: 280px; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-card); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-card); }
.seat .portrait { width: 42px; height: 42px; }
.seat .who { flex: 1; min-width: 0; }
.seat .who b { font-family: var(--font-display); font-size: 1.0625rem; font-weight: 500; }
.seat .who small { display: block; color: var(--ink-3); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .caps { font-size: 0.8125rem; color: var(--ink-3); }
.seat.turn { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.clock { font-family: var(--font-mono); font-size: 1.375rem; padding: 4px 10px; border-radius: var(--radius-control); background: var(--card-2); border: 1px solid var(--line); min-width: 92px; text-align: center; }
.clock.low { color: var(--danger); background: var(--danger-bg); }
.clock.idle { opacity: .6; }
.thinking { color: var(--accent); font-size: 0.8125rem; }
.thinking i { animation: blink 1.2s infinite; font-style: normal; }
.thinking i:nth-child(2) { animation-delay: .2s; } .thinking i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }
.side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 72px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 14px; box-shadow: var(--shadow-card); }
.card h3 { margin: 0 0 6px; font-size: 1rem; }
.speech { font-family: var(--font-display); font-size: 1rem; font-style: italic; color: var(--ink); min-height: 48px; }
.speech .by { display: block; font-style: normal; font-size: 0.75rem; color: var(--ink-3); margin-top: 4px; font-family: var(--font-sans); }
.moves { max-height: 280px; overflow-y: auto; font-family: var(--font-mono); font-size: 0.8125rem; display: grid; grid-template-columns: 36px 1fr 1fr; gap: 2px 6px; }
.moves .n { color: var(--ink-3); text-align: right; }
.moves .m { padding: 1px 6px; border-radius: 5px; }
.moves .m.last { background: var(--accent-bg); }
.moves .m.click { cursor: pointer; } .moves .m.click:hover { background: var(--card-2); }
.moves .m.inacc { color: var(--warn); } .moves .m.mist { color: #d9711f; } .moves .m.blund { color: var(--danger); } .moves .m.best { color: var(--ok); }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.opening { font-size: 0.8125rem; color: var(--ink-3); }

.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 10, 12, 0.55); }
.modal { width: min(520px, 100%); background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; padding: 26px; text-align: center; box-shadow: var(--shadow-pop); }
.modal h2 { font-size: 2rem; margin: 6px 0; }
.modal .portrait { width: 104px; height: 104px; margin: 0 auto; }
.modal .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.modal.win h2 { color: var(--ok); } .modal.loss h2 { color: var(--danger); }
.achv { margin: 16px auto 0; padding: 12px; border-radius: var(--radius-card); background: var(--warn-bg); max-width: 380px; }
.achv b { color: var(--warn); font-family: var(--font-display); font-size: 1.125rem; }
.promo { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.promo button { width: 72px; height: 72px; border-radius: var(--radius-card); border: 1px solid var(--line-2); background: var(--card-2); cursor: pointer; padding: 6px; }
.promo button:hover { border-color: var(--accent); }
.promo svg { width: 100%; height: 100%; }

/* ---------- Review ---------- */
.graph { width: 100%; height: 140px; display: block; border-radius: var(--radius-control); cursor: pointer; border: 1px solid var(--line); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.8125rem; color: var(--ink-3); margin-top: 6px; }
.legend b { font-weight: 700; }
.progressbar { height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; margin-top: 8px; }
.progressbar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------- Settings & misc ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 22px 16px 80px; }
.page h2 { font-size: 1.75rem; margin: 4px 0 14px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting p { margin: 2px 0 0; color: var(--ink-3); font-size: 0.8125rem; }
.switch { width: 44px; height: 24px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line-2); position: relative; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink-3); transition: left .15s, background .15s; }
.switch[aria-checked="true"] { background: var(--accent-solid); border-color: var(--accent-solid); }
.switch[aria-checked="true"]::after { left: 22px; background: #fff; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: 10px 16px; box-shadow: var(--shadow-pop); font-size: 0.875rem; }
footer.foot { text-align: center; color: var(--ink-3); font-size: 0.75rem; padding: 24px 16px; }
body.with-arena footer.foot { color: #a9aeb6; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .match { grid-template-columns: 1fr; }
  .side { position: static; }
  .board-wrap, .seat { width: min(100%, 640px); }
}
@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; text-align: center; justify-items: center; padding: 20px 16px; }
  .hero .portrait { width: 140px; height: 140px; }
  .hero .chips, .hero .actions { justify-content: center; }
  .cols { grid-template-columns: 1fr; }
  .cols > div { padding: 18px 16px; }
  .cols > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .node, .node.right { width: 100%; margin-left: 0; flex-direction: row; text-align: left; padding: 10px 12px 10px 10px; }
  .node.right .row { justify-content: flex-start; }
  .node .portrait { width: 60px; height: 60px; }
  .path svg.trail { display: none; }
  .statgrid, .band { grid-template-columns: repeat(2, 1fr); }
  .topbar .meter { display: none; }
  .clock { font-size: 1.125rem; min-width: 76px; }
  .home .hero-card { padding: 26px 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.gate { margin: 34px 0 6px; padding: 16px 18px; border-radius: var(--radius-card); background: var(--band); color: #e8eaed; text-align: center; }
.gate b { display: block; font-family: var(--font-display); font-size: 1.25rem; font-weight: 500; color: #fff; margin-bottom: 4px; }
.gate span { color: #b0b5bc; font-size: 0.875rem; }

.ratingchange { margin: 8px 0 0; font-size: 0.9375rem; color: var(--ink-2); }
.ratingchange.up b { color: var(--ok); } .ratingchange.down b { color: var(--danger); }
.lockline { margin: 10px 0 0; font-size: 0.8125rem; color: var(--ink-3); }
.freebar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 14px 0; }
.freebar input { flex: 1; min-width: 180px; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-control); border: 1px solid var(--line-2); background: var(--card); color: var(--ink); }
.freegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.fcard { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: var(--radius-card); border: 1px solid var(--line); background: var(--card);
  box-shadow: var(--shadow-card); color: inherit; text-decoration: none; }
.fcard:hover { border-color: var(--line-2); box-shadow: var(--shadow-card-hover); }
.fcard .portrait { width: 56px; height: 56px; flex: none; }
.fcard .lv { font-size: 0.75rem; font-weight: 700; letter-spacing: .08em; color: var(--brand); text-transform: uppercase; }
.fcard .nm { font-family: var(--font-display); font-size: 1.0625rem; line-height: 1.2; }
.fcard .tt { color: var(--ink-3); font-size: 0.75rem; }

/* ---------- Mobile (most players are on phones) ---------- */
.tabbar { display: none; }
a, button, select, input { touch-action: manipulation; }
@media (max-width: 720px) {
  .topbar { padding: 8px 12px; gap: 6px; }
  .topnav { display: none; }
  .topbar .meter { display: inline; font-size: 0.75rem; margin: 0; }
  .brand { font-size: 1rem; }
  .brand .mark { width: 26px; height: 26px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(0,0,0,.18);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; font-size: 0.6875rem; font-weight: 600;
    color: var(--ink-3); text-decoration: none; border-radius: 8px; min-height: 48px; justify-content: center; }
  .tabbar a span { font-size: 1.2rem; line-height: 1; }
  .tabbar a.on { color: var(--accent); background: var(--accent-bg); }
  body.in-game .tabbar { display: none; }
  #app { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.in-game #app { padding-bottom: env(safe-area-inset-bottom); }
  footer.foot { padding: 16px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 38px; }
  .home { min-height: auto; padding: 18px 12px; }
  .home .hero-card { padding: 22px 16px; }
  .home .actions .btn { width: 100%; }
  .map, .profile, .page { padding-left: 10px; padding-right: 10px; }
  .hero .actions .btn { flex: 1 1 auto; }
  .colorpick .btn { flex: 1 1 auto; }
  /* Match: board edge to edge, seats tight, details below. */
  .match { padding: 6px 6px 16px; gap: 10px; }
  .board-col { gap: 6px; }
  .board-wrap, .seat { width: 100%; min-width: 0; }
  .board-wrap canvas { border-radius: 4px; }
  .seat { padding: 6px 8px; }
  .seat .portrait { width: 36px; height: 36px; }
  .side { gap: 8px; }
  .card { padding: 12px; }
  .speech { min-height: 0; font-size: 0.9375rem; }
  .moves { max-height: 160px; }
  .modal { padding: 20px 16px; border-radius: 14px; }
  .modal .actions .btn { flex: 1 1 40%; }
  .freegrid { grid-template-columns: 1fr; }
  .band b { font-size: 1.25rem; }
}
@media (max-width: 360px) {
  .clock { font-size: 1rem; min-width: 64px; padding: 3px 6px; }
  .tabbar a { font-size: 0.625rem; }
}
@media (max-width: 960px) { .side .card.controls { order: -1; } }

.lesson { border-color: var(--accent); }
.lesson-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.lesson-head .portrait { width: 40px; height: 40px; flex: none; }
.lesson-head h3 { margin: 0; }
