body.theme-dark {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1c1c1f;
  --surface-raised: #242428;
  --border: #3f3832;
  --border-strong: #5c4a3a;
  --text: #b4b4b8;
  --text-heading: #c8c8cc;
  --text-muted: #8a8a90;
  --text-subtle: #74747a;
  --text-faint: #5e5e64;
  --accent: #a06038;
  --accent-hover: #b06c42;
  --accent-muted: rgba(160, 96, 56, 0.16);
  --btn-primary-text: #f5efe6;
  --btn-ghost-hover-bg: #2a2a2e;
  --btn-ghost-hover-text: #d0d0d4;
  --success: #5a7a52;
  --success-bg: #1c241c;
  --danger: #8a4c48;
  --danger-bg: #281c1c;
  --info: #5a6e78;
  --warning-bg: #2a241c;
  --warning-border: #5c4a32;
  --warning-text: #b09060;
  --reward-text: #7a9a72;
  --wrong-text: #b0706a;
  --log-bg: #1e1e22;
  --log-entry-border: #2e2e32;
  --modal-overlay: rgba(0, 0, 0, 0.72);
  --modal-bg: #1e1e22;
  --modal-header-border: #3f3832;
  --close: #7a7a80;
  --close-hover: #d0d0d4;
  --map-cell-bg: #fff8ee;
  --map-cell-border: #d0c0a4;
  --input-bg: #1a1a1c;
  --input-border: #4a4038;
  --science-track: #2a2a2e;
  --science-fill: #a06038;
  --chip-bg: #26262a;
  --chip-border: #3f3832;
  --strip-bg: rgba(255, 255, 255, 0.04);
  --strip-enemy: #8a4c48;
  --strip-friendly: #4a6470;
  --strip-empty: #5a5a60;
  --siege-accent: #8a6050;
  --siege-banner-bg: rgba(160, 96, 56, 0.06);
  --siege-label: #a07060;
  --siege-label-bg: rgba(160, 96, 56, 0.12);
  --siege-title: #b4b4b8;
  --tavern-divider: #3f3832;
  --chat-log-bg: rgba(0, 0, 0, 0.22);
  --theme-btn-bg: #1e1e22;
  --theme-btn-border: #5c4a3a;
  --theme-btn-active-bg: #a06038;
  --theme-btn-active-text: #f5efe6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
  --font-ui: 'IBM Plex Sans', 'Segoe UI', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', system-ui, sans-serif;
  /* Tektur has wide Cyrillic metrics on iOS and reads as “spaced” letters — keep HUD on Plex Sans. */
  --font-display: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --font-hud: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --tracking-tight: 0;
  --tracking-normal: 0;
  --tracking-wide: 0;
  --tracking-caps: 0;
  --tracking-hud: 0;
  --map-swamp-bg: #d8e8c8;
  --map-garrison-bg: #ecd8b0;
  --map-barbarian: #7a3810;
  --map-castle: #7a5828;
  --map-fort: #5a3868;
  --map-fort-room-bg: #f0e8d8;
  --map-fort-unknown: #7a1818;
  --map-treasure: #a07818;
  --map-colony: #2878a0;
  --map-swamp-label: #2a5828;
  --map-focus-border: #c87818;
  --map-empty-label: #a08068;
  --map-cleared: #6b5040;
  --map-oil-label: #6b5040;
  --season-summer-bg: #2a2418;
  --season-summer-text: #b09060;
  --season-winter-bg: #1c2428;
  --season-winter-text: #7a9aac;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: none;
}

body.theme-dark h1 {
  font-family: var(--font-display);
  letter-spacing: normal;
}

body.theme-dark .login-wrap,
body.theme-dark .login-wrap h1,
body.theme-dark .login-wrap label,
body.theme-dark .login-wrap .primary {
  font-family: var(--font-ui);
  letter-spacing: normal;
}

/* Match / lobby: same tight UI type as other themes; no HUD tracking leak. */
body.theme-dark .lobby-root,
body.theme-dark .lobby-root *,
body.theme-dark .lobby-map-overlay,
body.theme-dark .lobby-map-overlay *,
body.theme-dark .lobby-map-grid-toggle,
body.theme-dark .lobby-map-grid-toggle-text {
  font-family: var(--font-ui) !important;
  letter-spacing: normal !important;
  word-spacing: normal !important;
}

body.theme-dark .lobby-panel h2,
body.theme-dark .lobby-card h3,
body.theme-dark .lobby-log-title,
body.theme-dark .sect-title,
body.theme-dark .tavern-panel-label,
body.theme-dark .modal-title,
body.theme-dark .lobby-match-over,
body.theme-dark .lobby-modal-head strong {
  font-family: var(--font-ui) !important;
  letter-spacing: normal !important;
  font-weight: var(--weight-semibold) !important;
}

body.theme-dark .lobby-eco,
body.theme-dark .lobby-eco-row--res,
body.theme-dark .lobby-eco-row--army,
body.theme-dark .type-army,
body.theme-dark .lobby-unit-chip-qty,
body.theme-dark .lobby-eco input[type="number"],
body.theme-dark .lobby-root input[type="number"],
body.theme-dark .log-turn,
body.theme-dark .type-timer,
body.theme-dark #lobbyTurnRemain,
body.theme-dark #lobbyMapTurnRemain {
  font-family: var(--font-ui) !important;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: normal !important;
}

body.theme-dark .sect {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  border-color: var(--border-strong);
}

body.theme-dark .lobby-map {
  background-color: #e8dcc4;
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(255, 248, 230, 0.45) 0%, transparent 50%),
    url("/img/fog-of-war-parchment.png");
  background-repeat: repeat;
  border: 1px solid #d4c4a8;
}

body.theme-dark .lobby-cell.fog {
  border-color: transparent;
  background: transparent;
  color: transparent;
}

body.theme-dark .lobby-legend-empty {
  background-color: #3a3733;
  background-image:
    radial-gradient(rgba(0, 0, 0, 0.16) 0.5px, transparent 0.9px);
  background-size: 7px 7px;
  border-color: #4a453f;
}

body.theme-dark .lobby-map-stage--tessera {
  position: relative;
  width: max-content;
  max-width: 100%;
}

body.theme-dark .lobby-map-wrap:has(.lobby-map--tessera) {
  max-height: 480px;
  overflow: auto;
}

body.theme-dark .lobby-map-overlay .lobby-map-wrap:has(.lobby-map--tessera) {
  max-height: none;
  overflow: hidden;
}

body.theme-dark .lobby-map-stage--smooth {
  padding: 18px;
  background-color: #2a2826;
  background-image:
    radial-gradient(rgba(0, 0, 0, 0.18) 0.5px, transparent 0.9px);
  background-size: 7px 7px;
  background-repeat: repeat;
}

body.theme-dark .lobby-map-overlay .lobby-map-stage--smooth {
  background-color: transparent;
  background-image: none;
}

body.theme-dark .lobby-map-overlay .lobby-map--tessera-smooth {
  -webkit-mask-image:
    linear-gradient(to right, transparent 0, #000 52px, #000 calc(100% - 52px), transparent 100%),
    linear-gradient(to bottom, transparent 0, #000 52px, #000 calc(100% - 52px), transparent 100%);
  -webkit-mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-composite: destination-in;
  mask-image:
    linear-gradient(to right, transparent 0, #000 52px, #000 calc(100% - 52px), transparent 100%),
    linear-gradient(to bottom, transparent 0, #000 52px, #000 calc(100% - 52px), transparent 100%);
  mask-size: 100% 100%;
  mask-repeat: no-repeat;
  mask-composite: intersect;
}

body.theme-dark .lobby-map-stage--smooth .lobby-map-inks {
  position: absolute;
  left: 28px;
  top: 28px;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}

body.theme-dark .lobby-map--tessera {
  gap: 0;
  padding: 10px; /* keep in sync with LobbyMapShape.TESSERA_PAD */
  overflow: visible;
  max-height: none;
  background-color: #e8dcc4;
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(255, 248, 230, 0.45) 0%, transparent 50%),
    url("/img/fog-of-war-parchment.png");
  background-repeat: repeat;
}

body.theme-dark .lobby-map--tessera-smooth {
  background-color: transparent;
  background-image: none;
  border: none;
  box-shadow: none;
}

body.theme-dark .lobby-map--seamless {
  position: relative;
  overflow: visible;
  isolation: isolate;
  background-color: #e8dcc4;
  background-image:
    radial-gradient(ellipse at 32% 18%, rgba(255, 248, 230, 0.55) 0%, transparent 58%),
    radial-gradient(ellipse at 78% 86%, rgba(196, 176, 140, 0.16) 0%, transparent 52%),
    url("/img/fog-of-war-parchment.png");
  background-repeat: repeat;
}

body.theme-dark .lobby-map-wash {
  position: absolute;
  left: 10px; /* keep in sync with LobbyMapShape.TESSERA_PAD */
  top: 10px;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
  isolation: isolate;
  mix-blend-mode: multiply;
}

body.theme-dark .lobby-map-water {
  --lake-deep: #0c404c;
  --lake-mid: #1e6572;
  --lake-rim: #4a9aaa;
  --lake-shallow: #7ecad6;
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
  mix-blend-mode: normal;
  background: transparent;
}

body.theme-dark .lobby-map-water .lobby-map-water-body,
body.theme-dark .lobby-map-water .lobby-map-wash-flood {
  stroke: none;
}

body.theme-dark .lobby-map-water .lobby-map-wash-flood {
  fill: #4a4640;
}

body.theme-dark .lobby-map-wash-light {
  mix-blend-mode: soft-light;
  pointer-events: none;
}

body.theme-dark .lobby-map-rift {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
  mix-blend-mode: multiply;
}

body.theme-dark .lobby-map-rift .t-void-shade,
body.theme-dark .lobby-map-rift .t-void-face,
body.theme-dark .lobby-map-rift .t-void-bank,
body.theme-dark .lobby-map-rift .t-void-well {
  stroke: none;
}

body.theme-dark .lobby-map-rift .t-void-core {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.theme-dark .lobby-map--tessera .lobby-cell {
  border: none;
  border-radius: 0;
  overflow: visible;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  background-image: none;
  box-shadow: none;
  font-family: var(--font-ui);
  color: #4a3426;
}

/* Overlap by 1px so grid subpixels cannot flash the parchment behind same-color sectors. */
body.theme-dark .lobby-map--seamless .lobby-cell {
  position: relative;
  z-index: 1;
  width: calc(var(--lobby-cell, 60px) + 1px);
  height: calc(var(--lobby-cell, 60px) + 1px);
  max-width: none;
  max-height: none;
}

body.theme-dark .lobby-map--seamless .lobby-cell:has(.lobby-map-ico),
body.theme-dark .lobby-map--tessera .lobby-cell:has(.lobby-map-ico) {
  z-index: 2;
}

body.theme-dark .lobby-map--seamless .lobby-cell-terrain {
  overflow: visible;
}

body.theme-dark .lobby-map--seamless .lobby-cell-terrain--water {
  overflow: hidden;
  mix-blend-mode: normal;
}
body.theme-dark .lobby-map--seamless .lobby-cell-terrain--river,
body.theme-dark .lobby-map--seamless .lobby-cell-terrain--fissure {
  overflow: hidden;
}

body.theme-dark .lobby-map--tessera .lobby-cell.owned {
  background-color: transparent;
  background-image: none;
  box-shadow: none;
}

body.theme-dark .lobby-map--tessera .lobby-cell.fog {
  background: transparent;
  color: transparent;
}

body.theme-dark .lobby-map-fog-veil {
  position: absolute;
  left: 10px; /* keep in sync with LobbyMapShape.TESSERA_PAD */
  top: 10px;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
  mix-blend-mode: normal;
}

body.theme-dark .lobby-map--tessera .lobby-cell.reach,
body.theme-dark .lobby-map--tessera .lobby-cell.selected {
  outline: none;
  z-index: 3;
  filter: drop-shadow(0 0 3px rgba(200, 120, 24, 0.95));
}

body.theme-dark .lobby-map-inks {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}

body.theme-dark .lobby-map-sector-grid {
  left: 10px;
  top: 10px;
}

body.theme-dark .lobby-map-stage--smooth .lobby-map-sector-grid {
  left: 28px;
  top: 28px;
}

body.theme-dark .lobby-map-sector-grid path {
  stroke: #5c564c;
  opacity: 0.6;
}

body.theme-dark .lobby-map-inks path {
  fill: none;
  stroke: none;
  opacity: 0;
}

body.theme-dark .lobby-map-stage--smooth .lobby-map-inks--rim {
  display: none;
}

/* Cartographic ink roads: same-owner neighbors form one realm */
body.theme-dark .lobby-cell-roads {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

body.theme-dark .lobby-cell-roads svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

body.theme-dark .lobby-road-bed {
  fill: none;
  stroke: color-mix(in srgb, var(--lobby-owner, #8b5a2b) 36%, #c4a06a);
  stroke-width: 9.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.92;
}

body.theme-dark .lobby-road-groove {
  fill: none;
  stroke: color-mix(in srgb, var(--lobby-owner, #5c4033) 22%, #5c4033);
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2.6 2.1;
  opacity: 0.88;
}

body.theme-dark .lobby-road-hub {
  fill: color-mix(in srgb, var(--lobby-owner, #8b5a2b) 32%, #e8d4a8);
  stroke: #5c4033;
  stroke-width: 1.05;
}

body.theme-dark .lobby-cell-art {
  position: absolute;
  inset: 0;
  z-index: 2;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  pointer-events: none;
}

body.theme-dark .lobby-cell-art--multi {
  flex-direction: row;
  flex-wrap: wrap;
  max-width: 100%;
}

body.theme-dark .lobby-map-ico {
  position: relative;
  display: block;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  overflow: visible;
}

body.theme-dark .lobby-cell .lobby-map-ico--castle,
body.theme-dark .lobby-cell .lobby-map-ico--squad,
body.theme-dark .lobby-cell .lobby-map-ico--wandering_squad {
  width: 56px;
  height: 56px;
}

body.theme-dark .lobby-cell .lobby-map-ico:not(.lobby-map-ico--squad) {
  --lobby-obj-nudge: translate(
    calc(var(--lobby-obj-x, 0) * var(--lobby-cell, 60px) * 0.26),
    calc(var(--lobby-obj-y, 0) * var(--lobby-cell, 60px) * 0.26)
  );
  transform: var(--lobby-obj-nudge);
}

/* Human castle paints 202px of the 256 canvas; other keeps are narrower. */
body.theme-dark .lobby-cell .lobby-map-ico--castle.lobby-map-ico--race-lizard {
  transform: var(--lobby-obj-nudge, none) scale(calc(202 / 163));
  transform-origin: 50% 50%;
}

body.theme-dark .lobby-cell .lobby-map-ico--castle.lobby-map-ico--race-elf {
  transform: var(--lobby-obj-nudge, none) scale(calc(202 / 166));
  transform-origin: 50% 50%;
}

body.theme-dark .lobby-cell .lobby-map-ico--castle.lobby-map-ico--race-undead {
  transform: var(--lobby-obj-nudge, none) scale(calc(202 / 170));
  transform-origin: 50% 50%;
}

/* Ruins sprites: human opaque≈228; normalize other races to that width. */
body.theme-dark .lobby-cell .lobby-map-ico--castle.lobby-map-ico--ruined.lobby-map-ico--race-human {
  transform: var(--lobby-obj-nudge, none) scale(1);
  transform-origin: 50% 50%;
}

body.theme-dark .lobby-cell .lobby-map-ico--castle.lobby-map-ico--ruined.lobby-map-ico--race-lizard {
  transform: var(--lobby-obj-nudge, none) scale(calc(228 / 205));
  transform-origin: 50% 50%;
}

body.theme-dark .lobby-cell .lobby-map-ico--castle.lobby-map-ico--ruined.lobby-map-ico--race-elf {
  transform: var(--lobby-obj-nudge, none) scale(calc(228 / 170));
  transform-origin: 50% 50%;
}

body.theme-dark .lobby-cell .lobby-map-ico--castle.lobby-map-ico--ruined.lobby-map-ico--race-undead {
  transform: var(--lobby-obj-nudge, none) scale(calc(228 / 236));
  transform-origin: 50% 50%;
}

/* Lizard hero sprite is 363x251; keep the same height as other squads. */
body.theme-dark .lobby-cell .lobby-map-ico--squad.lobby-map-ico--race-lizard {
  width: calc(56px * 363 / 251);
  height: 56px;
}

body.theme-dark .lobby-map-legend-item .lobby-map-ico--squad.lobby-map-ico--race-lizard {
  width: calc(28px * 363 / 251);
  height: 28px;
}

@media (max-width: 900px) {
  body.theme-dark .lobby-map-ico {
    width: calc(var(--lobby-cell, 52px) * 0.68);
    height: calc(var(--lobby-cell, 52px) * 0.68);
  }
  body.theme-dark .lobby-cell .lobby-map-ico--castle,
  body.theme-dark .lobby-cell .lobby-map-ico--squad,
  body.theme-dark .lobby-cell .lobby-map-ico--wandering_squad {
    width: calc(var(--lobby-cell, 52px) * 0.88);
    height: calc(var(--lobby-cell, 52px) * 0.88);
  }
  body.theme-dark .lobby-cell .lobby-map-ico--squad.lobby-map-ico--race-lizard {
    width: calc(var(--lobby-cell, 52px) * 0.88 * 363 / 251);
    height: calc(var(--lobby-cell, 52px) * 0.88);
  }
  body.theme-dark .lobby-cell .lobby-map-ico:not(.lobby-map-ico--squad) {
    --lobby-obj-nudge: translate(
      calc(var(--lobby-obj-x, 0) * var(--lobby-cell, 52px) * 0.18),
      calc(var(--lobby-obj-y, 0) * var(--lobby-cell, 52px) * 0.18)
    );
  }
  body.theme-dark .lobby-cell-art--multi {
    gap: 0;
    transform: scale(0.92);
    transform-origin: center center;
  }
}

body.theme-dark .lobby-map-ico svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 1px 0 rgba(92, 64, 51, 0.32));
}

body.theme-dark .lobby-map-ico-obj {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(92, 64, 51, 0.32));
}

body.theme-dark .lobby-map-ico-hero-stack,
body.theme-dark .lobby-map-ico-obj-stack,
body.theme-dark .lobby-map-ico-hero {
  width: 100%;
  height: 100%;
  display: block;
}

body.theme-dark .lobby-map-ico-hero-stack,
body.theme-dark .lobby-map-ico-obj-stack {
  position: relative;
  isolation: isolate;
  pointer-events: none;
}

body.theme-dark .lobby-map-ico-hero {
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 1px 0 rgba(92, 64, 51, 0.32));
}

body.theme-dark .lobby-map-ico-hero-cloak,
body.theme-dark .lobby-map-ico-hero-hooves,
body.theme-dark .lobby-map-ico-hero-gold,
body.theme-dark .lobby-map-ico-castle-flag {
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-mode: alpha;
  mask-mode: alpha;
  mix-blend-mode: color;
}

body.theme-dark .lobby-cell .lobby-map-ico--artifact-blue {
  animation-name: lobby-art-blue-dark;
  animation-duration: 3.4s;
}
@keyframes lobby-art-blue-dark {
  0%, 100% {
    filter: drop-shadow(0 0 0 transparent);
    transform: var(--lobby-obj-nudge, none) scale(1);
  }
  50% {
    filter: drop-shadow(0 0 2px rgba(74, 106, 136, 0.7));
    transform: var(--lobby-obj-nudge, none) scale(1.06);
  }
}

body.theme-dark .lobby-map-ico-lvl {
  position: absolute;
  right: -1px;
  bottom: -1px;
  min-width: 8px;
  padding: 0 2px;
  font-family: var(--font-ui);
  font-size: var(--text-ui);
  font-weight: 400;
  line-height: 1.3;
  color: #3d2818;
  background: #f0e4c8;
  border: 1px solid #a07848;
  border-radius: 2px;
}

body.theme-dark .lobby-cell-pips {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 0;
  pointer-events: none;
}

body.theme-dark .lobby-map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

body.theme-dark .lobby-map-legend-item .lobby-map-ico {
  width: 28px;
  height: 28px;
}

body.theme-dark .lobby-map--tessera .lobby-cell.lobby-cell--meadow:not(.owned),
body.theme-dark .lobby-map--tessera .lobby-cell.lobby-cell--plain:not(.owned),
body.theme-dark .lobby-map--tessera .lobby-cell.lobby-cell--forest:not(.owned),
body.theme-dark .lobby-map--tessera .lobby-cell.lobby-cell--hill:not(.owned),
body.theme-dark .lobby-map--tessera .lobby-cell.lobby-cell--swamp:not(.owned),
body.theme-dark .lobby-map--tessera .lobby-cell.lobby-cell--water,
body.theme-dark .lobby-map--tessera .lobby-cell.lobby-cell--river,
body.theme-dark .lobby-map--tessera .lobby-cell.lobby-cell--ford,
body.theme-dark .lobby-map--tessera .lobby-cell.lobby-cell--fissure {
  background-color: transparent;
  background-image: none;
}

body.theme-dark .lobby-map-legend-item--terrain .lobby-cell-terrain--meadow {
  background-color: #c6dc9e;
}
body.theme-dark .lobby-map-legend-item--terrain .lobby-cell-terrain--plain {
  background-color: #ead6ae;
}
body.theme-dark .lobby-map-legend-item--terrain .lobby-cell-terrain--forest {
  background-color: #c6dc9e;
}
body.theme-dark .lobby-map-legend-item--terrain .lobby-cell-terrain--hill {
  background-color: #d2b790;
}
body.theme-dark .lobby-map-legend-item--terrain .lobby-cell-terrain--swamp {
  background-color: #b7c99a;
}
body.theme-dark .lobby-map-legend-item--terrain .lobby-cell-terrain--water {
  --lake-deep: #0c404c;
  --lake-mid: #1e6572;
  --lake-rim: #4a9aaa;
  --lake-shallow: #7ecad6;
  background-color: transparent;
}
body.theme-dark .lobby-map-legend-item--terrain .lobby-cell-terrain--river {
  background-color: #8aadc2;
}
body.theme-dark .lobby-map-legend-item--terrain .lobby-cell-terrain--fissure {
  background-color: #e0ccb0;
}

body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--water,
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--water {
  --lake-deep: #0c404c;
  --lake-mid: #1e6572;
  --lake-rim: #4a9aaa;
  --lake-shallow: #7ecad6;
  background: transparent;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--water .t-lake,
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--water .t-lake {
  stroke: none;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--water .t-wash,
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--water .t-wash {
  fill: #3a4850;
  stroke: none;
  opacity: 1;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--river .t-wash,
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--river .t-wash {
  fill: #3a4850;
  stroke: none;
  opacity: 0.48;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--water .t-ribbon,
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--water .t-ribbon {
  fill: #4a5860;
  stroke: none;
  opacity: 1;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--river .t-ribbon,
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--river .t-ribbon {
  fill: #4a5860;
  stroke: none;
  opacity: 0.72;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--water .t-ripple,
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--water .t-ripple {
  fill: none;
  stroke: #9aa8b0;
  stroke-width: 0.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.26;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--water .t-glint,
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--river .t-glint,
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--water .t-glint,
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--river .t-glint {
  fill: none;
  stroke: #c8d4d8;
  stroke-width: 1.05;
  stroke-linecap: round;
  opacity: 0.38;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--water .t-reflect,
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--water .t-reflect {
  fill: #6a787e;
  stroke: none;
  opacity: 0.14;
}
body.theme-dark .lobby-map--seamless .lobby-cell-terrain--water .t-lake,
body.theme-dark .lobby-map--seamless .lobby-cell-terrain--water .t-wash,
body.theme-dark .lobby-map--seamless .lobby-cell-terrain--water .t-ribbon,
body.theme-dark .lobby-map--seamless .lobby-cell-terrain--water .t-reflect,
body.theme-dark .lobby-map--seamless .lobby-cell-terrain--water .t-ripple,
body.theme-dark .lobby-map--seamless .lobby-cell-terrain--water .t-glint {
  opacity: 0;
}
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--river .t-mouth--wet {
  fill: #3a5048;
  stroke: none;
  opacity: 0.5;
}
body.theme-dark .lobby-cell-terrain--dark.lobby-cell-terrain--river .t-mouth--dry {
  fill: #4a4238;
  stroke: none;
  opacity: 0.55;
}

body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--fissure .t-stipple {
  fill: #3d2818;
  opacity: 0.45;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--fissure .t-bank {
  fill: none;
  stroke: #a07848;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--fissure .t-core {
  fill: none;
  stroke: #3d2818;
  stroke-width: 1.05;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--meadow .t-tuft,
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--meadow .t-reed,
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--swamp .t-tuft,
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--swamp .t-reed {
  fill: none;
  stroke: #4a7a38;
  stroke-width: 0.9;
  stroke-linecap: round;
  opacity: 0.8;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--plain .t-dust {
  fill: #6b5040;
  opacity: 0.35;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--forest .t-canopy {
  fill: #8aaa68;
  stroke: #3d5828;
  stroke-width: 0.75;
  stroke-linejoin: round;
  opacity: 0.85;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--forest .t-trunk {
  fill: none;
  stroke: #3d2818;
  stroke-width: 0.9;
  stroke-linecap: round;
}
body.theme-dark .lobby-cell-terrain--parchment.lobby-cell-terrain--hill .t-contour {
  fill: none;
  stroke: #6b5040;
  stroke-width: 1.05;
  stroke-linecap: round;
  opacity: 0.7;
}

body.theme-dark .lobby-unit-text { display: none; }
body.theme-dark .lobby-unit-art {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 10px;
  vertical-align: top;
}
body.theme-dark .type-army {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 8px;
  max-width: 100%;
  vertical-align: top;
}
body.theme-dark .lobby-unit-army {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 10px;
}
body.theme-dark .lobby-unit-army-prefix {
  display: flex;
  flex: 1 0 100%;
  align-items: center;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-right: 0;
}
body.theme-dark .lobby-unit-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  width: 4.8em;
  min-width: 3.6em;
  max-width: 5.4em;
  text-align: center;
  vertical-align: top;
}
body.theme-dark .lobby-unit-chip-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  image-rendering: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
body.theme-dark .lobby-unit-chip-name {
  font-family: var(--font-ui);
  font-size: var(--text-ui);
  line-height: 1.15;
  font-weight: 500;
  color: var(--text-heading);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  hyphens: none;
}
body.theme-dark .lobby-unit-chip-qty {
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-ui);
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
  letter-spacing: normal;
}
body.theme-dark .lobby-unit-chip--md {
  width: 4.8em;
  min-width: 3.6em;
}
body.theme-dark .lobby-unit-chip--md .lobby-unit-chip-img {
  width: 42px;
  height: 42px;
}
body.theme-dark .lobby-unit-chip--md .lobby-unit-chip-name {
  font-size: var(--text-ui);
  max-width: 100%;
}
body.theme-dark .lobby-unit-chip--sm {
  width: 4.6em;
  min-width: 3.4em;
  gap: 2px;
}
body.theme-dark .lobby-unit-chip--sm .lobby-unit-chip-img {
  width: 40px;
  height: 40px;
}
body.theme-dark .lobby-unit-chip--sm .lobby-unit-chip-name {
  font-size: var(--text-ui);
  max-width: 100%;
}
body.theme-dark .lobby-unit-chip--xs {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  gap: 0;
}
body.theme-dark .lobby-unit-chip--xs .lobby-unit-chip-img {
  width: 24px;
  height: 24px;
}
body.theme-dark .lobby-unit-chip--xs .lobby-unit-chip-name {
  display: none;
}
body.theme-dark .lobby-unit-chip--xs .lobby-unit-chip-qty {
  font-size: var(--text-ui);
  line-height: 1;
}
body.theme-dark .lobby-unit-chip--bare {
  width: auto;
  min-width: 28px;
  max-width: none;
}
body.theme-dark .lobby-unit-chip--bare .lobby-unit-chip-name {
  display: none;
}
body.theme-dark .lobby-unit-chip--lg {
  width: 4.8em;
  min-width: 3.6em;
  max-width: 5.4em;
}
body.theme-dark .lobby-unit-chip--lg .lobby-unit-chip-img {
  width: 40px;
  height: 40px;
}
body.theme-dark .lobby-eco .lobby-unit-chip,
body.theme-dark .lobby-eco .lobby-unit-chip--md,
body.theme-dark .lobby-eco .lobby-unit-chip--sm,
body.theme-dark .lobby-eco .lobby-unit-chip--lg {
  width: max-content;
  min-width: 42px;
  max-width: none;
}
body.theme-dark .lobby-eco .lobby-unit-chip-name {
  width: auto;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}
body.theme-dark .lobby-eco-row--army,
body.theme-dark .type-army {
  font-family: var(--font-ui);
}
body.theme-dark .lobby-eco-actions--hire,
body.theme-dark .lobby-eco-actions--reinf {
  align-items: flex-end;
}
body.theme-dark .lobby-unit-reinf {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
body.theme-dark .lobby-map-tip {
  position: fixed;
  z-index: 92;
  display: none;
  margin: 0;
  padding: 6px 8px;
  width: max-content;
  max-width: min(360px, calc(100vw - 24px));
  pointer-events: none;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--font-ui);
  font-size: var(--text-ui);
  font-weight: 400;
  line-height: 1.3;
  color: var(--text);
}
body.theme-dark #lobbyHireTip.lobby-map-tip {
  background: var(--modal-bg);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
}
body.theme-dark .lobby-map-tip:not([hidden]) { display: block; }
body.theme-dark .lobby-map-tip-line {
  margin: 0 0 2px;
  font-family: var(--font-ui);
  font-size: var(--text-ui);
  font-weight: 400;
  line-height: 1.3;
}
body.theme-dark .lobby-map-tip-line:first-child {
  font-weight: 400;
  color: var(--text);
}
body.theme-dark .lobby-map-tip-line:last-child { margin-bottom: 0; }
body.theme-dark .lobby-map-tip-line--army {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}
body.theme-dark .lobby-map-tip-label {
  flex: 0 0 auto;
  font-weight: 400;
  color: var(--text);
}
body.theme-dark .lobby-map-tip-extra {
  color: var(--text-muted);
  white-space: nowrap;
}
body.theme-dark .lobby-map-tip .lobby-unit-army {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
body.theme-dark .lobby-map-tip .lobby-unit-chip--xs {
  flex-direction: row;
  align-items: center;
  width: auto;
  min-width: 0;
  gap: 2px;
}
body.theme-dark .lobby-map-tip .lobby-unit-chip--xs .lobby-unit-chip-img {
  width: 22px;
  height: 22px;
}
body.theme-dark .lobby-map-tip .lobby-unit-chip--xs .lobby-unit-chip-qty {
  font-family: var(--font-ui);
  font-size: var(--text-ui);
  font-weight: 400;
}
body.theme-dark .fight-calc-inputs thead th .lobby-unit-chip {
  width: auto;
  min-width: 40px;
  max-width: none;
}
body.theme-dark .fight-calc-inputs thead th .lobby-unit-chip-img {
  width: 40px;
  height: 40px;
}
body.theme-dark .war-house-hire thead th[data-cost] .lobby-unit-chip {
  cursor: help;
}
body.theme-dark .lobby-modal--compact .lobby-unit-chip-name,
body.theme-dark .lobby-modal--compact .lobby-unit-chip-qty {
  font-family: var(--font-ui);
  font-size: var(--text-ui);
  font-weight: 400;
  line-height: 1.3;
}
body.theme-dark #lobbyHireTip,
body.theme-dark #lobbyHireTip .lobby-map-tip-line,
body.theme-dark #lobbyHireTip .lobby-map-tip-line:first-child,
body.theme-dark #lobbyMapTip,
body.theme-dark #lobbyMapTip .lobby-map-tip-line,
body.theme-dark #lobbyMapTip .lobby-map-tip-line:first-child,
body.theme-dark #lobbyMapTip .lobby-map-tip-label {
  font-family: var(--font-ui);
  font-size: var(--text-ui);
  font-weight: 400;
  line-height: 1.3;
}

body.theme-dark .theme-option-swatch {
  border-color: rgba(255, 255, 255, 0.16);
}

body.theme-dark button,
body.theme-dark .qty-input,
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  border-color: var(--border-strong);
}

body.theme-dark button.primary {
  background: var(--accent);
  color: var(--btn-primary-text);
  border-color: var(--accent);
}

body.theme-dark button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

body.theme-dark ::selection {
  background: #5c4a3a;
  color: #d0d0d4;
}

body.theme-dark .lobby-map-draw-rail {
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
body.theme-dark .lobby-map-draw-btn,
body.theme-dark .lobby-map-draw-who {
  color: var(--text-muted);
}
body.theme-dark .lobby-map-draw-btn.is-on,
body.theme-dark .lobby-map-draw-who.is-on {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}
body.theme-dark .lobby-map-draw-note {
  background: var(--surface-raised);
  color: var(--text);
  border-color: var(--border-strong);
}
