:root {
  --bg: #04070a;
  --panel: #0b1117;
  --panel-2: #101921;
  --line: #1b2731;
  --line-2: #26363f;
  --text: #dbeee2;
  --muted: #71897d;
  --accent: #3ee08a;
  --gold: #ffd25a;
  --heart: #ff4d5e;
  --warn: #ffb84d;
  --bad: #ff6b6b;
  --side: 24rem;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  /* Everything is sized in rem, so the whole UI grows with the screen: 14px on a 1080p
     window, larger on 1440p and 4K, never below 13px on small ones. main.js reads the
     result to size the canvas icons and the board header allowances. --ui-scale is the
     interface size from the settings (src/settings.js). */
  font-size: calc(clamp(13px, min(1.35vh, 0.78vw), 24px) * var(--ui-scale, 1));
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button, a.button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 0.5714rem;
  padding: 0.4286rem 0.7143rem;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
button:hover:not(:disabled), a.button:hover { border-color: var(--accent); }
a.button { display: inline-block; text-align: center; text-decoration: none; }
button:disabled { opacity: 0.38; cursor: not-allowed; }
button.active { border-color: var(--accent); background: #10301f; }
.ico { width: 1.4286rem; height: 1.4286rem; flex: none; }
kbd {
  font: 600 0.7143rem/1 'Segoe UI', sans-serif; color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 0.2143rem; padding: 2px 0.2857rem; background: rgba(0, 0, 0, 0.3);
}

#app { display: flex; flex-direction: column; height: 100vh; }
/* a game screen, not a page: clicking around never selects its text (chat and fields still do) */
#app, #hub { user-select: none; -webkit-user-select: none; }
#app input, #hub input, .chat-log, #mc-log { user-select: text; -webkit-user-select: text; }

/* ---------- HUD ---------- */
#hud {
  display: flex; align-items: center; gap: 0.7143rem; height: 4.2857rem; flex: none;
  padding: 0 1.1429rem; border-bottom: 1px solid var(--line);
  background: linear-gradient(#0d151c, #0a1016);
}
.brand { font-weight: 900; font-size: 1.5714rem; letter-spacing: 1px; margin-right: 1rem; }
.brand span { color: var(--accent); }
@keyframes hit { 0%, 100% { transform: none; } 25% { transform: scale(1.12); background: #4a0f18; } 60% { transform: translateX(-0.2143rem); } }
.spacer { flex: 1; }
.icon-btn { display: flex; align-items: center; justify-content: center; min-width: 2.8571rem; height: 2.8571rem; padding: 0 0.7143rem; font-weight: 700; }
.sound-ctl { display: flex; align-items: center; gap: 0.4286rem; }
#vol { width: 6.4286rem; accent-color: var(--accent); cursor: pointer; }
#vol.off { opacity: 0.4; }

/* ---------- layout ---------- */
main { flex: 1; display: flex; min-height: 0; }
#boards {
  flex: 1; min-width: 0; padding: 1rem; display: grid; gap: 1rem;
  align-content: center; justify-content: center;
}
#side {
  width: var(--side); flex: none; overflow-y: auto; padding: 1rem 0.2857rem 1rem 0;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; scrollbar-gutter: stable;
  display: flex; flex-direction: column; gap: 0.8571rem;
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 0.8571rem; padding: 0.8571rem; }
.panel h3 {
  margin: 0 0 0.7143rem; font-size: 0.7857rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: baseline;
}
.panel h3 small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text); }
.panel:empty, .panel.hidden, .icon-btn.hidden, #build-view .relic-only.hidden { display: none; }

/* ---------- boards ---------- */
.board-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 0.8571rem; padding: 0.5714rem;
  display: flex; flex-direction: column; gap: 0.4286rem;
}
.board-card.me { border-color: #1f5a3c; box-shadow: 0 0 0 1px #1f5a3c, 0 0 1.7143rem rgba(62, 224, 138, 0.08); }
.board-card.target { border-color: #5a3d1f; }
.board-card.out { opacity: 0.55; }
.board-head { display: flex; align-items: center; gap: 0.7143rem; font-weight: 600; height: 1.5714rem; }
.board-head .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-head .badge { font-size: 0.7857rem; font-weight: 700; padding: 2px 0.5714rem; border-radius: 0.7143rem; background: #10301f; color: var(--accent); }
.board-head .badge.target { background: #3a2610; color: var(--warn); }
.board-head .lives { display: flex; align-items: center; gap: 0.2857rem; color: var(--heart); font-variant-numeric: tabular-nums; }
.board-head .lives .ico { width: 1.1429rem; height: 1.1429rem; }
.board-head .lives b { color: #ffd6da; }
.board-head .money { display: flex; align-items: center; gap: 0.2857rem; color: var(--muted); font-size: 0.8571rem; }
.board-head .money .ico { width: 1rem; height: 1rem; color: var(--gold); }
.board-head .income { display: flex; align-items: center; gap: 0.2857rem; color: var(--muted); font-size: 0.8571rem; font-variant-numeric: tabular-nums; }
.board-head .income .ico { width: 1rem; height: 1rem; color: var(--accent); }
.board-head .income .round { font-size: 0.7143rem; opacity: 0.75; }
.board-head .lives.hit { animation: hit 0.45s; }
.board-card.pickable { cursor: pointer; }
.board-card.pickable:not(.target):not(.out):hover { border-color: #7a5428; }
.board-wrap { position: relative; }
.board-wrap canvas { display: block; border-radius: 0.4286rem; }
.board-card.me canvas { cursor: crosshair; }
.board-card:not(.me) canvas { cursor: inherit; }

/* ---------- tiles (shop and send) ---------- */
.tiles { display: grid; gap: 0.5714rem; }
#shop { grid-template-columns: repeat(3, 1fr); }
#send-grid { grid-template-columns: repeat(5, 1fr); gap: 0.4286rem; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0.4286rem 2px 0.3571rem; border-radius: 0.7143rem; background: var(--panel-2);
}
.tile canvas { display: block; }
.tile .price { font-size: 0.8571rem; font-weight: 700; color: #fff1c7; display: flex; align-items: center; gap: 0.2143rem; font-variant-numeric: tabular-nums; }
.tile .price .ico { width: 0.7857rem; height: 0.7857rem; color: var(--gold); }
.tile kbd { position: absolute; top: 0.2857rem; left: 0.2857rem; }
.tile .count { position: absolute; top: 0.2143rem; right: 0.3571rem; font-size: 0.7143rem; font-weight: 700; color: var(--muted); }
#send-grid .tile { padding: 0.2857rem 1px 0.2857rem; }
#relic-shop { grid-template-columns: repeat(4, 1fr); gap: 0.4286rem; }
#relic-shop .tile .price { color: #f3d9fa; }
#relic-shop .tile .price .ico, .tokens .ico { color: #e599f7; }
#build-view h3 { display: flex; align-items: center; }
.divider { border: 0; border-top: 1px solid var(--line-2); margin: 0.8571rem 0 0.7143rem; }
#build-hint { margin-top: 0.7143rem; }
#build-hint:empty { display: none; }
#build-panel.selecting #build-view, #build-panel:not(.selecting) #sel-panel { display: none; }
.sel-head .close { margin-left: auto; align-self: flex-start; padding: 0.2857rem 0.6429rem; font-size: 0.8571rem; color: var(--muted); }
.tokens { margin-left: auto; display: flex; align-items: center; gap: 0.2857rem; color: #f3d9fa; font-variant-numeric: tabular-nums; }
.tokens .ico { width: 1.1429rem; height: 1.1429rem; }
.tokens.gain { animation: gain 0.9s ease-out; }
@keyframes gain { 0% { transform: scale(1.5); filter: drop-shadow(0 0 0.4286rem #e599f7); } 100% { transform: none; } }
#send-grid .tile .price { font-size: 0.7857rem; }
/* send grid: a column header over each creep type, an income-efficiency bar under each tile */
#send-grid .send-col { font-size: 0.6429rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); text-align: center; cursor: help; }
#send-grid .tile .eco { display: block; width: 70%; height: 3px; border-radius: 2px; background: rgba(0, 0, 0, 0.45); overflow: hidden; }
#send-grid .tile .eco > i { display: block; height: 100%; background: var(--gold); }
/* creep modifier toggles above the send tiles */
.mods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.2857rem; margin-bottom: 0.4286rem; }
.mods .mod { display: flex; align-items: center; justify-content: center; gap: 0.2857rem; padding: 0.2857rem 2px; font-size: 0.7143rem; font-weight: 700; border-radius: 0.5rem; color: var(--muted); white-space: nowrap; }
.mods .mod.active { color: var(--mod); border-color: var(--mod); box-shadow: inset 0 0 0.5rem color-mix(in srgb, var(--mod) 35%, transparent); }

/* ---------- selection ---------- */
.sel-head { display: flex; align-items: center; gap: 0.7143rem; margin-bottom: 0.5714rem; }
.sel-head .title { font-weight: 700; font-size: 1.0714rem; }
.sel-head small { color: var(--muted); display: block; }
.stats { width: 100%; font-size: 0.8571rem; border-collapse: collapse; }
.stats td { padding: 0.2143rem 0; border-bottom: 1px solid var(--line); }
.stats td:first-child { color: var(--muted); }
.stats td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.stats b { color: var(--accent); }
.seg { display: flex; gap: 0.2857rem; margin-top: 0.7143rem; }
.seg button { flex: 1; padding: 0.2857rem 0; font-size: 0.7857rem; text-transform: capitalize; }
.actions { display: flex; gap: 0.5714rem; margin-top: 0.7143rem; }
.actions button { flex: 1; padding: 0.5714rem; font-weight: 700; display: flex; justify-content: center; align-items: center; gap: 0.4286rem; }
.actions .upgrade { background: #10301f; border-color: #1f5a3c; }
.actions .sell { background: #2a1416; border-color: #4a1a22; }
.hint { color: var(--muted); font-size: 0.8571rem; line-height: 1.45; }
.evolve { margin-top: 0.7143rem; display: flex; flex-direction: column; gap: 0.4286rem; }
.evolve-h { font-size: 0.7857rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--warn); }
.evo { display: flex; align-items: center; gap: 0.5714rem; padding: 0.4286rem 0.5714rem; text-align: left; background: #14202b; border-color: #2a4152; }
.evo:not(:disabled):hover { border-color: var(--accent); }
.evo canvas { flex: none; }
.evo > div { flex: 1; min-width: 0; }
.evo-name { font-weight: 700; font-size: 0.9286rem; }
.evo-desc { font-size: 0.8214rem; color: var(--muted); line-height: 1.3; }
.evo-stats { display: flex; flex-wrap: wrap; gap: 0.2143rem 0.5714rem; margin-top: 0.2143rem; font-size: 0.8rem; font-variant-numeric: tabular-nums; color: var(--muted); }
/* short windows: the description moves to the button's tooltip so both paths still fit */
@media (max-height: 920px) {
  .evo-desc { display: none; }
  .stats td { padding: 0.1429rem 0; }
}
.evolve-h.locked, .evolve-h.done { color: var(--muted); }
.actions .upgrade.locked { color: var(--muted); font-weight: 600; }
.busy { margin: 0 0 0.4286rem; padding: 0.2857rem 0.5714rem; border-radius: 0.5rem; background: #2a2410; color: var(--warn); font-size: 0.8571rem; font-weight: 700; }
.busy[hidden] { display: none; }
.seg-label { margin-top: 0.5714rem; font-size: 0.7857rem; color: var(--muted); }
.seg-label + .seg { margin-top: 0.2857rem; }
#tip .tree-h { margin: 0.4286rem 0 0.1429rem; }
#tip .tree { margin: 0; padding-left: 1.1rem; color: var(--muted); }
#tip .tree b { color: #e9f5ee; }
.evo-stats .up { color: var(--accent); }
.evo-stats .down { color: #ff8787; }
.evo .price { font-size: 0.8571rem; font-weight: 700; color: #fff1c7; display: flex; align-items: center; gap: 0.2143rem; flex: none; }
.evo .price .ico { width: 0.7857rem; height: 0.7857rem; color: var(--gold); }

/* ---------- wave panel ---------- */
.wave-big { display: flex; align-items: baseline; gap: 0.5714rem; }
.wave-big b { font-size: 2.1429rem; font-weight: 900; }
.wave-big small { color: var(--muted); }
.next-wave { display: flex; align-items: center; gap: 0.7143rem; margin: 0.7143rem 0; padding: 0.5714rem; border-radius: 0.7143rem; background: var(--panel-2); }
.next-wave .info { font-size: 0.8571rem; line-height: 1.4; }
.next-wave .traits { color: var(--warn); }
.skip { width: 100%; padding: 0.7143rem; font-weight: 800; background: #10301f; border-color: #1f5a3c; }
.check { display: flex; align-items: center; gap: 0.5714rem; margin-top: 0.7143rem; color: var(--muted); font-size: 0.8571rem; cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); width: 1.1429rem; height: 1.1429rem; }

/* ---------- tooltip, toast, overlay ---------- */
#tip {
  position: fixed; z-index: 20; pointer-events: none; display: none; max-width: 18.5714rem;
  background: #0d151c; border: 1px solid var(--line-2); border-radius: 0.7143rem; padding: 0.7143rem 0.8571rem;
  box-shadow: 0 0.5714rem 2.1429rem rgba(0, 0, 0, 0.6); font-size: 0.8571rem;
}
#tip.show { display: block; }
#tip .t { font-weight: 800; font-size: 1rem; margin-bottom: 2px; }
#tip .d { color: var(--muted); margin-bottom: 0.4286rem; }
#tip table { width: 100%; border-collapse: collapse; }
#tip td { padding: 1px 0; }
#tip td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#tip .tr { display: flex; flex-wrap: wrap; gap: 0.2857rem; margin-top: 0.4286rem; }
#tip .tr span { background: #2a1d0c; color: var(--warn); border-radius: 0.5714rem; padding: 1px 0.4286rem; font-size: 0.7857rem; }

#toast {
  position: fixed; left: calc((100vw - var(--side)) / 2); top: 5.2857rem; transform: translateX(-50%); z-index: 15;
  background: rgba(8, 13, 18, 0.92); border: 1px solid var(--line-2); border-radius: 0.7143rem;
  padding: 0.5714rem 1.1429rem; font-weight: 600; opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
body:has(#hub.show) #toast { left: 50vw; z-index: 45; }
#toast.show { opacity: 1; }
#toast.bad { border-color: var(--bad); color: #ffc9c9; }

#overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(2, 5, 8, 0.85); z-index: 30;
}
#overlay.show { display: flex; }
.card {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 1.1429rem;
  padding: 1.8571rem 2.1429rem; width: min(42.8571rem, calc(100vw - 2.2857rem)); max-height: calc(100vh - 2.2857rem); overflow-y: auto;
}
.card h1 { margin: 0 0 0.2857rem; font-size: 2.8571rem; font-weight: 900; }
.card h1 span { color: var(--accent); }
.card p { color: var(--muted); margin: 0.2857rem 0 1rem; line-height: 1.5; }
.card h4 { margin: 1.1429rem 0 0.4286rem; color: var(--muted); font-size: 0.7857rem; text-transform: uppercase; letter-spacing: 1px; }
.card .row { display: flex; gap: 0.5714rem; flex-wrap: wrap; }
.card .row button, .card .row a.button { flex: 1; min-width: 7.8571rem; padding: 0.7143rem; }
.card .mode { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.card .mode b { font-size: 1.0714rem; }
.card .mode small { color: var(--muted); }
.card .report-link a {
  display: block; text-align: center; text-decoration: none; font-weight: 800; color: var(--text);
  background: #12402a; border: 1px solid var(--accent); border-radius: 0.5714rem; padding: 0.7143rem;
}
.card .report-link a:hover { background: #185a3a; }
.card .primary { background: #12402a; border-color: var(--accent); font-weight: 800; font-size: 1.1429rem; }
.card ul { color: var(--muted); padding-left: 1.2857rem; line-height: 1.6; margin: 0.4286rem 0; font-size: 0.9286rem; }

/* ---------- versus field: boards joined edge to edge ---------- */
#boards.field { gap: 0; }
#boards.field .board-card { background: none; border: 0; border-radius: 0; padding: 0; box-shadow: none; gap: 0; }
#boards.field .board-card.bottom { flex-direction: column-reverse; }
#boards.field .board-head { height: 2rem; padding: 0 0.5714rem; }
#boards.field .board-wrap canvas { border-radius: 0; }
#boards.field .board-wrap::after { content: ''; position: absolute; inset: 0; pointer-events: none; }
#boards.field .board-card.me .board-wrap::after { box-shadow: inset 0 0 0 2px rgba(62, 224, 138, 0.55); }
#boards.field .board-card.target .board-wrap::after { box-shadow: inset 0 0 0 2px rgba(255, 170, 70, 0.6); }
#boards.field .board-card.pickable:not(.target):not(.out):hover .board-wrap::after { box-shadow: inset 0 0 0 2px rgba(255, 170, 70, 0.3); }
#boards.field .empty-slot { background: repeating-linear-gradient(45deg, #070b10 0 0.7143rem, #0a1017 0.7143rem 1.4286rem); }

/* ---------- menu: map size picker ---------- */
.card .row button.size { display: flex; align-items: center; gap: 0.7143rem; text-align: left; min-width: 6.4286rem; }
.card .size small { display: block; color: var(--muted); font-size: 0.7857rem; }
.size-ico { display: grid; grid-template-columns: repeat(2, 0.6429rem); gap: 2px; flex: none; }
.size-ico i { width: 0.6429rem; height: 0.5rem; border-radius: 2px; background: #1b2731; }
.size-ico i.on { background: var(--accent); }
button:disabled .size-ico i.on { background: var(--muted); }

/* ---------- menu: map picker with previews ---------- */
.card .row.maps button.map { flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 0.4286rem; padding: 0.5714rem; }
.card .row.maps canvas { display: block; border-radius: 0.2857rem; }
.card .row.maps button.map:not(.active) canvas { opacity: 0.75; }
.card .row input { flex: 1; padding: 0.7143rem; background: var(--panel-2); color: inherit; border: 1px solid var(--line-2); border-radius: 0.4286rem; font: inherit; }

/* ---------- hub: the login redirect, games, chat, players ---------- */
#hub { position: fixed; inset: 0; z-index: 40; display: none; background: var(--bg); }
#hub.show { display: block; }
#hub.auth { display: flex; align-items: center; justify-content: center; }
.auth-card { width: min(28rem, calc(100vw - 2.2857rem)); display: flex; flex-direction: column; }
#hub input {
  padding: 0.6429rem 0.7143rem; background: var(--panel-2); color: inherit; border: 1px solid var(--line-2);
  border-radius: 0.4286rem; font: inherit; min-width: 0;
}
#hub input:focus { outline: none; border-color: var(--accent); }

.hub {
  height: 100vh; display: grid; gap: 0.8571rem; padding: 0 0.8571rem 0.8571rem;
  grid-template-columns: minmax(0, 1fr) 17rem;
  grid-template-rows: auto minmax(0, 2.2fr) minmax(11rem, 1fr);
  grid-template-areas: 'head head' 'main players' 'chat players';
}
.hub-head {
  grid-area: head; display: flex; align-items: center; gap: 0.8571rem; height: 4.2857rem;
  margin: 0 -0.8571rem; padding: 0 1.1429rem; border-bottom: 1px solid var(--line); background: linear-gradient(#0d151c, #0a1016);
}
.me-name { font-weight: 700; color: var(--text); text-decoration: none; }
.me-name:hover { color: var(--accent); }
.hub .panel { min-height: 0; display: flex; flex-direction: column; }
.hub-main { grid-area: main; overflow-y: auto; }
.hub-chat { grid-area: chat; }
.hub-players { grid-area: players; }
.hub h3 { flex: none; }
.hub h3 .small { padding: 0.3571rem 0.8571rem; font-size: 0.8571rem; text-transform: none; letter-spacing: 0; }
.hub .primary { background: #12402a; border-color: var(--accent); font-weight: 800; }
.hub h4 { margin: 1rem 0 0.4286rem; color: var(--muted); font-size: 0.7857rem; text-transform: uppercase; letter-spacing: 1px; }
.hub .row { display: flex; gap: 0.5714rem; flex-wrap: wrap; }
.hub .row > input { flex: 1; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

/* games list: a card per open game, its map on top */
ul.games { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.8571rem; }
.game-card {
  display: flex; flex-direction: column; gap: 0.4286rem; padding: 0.5714rem 0.5714rem 0.7143rem; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 0.8571rem;
}
.game-card canvas { display: block; width: 100% !important; height: 7.5rem !important; object-fit: cover; border-radius: 0.5rem; }
.game-card .title { font-size: 1.2143rem; font-weight: 800; padding: 0 0.2857rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-card .meta { padding: 0 0.2857rem; color: var(--text); font-size: 0.9286rem; }
.game-card .meta small { display: block; color: var(--muted); font-size: 0.7857rem; }
.game-card .foot { display: flex; align-items: center; gap: 0.5714rem; padding: 0.2857rem 0.2857rem 0; margin-top: auto; }
.game-card .foot button { margin-left: auto; min-width: 6.4286rem; padding: 0.5rem 1rem; }
.pips { display: flex; align-items: center; gap: 0.2143rem; font-variant-numeric: tabular-nums; }
.pips i { width: 0.7143rem; height: 0.7143rem; border-radius: 50%; border: 2px solid var(--line-2); }
.pips i.on { background: var(--accent); border-color: var(--accent); }
.pips b { margin-left: 0.3571rem; font-size: 0.8571rem; color: var(--muted); }

/* settings: the button in the hub header and the dialog (src/settingspanel.js) */
.settings-btn { display: flex; align-items: center; gap: 0.4286rem; margin-right: 0.8571rem; }
.settings-btn .ico { width: 1.1429rem; height: 1.1429rem; }
#settings-dialog {
  position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center;
  background: rgba(2, 5, 8, 0.8);
}
#settings-dialog.show { display: flex; }
.settings-card { width: min(46rem, calc(100vw - 2.2857rem)); padding: 1.4286rem 1.8571rem; }
.settings-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.settings-top h2 { margin: 0; font-size: 1.8571rem; font-weight: 900; }
.settings-close { min-width: 2.4286rem; height: 2.4286rem; padding: 0; font-size: 1.1429rem; line-height: 1; }
.settings-card h4:first-of-type { margin-top: 0.7143rem; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1.1429rem;
  padding: 0.5rem 0; border-top: 1px solid var(--line);
}
.settings-card h4 + .set-row { border-top: 0; }
.set-label { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.set-label small { color: var(--muted); font-size: 0.7857rem; }
.opt-seg { display: flex; flex: none; gap: 0.2857rem; flex-wrap: wrap; justify-content: flex-end; }
.opt-seg button { padding: 0.3571rem 0.7857rem; font-size: 0.8571rem; min-width: 4.2857rem; white-space: nowrap; flex: none; }
.set-vol { display: flex; align-items: center; gap: 0.5714rem; flex: none; }
.set-vol input { width: 12.8571rem; accent-color: var(--accent); cursor: pointer; }
.set-vol output { min-width: 2.1429rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.settings-foot { display: flex; justify-content: space-between; gap: 0.7143rem; margin-top: 1.1429rem; }
.settings-foot button { padding: 0.5714rem 1.1429rem; }
.settings-foot .primary { background: #12402a; border-color: var(--accent); font-weight: 800; min-width: 8.5714rem; }
.fps { color: var(--muted); font-size: 0.8571rem; font-variant-numeric: tabular-nums; margin-right: 0.2857rem; }
.fps.hidden { display: none; }

/* a game you are in, and the settings editor */
.room { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 1.4286rem; }
.room h4:first-child, .settings h4:first-child { margin-top: 0; }
.seats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4286rem; }
.seats li { display: flex; align-items: center; gap: 0.5714rem; padding: 0.5rem 0.7143rem; border-radius: 0.5714rem; background: var(--panel-2); border: 1px solid var(--line-2); }
.seats li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.seats li.open { color: var(--muted); border-style: dashed; background: none; }
.crown { font-style: normal; font-size: 0.7143rem; font-weight: 700; padding: 1px 0.5rem; border-radius: 0.7143rem; background: #3a2610; color: var(--warn); }
.kick { padding: 0 0.4286rem; font-size: 0.7857rem; color: var(--muted); }
.room .hint { margin-top: 0.7143rem; }
.actions-row { margin-top: 1rem; }
.actions-row button { flex: 1; padding: 0.6429rem; }
.settings .row button { flex: 1; min-width: 6.4286rem; padding: 0.5714rem; }
.settings .mode { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.settings .mode small { color: var(--muted); }
.settings .row button.size { display: flex; align-items: center; gap: 0.7143rem; text-align: left; flex: 0 1 auto; }
.settings .size small { display: block; color: var(--muted); font-size: 0.7857rem; }
.settings .row.maps button.map { flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 0.4286rem; padding: 0.4286rem; }
.settings .row.maps canvas { display: block; border-radius: 0.2857rem; }
.settings .row.maps button.map:not(.active) canvas { opacity: 0.75; }
/* someone else's game: the settings show, but only the leader changes them */
.settings.readonly button { pointer-events: none; }
.settings.readonly button:not(.active) { opacity: 0.45; }

/* chat */
.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.2143rem; padding-right: 0.2857rem; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.chat-log .line { line-height: 1.45; overflow-wrap: anywhere; }
.chat-log time { color: var(--muted); font-size: 0.7857rem; margin-right: 0.4286rem; font-variant-numeric: tabular-nums; }
.chat-log b { color: var(--accent); margin-right: 0.4286rem; }
.chat-log .line.self b { color: var(--gold); }
.chat-form { display: flex; gap: 0.5714rem; margin-top: 0.5714rem; flex: none; }
.chat-form input { flex: 1; }

/* players */
.player-list { list-style: none; margin: 0; padding: 0 0.2857rem 0 0; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.player-list li { display: flex; align-items: center; gap: 0.5714rem; padding: 0.3571rem 0.4286rem; border-radius: 0.4286rem; }
.player-list li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; text-decoration: none; }
.player-list li a:hover { color: var(--accent); text-decoration: underline; }
.player-list li.self { background: var(--panel-2); font-weight: 700; }
.dot { width: 0.5714rem; height: 0.5714rem; border-radius: 50%; flex: none; background: var(--accent); }
.dot.st-lobby { background: var(--warn); }
.dot.st-playing { background: #74c0fc; }
.howto { margin-top: 1.4286rem; color: var(--muted); font-size: 0.9286rem; }
.howto summary { cursor: pointer; color: var(--text); font-weight: 600; }
.howto p { line-height: 1.5; }
.howto ul { padding-left: 1.2857rem; line-height: 1.6; }

@media (max-width: 900px) {
  .hub { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1.4fr) minmax(10rem, 1fr) 9rem; grid-template-areas: 'head' 'main' 'chat' 'players'; }
  .room { grid-template-columns: 1fr; }
}
/* Rank badges: a small shield in the tier's colour with its initial */
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 1.1429rem; height: 1.2857rem; margin-right: 0.3571rem; vertical-align: -0.2143rem;
  clip-path: polygon(50% 0, 100% 18%, 100% 62%, 50% 100%, 0 62%, 0 18%);
  background: var(--rc); color: #0b0f14; font-size: 0.7143rem; font-weight: 800; line-height: 1;
}
.rank-badge.rank-master, .rank-badge.rank-diamond { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45); }
table.result { width: 100%; border-collapse: collapse; margin: 0.5714rem 0 0.8571rem; font-variant-numeric: tabular-nums; }
table.result td { padding: 0.2857rem 0.4286rem; border-bottom: 1px solid var(--line); }
table.result tr.me td { color: var(--accent); }
table.result td.num { text-align: right; white-space: nowrap; }
table.result td.delta.up { color: var(--accent); font-weight: 700; }
table.result td.delta.down { color: var(--heart); font-weight: 700; }
.result-note { color: var(--muted); font-size: 0.8571rem; }
.me-name { display: inline-flex; align-items: center; gap: 0.2857rem; }
.me-name small { color: var(--muted); font-weight: 600; margin-left: 0.4286rem; }
.chat-log .line b .rank-badge { margin-right: 0.2857rem; }

/* bots: the BOT tag sits next to the name, never in it */
.bot-badge {
  display: inline-block; flex: none; margin-left: 0.3571rem; padding: 0.0714rem 0.3214rem; vertical-align: 0.0714rem;
  border: 1px solid #5b7cff; border-radius: 0.2857rem; background: rgba(91, 124, 255, 0.16);
  color: #aebcff; font-size: 0.6429rem; font-weight: 800; letter-spacing: 0.5px; line-height: 1.2;
}
.hub .bots-head { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; }
.hub .bots-head .small { padding: 0.1429rem 0.5714rem; font-size: 0.7857rem; }
.bot-list { flex: none; max-height: 45%; }
.bot-list li .small { margin-left: auto; padding: 0.1429rem 0.5rem; font-size: 0.7857rem; }
.bot-list .hint { color: var(--muted); font-size: 0.8571rem; }
.seats li.bot a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: inherit; text-decoration: none; }
.seats li.bot a:hover { color: var(--accent); text-decoration: underline; }
.chat-log .line.in-game { background: rgba(91, 124, 255, 0.07); border-radius: 0.2857rem; }
.chat-log .scope { font-style: normal; font-size: 0.7143rem; color: #aebcff; margin-right: 0.3571rem; text-transform: uppercase; letter-spacing: 0.5px; }

/* match chat, over the bottom left of the boards */
#match-chat {
  position: fixed; left: 1rem; bottom: 1rem; z-index: 14; width: min(28rem, calc(100vw - var(--side) - 2rem));
  display: flex; flex-direction: column; gap: 0.2857rem; pointer-events: none;
}
#mc-log { display: flex; flex-direction: column; gap: 0.2143rem; }
.mc-line {
  align-self: flex-start; max-width: 100%; padding: 0.2857rem 0.5714rem; border-radius: 0.4286rem;
  background: rgba(8, 13, 18, 0.82); border: 1px solid var(--line-2); overflow-wrap: anywhere; transition: opacity 0.6s;
}
.mc-line b { color: var(--accent); margin-right: 0.4286rem; }
.mc-line.self b { color: var(--gold); }
.mc-line.old { opacity: 0; }
#match-chat.typing .mc-line.old { opacity: 0.75; }
#mc-form { display: none; pointer-events: auto; }
#match-chat.typing #mc-form { display: block; }
#mc-input { width: 100%; font: inherit; color: var(--text); background: rgba(8, 13, 18, 0.95); border: 1px solid var(--accent); border-radius: 0.4286rem; padding: 0.4286rem 0.5714rem; }
body:has(#hub.show) #match-chat { display: none; }
.seats li .rank-badge, .seats li .bot-badge { flex: none; }
.hub-players .player-list:not(.bot-list) { flex: 0 1 auto; }
