
/* Layout: a walnut tabletop; the felt map sits in the middle like a game board, a card-stock panel at its side. */
:root {
  --wood-0: #1d1510;
  --wood-1: #2a1e16;
  --wood-2: #3a2a1e;
  --paper: #efe6d2;
  --paper-2: #e2d6bc;
  --ink: #241a13;
  --ink-2: #6c5c4b;
  --brass: #dca54a;
  --brass-ink: #2a1c08;
  --display: 'Saira Stencil One', 'Arial Narrow', Impact, sans-serif;
  --ui: 'Barlow Semi Condensed', 'Arial Narrow', system-ui, sans-serif;
  color-scheme: dark;
}
/* Map workshop: the game artwork and palette remain legible on small screens. */
.editor-inner { width: min(1440px, 100%); display: grid; gap: 16px; min-width: 0; }
.editor-screen { box-sizing: border-box; padding-top: 22px; }
.editor-library, .editor-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.editor-library { margin: 12px 0; }
.editor-library .field { flex: 1 1 220px; margin: 0; }
.editor-meta { display: grid; grid-template-columns: minmax(160px, 1fr) repeat(3, 80px) auto; gap: 10px; align-items: end; }
.editor-meta .field { margin: 0; min-width: 0; }
.editor-inner input, .editor-inner select { min-width: 0; width: 100%; box-sizing: border-box; }
.editor-inner input[type="checkbox"] { width: auto; }
.editor-actions { margin-bottom: 16px; align-items: center; }
.editor-actions .note { flex-basis: 100%; margin: 4px 0 0; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 16px; align-items: start; }
.editor-board { min-width: 0; position: sticky; top: 12px; }
.editor-board-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.editor-board-bar > b { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.editor-pan { min-height: 48px; padding: 12px 20px; font-size: 18px; font-weight: 800; flex: none; }
.editor-pan span { margin-right: 6px; font-size: 24px; line-height: 1; }
.editor-pan[aria-pressed="true"] { background: var(--brass); color: var(--brass-ink); box-shadow: inset 0 0 0 2px #68431a; }
.editor-navigation { margin: 0 0 10px; }
.editor-zoom { display: flex; gap: 4px; flex: none; }
#edScroll { overflow: auto; max-height: 68vh; background: #4a3424; border-radius: 6px; padding: 8px; box-sizing: border-box; touch-action: none; overflow-anchor: none; }
#edBoard { display: block; touch-action: none; cursor: crosshair; image-rendering: pixelated; }
#edScroll.panning, #edScroll.panning canvas { cursor: grabbing !important; }
#edTileInfo { margin: 10px 0 0; min-height: 20px; }
.editor-palette { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 12px 0; max-height: 380px; overflow: auto; padding: 3px; }
.palette-item { display: grid; justify-items: center; align-content: start; gap: 4px; padding: 5px 3px; font-size: 13px; line-height: 1.1; border: 1px solid #c9bb9c; background: var(--paper-2); color: var(--ink); border-radius: 5px; }
.palette-item canvas { display: block; pointer-events: none; }
.palette-item img { display: block; pointer-events: none; image-rendering: pixelated; }
.palette-item span { max-width: 100%; overflow-wrap: anywhere; }
#edArtPalette { max-height: 260px; }
#edArtTools { border-top: 1px dashed #b9ab8e; padding-top: 12px; }
#edArtFile { overflow-wrap: anywhere; font-size: 12px; }
.editor-rename { display: flex; gap: 6px; }
.editor-rename input { flex: 1; }
.editor-rename button { flex: none; }
.editor-palette-tabs { display: flex; gap: 6px; margin: 12px 0; }
.editor-palette-tabs [aria-pressed="true"] { background: #e9bd6d; border-color: #68431a; }
.editor-art-categories { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.editor-art-categories [aria-pressed="true"] { background: #e9bd6d; border-color: #68431a; }
.palette-item[aria-pressed="true"] { border-color: #68431a; background: #e9bd6d; box-shadow: inset 0 0 0 2px #68431a; }
.editor-tools .check { font-size: 14px; }
.editor-validation { border-top: 1px dashed #b9ab8e; padding-top: 10px; font-size: 14px; }
.editor-validation.is-invalid { color: #962c1e; }
.editor-assets { margin-top: 16px; }
.editor-assets summary { cursor: pointer; font-weight: bold; }
.editor-assets ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; max-height: 300px; overflow: auto; }
.editor-assets li { display: flex; gap: 8px; align-items: center; min-width: 0; font-size: 13px; }
.editor-assets img { flex: none; image-rendering: pixelated; }
.editor-assets li div { min-width: 0; overflow-wrap: anywhere; }
.editor-assets small { display: block; color: #75644e; }
@media (max-width: 860px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-board { position: static; }
  .editor-tools { grid-row: 1; }
  .editor-tools .field { display: inline-grid; width: calc(50% - 8px); vertical-align: top; margin-right: 4px; }
  .editor-palette { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); max-height: 155px; }
  .editor-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .editor-meta .ed-name, .editor-meta > button { grid-column: 1 / -1; }
  .editor-inner .hero h1 { font-size: 34px; }
  #edScroll { max-height: 60vh; }
}
@media (max-width: 520px) { .editor-pan { order: 1; width: 100%; } }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--wood-1);
  background-image:
    repeating-linear-gradient(92deg, rgba(255,255,255,0.018) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(88deg, rgba(0,0,0,0.12) 0 1px, transparent 1px 23px),
    radial-gradient(ellipse at 50% 40%, var(--wood-2), var(--wood-0) 80%);
  color: var(--paper);
  font: 500 16px/1.35 var(--ui);
  font-variant-numeric: tabular-nums;
}
.app { height: 100%; display: grid; grid-template-rows: auto 1fr; }

/* Header */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding: 10px 16px; border-bottom: 1px solid rgba(0,0,0,0.5);
  background: linear-gradient(var(--wood-0), rgba(29,21,16,0.85));
}
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand h1 { margin: 0; font: 400 26px/1 var(--display); letter-spacing: 0.02em; color: var(--brass); }
.brand span { color: #b9a78f; font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase; }
.turnchip { display: flex; align-items: center; gap: 10px; }
.daybox { text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; color: #b9a78f; }
.daybox b { display: block; font: 400 22px/1 var(--display); color: var(--paper); letter-spacing: 0; }
.who { line-height: 1.1; }
.who b { font-size: 18px; font-weight: 700; }
.who small { display: block; color: #b9a78f; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.fundsbox { text-align: right; }
.fundsbox small { display: block; color: #b9a78f; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.fundsbox b { font-size: 20px; font-weight: 800; color: var(--brass); }
.swatch { display: inline-block; width: 22px; height: 22px; border: 2px solid var(--ink); box-shadow: 0 0 0 1px rgba(255,255,255,0.2); flex: none; }
.swatch[data-shape="circle"] { border-radius: 50%; }
.swatch[data-shape="square"] { border-radius: 5px; }
.swatch[data-shape="diamond"] { transform: rotate(45deg) scale(0.85); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
button { font: 700 16px/1 var(--ui); cursor: pointer; border-radius: 8px; }
.btn { padding: 10px 14px; border: 1px solid rgba(239,230,210,0.35); background: transparent; color: var(--paper); }
.btn:hover { background: rgba(239,230,210,0.08); }
.btn[aria-pressed="true"] { background: rgba(200,68,47,0.3); border-color: #e27a64; }
.btn-primary { padding: 10px 16px; border: 1px solid #f0c372; background: var(--brass); color: var(--brass-ink); box-shadow: 0 2px 0 #8a5f1c; }
.btn-primary:hover { background: #e8b65e; }
button:focus-visible, input:focus-visible, canvas:focus-visible { outline: 3px solid #f6d58c; outline-offset: 2px; }

/* Stage */
.stage { position: relative; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; padding: 16px; }
.board-wrap { min-width: 0; min-height: 0; }
.board-frame { padding: 10px; border-radius: 10px; background: #4a3424; box-shadow: inset 0 0 0 2px #5d4330, 0 14px 30px rgba(0,0,0,0.55), 0 2px 0 #160f0b; }
#board { display: block; border-radius: 3px; touch-action: manipulation; image-rendering: pixelated; }

/* Panel */
.panel { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--paper); color: var(--ink); border-radius: 6px; padding: 12px 14px; box-shadow: 0 2px 0 #b9ab8e, 0 8px 18px rgba(0,0,0,0.35); }
.card h2 { margin: 0 0 8px; font: 700 13px/1 var(--ui); text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-2); }
.seats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.seat { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 6px 8px; border-radius: 6px; }
.seat .swatch { grid-row: span 3; width: 18px; height: 18px; }
.seat-name { font-weight: 700; font-size: 17px; }
.seat-stat { color: var(--ink-2); font-size: 14px; }
.seat-stat b { color: var(--ink); }
.seat.is-turn { background: var(--paper-2); box-shadow: inset 3px 0 0 var(--ink); }
.seat.is-out { opacity: 0.5; }
.info-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.info-title { font-weight: 800; font-size: 18px; }
.stars { color: #a8721c; letter-spacing: 1px; }
.stars i { font-style: normal; color: #cbbd9f; }
.muted { color: var(--ink-2); margin: 2px 0 0; font-size: 14px; }
.unit-card { display: flex; gap: 10px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed #c9bb9c; }
.stats { margin: 10px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stats div { background: var(--paper-2); border-radius: 4px; padding: 4px 6px; }
.stats dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.stats dd { margin: 0; font-weight: 700; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.log li { padding-left: 10px; border-left: 3px solid var(--seat, #b5aa94); }
.help { font-size: 14px; color: var(--ink-2); margin: 0; padding-left: 18px; display: grid; gap: 3px; }
.help b { color: var(--ink); }
.concede { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.linkish { background: none; border: none; padding: 0; color: var(--ink-2); text-decoration: underline; font-weight: 600; font-size: 14px; }
.confirm { font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mini-btn { padding: 6px 10px; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); font-size: 14px; }
.mini-btn.danger { background: #b23d29; color: var(--paper); border-color: #6d2416; }

/* Floating menus */
.menu { position: absolute; z-index: 5; display: grid; gap: 4px; padding: 6px; min-width: 150px; background: var(--paper); border-radius: 8px; box-shadow: 0 2px 0 #b9ab8e, 0 12px 26px rgba(0,0,0,0.5); }
.menu button { text-align: left; padding: 9px 12px; border: none; background: transparent; color: var(--ink); font-size: 17px; }
.menu button:hover, .menu button:focus-visible { background: var(--ink); color: var(--paper); outline: none; }
.menu button.quiet { color: var(--ink-2); font-weight: 600; }
.forecast { position: absolute; z-index: 5; width: 190px; padding: 10px 12px; background: var(--ink); color: var(--paper); border-radius: 8px; border: 1px solid #5a4636; box-shadow: 0 12px 26px rgba(0,0,0,0.5); pointer-events: none; }
.fc-row { display: flex; justify-content: space-between; font-size: 16px; }
.fc-row b { color: #ffd36b; }
.fc-hint { margin: 6px 0 0; font-size: 13px; color: #c9b9a2; }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(18,12,8,0.55); }
.sheet { width: min(460px, 100%); max-height: calc(100% - 32px); overflow: auto; background: var(--paper); color: var(--ink); border-radius: 10px; padding: 16px; box-shadow: 0 3px 0 #b9ab8e, 0 20px 50px rgba(0,0,0,0.6); }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.sheet h2 { margin: 0; font: 400 24px/1 var(--display); }
.build-list { display: grid; gap: 4px; }
.build-item { display: grid; grid-template-columns: 40px 1fr auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; padding: 6px 8px; border: 1px solid transparent; background: transparent; color: var(--ink); }
.build-item canvas { grid-row: span 2; }
.bi-name { font-size: 17px; font-weight: 700; }
.bi-meta { font-size: 13px; color: var(--ink-2); font-weight: 600; grid-column: 2; }
.bi-cost { grid-row: 1 / span 2; grid-column: 3; font-weight: 800; font-size: 17px; }
.build-item:hover:not(:disabled), .build-item:focus-visible { background: var(--paper-2); border-color: #c9bb9c; }
.build-item:disabled { opacity: 0.4; cursor: not-allowed; }
.turn-card { width: min(380px, 100%); text-align: center; background: var(--paper); color: var(--ink); border-radius: 10px; padding: 22px 20px 20px; border-top: 10px solid var(--seat); box-shadow: 0 3px 0 #b9ab8e, 0 20px 50px rgba(0,0,0,0.6); }
.turn-card .eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.turn-card h2 { margin: 6px 0 4px; font: 400 32px/1.05 var(--display); text-wrap: balance; }
.turn-card p { margin: 0 0 16px; color: var(--ink-2); }
.turn-card .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.field { display: grid; gap: 4px; margin-bottom: 10px; text-align: left; }
.field span { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.field input { font: 600 17px var(--ui); padding: 9px 10px; border-radius: 6px; border: 1px solid #b9ab8e; background: #fbf7ee; color: var(--ink); }
.dark-btn { padding: 10px 14px; border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 30; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 8px; border: 1px solid #5a4636; }

@media (max-width: 860px) {
  .app { height: auto; min-height: 100%; }
  .stage { grid-template-columns: 1fr; }
  .board-wrap { place-items: start center; }
  .panel { overflow: visible; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Home, join and lobby screens */
.screen { min-height: 100%; padding: 32px 16px 48px; display: grid; justify-items: center; align-content: start; gap: 18px; }
.screen-inner { width: min(720px, 100%); display: grid; gap: 16px; }
.hero { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.hero h1 { margin: 0; font: 400 clamp(34px, 6vw, 52px)/1 var(--display); color: var(--brass); }
.hero p { margin: 0; color: #b9a78f; font-size: 17px; }
.card h3 { margin: 0 0 6px; font: 400 22px/1.1 var(--display); color: var(--ink); }
.card p { margin: 0 0 10px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.form-row .field { flex: 1 1 180px; margin: 0; }
.field select { font: 600 17px var(--ui); padding: 9px 10px; border-radius: 6px; border: 1px solid #b9ab8e; background: #fbf7ee; color: var(--ink); }
.matches { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.match-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 12px; background: var(--paper-2); border-radius: 6px; }
.match-row .mr-title { font-weight: 800; font-size: 17px; }
.match-row .mr-sub { color: var(--ink-2); font-size: 14px; }
.match-row .mr-actions { grid-row: span 2; display: flex; gap: 6px; align-items: center; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 700; background: #d8ccb1; color: var(--ink); }
.pill.go { background: #e7b552; color: var(--brass-ink); }
.pill.done { background: #c9c1b0; color: var(--ink-2); }
a.dark-btn, a.btn-primary { display: inline-block; text-decoration: none; border-radius: 8px; font: 700 16px/1 var(--ui); }
.linkbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.linkbox code { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; font: 600 14px/1.3 ui-monospace, Consolas, monospace; background: #fbf7ee; border: 1px solid #c9bb9c; border-radius: 6px; padding: 8px 10px; color: var(--ink); }
.seat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.seat-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--paper-2); border-radius: 6px; flex-wrap: wrap; }
.seat-list .sl-name { font-weight: 700; flex: 1 1 auto; }
.seat-list .open { color: var(--ink-2); font-style: italic; font-weight: 600; }
.note { font-size: 14px; color: var(--ink-2); }
.empty { color: var(--ink-2); font-size: 15px; padding: 6px 0; }
.waiting { color: #b9a78f; font-size: 15px; }
.you-tag { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; background: var(--ink); color: var(--paper); border-radius: 4px; padding: 2px 6px; }
.btn-primary:disabled, .dark-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.seat .rekey { grid-column: 2; justify-self: start; margin-top: 2px; }

/* Commanders */
.powerbox { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 6px; border: 1px solid rgba(239,230,210,0.25); border-radius: 10px; }
.pb-text { line-height: 1.1; min-width: 92px; }
.pb-text small { display: block; color: #b9a78f; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.pb-text b { font-size: 16px; }
.meter { display: flex; gap: 2px; margin-top: 3px; }
.meter i { width: 11px; height: 11px; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); background: rgba(239,230,210,0.22); position: relative; overflow: hidden; }
.meter i::after { content: ''; position: absolute; inset: 0; width: var(--f, 0%); background: var(--brass); }
.meter i.big { width: 14px; height: 14px; }
.pbtn { padding: 8px 10px; font-size: 15px; }
.pbtn:disabled { opacity: 0.35; cursor: not-allowed; }
.pbtn.ready { border-color: #f0c372; color: #ffd78a; box-shadow: 0 0 0 2px rgba(220,165,74,0.35); }
.pbtn.on { background: var(--brass); color: var(--brass-ink); border-color: #f0c372; opacity: 1; }
.weather { padding: 6px 10px; border-radius: 999px; background: #c9a35b; color: var(--brass-ink); font-weight: 800; font-size: 14px; }
.weather[data-type="rain"] { background: #7fa6c4; color: #10202c; }
.co-list { display: grid; gap: 10px; }
.co-row { display: grid; grid-template-columns: 34px 1fr; gap: 2px 10px; align-items: start; }
.co-row canvas { grid-row: span 3; }
.co-row .co-title { font-weight: 800; font-size: 16px; }
.co-row .co-title span { font-weight: 600; color: var(--ink-2); font-size: 13px; }
.co-row p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.3; }
.co-row p b { color: var(--ink); }
.co-row .badge { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; background: var(--ink); color: #ffd36b; font-size: 12px; font-weight: 800; }
.co-guide { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.co-guide .co-row { background: var(--paper-2); border-radius: 6px; padding: 8px 10px; }
.commanders-sheet { width: min(840px, 100%); }
.commanders-sheet .sheet-head .muted { margin-top: 4px; }
.commanders-sheet .note { margin: 0 0 14px; }
.co-pick { font: 600 15px var(--ui); padding: 6px 8px; border-radius: 6px; border: 1px solid #b9ab8e; background: #fbf7ee; color: var(--ink); max-width: 100%; }
.seat-co { color: var(--ink-2); font-size: 14px; font-weight: 600; }
.hs-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.splash { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 25; display: flex; gap: 14px; align-items: center; padding: 14px 20px; background: var(--paper); color: var(--ink); border-radius: 10px; border-left: 10px solid var(--seat, var(--brass)); box-shadow: 0 3px 0 #b9ab8e, 0 20px 50px rgba(0,0,0,0.6); max-width: calc(100% - 32px); animation: splash-in 0.25s ease-out; }
.splash small { text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; color: var(--ink-2); font-size: 12px; }
.splash h2 { margin: 2px 0; font: 400 30px/1 var(--display); }
.splash p { margin: 0; color: var(--ink-2); font-size: 15px; }
@keyframes splash-in { from { transform: translate(-50%, -10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .splash { animation: none; } }
.card .meter i { background: #cdbf9f; }
.card .meter i::after { background: #b07a1c; }
@media (max-width: 1280px) { .brand span { display: none; } }
.uc-name { min-width: 0; }
.atkdef { margin: 0 0 0 auto; display: grid; gap: 2px; text-align: right; }
.atkdef div { display: flex; gap: 8px; justify-content: flex-end; align-items: baseline; }
.atkdef dt { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-2); }
.atkdef dd { margin: 0; font-weight: 800; font-size: 17px; min-width: 48px; }
.up { color: #2f7a3a; }
.down { color: #b23d29; }

/* Bar right above the map with End turn */
.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; overflow: hidden; }
.board-bar { flex: none; }
.board-scroll { flex: 1 1 auto; min-height: 0; width: 100%; overflow: auto; display: flex; justify-content: safe center; align-items: safe center; overscroll-behavior: contain; cursor: grab; touch-action: none; user-select: none; overflow-anchor: none; }
.board-scroll .board-frame { flex: none; margin: auto; }
.board-scroll.panning, .board-scroll.panning canvas { cursor: grabbing; }
.zoom { display: inline-flex; border: 1px solid rgba(239,230,210,0.35); border-radius: 8px; overflow: hidden; }
.zoom .btn { border: none; border-radius: 0; padding: 9px 12px; }
.zbtn { font-size: 20px; line-height: 0.8; min-width: 40px; }
.zlabel { font-size: 14px; min-width: 64px; border-left: 1px solid rgba(239,230,210,0.25) !important; border-right: 1px solid rgba(239,230,210,0.25) !important; font-variant-numeric: tabular-nums; }
.board-bar { display: flex; align-items: center; gap: 10px; max-width: 100%; }
.bb-turn { margin-right: auto; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; min-width: 0; }
.bb-turn .swatch { width: 18px; height: 18px; }
.bb-turn small { color: #b9a78f; font-weight: 600; font-size: 14px; }
#endTurn { padding: 12px 22px; font-size: 18px; }
#endTurn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
@media (max-width: 860px) { .board-scroll { max-height: 75vh; } }

.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; color: var(--ink); cursor: pointer; padding: 8px 0; }
.check input { width: 18px; height: 18px; accent-color: #b07a1c; }

.opt-row { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.tagbox { display: inline-flex; align-items: center; gap: 8px; padding-left: 10px; margin-left: 2px; border-left: 1px solid rgba(239,230,210,0.25); }
.tagbox .pb-text { min-width: 70px; }
.replay { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.rbtn { padding: 8px 10px; min-width: 36px; font-size: 16px; }
.rp-label { color: #d9cbb4; font-weight: 700; font-size: 14px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.team-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px; font-size: 12px; font-weight: 800; background: var(--ink); color: var(--paper); vertical-align: 2px; }
.co2-row { margin-top: 4px; }

.swatch[data-shape="tri"] { clip-path: polygon(50% 4%, 98% 92%, 2% 92%); border: none; box-shadow: none; }
.swatch[data-shape="hex"] { clip-path: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0 50%); border: none; box-shadow: none; }
.army-pick { font: 600 15px var(--ui); padding: 6px 8px; border-radius: 6px; border: 1px solid #b9ab8e; background: #fbf7ee; color: var(--ink); }
.hs-row.hs-3 { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.4fr); }
.hs-row .field { min-width: 0; }
.hs-row input, .hs-row select { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; }
@media (max-width: 520px) {
  .hs-row.hs-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .hs-row.hs-3 .field:last-child { grid-column: 1 / -1; }
}
#nmForm { box-sizing: border-box; width: 100%; }
#nmNames { display: grid; gap: 8px; margin-bottom: 12px; }
#hotSeat { scroll-margin-top: 16px; }
.form-row .mode-first { flex-basis: 100%; }
.setup-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
#createSetup { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; width: 100%; }
.setup-fields[hidden] { display: none !important; }
#nmSetup { width: 100%; text-align: left; }
#nmModeNote { text-align: left; }

/* Damage chart */
/* Reference cards share the game's terrain and unit art. */
#referenceSheet { z-index: 35; }
.reference-sheet { width: min(1000px, 100%); max-height: calc(100vh - 64px); box-sizing: border-box; display: flex; flex-direction: column; overflow: hidden; }
.reference-sheet .sheet-head, .reference-controls { flex-shrink: 0; }
.reference-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.reference-controls .field { flex: 1; min-width: 170px; }
.reference-controls [aria-pressed="true"] { background: var(--brass); }
.reference-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 20px; flex: 1; min-height: 0; }
#referenceList { display: flex; flex-direction: column; gap: 4px; min-height: 0; overflow: auto; }
#referenceDetail { min-height: 0; overflow: auto; padding-right: 5px; }
.reference-choice { text-align: left; padding: 9px 10px; color: var(--ink); border: 1px solid transparent; border-radius: 5px; background: var(--paper-2); font: 600 15px var(--ui); cursor: pointer; }
.reference-choice[aria-pressed="true"] { background: var(--brass); border-color: #9d752f; }
.reference-identity { display: flex; gap: 16px; align-items: center; }
.reference-identity canvas { flex: 0 0 72px; border-radius: 4px; image-rendering: pixelated; }
.reference-identity h3 { margin: 2px 0; font: 400 25px var(--display); }
.reference-identity p { margin: 2px 0; }
.reference-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 16px 0; }
.reference-stats div { background: var(--paper-2); padding: 9px; border-radius: 5px; }
.reference-stats dt { font-size: 12px; color: var(--ink-2); }
.reference-stats dd { margin: 3px 0 0; font-weight: 700; font-size: 16px; }
#referenceDetail h4 { margin: 18px 0 6px; font-size: 17px; }
.reference-notes { margin: 6px 0 14px; padding-left: 20px; }
.reference-notes li { margin: 5px 0; }
.reference-matchup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.reference-matchups { list-style: none; padding: 0; margin: 0; }
.reference-matchups li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid #d3c6ac; }
.reference-matchups .linkish { text-align: left; font-size: 15px; }
.reference-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.reference-table th, .reference-table td { padding: 7px 8px; text-align: left; border-bottom: 1px solid #d3c6ac; }
.reference-table thead { background: var(--paper-2); }
.reference-table td { font-variant-numeric: tabular-nums; }
.reference-damage summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.reference-sources { font-size: 13px; color: var(--ink-2); margin-top: 18px; }
.reference-sources a { color: var(--ink); }
.info-reference { margin: 7px 0; }
@media (max-width: 650px) {
  .reference-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 12px; }
  #referenceList { flex-direction: row; overflow-x: auto; max-height: none; }
  .reference-choice { flex: 0 0 auto; }
  .reference-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reference-matchup-grid { grid-template-columns: 1fr; gap: 0; }
  .reference-table th, .reference-table td { padding: 6px 3px; }
}
.chart-sheet { width: min(1180px, 100%); }
.chart-sheet .muted { margin-top: 4px; }
.chart-scroll { overflow: auto; max-height: min(62vh, 640px); border: 1px solid #c9bb9c; border-radius: 6px; background: #f6efdf; }
table.dmg { border-collapse: separate; border-spacing: 0; font: 600 13px/1 var(--ui); font-variant-numeric: tabular-nums; }
table.dmg th, table.dmg td { padding: 0; text-align: center; border-right: 1px solid rgba(36,26,19,0.08); border-bottom: 1px solid rgba(36,26,19,0.08); }
table.dmg thead th { position: sticky; top: 0; z-index: 2; background: var(--paper-2); padding: 4px 1px 3px; min-width: 34px; vertical-align: bottom; }
table.dmg thead th .ab { display: block; font: 700 10px/1 var(--ui); letter-spacing: 0.04em; color: var(--ink-2); margin-top: 2px; }
table.dmg tbody th { position: sticky; left: 0; z-index: 1; background: var(--paper-2); text-align: left; padding: 2px 8px 2px 4px; white-space: nowrap; font-weight: 700; }
table.dmg tbody th canvas { vertical-align: middle; margin-right: 4px; }
table.dmg thead th.corner { left: 0; z-index: 3; text-align: left; padding-left: 8px; font: 700 10px/1.2 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
table.dmg td { height: 28px; min-width: 34px; color: var(--ink); cursor: default; }
table.dmg td.none { color: rgba(36,26,19,0.22); }
table.dmg td.hot { color: #fff8ea; }
table.dmg td.mg { font-style: italic; box-shadow: inset 0 -3px 0 rgba(36,26,19,0.35); }
table.dmg .hl-row th, table.dmg th.hl-col { background: #d8c49b; }
table.dmg td.hl { outline: 1px solid rgba(36,26,19,0.25); outline-offset: -1px; }
table.dmg td.cur { outline: 2px solid var(--ink); outline-offset: -2px; }
table.dmg tr.mine th { box-shadow: inset 3px 0 0 var(--ink); }
.chart-info { min-height: 1.3em; margin: 8px 2px 4px; font-weight: 600; }
.chart-foot { font-size: 13px; color: var(--ink-2); }
.chart-foot p { margin: 4px 0; }
.chart-foot .key { display: inline-block; min-width: 26px; padding: 1px 4px; text-align: center; border-radius: 3px; background: rgba(178,58,38,0.45); color: var(--ink); font-weight: 700; }
.chart-foot .key-mg { font-style: italic; box-shadow: inset 0 -3px 0 rgba(36,26,19,0.35); }
.chart-source a { color: var(--ink); font-weight: 700; }
.match-options { margin: 10px 0; }
.match-options summary { cursor: pointer; font-weight: 700; }
.match-option { margin-top: 8px; }
.match-option .note { margin: 2px 0 0; }
