/* Levyhold client: a lantern-lit levy roll. Peat-dark panels in pixel frames (static/ui-art), brass gold kept for the unit acting, the
   thing selected and the one main action on a screen. Dark by default; data-theme="light" swaps the colour tokens and the frames only.
   Sizes come from the tokens below and clamp(); the page never scrolls, only the lists inside a panel do (.scroll).
   Layout steps repeat data/ui.yaml ui.client (tests/test_client_breakpoints.py checks them): phone at or under bp_phone_w 900, the narrower
   columns at or under bp_desktop_w 1600, big screens from bp_xl_w 2200, short screens at or under bp_short_h 500. */
:root {
  color-scheme: dark;
  --bg: #100c0b; --panel: #201814; --panel2: #30251d; --band: #171210; --ink: #efe8dc; --dim: #b9ad9d; --line: #857a6c;
  --steel: #33404e; --steel-hi: #475769; --steel-rim: #9eabb9; --banner: #7c1d22; --banner-ink: #f8ecd6; --grain: rgba(255, 220, 170, 0.035);
  --gold: #e3b04a; --gold-ink: #1a1400; --track: #0c0a0e; --bad: #ff8f85; --good: #7fd49a; --foe: #d0644f; --amber: #e8a33a;
  --hp: #6cc47e; --shield: #9fb8d8; --meter: #e3b04a; --buff: #6fa8e8; --debuff: #ff8f85;
  --co-wardens: #5b8fd0; --co-reivers: #e0645a; --co-fenfolk: #5fae6a; --co-foundry: #e08a35; --co-chapel: #ece6d0; --co-other: #9aa2ad; --chip-ink: #14161a; --chapel-ink: #14161a;
  --ch-mire: #a3b24a; --ch-orchard: #d9662b;
  --rar-common: #9aa2ad; --rar-fine: #6fc28a; --rar-rare: #6fa8e8; --rar-heroic: #c99ae8;
  --bevel-hi: rgba(255, 255, 255, 0.07); --bevel-lo: rgba(0, 0, 0, 0.45); --veil: rgba(8, 6, 10, 0.72);
  --plate: rgba(12, 10, 14, 0.8); --plate-ink: #f4efe4; --plate-hi: #ffd76a; --spr-edge: rgba(239, 232, 220, 0.55);
  --sky-top: #191620; --sky-low: #2a2430;
  --foe-rim: rgba(255, 228, 206, 0.9); --spr-dark: rgba(8, 6, 10, 0.85);
  --frame: url("/static/ui-art/frame_dark.png"); --frame-tile: url("/static/ui-art/frame_tile_dark.png");
  --tap: 36px; --px: 2px;
  --fs: clamp(14px, 0.35vw + 0.35vh + 6px, 17px);
  --fs-xs: 0.8rem; --fs-sm: 0.9rem; --fs-lg: 1.15rem; --fs-xl: 1.4rem; --fs-2xl: 1.8rem;
  --sp-1: 4px; --sp-2: 6px; --sp-3: 10px; --sp-4: 14px; --sp-5: 20px;
  --gap: clamp(6px, 0.8vw, 14px); --pad: clamp(10px, 1vw, 20px);
  --r: 2px; --r-pill: 999px; --bw: 2px;
  --z-label: 1; --z-tip: 4; --z-modal: 5;
  --sprite: 48px; --sprite-step: 16px; --evt: 420ms;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e2d3b5; --panel: #f5ebd6; --panel2: #e9dcc0; --band: #dbcaa8; --ink: #231e18; --dim: #4f463a; --line: #6c6152;
  --steel: #c5ced8; --steel-hi: #dfe5ec; --steel-rim: #5a6878; --banner: #7c1d22; --banner-ink: #fbf1df; --grain: rgba(90, 60, 20, 0.05);
  --gold: #8a6200; --gold-ink: #ffffff; --track: #cfc3a6; --bad: #a0281c; --good: #1a6a35; --foe: #a63a2b; --amber: #8f5a00;
  --hp: #237a36; --shield: #3e6390; --meter: #8a6200; --buff: #2e5f9e; --debuff: #a0281c;
  --co-wardens: #2e5f9e; --co-reivers: #a6322a; --co-fenfolk: #2f7a3c; --co-foundry: #a85a12; --co-chapel: #c9b571; --co-other: #6b7380; --chip-ink: #ffffff; --chapel-ink: #1d1f26;
  --ch-mire: #5d6a1c; --ch-orchard: #a3431a;
  --rar-common: #5f6670; --rar-fine: #2f7a3c; --rar-rare: #2e5f9e; --rar-heroic: #6e3a9e;
  --bevel-hi: rgba(255, 255, 255, 0.5); --bevel-lo: rgba(60, 40, 10, 0.25); --veil: rgba(40, 30, 15, 0.45);
  --plate: rgba(12, 10, 14, 0.8); --plate-ink: #f4efe4; --plate-hi: #ffd76a; --spr-edge: rgba(239, 232, 220, 0.55);
  --sky-top: #d8ccb0; --sky-low: #efe6d2;
  --foe-rim: rgba(255, 228, 206, 0.9); --spr-dark: rgba(8, 6, 10, 0.85);
  --frame: url("/static/ui-art/frame_light.png"); --frame-tile: url("/static/ui-art/frame_tile_light.png");
}
/* The engine kit (/tenshin_kit.css: the windows' structure, the key legend, Settings rows, ask() boxes) reads these. They name the
   tokens above, so each theme carries its own. Danger is --bad: light red in the dark theme and deep red in the light one, so its
   ink is the gold's ink, dark on the first and white on the second. */
:root {
  --tn-bg: var(--bg); --tn-panel: var(--panel); --tn-ink: var(--ink); --tn-muted: var(--dim); --tn-edge: var(--line);
  --tn-accent: var(--gold); --tn-on-accent: var(--gold-ink); --tn-danger: var(--bad); --tn-on-danger: var(--gold-ink); --tn-good: var(--good);
  --tn-font: system-ui, -apple-system, "Segoe UI", sans-serif; --tn-font-ui: var(--tn-font); --tn-radius: var(--r);
}

/* The map palette per chapter (data/chapters.yaml colour: peat brown and reed green for the Mire Road, ash and ember for the Burnt
   Orchard). world.js reads these off the canvas, one token per legend name (--t-<name>); the map key in the side panel paints its
   swatches from the same tokens. The map is a lit scene, so it keeps one palette in both themes. */
#map, .legend {
  --t-ground: #6b6a3e; --t-mud: #5b4a32; --t-reeds: #6e7d33; --t-reeds-hi: #9aae4a; --t-water: #2c3b38; --t-water-hi: #4d6660;
  --t-ford: #4e5a4a; --t-planks: #7a5a36; --t-planks-line: #4f3a22; --t-stone: #77756b; --t-wall: #2a2620; --t-wall-face: #1a1713;
  --t-sluice: #5f6b66; --t-spoil-heap: #4a3f2c; --t-dredger-hulk: #3b2f27; --t-reed-thicket: #445220;
  --t-ash: #6f6a64; --t-cinders: #4f4440; --t-burnt-tree: #2b211d; --t-orchard-row: #3f4a25; --t-kiln-brick: #8a4a32;
  --t-steps: #8b8378; --t-cliff: #3a332e; --t-cart-lane: #7d6a52; --t-ditch: #2e2a2a;
  --t-bell: #b08a3e; --t-pews: #5a3f28; --t-rubble: #6a645c;
  --t-keep-stone: #6d6b5c; --t-portcullis: #2f2b26; --t-ramparts: #575447; --t-siege-works: #7a5b3a;
  --t-barrow-mound: #4f5a36; --t-bone-scree: #c2b9a0; --t-standing-stone: #8d8a80; --t-crown: #c9a23e;
  --t-outline: #14110e;
  --t-shade: rgba(0, 0, 0, 0.07); --t-shadow: rgba(0, 0, 0, 0.35); --t-foe: #b8c45a; --t-label: #f4f1e6; --t-path: rgba(224, 180, 58, 0.55);
  --t-ring-easy: #7fd49a; --t-ring-close: #e8a33a; --t-ring-hard: #ff6b5e; --t-shut: #8a8f96; --t-pole: #3a2a1c;
  --t-mote: #f2e6a8; --t-vignette: rgba(6, 4, 3, 0.95); --t-threat: rgba(10, 4, 6, 0.9);
  --t-dust: #d8c9a0;
}
#map[data-chapter="orchard"] { --t-foe: #e0874a; --t-wall: #1e1714; --t-mote: #ffb36b; }
/* the Hill's chalk ground: lighter than its grass (--t-reeds), so the two read apart by tone and not by texture alone */
#map[data-chapter="hill"], .legend[data-chapter="hill"] { --t-ground: #958e70; }
/* the battle ground: the chapter's own floor tile at whole pixels, under three layers drawn in code: a far ridge on the horizon
   (--bd-far), a haze over the back of the floor (--bd-fog) so the front rank reads nearer, and a dark lip along the front (--bd-near) */
.stage { --ground: url("/static/art/tiles/mire_floor_a.png"); --bd-far: #2f3a1e; --bd-fog: rgba(20, 24, 12, 0.55); --bd-near: rgba(10, 8, 6, 0.5); }
.stage[data-chapter="orchard"] { --ground: url("/static/art/tiles/orchard_floor_a.png"); --sky-low: #33241f; --bd-far: #3a1f17; --bd-fog: rgba(36, 16, 10, 0.55); }
.stage[data-chapter="ford"] { --ground: url("/static/art/tiles/ford_floor_a.png"); --sky-low: #22303a; --bd-far: #1c2a33; --bd-fog: rgba(12, 20, 28, 0.55); }
.stage[data-chapter="abbey"] { --ground: url("/static/art/tiles/abbey_floor_a.png"); --sky-low: #2a2832; --bd-far: #24212b; --bd-fog: rgba(18, 16, 24, 0.55); }
.stage[data-chapter="keep"] { --ground: url("/static/art/tiles/keep_floor_a.png"); --sky-low: #262a20; --bd-far: #1f2419; --bd-fog: rgba(16, 18, 12, 0.55); }
.stage[data-chapter="hill"] { --ground: url("/static/art/tiles/hill_floor_a.png"); --sky-low: #2c2622; --bd-far: #2a2119; --bd-fog: rgba(22, 16, 12, 0.55); }
:root[data-theme="light"] .stage[data-chapter] { --sky-low: #efe6d2; }

* { box-sizing: border-box; }
html { font-size: var(--fs); }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 1rem/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font: inherit; color: inherit; }
img { image-rendering: pixelated; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.dim { color: var(--dim); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

#app { height: 100dvh; display: grid; padding: var(--gap); gap: var(--gap);
  padding: max(var(--gap), env(safe-area-inset-top)) max(var(--gap), env(safe-area-inset-right)) max(var(--gap), env(safe-area-inset-bottom)) max(var(--gap), env(safe-area-inset-left));
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "top" "coach" "mid"; }
/* the coach has its own full-width row under the top bar in both views, so Next sits in one place whether the map or a battle shows;
   while it is hidden the row is empty and only the grid gap remains */

/* ---- the action bar and its windows (windows.js on the engine's core/actbar.mjs and dragwin) ----------------------------------
   The map or the battle fills the window under the top bar. On the walk view the action bar takes one row under the map; each of
   its icons opens a window over the map. A window sits in the map's grid area where its own CSS puts it below, and dragwin moves
   it from there by `translate` and remembers the place. At or under 900 px (ui.client bp_phone_w) a window is the kit's bottom
   sheet (.tn-window.tn-sheet) on the bar, one at a time. A battle takes the whole screen, so the bar and the windows step away. */
:root { --team-w: clamp(240px, 19vw, 340px); --side-w: clamp(300px, 24vw, 440px); }
@media (max-width: 1600px) { :root { --side-w: clamp(280px, 27vw, 400px); } }
body[data-view="walk"] #app { grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: "top" "coach" "mid" "bar"; }
body:not(.live)[data-view="battle"] :is(.win-pane, #actbar) { display: none; }

/* the kit's .tn-actbar, in its own grid row under the map rather than fixed over it */
#actbar { position: static; grid-area: bar; justify-self: center; translate: none; --tn-actbar-icon: 40px; }

.win-pane { grid-area: mid; align-self: start; justify-self: end; margin: var(--gap);
  width: var(--side-w); max-width: calc(100% - var(--gap) * 2); max-height: calc(100% - var(--gap) * 2); padding: 0; gap: 0; overflow: hidden;
  --tn-window-z: calc(var(--z-label) + 1); }
.win-bar { display: flex; align-items: center; gap: var(--sp-2); flex: none; cursor: grab; touch-action: none; user-select: none; }
.win-bar h2 { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.dw-grabbing, body.dw-grabbing .win-bar { cursor: grabbing; }
.dw-ease { transition: translate var(--dw-ease, 140ms) ease-out; }
.win-x { flex: none; margin-right: var(--sp-1); }
.win-body { flex: 1 1 auto; min-height: 0; padding: var(--gap); overflow: hidden; }
.win-body > .scroll, .win-body > .hall { flex: 1 1 auto; min-height: 0; }
.lv-body { display: flex; flex-direction: column; gap: var(--gap); font: 1rem/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; }

/* where each window first opens: Team top left; Area, Hunts and Camp top right, a step apart; Levy Hall, Modes and the Board spread
   over the map beside Team; Help and Settings over the bar's middle */
#team-panel { justify-self: start; width: var(--team-w); height: min(calc(100% - var(--gap) * 2), 46em); }
#area-panel, #hunts-panel, #camp-panel { height: calc(100% - var(--gap) * 2); }
#hunts-panel { margin-right: calc(var(--gap) + var(--tap)); margin-top: calc(var(--gap) + var(--tap)); }
#camp-panel { margin-right: calc(var(--gap) + var(--tap) * 2); margin-top: calc(var(--gap) + var(--tap) * 2); }
:is(#hall-panel, #modes-panel, #board-panel) { width: min(calc(100% - var(--team-w) - var(--gap) * 3), 1400px); height: calc(100% - var(--gap) * 2); }
:is(#help-panel, #settings-panel) { align-self: end; justify-self: center; width: min(30em, calc(100% - var(--gap) * 2)); }

@media (max-width: 900px) {
  /* the sheet keeps the height it had and shows at once, without the kit's slide; ten buttons wrap to a second row (kit) */
  .win-pane, #team-panel, :is(#hall-panel, #modes-panel, #board-panel) { height: 60vh; }
  :is(#help-panel, #settings-panel) { height: auto; }
  .win-pane.tn-sheet { animation: none; }
  #actbar .tn-actbar-btn { min-width: var(--tap); padding-inline: 2px; }      /* the tap floor, as before: seven fit one row */
  .win-bar { cursor: default; }
}
/* laptops: the brand goes and the resource names are kept for screen readers only, so the stats and the studio nav fit one row */
@media (max-width: 1400px) {
  .brand { display: none; }
  .stat .k { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
/* the panel inset in plain steps (the design checker reads only plain lengths): 12px, then 16px on wide screens, 20px on big ones */
@media (min-width: 1601px) { .panel { padding: 16px; } }
@media (min-width: 2200px) { :root { --px: 3px; --fs: clamp(17px, 0.35vw + 0.35vh + 6px, 21px); } .panel { padding: 20px; } }

/* ---- pixel frames: a dark rim, a brass bevel lit from the top left, an inner line; the middle is the panel colour ---------------- */
.panel, #top, .coach, .endpanel, .inspect {
  border: calc(var(--px) * 4) solid var(--line); border-image: var(--frame) 4 / calc(var(--px) * 4) stretch;
  background: repeating-linear-gradient(118deg, var(--grain) 0 2px, transparent 2px 9px), var(--panel); background-clip: padding-box; image-rendering: pixelated; }
/* the top bar is a steel band; the area and the purse sit on it as leather tags */
#top { background: linear-gradient(to bottom, var(--steel-hi), var(--steel)); background-clip: padding-box; }

/* ---- top bar: where you are, what you hold, the help and the studio nav ---------------------------------------------------------- */
#top { grid-area: top; display: flex; align-items: center; gap: var(--gap); flex-wrap: nowrap; min-height: calc(var(--tap) + var(--px) * 8);
  padding: var(--sp-1) var(--pad); }
.brand { font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; font-size: var(--fs-sm); color: var(--gold); }
.stats { display: flex; gap: var(--sp-2); align-items: center; flex: none; }
.stat { display: inline-flex; gap: var(--sp-2); align-items: center; white-space: nowrap; padding: 6px 12px;
  background: var(--band); border: var(--bw) solid var(--panel2); border-radius: var(--r); min-height: calc(var(--tap) - var(--sp-1)); }
.stat .k { color: var(--dim); font-size: var(--fs-sm); }
.stat b { font-size: var(--fs-lg); }
.stat.where b { font-size: var(--fs-lg); color: var(--ink); }
.ico { width: max(16px, calc(var(--px) * 8)); height: max(16px, calc(var(--px) * 8)); flex: none; image-rendering: pixelated; display: block; }
.ico-sm { width: 16px; height: 16px; }
#tn-nav-host { flex: none; }
#help { margin-left: auto; }
progress { appearance: none; width: 100%; height: 6px; border: 1px solid var(--bevel-lo); border-radius: 0; background: var(--track); overflow: hidden; display: block; }
progress::-webkit-progress-bar { background: var(--track); }
progress::-webkit-progress-value { background: var(--gold); }
progress::-moz-progress-bar { background: var(--gold); }

/* ---- panels ------------------------------------------------------------------------------------------------------------------- */
.panel { padding: 12px; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
.panel h2 { margin: 0; font-size: var(--fs-lg); display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
  padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-3); background: var(--banner-face, var(--banner)); color: var(--banner-text, var(--banner-ink));
  border-bottom: var(--bw) solid var(--gold);
  background-image: var(--banner-art, none); background-repeat: no-repeat; background-position: left var(--sp-1) center;
  background-size: 48px; }
.intro { margin: 0; color: var(--dim); font-size: var(--fs-sm); }
.scroll { overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.sec { display: flex; flex-direction: column; gap: var(--gap); min-height: 0; flex: 1 1 0; }
#team-panel .lv-body { container: team / size; }
#team-panel .cards { flex: 1 1 0; min-height: 0; }      /* the cards take what the Bonuses list (up to 40%, 25% on a short screen) leaves, and scroll */
.sub-h { margin: 0; font-size: var(--fs-sm); color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.bonuses { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-1); align-content: start; flex: 0 1 auto; max-height: 40%; font-size: var(--fs-sm); }
.bonus { padding: var(--sp-1) var(--sp-3); border: var(--bw) solid var(--line); border-radius: var(--r); background: var(--band); }
/* a bonus one hero away has a dimmed edge and says so in words */
.bonus.near { border-color: var(--panel2); color: var(--dim); background: transparent; }
.mid { grid-area: mid; }

/* ---- buttons: a raised slab, pressed in when chosen -------------------------------------------------------------------------- */
.btn { min-height: var(--tap); padding: 0 var(--sp-4); border: var(--bw) solid var(--steel-rim); border-radius: var(--r);
  background: linear-gradient(to bottom, var(--steel-hi), var(--steel));
  box-shadow: inset 0 var(--bw) 0 var(--bevel-hi), inset 0 calc(var(--bw) * -2) 0 var(--bevel-lo);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.btn:hover { border-color: var(--gold); }
.btn:active { box-shadow: inset 0 var(--bw) 0 var(--bevel-lo); }
.btn[aria-pressed="true"] { border-color: var(--gold); background: var(--banner); color: var(--banner-ink); box-shadow: inset 0 0 0 var(--bw) var(--gold); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-main { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 800; }
.btn-main:hover { border-color: var(--ink); }
.btn-small { padding: 0 var(--sp-3); }
a.btn { text-decoration: none; color: var(--ink); }
.group { display: inline-flex; gap: var(--sp-1); align-items: center; }
.line { min-height: 1.4em; font-size: var(--fs-sm); }
.line.bad { color: var(--bad); }
#line:empty { position: absolute; }               /* an empty status line leaves no band under the map; it stays an aria-live region */
.kv { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-1); }
.kv li { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); border-bottom: 1px solid var(--panel2); padding-bottom: 2px; }
.links { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.pointed { outline: 3px dashed var(--buff); outline-offset: 3px; }
/* the coach's pointer is a dashed blue outline; a selected tab is a solid gold edge, so the two never read as the same thing */

/* ---- hero cards: portrait first, faction-tinted plate, role badge, level and power ------------------------------------------- */
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
/* a card keeps its own height in a short list: the list scrolls, a card never squeezes into the one under it */
.cards > li { flex: none; }
.card { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0 var(--sp-3); align-items: center;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2); background: var(--panel2); border: var(--bw) solid var(--line); border-radius: var(--r);
  box-shadow: inset 0 var(--bw) 0 var(--bevel-hi); min-height: var(--tap); }
.card:first-child:not(.pick) { border-color: var(--gold); }
.chip { grid-row: 1 / span 2; position: relative; width: max(40px, calc(var(--px) * 22)); height: max(40px, calc(var(--px) * 22)); border-radius: var(--r); display: grid;
  place-items: center; font-weight: 800; font-size: var(--fs-sm); border: var(--bw) solid var(--bevel-lo); color: var(--chip-ink); overflow: hidden;
  box-shadow: inset 0 calc(var(--bw) * -4) 0 var(--bevel-lo); }
.co-wardens { background: var(--co-wardens); }
.co-reivers { background: var(--co-reivers); }
.co-fenfolk { background: var(--co-fenfolk); }
.co-foundry { background: var(--co-foundry); }
.co-chapel { background: var(--co-chapel); color: var(--chapel-ink); }
.co-other { background: var(--co-other); }
.ch-mire { background: var(--ch-mire); }
.ch-orchard { background: var(--ch-orchard); }
.card-name { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.card-sub { color: var(--dim); font-size: var(--fs-xs); grid-column: 2 / span 2; display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-1); min-width: 0; }
.card-where { font-size: var(--fs-sm); white-space: nowrap; display: inline-flex; align-items: center; gap: var(--sp-1); }
.chip .spr, .portrait .spr { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated;
  filter: drop-shadow(1px 0 0 var(--spr-edge)) drop-shadow(-1px 0 0 var(--spr-edge)) drop-shadow(0 -1px 0 var(--spr-edge)); }
/* the role badge sits on the portrait's corner; the faction crest beside the faction name */
.badge { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; image-rendering: pixelated; }
.lead-tag { font-size: var(--fs-xs); font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: 0.06em; }
.card.pick { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); padding: 0; border: 0; background: transparent; box-shadow: none; }
.cards.picking { gap: var(--sp-2); }
/* the hero keeps a readable width; Move up or a Swap button goes under it when the column is too narrow for both on one line */
.pick-toggle { flex: 999 1 12em; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 var(--sp-3); justify-content: stretch;
  align-content: center; text-align: left; padding: var(--sp-1) var(--sp-2); height: auto; }
.card.pick > .btn-small { flex: 1 1 auto; max-width: 100%; white-space: normal; text-align: center; }
.pick-toggle .card-sub { grid-column: 2; }

/* ---- walk view ------------------------------------------------------------------------------------------------------------------ */
.coach { grid-area: coach; display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-2) var(--sp-4);
  border-image: none; border: var(--bw) solid var(--buff); background: var(--panel2); }
/* the box grows with the step's text; it never scrolls or clips */
.coach-text { flex: 1; min-width: 0; font-size: var(--fs-sm); }
.coach-btns { display: flex; gap: var(--sp-2); flex: none; }
/* a phone battle docks a battle step as one line right above the skill bar (coach.js reads --coach-dock), so the card never takes
   the middle of the battle, the fighters' HP or the skills; More opens the whole text, which scrolls inside a capped box */
@media (max-width: 900px), (max-height: 500px) { #battle { --coach-dock: bar; } }
.coach[data-anchor="bar"] { grid-area: auto; flex: none; gap: var(--sp-2); padding: var(--sp-1) var(--sp-2); }
.coach[data-anchor="bar"]:not([data-more="1"]) .coach-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coach[data-anchor="bar"][data-more="1"] .coach-text { max-height: 4.5em; overflow-y: auto; }
.mapwrap { flex: 1 1 0; min-height: 0; position: relative; }
.maptitle { position: absolute; z-index: var(--z-label); top: var(--sp-2); left: calc(var(--sp-2) + var(--lv-l, 0px)); margin: 0; padding: 2px var(--sp-3); border-radius: var(--r);
  pointer-events: none; background: var(--plate); color: var(--plate-ink); border: 1px solid var(--bevel-lo); font-size: var(--fs-sm); font-weight: 700;
  max-width: calc(100% - var(--sp-4) - var(--lv-l, 0px) - var(--lv-r, 0px)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border: var(--bw) solid var(--bevel-lo); border-radius: 0;
  touch-action: none; cursor: pointer; background: var(--t-wall); }
/* the map holds focus for the arrow keys almost all the time: a quiet edge, not the gold ring a chosen control wears */
#map:focus-visible { outline: var(--bw) solid var(--line); outline-offset: 0; }
/* The map's Pixi stage (scene.js) lies on #map inside its border and lets every pointer through to it. */
.mapwrap > .scene { position: absolute; inset: var(--bw); pointer-events: none; }
.mapwrap > .scene canvas { display: block; width: 100%; height: 100%; }
.groups { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-1); align-content: start; flex: none; }
/* the ring key folds behind a "?" row, so the group list sits right under its heading */
.ring-help { flex: none; font-size: var(--fs-sm); }
.ring-help > summary { display: flex; align-items: center; gap: var(--sp-2); min-height: calc(var(--tap) - var(--sp-2)); cursor: pointer; list-style: none; color: var(--dim); }
.ring-help > summary::-webkit-details-marker { display: none; }
.ring-help > summary:hover { color: var(--ink); }
.ring-help .q { display: inline-grid; place-items: center; flex: none; width: 1.6em; height: 1.6em; font-weight: 800; color: var(--ink);
  border: var(--bw) solid var(--steel-rim); border-radius: 50%; background: var(--steel); }
.ring-help[open] .q { border-color: var(--gold); }
.ring-help > .intro { margin-top: var(--sp-1); }
.groups li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: var(--sp-2); align-items: center; padding: 2px var(--sp-3);
  border: var(--bw) solid var(--panel2); border-radius: var(--r); background: var(--band); }
.groups li.beaten { color: var(--dim); }
.groups li.hunt { border-color: var(--buff); }
.groups li.boss { border-color: var(--foe); font-weight: 700; }
/* a long group name takes a second line rather than an ellipsis ("Th..." for The Reed Chief at 1024 px, audit 2026-11-19 #7) */
.g-name { min-width: 0; overflow-wrap: break-word; }
.linkish { min-height: var(--tap); background: transparent; border: 0; padding: 0; text-align: left; cursor: pointer; text-decoration: underline;
  text-decoration-color: var(--line); text-underline-offset: 3px; }
.linkish:disabled { text-decoration: none; cursor: default; }

/* The battle wipe (world.js): a canvas over the whole page, drawn only while a touch opens a battle. */
.lv-wipe { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 2147483600; }
.lv-wipe[hidden] { display: none; }
/* while the party walks (world.js sets body[data-walking="1"] after ui.client walk_fade_delay_ms) the windows, the action bar and the
   top bar fade to --walk-fade-op, all but the area name and the coin; the pointer over one, a focus inside it, or the coach pointing into it
   brings that one back. The timings come from ui.client through identity.js. */
.win-pane, #actbar, #top > *, .topmenu > *, .stats > .stat, #tracker > *, #alerts { transition: opacity var(--walk-fade-ms, 0ms) ease-out; }
body[data-walking="1"][data-view="walk"] :is(.win-pane, #actbar, #top > :not(.stats, .topmenu), .topmenu > *, .stats > .stat:not(.where, [data-point="coin"]), #tracker > *, #alerts):not(:hover, :focus-within, .pointed, :has(.pointed)) {
  opacity: var(--walk-fade-op, 1); }
/* a hero standing under the minimap or the objectives box (world.js underHud): that box fades the same way, and comes back under the pointer */
#hud-right > * { transition: opacity var(--walk-fade-ms, 0ms) ease-out; }
body[data-under-hud="1"][data-view="walk"] #hud-right > :not(:hover, :focus-within, .pointed, :has(.pointed)) { opacity: var(--walk-fade-op, 1); }
/* ---- the map's HUD (UI round 0.6 part 2: WoW and Factorio; tracker.js, minimap.js) --------------------------------------------
   Over the map: the minimap and the objective tracker down its right edge, the zone text in its middle on entering an area, the
   alerts tray at its lower right. The leader's XP bar runs along the foot of the screen, in the page's bottom margin. */
.hud-right { position: absolute; z-index: var(--z-label); top: var(--sp-2); right: calc(var(--sp-2) + var(--lv-r, 0px)); width: clamp(13em, 28%, 19em);
  max-height: calc(100% - var(--tap) - var(--sp-5) - var(--sp-2)); display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-2);
  pointer-events: none; }
.hud-right > * { pointer-events: auto; }
.minimap { flex: none; line-height: 0; padding: var(--px); background: var(--plate); border: var(--bw) solid var(--steel-rim);
  box-shadow: inset 0 0 0 var(--px) var(--bevel-lo), 0 var(--bw) 0 var(--bevel-lo); }
#minimap { display: block; image-rendering: pixelated; cursor: pointer; }
.tracker { flex: 0 1 auto; min-height: 0; width: 100%; display: flex; flex-direction: column; color: var(--plate-ink);
  background: var(--plate); border: 1px solid var(--bevel-lo); border-left: calc(var(--px) * 2) solid var(--gold); }
.tracker-head { flex: none; display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: var(--tap); padding: 0 var(--sp-2);
  background: transparent; border: 0; color: var(--plate-hi); cursor: pointer; text-align: left; }
.tracker-head:hover .tracker-title { text-decoration: underline; text-underline-offset: 3px; }
.tracker-title { flex: none; font-family: var(--font-display); font-size: var(--fs-lg); line-height: 1; }
.tracker-sum { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--plate-ink); font-size: var(--fs-sm); }
.tracker-fold { flex: none; margin-left: auto; width: 0.5em; height: 0.5em; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tracker[data-open="1"] .tracker-sum { display: none; }
.tracker[data-open="1"] .tracker-fold { transform: rotate(-135deg); }
.tracker[data-open="0"] .tracker-body { display: none; }
.tracker-body { flex: 0 1 auto; padding: 0 var(--sp-2) var(--sp-2); display: grid; gap: 2px; align-content: start; }
.tracker-h { margin: var(--sp-1) 0 0; font-family: var(--font-display); font-weight: 400; font-size: 1.05rem; line-height: 1.15; color: var(--plate-hi); }
.tracker-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.obj, .obj > .goal { display: grid; grid-template-columns: 1.1em minmax(0, 1fr) auto; column-gap: var(--sp-1); align-items: baseline; font-size: var(--fs-sm); }
.obj > .goal { grid-column: 1 / -1; width: 100%; min-height: var(--tap); align-content: center; padding: 2px var(--sp-1) 2px 0; text-align: left; color: inherit;
  background: transparent; border: var(--bw) solid transparent; border-radius: var(--r); cursor: pointer; }
.obj > .goal:hover { border-color: var(--gold); }
.goal-text { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; line-height: 1.2; overflow-wrap: anywhere; }
.goal-eta { white-space: nowrap; color: var(--plate-ink); }
.obj.done { color: var(--dim); }
.obj.done .goal-text { text-decoration: line-through; text-decoration-color: var(--line); }
.tick { color: var(--good); font-weight: 800; text-align: center; }
/* zone text: the area's name in the display face, the chapter under it; tracker.js fades it with the Web Animations API */
.zone { position: absolute; inset: 0; z-index: var(--z-label); margin: auto; height: fit-content; display: grid; justify-items: center; gap: var(--sp-1);
  padding: 0 var(--sp-4); pointer-events: none; text-align: center; }
.zone-name { font-family: var(--font-display); font-size: clamp(2rem, 4vw + 1rem, 5rem); line-height: 1; color: var(--plate-hi);
  text-shadow: 0 var(--bw) 0 var(--spr-dark), 0 0 var(--sp-4) var(--spr-dark), var(--bw) 0 0 var(--spr-dark), calc(var(--bw) * -1) 0 0 var(--spr-dark); }
.zone-sub { font-size: var(--fs-lg); font-weight: 700; color: var(--plate-ink); text-shadow: 0 1px 0 var(--spr-dark), 0 0 var(--sp-3) var(--spr-dark); }
/* the alerts tray: a framed square for each thing waiting on the player, its count in the corner */
.alerts { position: absolute; z-index: var(--z-label); right: calc(var(--sp-2) + var(--lv-r, 0px)); bottom: var(--sp-2); margin: 0; padding: 0; list-style: none; display: flex; gap: var(--sp-1); }
.alert { position: relative; display: grid; place-items: center; width: calc(var(--tap) + var(--sp-1)); height: calc(var(--tap) + var(--sp-1)); padding: 0;
  background: linear-gradient(to bottom, var(--steel-hi), var(--steel)); border: var(--bw) solid var(--amber); border-radius: var(--r); cursor: pointer;
  box-shadow: inset 0 var(--bw) 0 var(--bevel-hi), inset 0 calc(var(--bw) * -2) 0 var(--bevel-lo), 0 var(--bw) 0 var(--spr-dark); }
.alert:hover { border-color: var(--gold); }
.alert-ico { width: 70%; height: 70%; object-fit: contain; image-rendering: pixelated; }
/* the leader's XP bar, in segments (--xp-segs from ui.client hud_xp_segments, through tracker.js) */
.xpline { position: fixed; z-index: var(--z-label); left: 0; right: 0; bottom: 0; height: max(6px, var(--gap)); padding: 1px max(var(--gap), env(safe-area-inset-left)); }
.xpline-bar { position: relative; height: 100%; border-color: var(--line); background: var(--band); }
.xpline-bar::-webkit-progress-bar { background: var(--band); }
.xpline-bar::-webkit-progress-value { background: var(--buff); }
.xpline-bar::-moz-progress-bar { background: var(--buff); }
.xpline::after { content: ""; position: absolute; inset: 1px max(var(--gap), env(safe-area-inset-left)); pointer-events: none;
  background: repeating-linear-gradient(to right, transparent 0 calc(100% / var(--xp-segs, 1) - 1px), var(--bevel-lo) calc(100% / var(--xp-segs, 1) - 1px) calc(100% / var(--xp-segs, 1))); }
/* a hotkey chip (.key, which frame.css may restyle) */
.key { display: inline-block; min-width: 1.3em; padding: 0 2px; font-size: var(--fs-xs); font-weight: 800; line-height: 1.2;
  text-align: center; color: var(--dim); background: var(--band); border: 1px solid var(--steel-rim); border-bottom-width: 2px; border-radius: var(--r); }
/* phones: no minimap; the tracker spans the map's top under the title and starts folded to one line */
@media (max-width: 900px), (max-height: 500px) {
  .minimap { display: none; }
  .hud-right { left: calc(var(--sp-2) + var(--lv-l, 0px)); width: auto; top: calc(var(--sp-2) * 2 + 1.4rem); max-height: calc(100% - var(--tap) * 2 - var(--sp-5)); }
  .zone-name { font-size: clamp(1.8rem, 9vw, 3rem); }
}

/* ---- inside the windows: travel picker, map key, hunts, Levy Hall ------------------------------------------------------------ */
.sec-body { display: flex; flex-direction: column; gap: var(--gap); flex: 1 1 0; }
.sec-body h2 { font-size: var(--fs-lg); color: var(--ink); background: none; border: 0; border-left: calc(var(--px) * 3) solid var(--banner);
  padding: 0 0 0 var(--sp-2); }
.areas, .hunts, .legend, .heroes { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-1); align-content: start; }
.areas li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--sp-2); align-items: center; padding: var(--sp-1) var(--sp-3);
  border: var(--bw) solid var(--panel2); border-radius: var(--r); background: var(--band); }
.areas li.here { border-color: var(--gold); }
/* a chapter's areas fold under one summary row, drawn like a group row: the chapter name, then a fold mark that turns when open */
.area-chapter { display: grid; gap: var(--sp-1); }
.area-chapter > summary { display: flex; align-items: center; gap: var(--sp-2); padding: 2px var(--sp-3); list-style: none; cursor: pointer;
  border: var(--bw) solid var(--panel2); border-radius: var(--r); background: var(--band); font-weight: 700; }
.area-chapter > summary::-webkit-details-marker { display: none; }
.area-chapter > summary::after { content: ""; margin-left: auto; flex: none; width: 0.45em; height: 0.45em; border: solid var(--dim);
  border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform 0.15s; }
.area-chapter[open] > summary::after { transform: rotate(45deg); }
.area-chapter > summary:hover { border-color: var(--gold); }
.a-name { font-weight: 700; }
.a-sub { font-size: var(--fs-xs); grid-column: 1; color: var(--dim); }
.a-acts { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: var(--sp-1); }
.legend { grid-template-columns: repeat(auto-fill, minmax(9em, 1fr)); font-size: var(--fs-xs); }
.legend li { display: flex; gap: var(--sp-2); align-items: center; min-width: 0; overflow-wrap: anywhere; }
.sw { width: 14px; height: 14px; flex: none; border: 1px solid var(--line); border-radius: 0; }
/* a tile that blocks the way has a thick edge, so the key does not lean on colour alone */
.sw.block { border: 3px solid var(--ink); }
.sw[data-tile="ground"] { background: var(--t-ground); } .sw[data-tile="mud"] { background: var(--t-mud); }
.sw[data-tile="reeds"] { background: var(--t-reeds); } .sw[data-tile="water"] { background: var(--t-water); }
.sw[data-tile="ford"] { background: var(--t-ford); } .sw[data-tile="planks"] { background: var(--t-planks); }
.sw[data-tile="stone"] { background: var(--t-stone); } .sw[data-tile="wall"] { background: var(--t-wall); }
.sw[data-tile="sluice"] { background: var(--t-sluice); } .sw[data-tile="spoil-heap"] { background: var(--t-spoil-heap); }
.sw[data-tile="dredger-hulk"] { background: var(--t-dredger-hulk); } .sw[data-tile="reed-thicket"] { background: var(--t-reed-thicket); }
.sw[data-tile="ash"] { background: var(--t-ash); } .sw[data-tile="cinders"] { background: var(--t-cinders); }
.sw[data-tile="burnt-tree"] { background: var(--t-burnt-tree); } .sw[data-tile="orchard-row"] { background: var(--t-orchard-row); }
.sw[data-tile="kiln-brick"] { background: var(--t-kiln-brick); } .sw[data-tile="steps"] { background: var(--t-steps); }
.sw[data-tile="cliff"] { background: var(--t-cliff); } .sw[data-tile="cart-lane"] { background: var(--t-cart-lane); }
.sw[data-tile="ditch"] { background: var(--t-ditch); }
.sw[data-tile="bell"] { background: var(--t-bell); } .sw[data-tile="pews"] { background: var(--t-pews); }
.sw[data-tile="rubble"] { background: var(--t-rubble); }
.sw[data-tile="keep-stone"] { background: var(--t-keep-stone); } .sw[data-tile="portcullis"] { background: var(--t-portcullis); }
.sw[data-tile="ramparts"] { background: var(--t-ramparts); } .sw[data-tile="siege-works"] { background: var(--t-siege-works); }
.sw[data-tile="barrow-mound"] { background: var(--t-barrow-mound); } .sw[data-tile="bone-scree"] { background: var(--t-bone-scree); }
.sw[data-tile="standing-stone"] { background: var(--t-standing-stone); } .sw[data-tile="crown"] { background: var(--t-crown); }
.hunts li { display: grid; gap: var(--sp-1); padding: var(--sp-2) var(--sp-3); border: var(--bw) solid var(--line); border-radius: var(--r); background: var(--panel2); }
.hunts li.shut { border-color: var(--panel2); background: transparent; }
.h-head { display: flex; gap: var(--sp-2); align-items: center; }
.h-head .chip { width: calc(var(--px) * 16); height: calc(var(--px) * 16); }
.h-name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-state { font-size: var(--fs-xs); font-weight: 800; padding: 1px var(--sp-2); border-radius: var(--r-pill); }
.h-state.is-open { border: var(--bw) solid var(--good); }
.h-state.is-shut { border: var(--bw) solid var(--panel2); color: var(--dim); }
.h-facts, .h-note { margin: 0; font-size: var(--fs-xs); }
.h-acts { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.h-ask { font-size: var(--fs-sm); font-weight: 700; }

/* ---- Levy Hall: a roster of cards, and one hero's page -------------------------------------------------------------------------- */
.hall { display: flex; flex-direction: column; gap: var(--gap); flex: 1 1 0; min-height: 0; }
/* the roster and a hero's page take the room left under the purse line, and never fold to nothing on a short screen */
.hall > .scroll { flex: 1 1 0; min-height: calc(var(--tap) * 2); }
.hall-purse { font-size: var(--fs-sm); display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); align-items: center; }
.purse-item { display: inline-flex; gap: var(--sp-1); align-items: center; white-space: nowrap; }
.heroes { grid-template-columns: repeat(auto-fill, minmax(min(100%, 13em), 1fr)); gap: var(--sp-2); }
.hero-row { position: relative; width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 var(--sp-3); justify-content: stretch;
  text-align: left; padding: var(--sp-2); height: auto; }
.hero-row .chip { width: max(48px, calc(var(--px) * 24)); height: max(48px, calc(var(--px) * 24)); }
.hr-bar { grid-column: 1 / -1; height: 4px; margin-top: var(--sp-1); }
.hr-bar::-webkit-progress-value { background: var(--shield); }
.hr-bar::-moz-progress-bar { background: var(--shield); }
.hero-row.locked { border-color: var(--panel2); background: transparent; }
/* a step the player can take now (a star to add, a hero to bring in): the words on a gold edge, never the colour alone */
.ready-tag { grid-column: 1 / -1; justify-self: start; margin-top: var(--sp-1); padding: 0 var(--sp-2); font-size: var(--fs-xs); font-weight: 800;
  color: var(--ink); border: var(--bw) solid var(--gold); border-radius: var(--r); }
.hero-row.locked .chip { filter: grayscale(0.85); opacity: 0.75; }
.hr-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr-sub { grid-column: 2; font-size: var(--fs-xs); color: var(--dim); display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--sp-2); }
.starrow { display: inline-flex; gap: 0; }
.starrow .ico-sm { width: 12px; height: 12px; }
.hd-top { display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-2); background: var(--band); border-radius: var(--r); }
.hd-who h3 { margin: 0; font-size: var(--fs-xl); line-height: 1.1; }
.hd-who p { margin: 0; font-size: var(--fs-sm); display: flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; }
.portrait { position: relative; width: max(64px, calc(var(--px) * 48)); aspect-ratio: 1; flex: none; border-radius: var(--r); border: var(--bw) solid var(--bevel-lo);
  display: grid; place-items: center; font-weight: 800; color: var(--chip-ink); overflow: hidden; box-shadow: inset 0 calc(var(--bw) * -6) 0 var(--bevel-lo); }
.portrait .badge { width: 24px; height: 24px; }
.hd { display: flex; flex-direction: column; gap: var(--gap); flex: 1 1 0; }
.hd-sec { display: grid; gap: var(--sp-2); border-top: var(--bw) solid var(--panel2); padding-top: var(--sp-2); }
.hd-sec h4 { margin: 0; font-size: var(--fs-sm); color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.hd-sec p { margin: 0; }
.src { margin: 0; font-size: var(--fs-sm); }
.step { display: grid; gap: 2px; justify-items: start; }
.step .btn { min-width: 10em; }
.step-note { margin: 0; font-size: var(--fs-xs); color: var(--dim); }
.step-note.bad { color: var(--bad); font-weight: 700; }
.step-note.good { color: var(--good); font-weight: 700; }
.xpbar { height: 10px; }
.skill-row { display: grid; gap: 2px; padding: var(--sp-2); background: var(--band); border-radius: var(--r); }
.sk-head { font-weight: 700; }
.sk-text { font-size: var(--fs-xs); }
.stars { font-weight: 800; display: inline-flex; align-items: center; gap: var(--sp-1); }
.leader p { font-size: var(--fs-sm); }
.g-pow { font-size: var(--fs-sm); white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: var(--bw) solid var(--line); }
.dot.easy { background: var(--good); }
.dot.close { background: var(--amber); border-radius: 2px; }
.dot.hard { background: var(--bad); transform: rotate(45deg); border-radius: 0; }

/* gear: a row per slot; a piece's rarity says itself in a word and in its chip's edge (solid, double, ridged, thick) */
.gear-row { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) auto; gap: var(--sp-1) var(--sp-2); align-items: center; padding: var(--sp-1) var(--sp-2);
  background: var(--band); border-radius: var(--r); }
.gear-slot { font-size: var(--fs-xs); color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.gear-acts { display: flex; flex-wrap: wrap; gap: var(--sp-1); justify-content: flex-end; }
.piece { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--sp-2); min-width: 0; }
.piece-stats { flex: 1 1 100%; font-size: var(--fs-xs); }
.rar { font-size: var(--fs-xs); font-weight: 800; padding: 0 var(--sp-1); border-radius: var(--r); }
.rar-common { border: var(--bw) solid var(--rar-common); color: var(--rar-common); }
.rar-fine { border: 3px double var(--rar-fine); color: var(--rar-fine); }
.rar-rare { border: 3px ridge var(--rar-rare); color: var(--rar-rare); }
.rar-heroic { border: 3px solid var(--rar-heroic); color: var(--rar-heroic); box-shadow: inset 0 0 0 1px var(--rar-heroic); }
.set-tag { font-size: var(--fs-xs); font-weight: 700; padding: 0 var(--sp-1); border: 1px solid var(--line); border-radius: var(--r-pill); }
.set-on { margin: 0; font-size: var(--fs-sm); color: var(--good); font-weight: 700; }
.gear-list { list-style: none; margin: 0; padding: 0 0 0 var(--sp-3); display: grid; gap: var(--sp-1); border-left: var(--bw) solid var(--gold); }
.gear-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); padding: var(--sp-1) 0; border-bottom: 1px solid var(--panel2); }
/* the phone's nearest groups under the map (main.js fills #near): one row that scrolls sideways; only in the phone layout */
/* the chips wrap to a second line rather than run off the right edge (at most ui.client near_groups of them) */
#near { display: none; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); margin: 0; padding: 0; list-style: none; flex: none; }
#near > li { flex: 0 1 auto; min-width: 0; max-width: 100%; }
#near .btn { display: inline-flex; align-items: center; gap: var(--sp-1); max-width: 100%; text-align: left; }
#near .dot { flex: none; }
.gear-list li.gear-worn-h { padding-top: var(--sp-2); border-bottom: 0; font-size: var(--fs-sm); font-weight: 700; color: var(--dim); }
/* a piece another hero wears, armed by the first press: the second press takes it, so it reads as a warning */
.btn.warn { border-color: var(--bad); color: var(--bad); box-shadow: inset 0 0 0 var(--bw) var(--bad); }

/* the camp: the patrol out and its earnings, the picker, the next camp level; the welcome-back card on load */
.camp { gap: var(--gap); }
.camp-head h2 { border: 0; padding: 0; }
.camp-who { margin: 0; font-weight: 700; }
.camp-time { height: 8px; }
.camp-pick { display: grid; gap: var(--sp-2); align-content: start; }
.camp-heroes { max-height: 40vh; }
.camp-areas { flex-wrap: wrap; }
.camp-earned li span:first-child { display: inline-flex; align-items: center; gap: var(--sp-2); }
.welcome { position: fixed; z-index: var(--z-modal); }
/* the Modes tab: three parts (this week's event, the Trials, the Tower) behind one row of buttons; a shut part keeps its button,
   dimmed, and says which chapter opens it (dashed edges belong to the coach's pointer alone) */
.modes { gap: var(--sp-2); }
.modes > * { flex: none; }          /* the whole panel scrolls; a part never squeezes its own list */
.mode-tabs { flex-wrap: wrap; }
.mode-tabs .shut { border-color: var(--panel2); color: var(--dim); }
.mode-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.mode-head h2 { border: 0; padding: 0; }
.mode-rules { margin: 0; padding-left: 1.2em; font-size: var(--fs-sm); }
.mode-hero { display: flex; align-items: center; gap: var(--sp-2); }
.mode-hero .intro { margin: 0; }
.mode-total { margin: 0; font-weight: 700; color: var(--gold); }
.mode-points { width: 100%; height: 8px; }
.mode-miles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5em, 1fr)); gap: var(--sp-1); font-size: var(--fs-sm); }
.mode-miles > li { padding: var(--sp-1) var(--sp-2); border: var(--bw) solid var(--line); border-radius: var(--r); }
.mode-miles > li.paid { border-color: var(--gold); color: var(--dim); }
.pay { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 var(--sp-2); }
.pay li, .hunts .pay li { display: inline-flex; padding: 0; border: 0; background: none; align-items: center; gap: var(--sp-1); }
.mode-prize { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.mode-rule { color: var(--dim); }
.mode-groups, .mode-trials { align-content: start; }
.mode-floor { margin: 0; }
.mode-next { display: grid; gap: var(--sp-1); }
.mode-pick .card.spent { opacity: 0.55; }
.mode-pick .camp-heroes { max-height: none; }
.mode-go { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
/* the Daily Levy part: the facts, the five battles, the six offered heroes (a small "Yours" mark on owned ones), the player's days */
.mode-daily { display: grid; gap: var(--sp-2); align-content: start; }
.daily-score { color: var(--dim); }
.daily-facts, .daily-days { margin: 0; }
.daily-battles { counter-reset: none; }
.daily-offer { max-height: none; }
.pick-toggle .own { grid-column: 2; justify-self: start; padding: 0 var(--sp-1); font-size: var(--fs-xs); font-weight: 700; color: var(--ink);
  border: var(--bw) solid var(--gold); border-radius: var(--r); }
/* the Board tab: a part per board behind one row of buttons, ranked rows, then the unranked ones under their own line */
.board { gap: var(--sp-2); }
.board > * { flex: none; }
.board-sec { display: grid; gap: var(--sp-2); align-content: start; }
.bsel { justify-self: start; max-width: 100%; min-height: var(--tap); padding: 0 var(--sp-2); font: inherit; color: var(--ink); background: var(--panel2);
  border: var(--bw) solid var(--line); border-radius: var(--r); }
.brows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-1); }
.brow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-2); border-bottom: var(--bw) solid var(--line); }
.brow.me { background: var(--band); }
.brow .rank { flex: none; min-width: 2em; color: var(--dim); }
.brow .bname { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .bval { flex: none; font-weight: 700; }
.brow .bdays { flex: none; font-size: var(--fs-xs); }
.board-unranked { margin: 0; }
.brow .byou { flex: none; font-size: var(--fs-xs); font-weight: 700; color: var(--gold); }
.brow.me .byou { color: inherit; }   /* light theme: gold on the row's band is 3.4:1 */
.brow .byou-note { flex: 1 1 100%; font-size: var(--fs-xs); }
.welcome-title { margin: 0; font-size: var(--fs-2xl); color: var(--gold); text-align: center; }

/* ---- the wide windows (wide screens): Levy Hall, Modes and the Board open spread over the map (their size is in the action bar
   block). Phones keep one sheet at a time. */
@media (min-width: 901px) {
  /* the roster: four to six cards across, flowing with the width */
  #hall-panel .hall .heroes { grid-template-columns: repeat(auto-fill, minmax(max(10em, calc((100% - 5 * var(--sp-3)) / 6)), 1fr)); }
  /* a hero's page: the card, level, stars and leader bonus on the left; gear and skills on the right, each column scrolling
     with the page */
  #hall-panel .hd.hd-cols { display: grid; grid-template-columns: minmax(16em, 2fr) minmax(0, 3fr); align-items: start; column-gap: var(--pad); }
  #modes-panel .modes, #board-panel .board { max-width: 60em; }
}
.hall > [data-step="back"] { align-self: flex-start; }
.hd-col { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.hd-col > .hd-top { flex: none; }
/* a shut Modes part or an empty board: its one short line beside the mode's icon (static/art/ui-index.json modes), not a column of
   empty panel; the line itself comes from modes.js and board.js (a board's "nobody yet" is the dim line right after its intro or
   its picker; with rows, a list comes there instead) */
.mode-shut, .board-sec > :is(.intro, .bsel) + p.dim { display: flex; align-items: center; gap: var(--sp-3); margin: 0; padding: var(--sp-2) var(--sp-3);
  color: var(--dim); background: var(--band); border: var(--bw) solid var(--panel2); border-radius: var(--r); }
.mode-shut::before, .board-sec > :is(.intro, .bsel) + p.dim::before { content: ""; flex: none; width: 48px; height: 48px; image-rendering: pixelated;
  background: var(--mode-ico, none) center / contain no-repeat; }
#modes:has([data-part="event"][aria-pressed="true"]), .board-event { --mode-ico: url("/static/art/modes/events.png"); }
#modes:has([data-part="trials"][aria-pressed="true"]) { --mode-ico: url("/static/art/modes/trials.png"); }
#modes:has([data-part="tower"][aria-pressed="true"]), .board-tower { --mode-ico: url("/static/art/modes/tower.png"); }
#modes:has([data-part="daily"][aria-pressed="true"]), .board-daily { --mode-ico: url("/static/art/modes/daily.png"); }
/* light mode: a star not yet earned is a faint shape, so a row of five never reads as five earned */
:root[data-theme="light"] .starrow img[src$="star_empty.png"] { opacity: 0.35; }

/* ---- battle: static/css/battle.css ----------------------------------------------------------------------------- */

/* ---- phone: a one-row top bar, the map and the action bar, whose windows open as bottom sheets ------------------------------- */
/* the top bar's help and studio links: inline on a wide screen, behind one Menu button on a phone (a popover, so no script) */
.menu-btn { display: none; }
.topmenu { display: contents; }
@media (max-width: 900px) {
  :root { --tap: 48px; --fs: 15px; --px: 1px; --side-w: min(360px, calc(100vw - 24px)); }
  /* the nearest groups under the map: on the phone layout only, where the Area window is a sheet away */
  #near { display: flex; }
  body[data-view="battle"] #battle { display: flex; }
  /* one row: the area, coin, Menu; drill marks and team power are in the Hall and Team windows; the goals are on the map's tracker */
  .stats { flex: 0 1 auto; flex-wrap: nowrap; min-width: 0; }
  .stats .stat:nth-child(n+3) { display: none; }
  .stat.where { min-width: 0; }
  .stat.where b { overflow: hidden; text-overflow: ellipsis; font-size: var(--fs); }
  .menu-btn { display: inline-flex; flex: none; }
  .topmenu { display: none; }
  .topmenu:popover-open { display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-2); position: fixed; inset: var(--sp-5) var(--sp-2) auto auto;
    margin: 0; padding: var(--sp-2); background: var(--panel); color: var(--ink); border: var(--bw) solid var(--gold); border-radius: var(--r); }
  #top { flex-wrap: nowrap; gap: var(--sp-1); padding: 2px var(--sp-2); }
  .brand, .stat .k { display: none; }
  .stat { padding: 4px 8px; min-height: 0; }
  #tn-nav-host .tn-nav-btn { min-height: 44px; min-width: 44px; }
  .btn { min-width: var(--tap); }
  .stats { gap: var(--sp-1); }
  .heroes { grid-template-columns: minmax(0, 1fr); }
  /* the group list keeps three rows in its sheet */
  #groups:not(:empty) { min-height: calc(3 * var(--tap)); }
}
/* short screens (landscape phones, 640x360): one row for the top bar, both sides of the battle in one row each */
@media (max-height: 500px) {
  :root { --tap: 40px; --fs: 14px; --px: 1px; }
  .brand, .track-k { display: none; }
  #top { flex-wrap: nowrap; padding: 0 var(--sp-2); min-height: 0; }
  .stats { flex: none; flex-wrap: nowrap; }
  .stat.where { display: none; }
  .hall > .scroll { min-height: var(--tap); }
  .hd-top { padding: 2px var(--sp-2); }
  .portrait { width: calc(var(--tap) - var(--sp-1)); }
  .stat .k { display: none; }
  .links { display: none; }
}
/* a phone held sideways (844x390): one thin top bar and the map takes the rest of the height, with no window open at first
   (main.js opens none on a short screen) and the nearest groups laid over its foot; a coach step, when there is
   one, sits under the bar */
@media (max-width: 900px) and (max-height: 500px) {
  body[data-view="walk"] #app { padding: 2px; gap: 2px; }
  body[data-view="walk"] #top { padding: 0 var(--sp-1); }
  #walk { position: relative; }
  #walk .mapwrap { flex: 1 1 auto; min-height: 0; }
  #walk #near { position: absolute; left: var(--sp-2); right: var(--sp-2); bottom: var(--sp-2); z-index: 2; flex-wrap: nowrap;
    overflow-x: auto; pointer-events: none; }
  #walk #near > li { flex: none; pointer-events: auto; }
}
@media (hover: none) { .btn:hover { border-color: var(--line); } }
@media (pointer: coarse) { :root { --tap: 44px; } }
@media (pointer: coarse) and (max-width: 900px) { :root { --tap: 48px; } }
@media (pointer: coarse) and (max-height: 500px) { :root { --tap: 44px; } }
/* with reduced motion every CSS animation and transition stops (battle.css keeps an outline for a hit and a skill, so they still show) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
/* Settings' Motion off (data-motion on <html>, this browser only) does the same */
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after { transition: none !important; animation: none !important; }
