* {
  box-sizing: border-box;
}
html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
  color: #eee;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* buttons are buttons: their text can't be selected or dragged off like a link, no highlight or focus
   ring on a tap or click (a ring only for keyboard focus); fields stay selectable */
button, .btn, .menu-button, .tab-btn {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
button *, .ic { pointer-events: none; -webkit-user-drag: none; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid #7cc35a; outline-offset: 1px; }
input, textarea { user-select: text; -webkit-user-select: text; }

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #111;
  /* the HUD's sizes and motion: the menu's own easing (title-drop, menu-rise), the buttons' spring */
  --top-h: calc(50px + env(safe-area-inset-top));
  --dock-h: calc(60px + env(safe-area-inset-bottom));
  /* (the bars are zoomed by the Interface size: what lies over the map unzoomed, the FPS, a toast, the defeat
     panel, measures them in the screen's own pixels: the top bar's bottom, under the stock's strip, the dock's top) */
  --hud-top: calc(var(--top-h) * var(--ui-scale, 1));
  --hud-under-strip: calc((var(--top-h) + 48px) * var(--ui-scale, 1));
  --hud-dock: calc(var(--dock-h) * var(--ui-scale, 1));
  --ease-settle: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* the map fills the screen; the HUD lies over it, so nothing opening or closing resizes the map */
#main-area {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  /* fills the game area; its pixel size follows it (fitCanvasToScreen in input.js) */
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  cursor: crosshair;

  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- Buttons answer the hand: every kind the same way */
button {
  touch-action: manipulation;
  /* a springy return when let go; colours ease */
  transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.12s ease, background-color 0.15s ease,
    border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, color 0.15s ease;
}
/* the mouse over it (not on touch screens, where it would stick after a tap): lighter, a brighter edge,
   lifted a pixel */
@media (hover: hover) {
  button:not(:disabled):hover { filter: brightness(1.15); border-color: rgba(255, 255, 255, 0.4); }
  button:not(:disabled):not(.color-swatch):hover { transform: translateY(-1px); }
}
/* pressed: in at once, a little smaller and darker */
button:not(:disabled):active { transform: scale(0.95); filter: brightness(0.85); transition-duration: 0.05s; }
/* chosen (a faction, a difficulty, a tab...): a soft glow around it */
.btn.active, .tab-btn.active, .fps-option.active, .difficulty-option.active, .cards-option.active, .faction-option.active,
.wave-option.active, .map-option.active, .battle-size-option.active, .item-row .item-name.active {
  box-shadow: 0 0 0 1px rgba(70, 184, 218, 0.6), 0 0 10px rgba(70, 184, 218, 0.45);
}
/* a price the stock can't pay: the button dimmed, the parts it's short of in red */
button.cant-afford { opacity: 0.6; }
.cost-part.short { color: #ff6b6b; font-weight: bold; }
/* what it did worked: a green flash; it didn't: a shake */
@keyframes btn-ok { 0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.9); } 100% { box-shadow: 0 0 0 10px rgba(46, 204, 113, 0); } }
@keyframes btn-no { 0%, 100% { translate: 0; } 20% { translate: -5px; } 40% { translate: 5px; } 60% { translate: -3px; } 80% { translate: 3px; } }
button.btn-ok { animation: btn-ok 0.45s ease-out; }
button.btn-no { animation: btn-no 0.35s ease; }
/* on a phone, room for a finger: no button lower than this */
@media (pointer: coarse) {
  .btn, .tab-btn, .fps-option, .difficulty-option, .cards-option, .faction-option, .wave-option, .map-option, .battle-size-option { min-height: 36px; }
  .menu-button, #play-button { min-height: 44px; }
}

.resources-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  font-size: 10px;
}
.resources-grid div, .resource-group-members div {
  background: rgba(0, 0, 0, 0.35);
  padding: 3px 2px;
  border-radius: 4px;
  text-align: center;
  white-space: nowrap;
  /* never wider than its column: long labels end in … instead of stretching the panel */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#resources-hud .population-tile {
  grid-column: span 2;
}

/* a group tile opens a row of its members under the resource tiles */
.resources-grid .resource-group {
  cursor: pointer;
  border: 1px solid #353a46;
}
.resources-grid .resource-group.open {
  border-color: #7cc35a;
  background: rgba(63, 122, 46, 0.35);
}
.resource-details {
  /* an open group drops down over what's below, so the panel doesn't change size */
  position: relative;
  height: 0;
  z-index: 30;
}
.resource-group-members {
  position: absolute;
  left: 0;
  right: 0;
  top: 2px;
  padding: 4px;
  background: #1b1d22;
  border: 1px solid #7cc35a;
  border-radius: 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  font-size: 10px;
  margin-top: 3px;
}
.gear-actions {
  /* armour / shield, backpack / watering can: a block of their own under the main buttons */
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #353a46;
}

.resource-group-members[hidden] {
  display: none;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.btn {
  background: #2c303b;
  color: #fff;
  border: 1px solid #414757;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: bold;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  touch-action: pan-y;
  width: auto;
  box-sizing: border-box;
}

.btn.active { background: #3f7a2e; border-color: #7cc35a; }
.btn-demolish { background: #962d2d; }
.btn-disarm { background: #d35400; text-align: center; }
.btn-armor { background: #27ae60; text-align: center; }

.btn-grid-2col {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.recruit-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin-bottom: 6px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #2d313b;
}

#toast-notification {
  position: absolute;
  top: calc(var(--hud-under-strip) + 4px); /* under the strip of the main stock */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(192, 57, 43, 0.95);
  color: white;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  text-align: center;
  border: 1px solid rgba(255,255,255,0.2);
}

@media (min-width: 768px) {
  .resources-grid, .resource-group-members {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  #resources-hud .population-tile {
    grid-column: span 2;
  }
}

/* ========================================== */
/*            АККУРАТНОЕ МИНИ-МЕНЮ           */
/* ========================================== */
#main-menu, .menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 11, 14, 0.92);
  color: #eee;
}
/* behind the main menu: a little world of the game's own (#193, menu-scene.js), the game's panels hidden */
#main-menu { background: #0b0c0e; overflow-y: auto; }
/* the world behind the menu steps back (darker, duller, darker still at the edges) so the menu stands out;
   no blur (#256) */
body.menu-world #main-menu { background: transparent; }
/* the dark edges: a layer of their own, faded in (a gradient itself can't be) */
#main-menu::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.55) 100%);
}
body.menu-world #main-menu::before { opacity: 1; transition: opacity 0.8s ease; }
#gameCanvas, #worldCanvas { transition: filter 0.4s ease, transform 0.4s ease; }
/* the low sun's colour over both canvases, with WebGL on (drawDuskTint in world.daytime.js) */
#dusk-tint { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: soft-light; }
#dusk-tint[hidden] { display: none; }
/* back into the menu from a game: it steps back in 0.8 s (into a game, sharp again in 0.4 s, above) */
body.menu-world #gameCanvas, body.menu-world #worldCanvas { filter: brightness(0.8) saturate(0.85);
  transition: filter 0.8s ease, transform 0.8s ease; }
/* the menu put away to watch the scene (#256): its panels and title gone, the dark edges too; a little bar to
   change the scene and bring the menu back */
body.menu-ui-hidden #main-menu .main-menu-content, body.menu-ui-hidden #menu-title, body.menu-ui-hidden #menu-eye-box { display: none !important; }
body.menu-ui-hidden #main-menu::before { opacity: 0; }
body.menu-ui-hidden.menu-world #gameCanvas, body.menu-ui-hidden.menu-world #worldCanvas { filter: none; }
#menu-eye-box { left: auto; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: none; }
body.menu-world #menu-eye-box { display: flex; }
#menu-scene-bar { left: auto; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: none; flex-direction: row; width: auto; gap: 8px; }
body.menu-ui-hidden #menu-scene-bar { display: flex; }

/* ---- The game opening, as the page loads (#main-menu.intro, main.js; the curtain lifted, menu-scene.js):
   - dark at first: a curtain over everything while the world behind the menu is made;
   - the curtain lifts (#main-menu.lifted) onto the world already out of focus;
   - the name drops in from above with a little bounce, then the buttons fade up */
#intro-curtain { position: fixed; inset: 0; background: #0b0c0e; pointer-events: none; opacity: 1; transition: opacity 0.55s ease; }
#main-menu.lifted #intro-curtain { opacity: 0; }
@keyframes title-drop { 0% { opacity: 0; transform: translateY(-60px); } 70% { opacity: 1; transform: translateY(6px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes menu-rise { 0% { opacity: 0; transform: translateY(16px); } 100% { opacity: 1; transform: translateY(0); } }
#main-menu.intro .menu-title span { display: inline-block; animation: title-drop 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both; }
#main-menu.intro .main-menu-content[data-screen="home"] { animation: menu-rise 0.4s ease-out 0.2s both; }
body.menu-world #defeat-overlay { display: none !important; }
#main-menu .main-menu-content { position: relative; z-index: 1; flex-shrink: 0; }

.main-menu-content {
  width: 90%;
  max-width: 320px;
  padding: 20px;
  background: #16171a;
  border: 2px solid #2a2d34;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: center;
}

.main-menu-content[data-screen="endless"] {
  gap: 9px;
  padding: 14px;
  max-height: var(--menu-room);
  overflow-y: auto;
}

.main-menu-content[data-screen="saves"] {
  gap: 9px;
  padding: 14px;
  max-height: var(--menu-room);
  overflow-y: auto;
}

.main-menu-content[data-screen="battle"] {
  gap: 9px;
  padding: 14px;
}
/* a mode's few words: a card popped up over its screen, the screen dimmed behind */
.menu-popup { position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0, 0, 0, 0.45); animation: menu-screen-in 0.18s ease backwards; }
.menu-popup[hidden] { display: none; }
/* (the card solid, not see-through as the menu's panels: its words over the screen behind didn't read, Lima; its Back in a
   row of its own over them) */
#main-menu .menu-popup-card { gap: 12px; max-width: 360px; padding-top: 44px; background: rgba(46, 60, 36, 0.98);
  animation: drawer-down 0.3s cubic-bezier(0.34, 1.4, 0.64, 1) backwards; }
.menu-popup-card h1 { display: none; } /* (the screen behind already says its name: the card only its words) */
.menu-popup-card p { margin: 0; color: #e4dcc0; font-size: 15px; line-height: 1.5; text-align: center; }
.mode-title-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.mode-title-trigger .ic { width: 0.85em; height: 0.85em; opacity: 0.75; }
.mode-title-trigger:hover, .mode-title-trigger:focus-visible { color: #f1c40f; }
.mode-title-trigger:focus-visible { outline: 2px solid #f1c40f; outline-offset: 3px; border-radius: 3px; }

.main-menu-content[data-screen="endless"] .wave-settings { gap: 4px; }
.main-menu-content[data-screen="plague"] { max-height: var(--menu-room); overflow-y: auto; }
.plague-menu { gap: 12px; }
.plague-spawn-settings { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.plague-range { display: flex; flex-direction: column; gap: 6px; }
.plague-range-fields { display: flex; align-items: center; justify-content: center; gap: 8px; }
.plague-range-fields[hidden] { display: none; }
.plague-spawn-settings .menu-number { width: 72px; }
.wave-settings.endless-world-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 8px;
  text-align: left;
}
.endless-world-settings .wave-options { gap: 3px; margin-top: 3px; }
.endless-world-settings .wave-option { padding: 5px 0; font-size: 11px; }

/* the game's name on the main menu's first screen (no plate behind it): the buttons in the middle of the
   screen, the name in the middle of the space above them. --title-size is its letters' height: 10% of
   the screen's width (it fits a phone's width with room to spare), at least 34px, at most 110px */
#main-menu { --title-size: clamp(34px, min(10vw, 15vh), 110px); flex-direction: column; justify-content: safe center; }
/* the menu bigger on a bigger screen (it's laid out in pixels a phone's size): all of it, panes, text, buttons */
/* (--menu-room: the height a screen may take under the menu's top, in its own zoomed pixels: a screen taller
   scrolls inside itself, rather than going off the bottom) */
/* (--ui-scale: the player's Interface size, Settings > General, on the menu and the game's panels alike) */
#main-menu { --menu-auto: 1; --menu-zoom: calc(var(--menu-auto) * var(--ui-scale, 1)); zoom: var(--menu-zoom);
  --menu-top: clamp(16px, 9vh, 96px); --menu-room: calc(100vh / var(--menu-zoom) - var(--menu-top) - 24px); }
@media (min-width: 900px) and (min-height: 520px) { #main-menu { --menu-auto: 1.15; } }
@media (min-width: 1300px) and (min-height: 760px) { #main-menu { --menu-auto: 1.3; } }
@media (min-width: 1700px) and (min-height: 950px) { #main-menu { --menu-auto: 1.45; } }
.hud-layer, #pause-menu { zoom: var(--ui-scale, 1); }
/* On a wide screen the long screens laid out wide, in two columns, rather than scrolling down: Endless's (Play and
   Saves side by side, the factions on the left, the rest beside them), the Plague's, and the generator's cards */
@media (min-width: 900px) and (min-height: 520px) {
  #main-menu .main-menu-content[data-screen="endless"]:not([hidden]), #main-menu .main-menu-content[data-screen="plague"]:not([hidden]),
  #main-menu .main-menu-content[data-screen="generator"]:not([hidden]) {
    width: min(780px, calc(94vw / var(--menu-zoom))); max-width: none;
    display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: row dense; column-gap: 18px; align-content: start; align-items: start; }
  #main-menu .main-menu-content[data-screen="endless"] > h1, #main-menu .main-menu-content[data-screen="plague"] > h1,
  #main-menu .main-menu-content[data-screen="generator"] > :not(.menu-back) { grid-column: 1 / -1; }
  #main-menu .main-menu-content[data-screen="endless"] > .faction-settings { grid-column: 1; grid-row: span 3; }
  #main-menu .main-menu-content[data-screen="endless"] > [data-seed-slot], #main-menu .main-menu-content[data-screen="endless"] > .endless-more { grid-column: 1 / -1; }
  #main-menu .endless-more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; align-items: start; }
  #main-menu .main-menu-content[data-screen="plague"] > :not(h1):not(.menu-back):not(button) { grid-column: 1 / -1; }
  #main-menu .generator-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; align-items: start; }
  #main-menu .generator-fields > [data-card="nature"] { grid-column: 1 / -1; }
  #main-menu .generator-fields > [data-card="nature"] .generator-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
}
/* a screen other than the first: from near the top, not in the middle of the screen (room below for a group's panel
   on a phone, and Modes not floating halfway down) */
#main-menu:not([data-menu-screen="home"]) { justify-content: flex-start; padding-top: var(--menu-top); padding-bottom: 16px; }
.menu-title {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--title-size) * 1.6);
  color: #f1c40f;
  font-size: var(--title-size);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: 2px;
  white-space: nowrap;
  /* a dark outline and shadow, to read on the grass */
  text-shadow: -2px -2px 0 #3d2c00, 2px -2px 0 #3d2c00, -2px 2px 0 #3d2c00, 2px 2px 0 #3d2c00,
    0 4px 0 #7d5a00, 0 8px 18px rgba(0, 0, 0, 0.75);
  pointer-events: none; /* taps go through it, to the world behind */
}
/* as much room below the buttons as the name has above them, so the buttons sit in the middle */
#main-menu[data-menu-screen="home"]::after { content: ''; flex: 1 1 0; }
#main-menu:not([data-menu-screen="home"]) .menu-title { display: none; }

.main-menu-content h1 {
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  margin: 0;
  letter-spacing: 1px;
}

.menu-overlay[hidden] {
  display: none;
}

.menu-button {
  width: 100%;
  padding: 12px 0;
  font-size: 15px;
  font-weight: bold;
  color: #eee;
  background: #2a2d34;
  border: 1px solid #3d414b;
  border-radius: 6px;
  cursor: pointer;
}

.menu-button-primary {
  color: #fff;
  background: #27ae60;
  border-color: #2ecc71;
}

#play-button {
  width: 100%;
  padding: 12px 0;
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  background: #27ae60;
  border: 1px solid #2ecc71;
  border-radius: 6px;
  cursor: pointer;
}

#play-button:active {
  transform: scale(0.97);
  filter: brightness(1.2);
}

.wave-settings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: #8a91a0;
  font-weight: bold;
  text-transform: uppercase;
}

.wave-options {
  display: flex;
  gap: 6px;
}

.wave-option {
  flex: 1;
  padding: 8px 0;
  background: #252830;
  border: 1px solid #353a46;
  border-radius: 5px;
  color: #8a91a0;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}

.map-option, .map-source-option, .editor-size-option, .battle-size-option {
  flex: 1;
  padding: 8px 0;
  background: #252830;
  border: 1px solid #353a46;
  border-radius: 5px;
  color: #8a91a0;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}

.map-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#wave-custom {
  align-self: center;
}

.map-custom[hidden], .menu-number[hidden] {
  display: none;
}

.editor-start {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}
.editor-start-title { color: #b6c1b8; font-size: 11px; }
.editor-start-options { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.editor-start-options .editor-launch-option { min-width: 0; min-height: 48px; padding: 6px; font-size: 12px; line-height: 1.2; }

.menu-number {
  width: 70px;
  padding: 6px;
  background: #111318;
  border: 1px solid #353a46;
  border-radius: 5px;
  color: #fff;
  text-align: center;
  font-size: 12px;
}

.difficulty-option, .cards-option, .fps-option {
  flex: 1;
  padding: 8px 0;
  background: #252830;
  border: 1px solid #353a46;
  border-radius: 5px;
  color: #8a91a0;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}

.main-menu-content[hidden] {
  display: none;
}

.menu-button:disabled {
  opacity: 0.45;
  cursor: default;
}

#fps-counter {
  position: absolute;
  top: var(--hud-under-strip); /* under the top bar and the stock's strip, whatever the Interface size */
  left: 10px;
  z-index: 6;
  font: bold 11px monospace;
  color: #2ecc71;
  text-shadow: 1px 1px 2px #000;
  white-space: pre;
}
#fps-counter[hidden] {
  display: none;
}

/* the performance monitor (app/perfmon.js): over the game, out of the way of the top bar and the dock */
#perf-panel {
  position: fixed;
  top: calc(var(--hud-top) + 6px);
  right: calc(env(safe-area-inset-right, 0px) + 8px);
  z-index: 40;
  width: 248px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.62);
  border-radius: 6px;
  pointer-events: auto;
}
#perf-panel[hidden] {
  display: none;
}
#perf-panel canvas {
  /* (not the game's: the rule for every canvas would stretch it over the panel) */
  position: static;
  display: block;
  width: 240px !important;
  height: 60px !important;
  cursor: default;
}
#perf-panel pre {
  margin: 4px 0;
  font: 10px/1.25 monospace;
  color: #ecf0f1;
  white-space: pre;
  overflow: hidden;
}
#perf-panel .perf-buttons {
  display: flex;
  gap: 4px;
}
#perf-panel .perf-buttons button {
  flex: 1;
  font: bold 11px sans-serif;
  padding: 5px 2px;
  border: 0;
  border-radius: 4px;
  background: #34495e;
  color: #fff;
}

.menu-back {
  align-self: flex-start;
  background: none;
  border: none;
  color: #8a91a0;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
}

.wave-option.active, .map-option.active, .battle-size-option.active, .map-source-option.active, .editor-size-option.active,
.difficulty-option.active, .cards-option.active, .fps-option.active {
  background: #3f7a2e;
  color: #fff;
  border-color: #7cc35a;
}

.seed-settings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: #8a91a0;
  font-weight: bold;
  text-transform: uppercase;
}

#seed-input {
  width: 100%;
  padding: 8px 10px;
  background: #111318;
  border: 1px solid #353a46;
  border-radius: 5px;
  color: #fff;
  text-align: center;
  font-size: 12px;
  outline: none;
}

#seed-input:focus {
  border-color: #7cc35a;
}

.seed-row {
  display: flex;
  gap: 6px;
}

/* small unlabeled button next to the seed: a new random seed */
#seed-reroll, #btn-generate-name {
  flex: 0 0 auto;
  width: 34px;
  background: #111318;
  border: 1px solid #353a46;
  border-radius: 5px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

#seed-reroll:active, #btn-generate-name:active {
  border-color: #7cc35a;
}

/* battle mode (#38) and the map editor (#37): their own sheets and dock rows (the HUD, below) */
.battle-row { display: flex; gap: 4px; }
.battle-row > * { flex: 1; }
.battle-row .fps-option { padding: 6px 0; }
#battle-presets .tile-cost, #editor-tools .tile-cost { white-space: nowrap; }
.tile-name .ic + .ic { margin-left: -6px; }
.battle-hint {
  font-size: 11px;
  color: #8a91a0;
  text-align: center;
}
.battle-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}
.battle-presets .btn {
  font-size: 11px;
  padding: 6px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#editor-tools { grid-auto-rows: minmax(30px, auto); }
.editor-toolbar { display: flex; align-items: center; gap: 6px; }
.editor-toolbar .fps-option { padding: 6px 10px; white-space: nowrap; }
.editor-toolbar #editor-name { flex: 1; min-width: 0; }
.editor-brush { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #8a91a0; }
.editor-only { display: none; }
body[data-hud="editor"] .editor-only { display: inline-flex; }
.btn.editor-only:disabled { opacity: 0.35; }
#editor-tools .panel-heading:first-child { margin-top: 0; }
.editor-visibility-setting { margin: 6px 0; }

/* lists of saved maps and presets (#143): a row each, with its own delete that asks first */
.item-list { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; flex-shrink: 0; }
.item-row { display: flex; align-items: center; gap: 4px; }
.item-row .item-name { flex: 1; min-width: 0; text-align: left; padding: 7px 10px; background: #252830; border: 1px solid #353a46;
  border-radius: 5px; color: #ddd; font-size: 12px; font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.item-row .item-name.active { background: #3f7a2e; border-color: #7cc35a; color: #fff; }
.item-row .item-delete, .item-row .item-confirm, .item-row .item-cancel { padding: 7px 10px; background: #252830; border: 1px solid #353a46;
  border-radius: 5px; color: #ddd; font-size: 12px; font-weight: bold; cursor: pointer; }
.item-row .item-confirm { background: #c0392b; border-color: #e74c3c; color: #fff; }
.item-row .item-question { flex: 1; font-size: 12px; text-align: left; color: #f1c40f; text-transform: none; }
.item-list.no-delete .item-delete { display: none; }
.item-list-empty { font-size: 12px; color: #8a91a0; font-weight: normal; text-transform: none; }
#main-menu.custom-map .random-map-only,
#main-menu:not(.custom-map) .custom-map-only { display: none; }

/* the selected settler's info (#180) */
#selected-info { flex-basis: 100%; font-size: 11px; color: #ccc; margin-top: 2px; }
#selected-info[hidden] { display: none; }
#selected-info .progression-button { align-self: flex-start; border: 0; background: transparent; color: #f1c40f; font: inherit; padding: 2px 0; cursor: pointer; }
#selected-info .progression-button:focus-visible { outline: 1px solid #f1c40f; outline-offset: 1px; }
#selected-info .progression-view-title { font-weight: bold; color: #eee; }
#selected-info .progression-list { display: flex; flex-direction: column; gap: 1px; }
#selected-info .selected-carrying-line { height: 1.4em; overflow: hidden; white-space: nowrap; }

/* sections of the panel's tabs (#181) */
.panel-heading { font-size: 10px; color: #8a91a0; text-transform: uppercase; letter-spacing: 0.5px; margin: 6px 0 3px; text-align: center; }
.panel-heading:first-child { margin-top: 0; }
.panel-section[hidden] { display: none; }
.tab-pane .gear-actions { margin-top: 0; padding-top: 0; border-top: none; }

/* tabs a faction doesn't have (#164) */
.tab-btn[hidden], #tab-tools .btn[hidden], #tab-weapons .btn[hidden] { display: none; }

/* saves (#156): only in Endless */
body.battle-mode #save-game-button, body.editor-mode #save-game-button { display: none; }
#save-actions[hidden] { display: none; }
#save-actions { display: flex; gap: 8px; }
#save-actions > button { flex: 1; }
#save-status { min-height: 1.1em; }
.save-import-actions { display: flex; justify-content: center; margin-top: 4px; }
.save-import-actions .btn { padding: 8px 16px; font-size: 13px; }
/* (nothing saved yet: said in the middle, as the list would be) */
#save-list .item-list-empty, #map-manager-list .item-list-empty { grid-column: 1 / -1; width: 100%; align-self: stretch; text-align: center; font-size: 14px; color: var(--text-dim, #a9b0a0); padding: 10px 0; }
/* the Plague's two ranges: a label, then from – to */
.plague-range-fields { display: flex; align-items: center; gap: 8px; }
.plague-range-fields input { width: 72px; }
.plague-range > div:first-child { text-align: center; }
/* (the one button above the settings now: across the screen) */
#main-menu .main-menu-content[data-screen="endless"] > #play-button, #main-menu .main-menu-content[data-screen="plague"] > #plague-play { grid-column: 1 / -1; grid-row: auto; order: 99; }
#save-list { width: 100%; }

/* factions and their colours (#43) */
.faction-settings { gap: 6px; }
.faction-side { display: flex; align-items: center; gap: 6px; }
.faction-side > span { width: 52px; font-size: 14px; color: var(--text, #eee); text-align: left; }
.faction-options { flex: 1; display: flex; gap: 4px; }
.faction-option { flex: 1; padding: 6px 2px; background: #252830; border: 1px solid #353a46; border-radius: 5px; color: #ddd;
  font-size: 11px; font-weight: bold; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.faction-option.active { background: #3f7a2e; border-color: #7cc35a; color: #fff; }
.faction-option:disabled { opacity: 0.45; cursor: default; }
.color-options { display: flex; flex-wrap: nowrap; gap: 4px; justify-content: flex-end; }
.color-swatch { flex: 1 1 0; min-width: 14px; max-width: 26px; aspect-ratio: 1; border-radius: 50%; border: 2px solid #353a46; cursor: pointer; padding: 0; } /* (#326) all in one line */
.color-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px #7cc35a; }
.color-swatch:disabled { opacity: 0.25; cursor: default; }

/* map generator screen (#20) */
.menu-gear {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #252830;
  border: 1px solid #353a46;
  border-radius: 6px;
  font-size: 16px;
  padding: 4px 8px;
  cursor: pointer;
}
.main-menu-content {
  position: relative;
  max-height: var(--menu-room);
  overflow-y: auto;
}
.main-menu-content.generator-screen { max-height: min(calc(75vh / var(--menu-zoom)), var(--menu-room)); }
/* The map generator: a card a group that folds (its head its name), a share a slider with its value, a count a number */
.generator-fields { display: flex; flex-direction: column; gap: 10px; text-align: left; font-size: 13px; }
.gen-card { background: rgba(0, 0, 0, 0.18); padding: 6px 12px 10px; }
.gen-card-head { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 4px 0;
  font-size: 12px; font-weight: bold; color: #e8c76a; letter-spacing: 0.06em; text-transform: uppercase; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.gen-card-head::-webkit-details-marker { display: none; }
.gen-card-head::after { content: ''; width: 7px; height: 7px; margin-right: 4px; border-right: 2px solid #e8c76a; border-bottom: 2px solid #e8c76a;
  transform: rotate(-45deg); transition: transform 0.2s ease; }
.gen-card[open] > .gen-card-head::after { transform: rotate(45deg); }
.generator-fields h3 { margin: 8px 0 2px; font-size: 12px; font-weight: bold; color: #d4cfb6; }
.generator-grid { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.generator-field { display: flex; align-items: center; gap: 10px; color: #eee; }
.generator-field > span:first-child { flex: 0 0 40%; min-width: 0; }
.generator-field > span:last-child { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; color: #d4cfb6; }
.generator-field input[type="number"] { width: 64px; padding: 4px; background: #111318; border: 1px solid #353a46; border-radius: 4px; color: #fff; text-align: center; }
.generator-field input[type="range"] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; width: auto; height: 8px; margin: 0; border-radius: 4px; cursor: pointer;
  background: linear-gradient(to right, #6fa34f 0 var(--fill, 0%), #1e1f19 var(--fill, 0%) 100%); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7); }
.generator-field input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8e2, #d9cfae 70%); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); }
.generator-field input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: none; border-radius: 50%; background: #e9e2c8; }
.gen-value { flex: 0 0 40px; text-align: right; font-style: normal; font-size: 12px; color: #e8c76a; font-variant-numeric: tabular-nums; }
/* the presets: the chosen one's name, a list of them dropping from it; Save on the right */
.preset-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.preset-label { flex: none; color: #d4cfb6; font-size: 14px; }
.preset-pick-wrap { position: relative; flex: 0 1 260px; min-width: 0; }
#preset-pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; height: 35px; padding: 0 14px; }
#preset-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#preset-pick::after { content: ''; flex: none; width: 7px; height: 7px; margin-top: -4px; border-right: 2px solid #e8c76a; border-bottom: 2px solid #e8c76a;
  transform: rotate(45deg); transition: transform 0.2s; }
#preset-pick[aria-expanded="true"]::after { margin-top: 3px; transform: rotate(-135deg); }
/* the list drops down over what's under it */
.preset-menu { position: absolute; left: 0; top: calc(100% + 4px); z-index: 20; min-width: 100%; max-height: 260px; overflow: auto;
  display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 8px; background: #2a3322; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6); }
.preset-menu[hidden] { display: none; }
.preset-menu #preset-standard { flex: none; height: 35px; padding: 0 14px; text-align: left; }
.preset-menu .preset-list { display: flex; flex-direction: column; gap: 4px; }
.preset-menu .item-row { flex: none; display: flex; gap: 4px; }
.preset-menu .item-row .item-name { flex: 1; height: 35px; padding: 0 14px; text-align: left; }
.preset-menu .item-row .item-delete { flex: none; width: 35px; height: 35px; padding: 0; }
.preset-menu .item-question { flex: 1; align-self: center; font-size: 12px; }
#preset-save { flex: none; height: 35px; padding: 0 16px; margin-left: auto; }
/* (the new preset's name typed in the place of the chosen one's) */
#preset-name { width: 100%; height: 35px; padding: 0 14px; background: #111318; border: 1px solid #7cc35a; border-radius: 6px; color: #fff;
  font: inherit; font-size: 14px; outline: none; }
#preset-name[hidden], .preset-bar.naming #preset-pick { display: none; }

/* (#326) the selected settler's card: everything shown, scrolling when there's a lot */
.selected-unit-box.has-settler { position: relative; display: flex; flex-direction: column; width: min(94vw, 400px); height: min(30vh, 220px); box-sizing: border-box; white-space: normal; overflow: hidden; padding: 8px 48px 8px 10px; }
.sel-head { display: flex; align-items: center; gap: 6px; min-height: 36px; flex-shrink: 0; }
.selected-unit-content { flex: 1; min-height: 0; margin-right: -48px; padding-right: 48px; overflow-y: auto; }
.selected-name-button { min-width: 0; max-width: 45%; padding: 0; border: 0; background: none; color: #f1c40f; font: inherit; font-size: 13px; font-weight: bold; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.selected-name-button:hover { color: #ffe66d; }
.selected-role { min-width: 0; color: #ccc; font-size: 12px; }
.sel-name-editor { display: none; align-items: center; flex: 1; min-width: 80px; gap: 4px; }
.editing-name .selected-name-button { display: none; }
.editing-name .sel-name-editor { display: flex; }
.sel-name-editor input { flex: 1; min-width: 0; padding: 4px 6px; background: #111318; border: 1px solid #353a46; border-radius: 4px; color: #fff; }
.sel-name-editor #btn-generate-name { padding: 0; min-height: 0; }
.sel-group { font-size: 11px; color: #aaa; white-space: nowrap; }
#btn-deselect { position: absolute; top: 5px; right: 5px; width: 40px; height: 40px; min-height: 40px !important; padding: 7px !important; font-size: 20px !important; line-height: 1; text-align: center; z-index: 1; }
#btn-deselect .ic { width: 22px; height: 22px; vertical-align: middle; }
#selected-info { display: flex; flex-direction: column; gap: 1px; line-height: 1.35; }
.sel-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 4px; margin-top: 6px; }
.sel-actions .btn { font-size: 11px; padding: 5px 6px; min-height: 0; white-space: normal; line-height: 1.2; }
.sel-actions .btn.on { background: #1e8449; border-color: #27ae60; }
.give-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 4px; margin-top: 6px; }
.give-list[hidden] { display: none; }
.give-list .btn { font-size: 11px; padding: 5px 6px; min-height: 0; }
/* The Units tab uses the same compact tile grid as the other tabs. */
.units-list { gap: 4px; }
.units-kind { margin-top: 6px; }
.unit-hp { width: 100%; height: 5px; border-radius: 3px; background: #3b2626; overflow: hidden; }
.unit-hp span { display: block; height: 100%; background: #2ecc71; }
.unit-state { display: block; width: 100%; min-width: 0; min-height: 1.15em; overflow: hidden; font-size: 9px; line-height: 1.15; opacity: 0.8; text-overflow: ellipsis; white-space: nowrap; }
.unit-give { padding: 0 6px 4px; }
.give-empty { grid-column: 1 / -1; font-size: 11px; color: #aaa; text-align: center; }
.sel-hint { font-size: 10.5px; color: #aaa; text-align: center; margin-top: 5px; }
.sel-hint:empty { display: none; }

/* on a phone the sheets stay compact (#188): tighter tiles, the hire buttons in one row */
@media (max-width: 767px) {
  .resources-grid div, .resource-group-members div { padding: 2px 2px; line-height: 1.25; }
  .recruit-row { flex-wrap: nowrap; }
  .recruit-row .btn { padding: 4px 5px; font-size: 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #raid-bar { width: min(94vw, 420px); }
  #raid-bar span { flex-basis: 100%; }
  #raid-bar .btn { flex: 1 1 calc(50% - 6px); font-size: 11px; }
}

/* the defeat screen (#191): over the game, which shows the base; the panel and possession go dead */
/* (in the middle of the map between the top bar with its strip and the dock, never over them; as big as the bars) */
#defeat-overlay { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--hud-under-strip) + 8px) 8px calc(var(--hud-dock) + 8px); background: rgba(0, 0, 0, 0.25); }
#defeat-overlay[hidden] { display: none; }
.defeat-box { zoom: var(--ui-scale, 1); background: rgba(20, 21, 26, 0.92); border: 1px solid #c0392b; border-radius: 8px; padding: 14px 18px; text-align: center; box-shadow: 0 6px 18px rgba(0,0,0,0.6); max-width: min(90%, 360px); }
.defeat-title { color: #e74c3c; font: bold 32px sans-serif; }
.defeat-survived { color: #fff; font-size: 16px; margin: 6px 0 12px; }
.defeat-buttons { display: flex; flex-direction: column; gap: 8px; }
.defeat-buttons .menu-button { margin: 0; }
body.defeated #dock, body.defeated #hud-bottom, body.defeated #resource-strip { pointer-events: none; opacity: 0.4; }


/* ========================================== */
/*   The HUD over the map (index.html)        */
/* ========================================== */
/* - the top bar: pause on the left, the mode's state in the middle (body[data-hud]), its actions on the right;
   - Endless: a strip of the main stock under it, a tap drops down all of it;
   - the dock at the bottom: a button per sheet; the sheet rises over the map above it, with the selected
     settler's card and the chip of the tool picked.
   They come in as a game starts and go as it ends (body.menu-world): the menu's own easing; the sheet
   rises like the menu's buttons (menu-rise), the chip pops with the buttons' spring. */
.hud-layer {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 20;
  visibility: hidden;
  opacity: 0;
  transition: transform 0.35s ease-in, opacity 0.3s ease, visibility 0s 0.35s;
}
#top-bar, #resource-strip, #battle-actions { transform: translateY(-140%); }
#dock, #hud-bottom { transform: translateY(140%); }
body[data-hud]:not(.menu-world) :is(#top-bar, #resource-strip, #battle-actions, #dock, #hud-bottom) {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: transform 0.55s var(--ease-settle), opacity 0.3s ease, visibility 0s;
}
/* one after the other, as the menu's title and buttons do */
body[data-hud]:not(.menu-world) :is(#resource-strip, #battle-actions) { transition-delay: 0.12s; }
body[data-hud]:not(.menu-world) #hud-bottom { transition-delay: 0.12s; }

/* ---- The top bar */
#top-bar {
  top: 0;
  height: var(--top-h);
  padding: env(safe-area-inset-top) 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #fff;
}
.btn-pause-square {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 16px;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
}
/* (in the room between pause and the actions, never under them, at any Interface size: the actions as wide as
   pause at least, so the middle stays in the middle of the screen) */
.top-center {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  container-type: inline-size;
}
/* little room (a phone held upright at a big Interface size): the wave's number without the word, on one line */
@container (max-width: 230px) {
  .top-wave-word { display: none; }
  .top-center .top-wave-main { column-gap: 8px; }
  .top-center .top-battle { gap: 4px; padding: 4px 6px; font-size: 12px; }
  .top-center .top-battle .battle-clear { width: 22px; height: 22px; }
}
.top-battle { min-width: 0; max-width: 100%; }
/* each side's broom on its colour, in the top bar beside its count (away from Fight!, Lima) */
.top-battle .battle-clear { min-height: 0; width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  flex: none; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.45); }
.top-battle .battle-clear .ic { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.7)); }
#battle-phase-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.top-wave, .top-battle, .top-editor { display: none; }
body[data-hud="endless"] .top-wave, body[data-hud="battle"] .top-battle, body[data-hud="editor"] .top-editor { display: flex; }
/* Endless: one dark plate as the Plague's (theme.css), the time of day's dial, then the wave's name and the time
   to it, big and white, a bar running down under them */
.top-wave {
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 4px 12px 4px 5px;
  border-radius: 8px;
  white-space: nowrap;
}
.top-wave-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  column-gap: 10px;
  row-gap: 3px;
  min-width: 0;
  font-size: 15px;
}
.top-wave-name { color: var(--gold, #f1c40f); font-weight: 700; }
.top-wave-time { font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; }
.top-wave-bar { flex-basis: 100%; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
#wave-progress { display: block; height: 100%; width: 100%; background: var(--gold, #f1c40f); transition: width 0.3s linear, background-color 0.3s ease; }
/* the last seconds pulse red; a wave coming in shakes it (the buttons' "no") */
@keyframes wave-soon { 0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.75); } 100% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); } }
.top-wave.soon { animation: wave-soon 1s ease-out infinite; }
.top-wave.soon .top-wave-time { color: #ff6b6b; }
.top-wave.soon #wave-progress { background: #e74c3c; }
.top-wave.arrived { animation: btn-no 0.45s ease; }
/* battle: placing, fighting or who won, and the count on each side */
.top-battle, .top-editor {
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  color: #fff;
}
.battle-score { font-variant-numeric: tabular-nums; }
.battle-score.green { color: #2ecc71; }
.battle-score.red { color: #e74c3c; }
/* (#326) the battle's music: a row per faction, its name then its tracks */
#battle-music .battle-music-row { flex-wrap: wrap; justify-content: center; align-items: center; }
#battle-music .battle-music-row .sub-tab { flex: 0 0 auto; padding: 4px 10px; }
.top-editor { border: none; cursor: pointer; font: inherit; font-size: 13px; overflow: hidden; }
#editor-map-label { overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 38px; flex: none; }
.top-actions .btn { padding: 7px 10px; font-size: 13px; }
/* battle (#255): under the top bar, clearing each side round Fight! in the middle; in a fight the auto
   battle and calling it off; nothing while the result shows */
#battle-actions { top: calc(var(--top-h) + 6px); left: 50%; right: auto; translate: -50% 0; max-width: calc(100% - 16px);
  display: flex; align-items: center; gap: 6px; }
body:not([data-hud="battle"]) #battle-actions { display: none; }
#battle-actions .btn { min-height: 34px; padding: 4px 10px; font-size: 12px; white-space: nowrap; }
#battle-actions #battle-fight { font-size: 14px; padding: 6px 16px; }
#battle-actions .btn.on { background: #1e8449; border-color: #27ae60; }
body:not([data-battle-phase="setup"]) .battle-setup-only,
body:not([data-battle-phase="fight"]):not([data-battle-phase="result"]) .battle-fight-only { display: none; }
/* (#299) the world map: Endless only */
body:not([data-hud="endless"]) .btn-worldmap { display: none; }
.btn-worldmap {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 6px;
  text-align: center;
}
.btn-worldmap .ic { width: 26px; height: 26px; }
.world-map { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 12, 0.72); }
.world-map[hidden] { display: none; }
.world-map-box { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 8px; background: rgba(20, 26, 32, 0.95); box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6); max-width: calc(100vw - 32px); }
.world-map-head, .world-map-foot { zoom: var(--ui-scale, 1); display: flex; align-items: center; gap: 8px; color: #ecf0f1; font-size: 15px; }
.world-map-head b { flex: 1; }
.world-map-foot { justify-content: space-between; flex-wrap: wrap; font-size: 13px; color: #d4cfb6; }
.world-map-foot .btn { margin-left: auto; padding: 7px 12px; font-size: 14px; }
/* (not the game's own canvas filling the screen: its side the room there is, a side shorter for a map not square) */
#world-map-canvas { --side: min(calc(100vw - 52px), calc(100vh - 170px)); position: static; width: calc(var(--side) * var(--map-w, 1)) !important; height: calc(var(--side) * var(--map-h, 1)) !important;
  image-rendering: pixelated; border-radius: 4px; touch-action: manipulation; }

/* ---- Endless: the main stock under the top bar, and all of it dropped down */
#resource-strip {
  top: calc(var(--top-h) + 6px);
  left: 50%;
  right: auto;
  translate: -50% 0;
  max-width: calc(100% - 16px);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
body:not([data-hud="endless"]) #resource-strip { display: none; }
.strip-chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 5px; white-space: nowrap; }
.strip-chip b { font-variant-numeric: tabular-nums; }
.strip-more { flex: none; padding: 0 4px; transition: transform 0.25s var(--ease-settle); }
/* a phone: the chips closer, so the arrow that drops the rest down stays on the screen at a big Interface size */
@media (max-width: 480px) {
  #resource-strip { gap: 2px; padding: 2px; }
  .strip-chip { padding: 2px 4px; gap: 2px; }
  .strip-more { padding: 0 2px; }
}
body.resources-open .strip-more { transform: rotate(180deg); }
#resources-panel {
  top: calc(var(--top-h) + 42px);
  left: 50%;
  right: auto;
  translate: -50% 0;
  width: min(760px, calc(100% - 12px));
  padding: 6px; /* no scrolling: an open group's row drops over the map below it */
  border-radius: 8px;
  transform: translateY(-10px);
  transition: transform 0.2s ease-in, opacity 0.2s ease, visibility 0s 0.2s;
}
body.resources-open[data-hud="endless"]:not(.menu-world) #resources-panel {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: transform 0.35s var(--ease-settle), opacity 0.2s ease, visibility 0s;
}

/* ---- Over the dock: the selected settler, the chip of the tool picked, the open sheet */
#hud-bottom {
  bottom: var(--dock-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 6px 6px;
  pointer-events: none;
}
#hud-bottom > * { pointer-events: auto; }
.selected-unit-box {
  display: none;
  white-space: nowrap;
  border-radius: 6px;
  padding: 4px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}
.selected-unit-box.has-settler { animation: menu-rise 0.3s var(--ease-settle); }
#placing-chip { display: none; align-items: stretch; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6); }
@keyframes chip-pop { 0% { opacity: 0; transform: scale(0.6); } 100% { opacity: 1; transform: none; } }
/* it pops once the sheet has sunk away (until then it would stand above it) */
body.placing:not(.sheet-open) #placing-chip { display: flex; animation: chip-pop 0.35s var(--spring) 0.22s both; }
.placing-what { border: none; background: none; color: #fff; font: inherit; font-size: 13px; padding: 9px 14px; cursor: pointer; white-space: nowrap; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; }
.placing-close { border: none; color: #fff; padding: 0 14px; font-size: 14px; cursor: pointer; }
.placing-close[hidden] { display: none; }
/* the sheet's frame rises in and sinks away (display flips at the end of the way out) */
/* (#279) the one scroll of a sheet: what's in it doesn't scroll by itself (two scroll bars) */
#sheet-frame {
  display: none;
  width: min(760px, 100%);
  height: auto;
  max-height: 30vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.18s ease, transform 0.22s ease-in, display 0.22s allow-discrete;
}
body.sheet-open #sheet-frame {
  display: block;
  opacity: 1;
  transform: none;
  transition: opacity 0.25s ease, transform 0.35s var(--ease-settle), display 0.35s allow-discrete;
}
@starting-style { body.sheet-open #sheet-frame { opacity: 0; transform: translateY(16px); } }
.hud-sheet { display: none; }
.hud-sheet.open { display: flex; flex-direction: column; gap: 6px; }

/* ---- The dock: one row per mode */
#dock { bottom: 0; height: var(--dock-h); padding-bottom: env(safe-area-inset-bottom); }
.dock-row { display: none; height: 100%; max-width: 640px; margin: 0 auto; gap: 4px; padding: 5px 6px; }
/* (the editor's: its kinds of button set apart by a wider gap) */
.dock-row .dock-apart { margin-left: 14px; }
@media (max-width: 520px) { .dock-row .dock-apart { margin-left: 6px; } }
body[data-hud="endless"] .dock-row[data-hud-mode="endless"],
body[data-hud="battle"] .dock-row[data-hud-mode="battle"],
body[data-hud="editor"] .dock-row[data-hud-mode="editor"] { display: flex; }
.dock-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 2px;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
}
.dock-btn .ic { font-size: 22px; }
.dock-btn span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-btn[hidden] { display: none; }
/* a battle's dock rests while it's fought */
body[data-battle-phase="fight"] .dock-row[data-hud-mode="battle"],
body[data-battle-phase="result"] .dock-row[data-hud-mode="battle"] { opacity: 0.4; pointer-events: none; }

/* the world's seed, in the pause menu (it was over the map) */
.pause-seed { font-size: 13px; color: #d4cfb6; word-break: break-all; user-select: text; -webkit-user-select: text; }

/* the colony sheet's stock row: what there is of what its prices ask for (bottom-panel.js) */
.sheet-stock { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; font-size: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--edge, #2d313b); }
.sheet-stock[hidden] { display: none; }

/* what a thing in the sheet is and does (#213, ui/item-info.js): over the sheet while pointed at or long-pressed */
#info-card { display: none; width: min(420px, 100%); padding: 8px 12px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6); font-size: 12px; pointer-events: none; }
body.sheet-open.info-open #info-card { display: block; animation: menu-rise 0.18s var(--ease-settle); }
.info-title { font-size: 14px; color: #fff; }
.info-desc { margin: 3px 0 5px; color: #d0d4dc; }
.info-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; color: #b6c1b8; }
.info-stat b { color: #fff; font-variant-numeric: tabular-nums; }

/* on a touch screen: the button whose card shows, a second tap presses it */
button.armed { outline: 2px solid #f1c40f; outline-offset: 1px; }

/* a building's card (#211) */
.card-title { font-size: 15px; color: #fff; text-align: center; }
.card-info { font-size: 12px; color: #c9cdd6; text-align: center; }
.card-hall[hidden] { display: none; }
.card-hint { font-size: 12px; color: #8a91a0; }
.hall-link { display: flex; justify-content: center; margin-bottom: 6px; }
#card-actions:empty { display: none; }

/* what the selected settler holds, a "take off" on each */
.selected-gear { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 4px; }
.selected-gear[hidden] { display: none; }
.selected-gear .btn { padding: 2px 7px; font-size: 11px; min-height: 0; }
.selected-gear .btn .ic-no { width: 10px; height: 10px; }
/* a thing it has: its name, then into the store or taken apart (#248) */
.gear-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 2px 1px 6px; font-size: 11px; border: 1px solid #4a5160; border-radius: 5px; }
.selected-gear .btn-store { background: #3f7a2e; }
.info-cost { color: #c9cdd6; }
.info-cost b { color: #fff; font-variant-numeric: tabular-nums; }
.info-cost.short, .info-cost.short b { color: #ff6b6b; }

/* the save button says how the save went (#254) */
#save-game-button.save-ok { background: #27ae60; color: #fff; }
#save-game-button.save-no { background: #c0392b; color: #fff; }

/* every tab's things as tiles (#261): a grid of compact buttons, the icon and name over the cost; a tap
   does it. Craft tiles: how many are stored in a corner, and under one with some, Give and Take apart */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; }
.btn.tile { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; position: relative;
  min-height: 40px; padding: 4px 6px; white-space: normal; text-align: left; font-size: 11px; line-height: 1.15; width: 100%; }
.tile-name { display: flex; align-items: center; gap: 4px; min-width: 0; }
.tile-name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.tile-cost { color: #aeb4c0; font-size: 10px; font-weight: normal; }
.tile-count { position: absolute; top: 2px; right: 4px; color: #f1c40f; font-size: 10px; }
.tile-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-acts { display: flex; gap: 2px; }
.tile-acts[hidden] { display: none; }
.btn.tile-act { flex: 1; padding: 1px 0; min-height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.sub-tabs { display: flex; gap: 4px; margin-bottom: 4px; }
.btn.sub-tab { flex: 1; }
.btn.sub-tab.on { background: var(--plank-green) center / cover; border-color: transparent; color: #fff; box-shadow: var(--glow); } /* (chosen: green, as everywhere, not blue) */

/* the stock's drop-down, one level (#248) */
#resources-hud.res-lines { display: flex; flex-direction: column; gap: 4px; }
.res-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 2px 0; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.res-line:first-child { border-top: none; }
/* (a group's name: light and bold, as the sheets' headings, not a thin grey) */
.res-line-name { color: #e8dcc0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; min-width: 84px; }
.res-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; white-space: nowrap; }

/* Point on a tile with several things on it: which one (#261) */
#pick-menu { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 3px; padding: 4px; min-width: 130px;
  background: rgba(24, 27, 34, 0.96); border: 1px solid #4a5160; border-radius: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
#pick-menu .btn { text-align: left; font-size: 12px; padding: 6px 8px; }

/* the saves as tiles (#254): its world, its wave and time; a small × in the corner, red while it asks */
/* saved games and maps: a row each, its tile (tap to load / pick) and, beside it, Rename, Export and the × */
.save-tiles { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.save-tile-wrap { position: relative; min-width: 0; display: flex; flex-direction: row; align-items: stretch; gap: 6px; }
.save-tile-wrap.current .save-tile { box-shadow: 0 0 0 2px #7cc35a; }
.save-tile-wrap .save-tile { flex: 1 1 auto; min-width: 0; min-height: 48px; text-align: left; }
.save-name-input { display: none; flex: 1 1 auto; min-width: 0; box-sizing: border-box; text-align: left; padding: 0 12px; }
.save-tile-wrap.renaming .save-name-input { display: block; }
.save-tile-wrap.renaming .save-tile { display: none; }
.save-map-actions, .save-map-confirm-buttons { display: flex; align-items: stretch; gap: 4px; flex: none; }
.save-map-actions .btn.tile-act { flex: none; padding: 0 12px; font-size: 13px; }
.save-map-actions .save-delete { flex: 0 0 28px; min-height: 28px; padding: 2px 4px; font-size: 10px; }
.save-map-actions .save-delete[hidden] { display: none; }
.save-map-actions .save-export[hidden] { display: none; }
.save-map-actions .save-delete.asking { flex: 1 1 auto; padding: 2px 8px; } /* (a save's "Delete?", in Export's place) */
.save-map-confirm { display: flex; flex-direction: column; gap: 4px; }
.save-map-confirm .item-question { font-size: 12px; line-height: 1.2; text-align: center; color: #f1c40f; }
.save-map-confirm-buttons .btn { flex: 1 1 0; min-width: 0; min-height: 28px; padding: 4px; }

/* the blight-by-itself switch (#253) */
#btn-auto-blight.on { background: #6c3483; border-color: #a569bd; }
#btn-base-zone.on { background: #117864; border-color: #48c9b0; color: #fff; }

/* Cards (#255): a locked thing's tile greyed under a lock; three cards over the map after a wave beaten */
.btn.tile.locked { opacity: 0.45; filter: grayscale(0.8); }
.btn.tile.no-place { opacity: 0.55; }
.tile-marks { position: absolute; top: 2px; right: 3px; display: flex; gap: 1px; font-size: 13px; pointer-events: none; }
#card-offer { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 16px; background: rgba(8, 10, 16, 0.72); }
.card-offer-title { color: #f5f0e1; font-size: 18px; font-weight: 700; text-align: center; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7); }
.card-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 100%; }
.card { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 132px; min-height: 186px; padding: 10px 8px;
  background: linear-gradient(180deg, #2b303b, #1d2028); border: 2px solid var(--card-edge); border-radius: 8px; color: #f5f0e1;
  box-shadow: 0 0 14px var(--card-glow), 0 6px 16px rgba(0, 0, 0, 0.6); cursor: pointer; font: inherit; }
.card:hover { transform: translateY(-3px); }
.card-common { --card-edge: #95a5a6; --card-glow: rgba(149, 165, 166, 0.25); }
.card-rare { --card-edge: #3498db; --card-glow: rgba(52, 152, 219, 0.45); }
.card-legendary { --card-edge: #f1c40f; --card-glow: rgba(241, 196, 15, 0.55); }
.card-rarity { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--card-edge); font-weight: 700; }
.card-icon { font-size: 46px; line-height: 1; margin: 6px 0; }
.card-name { font-size: 14px; text-align: center; }
.card-kind { font-size: 11px; color: #aeb4c0; }
.card-cost { font-size: 11px; color: #d5d8dc; margin-top: auto; }
@media (max-width: 460px) { .card { width: 100px; min-height: 160px; } .card-icon { font-size: 36px; } }

body[data-plague="yes"] #hud-bottom,
body[data-plague="yes"] #resource-strip,
body[data-plague="yes"] .top-wave { display: none !important; }
body[data-plague="yes"] .plague-upgrades-toggle { display: flex; }
body:not([data-plague="yes"]) .plague-upgrades-toggle { display: none; }
body[data-hud="plague"] .dock-row[data-hud-mode="plague"] { display: flex; }
#plague-actions[hidden], .plague-modal[hidden] { display: none !important; }
.dock-row[data-hud-mode="plague"] {
  height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
  padding: 3px 6px 5px;
}
#plague-actions { width: min(100%, 360px); }
.plague-stats { display: none; }
body[data-hud="plague"] .plague-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: 100%; /* (the room between pause and the right edge, zoomed or not: theme.css its plate) */
  padding: 3px 5px;
  border-radius: 8px;
}
.plague-stat {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 7px;
  color: #e4d8ed;
  font-size: 11px;
  white-space: nowrap;
}
.plague-stat + .plague-stat { border-left: 1px solid rgba(200, 192, 206, 0.22); }
.plague-stat .ic { width: 16px; height: 16px; flex: none; }
.plague-stat-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.plague-stat b { color: #fff; font-size: 15px; font-variant-numeric: tabular-nums; }
/* the level, then how far to the next one: smaller and lighter, not a second number jammed against it */
.plague-stat #plague-experience { color: #c8c0ce; font-size: 12px; font-weight: 600; }
body[data-hud="plague"] .plague-upgrades-toggle {
  display: flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  margin-left: 2px;
  border: 1px solid rgba(200, 192, 206, 0.28);
  background: rgba(255, 255, 255, 0.08);
}
#plague-actions #plague-revive {
  position: relative;
  flex: 0 0 50px;
  align-self: center;
  flex-direction: row;
  gap: 6px;
  width: min(100%, 150px);
  overflow: hidden;
}
#plague-revive .ic { flex: none; font-size: 18px; }
.plague-revive-progress {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: rgba(164, 112, 190, 0.36);
  transition: width 0.1s linear;
}
#plague-revive .ic, #plague-revive-label {
  position: relative;
  z-index: 1;
}
#plague-revive:disabled { opacity: 0.85; cursor: default; }
.plague-modal {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px;
  overflow: auto;
  background: rgba(8, 10, 16, 0.9);
  color: #f5f0e1;
}
/* (#404) the three side by side, as wide as each other, on a phone's screen too */
.plague-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: min(640px, 100%); }
.plague-upgrade-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  min-height: 132px;
  padding: 14px;
  border: 1px solid #8e6a9c;
  border-radius: 8px;
  background: linear-gradient(160deg, #33273b, #1d2028);
  color: #f5f0e1;
  text-align: center;
  font: inherit;
  cursor: pointer;
}
.plague-upgrade-card span { color: #c8c0ce; font-size: 12px; }
@media (max-width: 520px) {
  .plague-card-grid { gap: 6px; }
  .plague-upgrade-card { min-height: 110px; padding: 8px 6px; gap: 6px; font-size: 13px; overflow-wrap: anywhere; }
  .plague-upgrade-card span { font-size: 11px; }
}
.plague-character-stat b.raised { color: #b8e986; }
.plague-upgrades-modal { z-index: 76; }
.plague-upgrades-content {
  width: min(560px, 100%);
  max-height: min(75vh, 640px);
  padding: 18px;
  overflow: auto;
  border: 1px solid #8e6a9c;
  border-radius: 8px;
  background: linear-gradient(160deg, #33273b, #1d2028);
}
.plague-upgrades-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plague-upgrades-heading h2 { flex: 1 1 auto; min-width: 0; margin: 0; overflow-wrap: anywhere; }
#plague-upgrades-close { display: flex; flex: 0 0 36px; align-items: center; justify-content: center; width: 36px; height: 36px; min-width: 36px; padding: 0; }
#plague-upgrades-close .ic { flex: none; }
.plague-character-stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.plague-character-group {
  min-width: 0;
  padding: 8px 10px 6px;
  border: 1px solid rgba(142, 106, 156, 0.38);
  border-radius: 8px;
  background: linear-gradient(120deg, rgba(142, 106, 156, 0.1), rgba(29, 32, 40, 0.48));
}
.plague-character-group-title {
  margin: 0 0 4px;
  padding: 0 0 5px;
  border-bottom: 1px solid rgba(187, 143, 206, 0.34);
  color: #d7b5e5;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.plague-character-group-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 18px;
}
.plague-character-stat {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  padding: 4px 0;
  border-bottom: 1px solid rgba(200, 192, 206, 0.16);
  font-size: 12px;
}
.plague-character-stat span { flex: 1 1 auto; min-width: 0; color: #c8c0ce; overflow-wrap: anywhere; }
.plague-character-stat b { flex: 0 0 auto; max-width: 45%; color: #fff; text-align: right; white-space: normal; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .dock-row[data-hud-mode="plague"] { padding-inline: 5px; }
  body[data-hud="plague"] .plague-stats { gap: 1px; padding: 2px 3px; }
  .plague-stat { gap: 3px; font-size: 8px; padding: 5px 4px; }
  .plague-stat .ic { width: 13px; height: 13px; }
  .plague-stat b { font-size: 12px; }
  body[data-hud="plague"] .plague-upgrades-toggle { width: 30px; height: 30px; flex-basis: 30px; }
  .plague-upgrades-content { padding: 12px; }
  .plague-character-stats { gap: 7px; }
  .plague-character-group { padding: 7px 8px 5px; }
  .plague-character-group-stats { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .plague-character-stat { gap: 8px; padding: 5px 0; font-size: 11px; }
}

/* A raid on an enemy camp (#255): the bar under the top of the screen, the party picker */
#raid-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; pointer-events: auto;
  width: max-content; max-width: calc(100vw - 16px); padding: 4px 6px; border-radius: 8px; background: rgba(24, 27, 34, 0.9); border: 1px solid #7b241c;
  color: #f5f0e1; font-size: 12px; white-space: nowrap; }
#raid-bar span { flex: 1 1 100%; min-width: 0; padding: 0 4px; overflow-wrap: anywhere; white-space: normal; }
#raid-bar .btn { flex: 1 1 auto; min-width: 0; min-height: 30px; padding: 4px 8px; font-size: 12px; white-space: normal; }
#raid-bar .btn small { display: block; }
#raid-bar .btn.on { background: #1e8449; border-color: #27ae60; }
.btn.raid-go { background: #922b21; border-color: #e74c3c; color: #fff; }
#raid-picker { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 16px; background: rgba(8, 10, 16, 0.75); }
.raid-camp-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: min(560px, 94vw); }
.raid-camp-option { min-height: 38px; max-width: 260px; white-space: normal; font-size: 12px; }
.raid-camp-option.on { background: #1e8449; border-color: #27ae60; }
.raid-roster { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 560px; max-height: 50vh; overflow-y: auto; }
.raid-unit { display: flex; align-items: center; gap: 2px; padding: 6px 8px; font-size: 18px; opacity: 0.5; }
.raid-unit.on { opacity: 1; box-shadow: 0 0 0 2px #e74c3c; }
.raid-hp { font-size: 11px; color: #aeb4c0; margin-left: 3px; }
.raid-picker-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.raid-scout-status { width: 100%; text-align: center; }

/* the battle's and the editor's sheets as Endless's (#255): long ones scroll; the brush sizes small, dragging wide */
.editor-brush .sub-tab:last-child { flex: 2.2; }

/* the Craft tab in one (#279): a heading for each kind, its places under it */
.craft-kind { margin: 8px 0 2px; padding-bottom: 2px; border-bottom: 1px solid rgba(255, 255, 255, 0.12); color: #f5f0e1; font-size: 13px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
#craft-tools .craft-kind { margin-top: 0; }

/* a storage's card (#279): what's in it, by it, what it keeps */
.card-store { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; font-size: 12px; }
.card-store[hidden] { display: none; }
.card-store-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.card-store-line b { color: #aeb4c0; font-weight: 600; font-size: 11px; }
.card-store-line small { color: #8a91a0; margin-left: -4px; }

/* the time of day (#279): a dial of morning, day, evening and night, a hand on now, the sun or the moon */
.day-clock { display: none; position: relative; width: 34px; height: 34px; border-radius: 50%; flex: none;
  border: 2px solid rgba(0, 0, 0, 0.55); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); align-self: center; }
body[data-hud="endless"] .day-clock { display: block; }
.day-hand { position: absolute; left: 50%; top: 50%; width: 2px; height: 15px; margin-left: -1px; background: #fff; border-radius: 1px;
  transform-origin: 50% 0; box-shadow: 0 0 2px #000; }
.day-face { position: absolute; inset: 9px; border-radius: 50%; background: rgba(15, 18, 30, 0.85); display: flex; align-items: center; justify-content: center; font-size: 11px; }
.day-face .ic { width: 13px; height: 13px; }

/* the stock's drop-down (#279): names by the numbers, how it's changed in a minute, nothing of a thing hidden */
.res-chip[hidden], .res-line[hidden] { display: none; }
.res-chip .res-name { color: #c9c4b0; font-size: 12px; }
/* the base's strength: white, red only once it's half gone (hud.js) */
#base-hp-txt { color: #fff; }
#base-hp-txt.low { color: #e74c3c; }
.res-chip .res-rate { font-style: normal; font-size: 10px; color: #58d68d; }
.res-chip .res-rate.down { color: #ec7063; }
/* the arrows a raid takes (#279) */
.raid-arrows { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 6px 0; }
.raid-arrows .btn { min-width: 34px; }
/* (#279) what's not the faction's in the Zones tab stays hidden (a tile's display would show it) */
#tab-farming .eats-only[hidden], #tab-farming .farm-only[hidden], #tab-farming .undead-only[hidden] { display: none !important; }
#tab-farming .undead-only { margin-top: 6px; }
.settings-note { font-size: 12px; color: #f1c40f; margin-top: 4px; }

/* (#326) while the game starts: only the dark background, not the menu half made */
body.booting > * { visibility: hidden; }

/* (#326) a plain black loading screen with a clear, high-contrast progress indicator */
/* the world being made or read: the menu's own green, a panel as the menu's, its words large, the bar a groove filling green */
#loading-screen { position: fixed; inset: 0; z-index: 20000; display: flex; align-items: center; justify-content: center; pointer-events: all;
  background: #111a0d radial-gradient(ellipse at 50% 40%, #33452a 0%, #1d2a17 60%, #111a0d 100%); }
#loading-screen[hidden] { display: none; }
.loading-box { width: min(460px, 82vw); padding: 22px 26px 26px; text-align: center; color: var(--text-bright, #fff); border-radius: 8px;
  background: rgba(62, 78, 46, 0.93); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7); }
#loading-title { font-family: var(--font, inherit); font-size: 22px; font-weight: 700; margin-bottom: 16px; letter-spacing: 0.03em; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); }
.loading-bar { height: 14px; border-radius: 7px; background: #1e1f19; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6); overflow: hidden; padding: 2px; box-sizing: border-box; }
#loading-fill { height: 100%; width: 0; border-radius: 5px; background: linear-gradient(to bottom, #8fd06a, #5f9e43); transition: width 0.15s ease-out; }
body.loading #main-menu .main-menu-content, body.loading #menu-title, body.loading #menu-eye-box, body.loading #menu-scene-bar, body.loading #menu-flags { display: none !important; }

/* (#326) leaving a possessed unit whose card is closed: a pill over the dock */
#btn-leave-unit { align-self: center; margin-bottom: 8px; padding: 8px 16px; border-radius: 6px; pointer-events: auto; }

/* (#326) the eye and language flag use matching compact control boxes at opposite corners */
.flag-box { position: fixed; left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 5;
  display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 4px; width: 44px; box-sizing: border-box;
  background: rgba(13, 20, 13, 0.94); border: 1px solid rgba(180, 195, 180, 0.28); border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45); }
body.menu-ui-hidden #menu-flags { display: none; }
.flag-button { display: flex; padding: 1px; background: none; border: 1px solid transparent; border-radius: 3px; cursor: pointer; line-height: 0; }
.menu-eye-button { width: 34px; height: 24px; align-items: center; justify-content: center; color: #d5dfd5; }
.menu-eye-button .ic { width: 20px; height: 20px; }
.flag-button .flag { width: 100%; height: auto; }
.flag-button.active { border-color: #7cc35a; }
.language-option { display: inline-flex; align-items: center; gap: 6px; }
/* Settings' language: a drop-down */
.language-picker { position: relative; }
.language-current { width: 100%; justify-content: center; }
.language-caret { display: inline-block; width: 0; height: 0; margin-left: 6px; opacity: 0.8; /* (a drawn triangle, not a text arrow) */
  border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; }
.language-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 5; display: flex; flex-direction: column;
  gap: 4px; padding: 4px; background: #1b2419; border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7); }
.language-list[hidden] { display: none; }
.language-list .language-option { justify-content: center; }
/* (a developers' row, hidden: its class's display mustn't show it) */
.dev-setting[hidden] { display: none; }
/* (glide.js) the soft light sliding under the mouse along a row of options */
.glide { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; border-radius: 6px; opacity: 0;
  background: rgba(255, 236, 190, 0.1); box-shadow: inset 0 0 0 1px rgba(255, 228, 160, 0.45), 0 0 10px rgba(255, 220, 140, 0.18);
  /* (placed in shares of its row, as the tracks' thumb: in pixels it came out a menu's zoom off in some browsers) */
  will-change: left, opacity; transition: left 0.22s cubic-bezier(0.22, 0.9, 0.3, 1), top 0.22s ease, width 0.22s ease, opacity 0.18s ease; }
.glide.on { opacity: 1; }
/* An Off / On setting as a switch: its name on the left, a track with a knob on the right. The two buttons are still
   there (its halves, their words hidden), so a tap on either half works; a tap on the chosen half flips it
   (menu.screens.js initSwitches) */
.wave-settings.switch-row { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.switch-row .settings-note { flex-basis: 100%; text-align: left; }
.wave-options.switch { position: relative; flex: none; width: 58px; height: 30px; gap: 0; padding: 0; border-radius: 15px;
  background: #1e1f19; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06); transition: background-color 0.25s ease; }
.wave-options.switch .fps-option { flex: 1; min-height: 0; height: 100%; padding: 0; border: none; border-radius: 15px; font-size: 0;
  color: transparent; background: transparent; box-shadow: none; position: relative; z-index: 1; cursor: pointer; }
.wave-options.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8e2, #d9cfae 70%); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1); will-change: transform; }
.wave-options.switch:has(> .fps-option:last-of-type.active) { background: #4f7a3a; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.45), 0 0 10px rgba(120, 190, 90, 0.35); }
.wave-options.switch:has(> .fps-option:last-of-type.active)::after { transform: translateX(28px); }
/* Settings' groups: a panel drawn out beside Settings (under it on a narrow screen), stretching out to its place */
#main-menu .settings-drawer:not([hidden]) { position: fixed; z-index: 2; margin: 0; overflow-y: auto; max-width: none;
  top: var(--drawer-top); left: var(--drawer-left); width: var(--drawer-width); max-height: var(--drawer-max-height);
  background: rgba(30, 50, 34, 0.42); transform-origin: left center; animation: drawer-out 0.36s cubic-bezier(0.34, 1.4, 0.64, 1) backwards; }
#main-menu .settings-drawer.below:not([hidden]) { transform-origin: center top; animation-name: drawer-down; }
#main-menu .settings-drawer h2 { margin: 0; font-size: 18px; color: var(--text-bright, #fff); }
@keyframes drawer-out { from { opacity: 0; transform: translate3d(-28px, 0, 0) scaleX(0.82); } to { opacity: 1; transform: none; } }
@keyframes drawer-down { from { opacity: 0; transform: translate3d(0, -18px, 0) scaleY(0.82); } to { opacity: 1; transform: none; } }
.main-menu-content .menu-button.settings-group.active { background: var(--plank-green) center / cover; color: var(--text-bright); box-shadow: var(--glow); }
/* (in a panel the language's list opens in its place, not over the panel's edge) */
.settings-drawer .language-list { position: static; margin-top: 4px; box-shadow: none; }
/* Settings' sound and music: how loud, a slider from 0 to 100, its part up to the knob filled */
.wave-settings.volume-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.volume { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 190px; }
.volume-value { min-width: 26px; text-align: right; font-size: 12px; color: #d4cfb6; font-variant-numeric: tabular-nums; }
.volume-slider { -webkit-appearance: none; appearance: none; flex: 1; height: 8px; border-radius: 4px; cursor: pointer; margin: 0;
  background: linear-gradient(to right, #6fa34f 0 var(--fill, 100%), #1e1f19 var(--fill, 100%) 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7); }
.volume-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8e2, #d9cfae 70%); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); transition: transform 0.15s ease; }
.volume-slider::-moz-range-thumb { width: 22px; height: 22px; border: none; border-radius: 50%; background: #e9e2c8; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); }
.volume-slider:active::-webkit-slider-thumb { transform: scale(1.15); }
/* Sound's Advanced, and the music player's own screen: wide, in the middle, the tracks in two columns where there's room */
.settings-advanced { margin-top: 4px; }
#main-menu .main-menu-content.music-screen { width: min(760px, 94vw); max-width: none; max-height: var(--menu-room); overflow-y: auto; }
.music-screen #music-player:not(#x) { max-height: none; overflow: visible; }
/* a card a group, side by side where there's room; a night track with a moon by its name */
/* A row of options as one segmented track, no gaps: the chosen one's green plank slides along it, as a switch's
   knob does (menu.screens.js initSegments) */
.wave-options.segmented { position: relative; gap: 0; padding: 3px; border-radius: 8px; background: #1e1f19;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05); }
.wave-options.segmented > button { position: relative; z-index: 1; background: transparent !important;
  box-shadow: none !important; border: none; border-radius: 5px; transition: color 0.2s ease; }
.wave-options.segmented > .active { color: #fff; }
.segment-thumb { position: absolute; left: 0; top: 3px; bottom: 3px; z-index: 0; border-radius: 5px; pointer-events: none;
  background: var(--plank-green) center / cover; box-shadow: var(--glow); transition: left 0.28s cubic-bezier(0.34, 1.3, 0.64, 1), width 0.28s ease; }
.segment-thumb.jump { transition: none; }
/* the editor's generate switch with the generator's gear beside it (not in the pane's corner) */
.switch-with-gear { display: inline-flex; align-items: center; gap: 8px; }
.switch-with-gear .menu-gear { position: static !important; }
.options-with-gear { display: flex; align-items: center; gap: 8px; }
.options-with-gear > .wave-options { flex: 1; min-width: 0; }
.options-with-gear > .menu-gear { position: static !important; flex: none; }
.music-screen > h1 { display: flex; align-items: center; gap: 14px; } /* ——— Music ——— */
.music-screen > h1::before, .music-screen > h1::after { content: ''; flex: 1; height: 2px; background: linear-gradient(to right, transparent, rgba(232, 199, 106, 0.7)); }
.music-screen > h1::after { background: linear-gradient(to left, transparent, rgba(232, 199, 106, 0.7)); }
.music-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.music-card { background: rgba(0, 0, 0, 0.18); border-radius: 0; padding: 6px 12px 8px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05); }
.music-card .music-group { margin-top: 4px; }
.music-number { margin-right: 6px; font-size: 12px; color: #e8c76a; white-space: nowrap; }
.music-name { flex-direction: row !important; align-items: baseline; flex-wrap: wrap; }
.music-moon { width: 14px; height: 14px; margin-left: 6px; align-self: center; }
.music-row:not(.night) .music-moon { display: none !important; }

@media (prefers-reduced-motion: reduce) { #main-menu .settings-drawer { animation: none; } .wave-options.switch::after { transition: none; } }
.glide.jump { transition: none; }
/* a menu screen coming in: faded up a little, not appearing at once */
@keyframes menu-screen-in { from { opacity: 0; } to { opacity: 1; } }
/* (the blur behind a screen off while it comes in: fading a blurred backdrop is what stuttered) */
/* (backwards, not both: a transform left on a panel after it came in put the scene's canvas over it) */
#main-menu .main-menu-content:not([hidden]) { animation: menu-screen-in 0.26s ease 0.05s backwards; }
/* the language's flag and the eye: on the first screen only */
#main-menu:not([data-menu-screen="home"]) #menu-flags, #main-menu:not([data-menu-screen="home"]) #menu-eye-box { display: none !important; }
@media (prefers-reduced-motion: reduce) { #main-menu .main-menu-content:not([hidden]) { animation: none; } .glide { transition: none; } }
.language-option .flag { flex: none; }

/* (#326) the music player in Settings: a long list that scrolls inside the panel */
#music-player { max-height: 38vh; overflow-y: auto; text-align: left; padding-right: 2px; }
.music-group { margin: 10px 0 4px; font-size: 12px; font-weight: bold; color: #e8c76a; letter-spacing: 0.06em; text-transform: uppercase; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.music-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.music-row.off .music-name { opacity: 0.45; }
.music-listen { flex: none; width: 34px; min-height: 30px; padding: 0; }
.music-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.music-name b { font-size: 13px; }
.music-part { margin: 6px 0 2px; font-size: 12px; color: #d4cfb6; break-after: avoid; } /* (when the tracks under it play) */
.music-toggle { flex: none; min-width: 52px; min-height: 30px; padding: 0 8px; font-size: 12px; }
.music-toggle.on, .music-listen.on { background: #3f7a2e; border-color: #7cc35a; color: #fff; }

/* The editor's brush: a slider at the left of the screen, half way down, only in the editor */
#editor-brush { position: fixed; left: 10px; top: 50%; transform: translateY(-50%); z-index: 6; display: none; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px 8px; border-radius: 8px; background: rgba(24, 30, 18, 0.88); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6); color: #d4cfb6; font-size: 12px; font-weight: bold; }
body.editor-mode:not(.menu-world) #editor-brush { display: flex; zoom: var(--ui-scale, 1); }
#editor-brush input { -webkit-appearance: none; appearance: none; writing-mode: vertical-lr; direction: rtl; width: 8px; height: 110px; margin: 0; border-radius: 4px; cursor: pointer;
  background: linear-gradient(to top, #6fa34f 0 var(--fill, 0%), #1e1f19 var(--fill, 0%) 100%); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7); }
#editor-brush input::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff8e2, #d9cfae 70%); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); }
#editor-brush b { color: #e8c76a; }

/* The editor's Map sheet: two columns where there's room (its name and look; its time and weather) */
.editor-map-grid { display: grid; grid-template-columns: 1fr; gap: 6px 22px; }
@media (min-width: 700px) { .editor-map-grid { grid-template-columns: 1fr 1fr; } }
.editor-map-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* the saves' and maps' screens wide enough for a row of a save and its buttons */
#main-menu .main-menu-content.save-manager:not([hidden]) { width: min(620px, calc(94vw / var(--menu-zoom))); max-width: none; }
.save-map-actions .btn.tile-act { align-self: center; height: 38px; }
#save-actions { display: flex; gap: 8px; }
#save-actions .menu-button { flex: 1; min-height: 44px; padding: 8px 12px; font-size: 15px; }

/* Endless: the rest of its settings folded under More, opened with a tap on it */
.endless-more { width: 100%; }
.endless-more > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 0; font-size: 16px; font-weight: 700; color: var(--text, #eee); }
.endless-more > summary::-webkit-details-marker { display: none; }
.endless-more > summary::after { content: ''; width: 7px; height: 7px; margin-top: -4px; border-right: 2px solid #e8c76a; border-bottom: 2px solid #e8c76a;
  transform: rotate(45deg); transition: transform 0.25s; }
.endless-more[open] > summary::after { margin-top: 3px; transform: rotate(-135deg); }
.endless-more-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.endless-more-grid > * { width: 100%; min-width: 0; }
.endless-more[open] .endless-more-grid { animation: more-in 0.3s ease-out; }
@keyframes more-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---- Battles' sheets: each setting a row, its name on the left and its choices on a track on the right (a choice of one,
   the chosen one's green plank sliding along it, as the main menu's settings: battle.panel.js placeSheetTracks); an add-on
   a switch, on or off */
.battle-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 8px; }
.battle-row[hidden] { display: none; }
.battle-row-name { font-size: 13px; font-weight: 700; color: #ece4cb; text-align: left; }
.sheet-track { position: relative; display: flex; gap: 0; padding: 3px; border-radius: 8px; background: #1e1f19; min-width: 0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06); }
html:root .sheet-track > .seg-option { position: relative; z-index: 1; flex: 1 1 0; min-width: 0; min-height: 32px; margin: 0; padding: 4px 4px;
  background: transparent !important; box-shadow: none !important; border: none; border-radius: 6px; cursor: pointer;
  font-family: var(--font); font-size: 12px; font-weight: 700; line-height: 1.1; color: #ddd5bb; white-space: normal; transition: color 0.2s ease; }
html:root .sheet-track > .seg-option.on { color: #fff; }
html:root .sheet-track > .seg-option:disabled { cursor: default; opacity: 0.55; }
@media (hover: hover) { html:root .sheet-track > .seg-option:not(:disabled):not(.on):hover { color: #fff; transform: none; } }
.sheet-track .segment-thumb { top: 3px; bottom: auto; }

/* the units' sheet: the next unit's picture beside its choices; buildings have none of it */
.battle-unit-setup { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; margin-bottom: 2px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
#battle-panel[data-category="buildings"] .battle-unit-setup { display: none; }
.battle-preview { position: static; flex: none; width: 112px !important; height: 112px !important; cursor: default; touch-action: auto; border-radius: 8px; background: radial-gradient(circle at 50% 62%, rgba(120, 150, 90, 0.35), rgba(0, 0, 0, 0.25) 70%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.battle-unit-choices { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.battle-gear { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.battle-toggle { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; min-height: 34px; padding: 4px 6px 4px 10px;
  border: none; border-radius: 6px; background: rgba(0, 0, 0, 0.28); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07); cursor: pointer;
  font-family: var(--font); font-size: 12px; font-weight: 700; color: #ece4cb; text-align: left; }
.battle-toggle > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* (a small switch: its track dark with the knob left when off, green with the knob right when on) */
.battle-toggle .toggle-knob { position: relative; flex: none; width: 38px; height: 22px; border-radius: 11px; background: #1e1f19;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06); transition: background-color 0.25s ease; }
.battle-toggle .toggle-knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8e2, #d9cfae 70%); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.battle-toggle.on { color: #fff; }
.battle-toggle.on .toggle-knob { background: #4f7a3a; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.45), 0 0 8px rgba(120, 190, 90, 0.35); }
.battle-toggle.on .toggle-knob::after { transform: translateX(16px); }
@media (max-width: 560px) {
  /* (narrow: the tracks across the whole sheet, the picture beside the switches under them) */
  .battle-unit-setup { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 6px 8px; }
  .battle-unit-choices { display: contents; }
  .battle-unit-setup > .battle-preview { order: 1; }
  .battle-unit-setup .battle-gear { order: 2; align-self: center; }
  .battle-unit-setup .battle-row { grid-column: 1 / -1; }
  html:root .sheet-track > .seg-option { font-size: 11px; padding: 4px 2px; }
  .battle-preview { width: 76px !important; height: 76px !important; }
  .battle-gear { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .battle-row { grid-template-columns: 70px minmax(0, 1fr); gap: 6px; }
  .battle-row-name { font-size: 12px; }
}

/* the battle's settings: the field on one side, how it looks and the fight on the other where there's room, the colours under
   them; the frame taller and wider for it, so it doesn't scroll */
.battle-settings-grid { display: grid; grid-template-columns: 1fr; gap: 6px 20px; }
.battle-settings-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
@media (min-width: 760px) { .battle-settings-grid { grid-template-columns: 1fr 1fr; } }
.battle-size-fields { display: flex; align-items: center; gap: 6px; color: #ece4cb; }
[data-sheet="battle-settings"] .battle-hint { margin: 0; text-align: left; padding-left: 96px; font-size: 12px; color: #d8d0b6; }
@media (max-width: 560px) { [data-sheet="battle-settings"] .battle-hint { padding-left: 76px; } }
.battle-colors { display: grid; grid-template-columns: 1fr; gap: 6px 20px; margin-top: 4px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
@media (min-width: 760px) { .battle-colors { grid-template-columns: 1fr 1fr; } }
.battle-colors .color-options { justify-content: flex-start; }
#sheet-frame:has(> [data-sheet="battle-settings"].open) { width: min(920px, 100%); max-height: min(72vh, 520px); }
#sheet-frame:has(> #battle-panel.open) { max-height: min(60vh, 560px); }

#battle-actions #battle-fight { flex: none; }
/* a notice in a battle comes up under Fight!, never over it */
body[data-hud="battle"] #toast-notification { top: calc((var(--top-h) + 6px + 46px) * var(--ui-scale, 1) + 8px); }

/* a side's colour: one circle beside its factions, its others dropping from it on a tap */
.color-pick { position: relative; flex: none; display: flex; align-items: center; }
.color-current { width: 30px; height: 30px; min-height: 0; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.85); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.55); transition: transform 0.15s ease; }
.color-current:active { transform: scale(0.92); }
.color-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; display: grid; grid-template-columns: repeat(5, 28px); /* (two rows of five: ten in a row, 372 px, went off a phone's screen) */
  gap: 8px; padding: 10px; border-radius: 8px; background: #2a3322; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6); animation: pop-in 0.22s ease-out; }
.color-pop[hidden] { display: none; }
.color-pop .color-swatch { width: 28px; height: 28px; max-width: none; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: none; } }

/* Endless's and the Plague's settings: each one's name at the left over its choices, as a form reads, not centred */
#main-menu :is([data-screen="endless"], [data-screen="plague"]) .wave-settings > div:not([class]):first-child,
#main-menu :is([data-screen="endless"], [data-screen="plague"]) .endless-world-settings > div > div:first-child,
#main-menu :is([data-screen="endless"], [data-screen="plague"]) .plague-range > div:first-child,
#main-menu :is([data-screen="endless"], [data-screen="plague"]) .seed-settings > label { text-align: left; align-self: stretch; padding-left: 4px; }
#main-menu [data-screen="plague"] .plague-range-fields { justify-content: flex-start; }
