/* =========================================================
   MAIN MAP CONTROLS
   ========================================================= */

:root {
  --map-control-z-index: 2400;
  --map-control-hitbox-outline: transparent;
  --map-editor-brass-border: rgba(196, 148, 74, 0.74);
  --map-editor-brass-border-soft: rgba(214, 168, 94, 0.36);
  --map-editor-brass-glow: rgba(242, 211, 123, 0.18);
  --map-editor-brass-text: #f2d37b;
  --map-editor-brass-text-hot: #fff2c8;
  --map-tools-utility-width: min(324px, calc(100vw - 16px));
  --map-tools-pane-width: min(calc(var(--map-tools-utility-width) + 13px), calc(100vw - 16px));
  --map-tools-pane-height: min(62vh, 560px);
  --map-editor-brass-bg:
    radial-gradient(circle at 50% 20%, rgba(181, 128, 55, 0.22), transparent 42%),
    linear-gradient(180deg, rgba(75, 49, 24, 0.94), rgba(33, 22, 13, 0.98));
  --map-editor-brass-bg-hot:
    radial-gradient(circle at 50% 18%, rgba(255, 213, 120, 0.24), transparent 42%),
    linear-gradient(180deg, rgba(129, 88, 34, 0.94), rgba(66, 43, 16, 0.98));
}

#codex-button,
#map-reset-button,
#map-view-button,
#map-draw-button {
  position: fixed;

  padding: 0;
  border: none;

  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;

  z-index: var(--map-control-z-index);
  pointer-events: auto;
  cursor: pointer;

  touch-action: manipulation;

  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;

  user-select: none;

  outline: 1px solid var(--map-control-hitbox-outline);
  outline-offset: -1px;
  box-shadow: none;

  will-change: transform, filter;
}

/* Codex Button */

#codex-button {
  bottom: 21px;
  left: 21px;

  width: 126px;
  height: 126px;

  background-image: url("../assets/Codex_Book_Button.png");
  background-size: 118px 118px;

  transition:
    transform 0.18s ease,
    filter 0.18s ease;

  filter:
    drop-shadow(0 8px 15px rgba(0, 0, 0, 0.48))
    drop-shadow(0 3px 5px rgba(0, 0, 0, 0.34))
    drop-shadow(0 0 10px rgba(255, 225, 160, 0.12));
}

#codex-button::before {
  content: "CODEX";

  position: absolute;
  left: 50%;
  top: 50%;

  transform: translate(-50%, -50%);

  z-index: 2;

  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 1.82rem;
  letter-spacing: 0.21em;
  line-height: 1;

  color: #f2dfb6;

  text-shadow:
    0 0 10px rgba(25, 12, 4, 0.96),
    0 0 22px rgba(25, 12, 4, 0.88),
    0 0 42px rgba(25, 12, 4, 0.76),
    0 3px 6px rgba(0, 0, 0, 0.72),
    0 0 6px rgba(255, 220, 150, 0.30);

  opacity: 0;

  pointer-events: none;

  transition:
    opacity 220ms ease,
    color 220ms ease,
    text-shadow 220ms ease;
}

#codex-button::after {
  content: "";

  position: absolute;
  left: 50%;
  top: 50%;

  width: 96px;
  height: 32px;

  transform: translate(-50%, -50%);

  z-index: 1;

  border-radius: 999px;

  background:
    radial-gradient(
      ellipse at center,
      rgba(20, 10, 3, 0.74) 0%,
      rgba(20, 10, 3, 0.58) 48%,
      rgba(20, 10, 3, 0.00) 74%
    );

  opacity: 0;

  pointer-events: none;

  transition:
    opacity 220ms ease;
}

#codex-button.codex-retro-mode::before {
  color: #f2dfb6;

  text-shadow:
    0 0 12px rgba(0, 0, 0, 1),
    0 0 26px rgba(0, 0, 0, 0.96),
    0 0 48px rgba(0, 0, 0, 0.88),
    0 3px 8px rgba(0, 0, 0, 0.90),
    0 0 8px rgba(25, 12, 4, 0.78);
}

#codex-button.codex-retro-mode:hover::after,
#codex-button.codex-retro-mode.codex-label-visible::after {
  opacity: 1;
}

#codex-button:focus,
#codex-button:focus-visible,
#codex-button:active {
  outline: 1px solid var(--map-control-hitbox-outline);
  outline-offset: -1px;
  box-shadow: none;
  background-color: transparent;
}

#codex-button:hover {
  transform: scale(1.035);

  filter:
    drop-shadow(0 10px 18px rgba(0, 0, 0, 0.54))
    drop-shadow(0 4px 7px rgba(0, 0, 0, 0.36))
    drop-shadow(0 0 14px rgba(255, 225, 160, 0.16));
}

#codex-button:hover::before {
  opacity: 1;
}

#codex-button.codex-label-visible::before {
  opacity: 1;
}

#codex-button.codex-label-visible {
  transform: scale(1.035);

  filter:
    drop-shadow(0 10px 18px rgba(0, 0, 0, 0.54))
    drop-shadow(0 4px 7px rgba(0, 0, 0, 0.36))
    drop-shadow(0 0 14px rgba(255, 225, 160, 0.16));
}

#codex-button:active {
  transform: scale(0.985);
}

/* Map Reset Button */

#map-reset-button {
  bottom: 311px;
  left: 21px;

  width: 126px;
  height: 126px;

  background-image: url("../assets/Atlas_Compass.png");
  background-size: 116px 116px;

  transition:
    transform 0.14s ease,
    filter 0.14s ease;

  filter:
    drop-shadow(0 8px 14px rgba(0, 0, 0, 0.46))
    drop-shadow(0 3px 5px rgba(0, 0, 0, 0.32))
    drop-shadow(0 0 10px rgba(255, 225, 160, 0.10));
}

#map-reset-button:hover {
  transform: scale(1.035);

  filter:
    drop-shadow(0 10px 18px rgba(0, 0, 0, 0.52))
    drop-shadow(0 4px 7px rgba(0, 0, 0, 0.36))
    drop-shadow(0 0 14px rgba(255, 225, 160, 0.14));
}

#map-reset-button:active {
  transform: scale(0.95) rotate(-2deg);

  filter:
    drop-shadow(0 5px 10px rgba(0, 0, 0, 0.50))
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.36))
    drop-shadow(0 0 8px rgba(255, 225, 160, 0.10));
}

#map-reset-button:focus,
#map-reset-button:focus-visible {
  outline: 1px solid var(--map-control-hitbox-outline);
  outline-offset: -1px;
  box-shadow: none;
  background-color: transparent;
}

#map-draw-button {
  bottom: 166px;
  left: 21px;

  width: 126px;
  height: 126px;

  background-image: url("../assets/codex_map_button.png");
  background-size: 118px 118px;

  color: transparent;
  font-size: 0;

  transition:
    transform 0.18s ease,
    filter 0.18s ease;

  filter:
    drop-shadow(0 8px 15px rgba(0, 0, 0, 0.48))
    drop-shadow(0 3px 5px rgba(0, 0, 0, 0.34))
    drop-shadow(0 0 10px rgba(255, 225, 160, 0.12));
}

#map-view-button {
  bottom: 62px;
  left: 166px;
}

#map-view-button {
  width: 104px;
  height: 44px;
  border: 1px solid var(--map-editor-brass-border-soft);
  border-radius: 7px;

  background: var(--map-editor-brass-bg);
  color: var(--map-editor-brass-text);

  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;

  box-shadow:
    0 12px 20px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 234, 186, 0.08),
    inset 0 0 0 1px rgba(252, 221, 154, 0.05);

  transition:
    transform 140ms ease,
    filter 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

#map-draw-button::before {
  content: "MAP\A TOOLS";

  position: absolute;
  left: 50%;
  top: 50%;

  transform: translate(-50%, -50%);

  z-index: 2;

  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 1.82rem;
  letter-spacing: 0.21em;
  line-height: 0.78;
  white-space: pre;
  text-align: center;

  color: #f2dfb6;

  text-shadow:
    0 0 10px rgba(25, 12, 4, 0.96),
    0 0 22px rgba(25, 12, 4, 0.88),
    0 0 42px rgba(25, 12, 4, 0.76),
    0 3px 6px rgba(0, 0, 0, 0.72),
    0 0 6px rgba(255, 220, 150, 0.30);

  opacity: 0;

  pointer-events: none;

  transition:
    opacity 220ms ease,
    color 220ms ease,
    text-shadow 220ms ease;
}

#map-view-button::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(247, 208, 132, 0.16);
  border-radius: 4px;
  pointer-events: none;
}

#map-view-button[hidden],
#map-draw-button[hidden],
.map-view-panel[hidden],
.map-draw-panel[hidden] {
  display: none;
}

#map-draw-button:focus,
#map-draw-button:focus-visible,
#map-draw-button:active {
  outline: 1px solid var(--map-control-hitbox-outline);
  outline-offset: -1px;
  box-shadow: none;
  background-color: transparent;
}

#map-draw-button.active,
#map-draw-button:hover {
  transform: scale(1.035);

  filter:
    drop-shadow(0 10px 18px rgba(0, 0, 0, 0.54))
    drop-shadow(0 4px 7px rgba(0, 0, 0, 0.36))
    drop-shadow(0 0 14px rgba(255, 225, 160, 0.16));
}

#map-draw-button.active::before,
#map-draw-button:hover::before {
  opacity: 1;
}

#map-view-button.active,
#map-view-button:hover,
#map-view-button:focus-visible {
  transform: scale(1.035);
  border-color: rgba(242, 211, 123, 0.72);
  background: var(--map-editor-brass-bg-hot);
  color: var(--map-editor-brass-text-hot);
  filter: brightness(1.07);
  box-shadow:
    0 14px 24px rgba(0, 0, 0, 0.38),
    inset 0 0 18px var(--map-editor-brass-glow);
}

#map-view-button:active {
  transform: scale(0.98);
  box-shadow:
    0 8px 14px rgba(0, 0, 0, 0.38),
    inset 0 2px 8px rgba(0, 0, 0, 0.28),
    inset 0 0 14px rgba(242, 211, 123, 0.12);
}

#map-draw-button:active {
  transform: scale(0.985);
}

.map-control-panel {
  position: fixed;
  left: 21px;
  bottom: 408px;
  z-index: var(--map-control-z-index);

  width: min(260px, calc(100vw - 42px));
  max-height: calc(100vh - 132px);
  padding: 12px;
  border: 1px solid rgba(242, 211, 123, 0.45);
  border-radius: 10px;

  background:
    linear-gradient(145deg, rgba(41, 27, 14, 0.94), rgba(20, 13, 8, 0.92));
  color: #f4dfaf;

  font-family: 'Spectral', Georgia, serif;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.42);
  pointer-events: auto;
  overflow-y: auto;
}

.map-view-panel {
  z-index: calc(var(--map-control-z-index) + 4);
}

.map-draw-panel {
  left: 4px;
  right: 4px;
  bottom: 4px;
  display: block;
  width: auto;
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  overflow: visible;
}

.map-edit-pane {
  position: fixed;
  left: 8px;
  top: 8px;
  bottom: 88px;
  z-index: var(--map-control-z-index);
  box-sizing: border-box;
  width: var(--map-tools-pane-width);
  padding: 10px;
  border: 1px solid rgba(196, 148, 74, 0.74);
  border-radius: 10px;
  background:
    radial-gradient(circle at top, rgba(112, 72, 28, 0.24), transparent 24%),
    linear-gradient(180deg, rgba(55, 36, 18, 0.98), rgba(21, 13, 7, 0.985));
  box-shadow:
    0 26px 56px rgba(0, 0, 0, 0.46),
    inset 0 0 0 1px rgba(252, 221, 154, 0.08),
    inset 0 0 22px rgba(0, 0, 0, 0.26);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  overflow: hidden;
}

.map-edit-pane::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(247, 208, 132, 0.18);
  border-radius: 7px;
  pointer-events: none;
}

.map-edit-pane-header,
.map-edit-pane-body,
.map-edit-utility-pane {
  position: relative;
  z-index: 1;
}

.map-edit-pane-header {
  display: grid;
  justify-items: end;
  gap: 3px;
  padding: 8px 10px 9px;
  border: 1px solid rgba(214, 168, 94, 0.28);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(74, 48, 23, 0.72), rgba(35, 23, 12, 0.60));
  box-shadow:
    inset 0 -1px 0 rgba(255, 232, 179, 0.08),
    inset 0 1px 0 rgba(255, 232, 179, 0.06);
}

.map-edit-pane-kicker {
  text-align: right;
  color: rgba(242, 211, 123, 0.76);
  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.map-edit-section-copy {
  display: none;
}

.map-edit-pane-body {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  margin-top: 8px;
  padding-right: 2px;
  overflow: hidden;
}

.map-edit-pane,
.map-edit-pane *,
.map-view-panel,
.map-view-panel *,
.map-draw-panel,
.map-draw-panel * {
  scrollbar-width: thin;
  scrollbar-color: rgba(207, 154, 79, 0.72) rgba(28, 18, 10, 0.34);
}

.map-edit-pane ::-webkit-scrollbar,
.map-view-panel ::-webkit-scrollbar,
.map-draw-panel ::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.map-edit-pane ::-webkit-scrollbar-track,
.map-view-panel ::-webkit-scrollbar-track,
.map-draw-panel ::-webkit-scrollbar-track {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(24, 15, 8, 0.46), rgba(78, 49, 24, 0.22));
}

.map-edit-pane ::-webkit-scrollbar-thumb,
.map-view-panel ::-webkit-scrollbar-thumb,
.map-draw-panel ::-webkit-scrollbar-thumb {
  border: 1px solid rgba(255, 226, 158, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(231, 178, 91, 0.86), rgba(116, 71, 31, 0.88));
  box-shadow: inset 0 0 0 1px rgba(39, 24, 12, 0.34);
}

.map-edit-pane ::-webkit-scrollbar-thumb:hover,
.map-view-panel ::-webkit-scrollbar-thumb:hover,
.map-draw-panel ::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(180deg, rgba(255, 207, 118, 0.96), rgba(151, 91, 37, 0.94));
}

.map-edit-utility-pane {
  flex: 0 0 auto;
  display: grid;
  gap: 7px;
  margin-top: 8px;
  padding: 8px 10px 10px;
  border: 1px solid rgba(214, 168, 94, 0.24);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(62, 40, 20, 0.72), rgba(29, 19, 11, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 232, 179, 0.06);
  pointer-events: auto;
}

.map-edit-section-menu {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: grid;
  grid-template-columns: var(--map-tools-utility-width) minmax(0, 1fr);
  gap: 7px;
  z-index: calc(var(--map-control-z-index) + 1);
  min-height: 58px;
  padding: 8px;
  border: 1px solid rgba(196, 148, 74, 0.74);
  border-radius: 10px;
  background:
    radial-gradient(circle at top, rgba(112, 72, 28, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(51, 33, 17, 0.985), rgba(22, 14, 8, 0.99));
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(252, 221, 154, 0.08);
  pointer-events: auto;
}

.map-edit-rail-utility,
.map-edit-rail-main {
  display: grid;
  gap: 7px;
}

.map-edit-pane[hidden],
.map-edit-rail-main[hidden],
.map-edit-apply-row[hidden],
.map-generation-popout[hidden] {
  display: none !important;
}

[data-overlay-subview-group][hidden] {
  display: none !important;
}

[data-poi-subview-group][hidden] {
  display: none !important;
}

.map-edit-rail-utility {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.map-edit-rail-main[data-map-tool-mode-panel="chooser"],
.map-edit-rail-main[data-map-tool-mode-panel="cartographer"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.map-edit-rail-main[data-map-tool-mode-panel="surveyor"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.map-edit-section-menu button {
  min-height: 40px;
  padding: 5px 6px 6px;
  border: 1px solid rgba(214, 168, 94, 0.36);
  border-radius: 7px;
  background:
    radial-gradient(circle at 50% 20%, rgba(181, 128, 55, 0.22), transparent 42%),
    linear-gradient(180deg, rgba(75, 49, 24, 0.9), rgba(33, 22, 13, 0.98));
  color: #f2d37b;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.08;
  cursor: pointer;
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 234, 186, 0.08);
}

.map-edit-mode-button-close .map-edit-mode-label,
#map-edit-view-button .map-edit-mode-label {
  font-size: 0.64rem;
}

.map-edit-mode-button-close .map-edit-mode-icon,
#map-edit-view-button .map-edit-mode-icon {
  font-size: 0.78rem;
}

.map-edit-section-menu button.active,
.map-edit-section-menu button:hover,
.map-edit-section-menu button:focus-visible {
  color: #fff2c8;
  border-color: rgba(242, 211, 123, 0.72);
  box-shadow:
    0 12px 20px rgba(0, 0, 0, 0.30),
    inset 0 0 18px rgba(242, 211, 123, 0.18);
  filter: brightness(1.07);
}

.map-generation-popout {
  position: fixed;
  left: calc(23px + var(--map-tools-utility-width));
  right: 16px;
  bottom: 84px;
  z-index: calc(var(--map-control-z-index) + 2);
  display: grid;
  grid-template-columns: 150px repeat(2, minmax(0, 1fr));
  gap: 0;
  min-height: 48px;
  border: 1px solid rgba(252, 213, 126, 0.86);
  border-bottom-color: rgba(196, 148, 74, 0.72);
  border-radius: 13px 13px 6px 6px;
  background:
    radial-gradient(circle at 50% 0%, rgba(242, 211, 123, 0.24), transparent 42%),
    linear-gradient(180deg, rgba(76, 47, 21, 0.99), rgba(22, 14, 8, 0.99));
  box-shadow:
    0 0 0 1px rgba(28, 16, 7, 0.72),
    0 0 24px rgba(242, 190, 92, 0.20),
    0 18px 34px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(252, 221, 154, 0.16);
  overflow: hidden;
  pointer-events: auto;
}

.map-generation-popout.map-generation-popout-three {
  grid-template-columns: 150px repeat(3, minmax(0, 1fr));
}

.map-generation-popout[hidden] {
  display: none;
}

.map-cartographer-subsection-title {
  display: grid;
  align-items: center;
  padding: 0 16px;
  border-right: 1px solid rgba(242, 211, 123, 0.24);
  color: #f6d88d;
  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: uppercase;
}

.map-generation-popout button {
  position: relative;
  min-height: 48px;
  border: 0;
  border-right: 1px solid rgba(242, 211, 123, 0.26);
  background:
    radial-gradient(circle at 50% 12%, rgba(242, 211, 123, 0.18), transparent 46%),
    linear-gradient(180deg, rgba(91, 56, 25, 0.94), rgba(35, 22, 12, 0.98));
  color: #f2d37b;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
}

.map-generation-popout button:last-child {
  border-right: 0;
}

.map-generation-popout button.active,
.map-generation-popout button:hover,
.map-generation-popout button:focus-visible {
  color: #fff6d9;
  background:
    radial-gradient(circle at 50% 5%, rgba(255, 227, 150, 0.34), transparent 52%),
    linear-gradient(180deg, rgba(122, 75, 29, 0.98), rgba(49, 29, 12, 0.99));
  box-shadow:
    inset 0 0 0 1px rgba(255, 227, 150, 0.20),
    inset 0 -5px 0 rgba(242, 211, 123, 0.54),
    inset 0 0 22px rgba(242, 211, 123, 0.22);
  filter: brightness(1.12);
}

.map-edit-mode-button {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  text-align: center;
}

.map-tools-mode-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 12;
  width: min(300px, 46vw);
  padding: 9px 10px;
  border: 1px solid rgba(214, 168, 94, 0.52);
  border-radius: 8px;
  background:
    radial-gradient(circle at top left, rgba(124, 79, 31, 0.24), transparent 42%),
    linear-gradient(180deg, rgba(39, 24, 12, 0.98), rgba(19, 12, 7, 0.99));
  color: #f7e4b7;
  font-family: 'Marcellus', Georgia, serif;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.32;
  text-align: left;
  text-transform: none;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(255, 234, 186, 0.06);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 3px);
  transition: opacity 60ms ease, transform 60ms ease;
}

.map-edit-mode-button:hover .map-tools-mode-tooltip,
.map-edit-mode-button:focus-visible .map-tools-mode-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.map-edit-mode-icon {
  font-size: 0.92rem;
  line-height: 1;
}

.map-edit-mode-label {
  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.map-edit-region-icon {
  transform: rotate(30deg);
}

.map-draw-panel-title {
  margin-bottom: 0;

  color: #f3dcaa;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.28rem;
  letter-spacing: 0.06em;
  text-align: right;
  text-transform: uppercase;
  text-shadow:
    0 1px 0 rgba(255, 235, 188, 0.08),
    0 6px 14px rgba(0, 0, 0, 0.32);
}

.map-draw-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.map-draw-panel-header .map-draw-panel-title {
  margin-bottom: 0;
}

.map-panel-close-button,
.map-edit-collapse-button {
  border: 1px solid rgba(242, 211, 123, 0.42);
  border-radius: 999px;
  background: linear-gradient(145deg, #3c2714, #21150c);
  color: #f4dfaf;
  font: inherit;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.map-panel-close-button {
  padding: 5px 10px;
}

.map-edit-collapse-button {
  display: none !important;
  width: 100%;
  min-height: 28px;
  margin-bottom: 7px;
}

.map-draw-panel-section {
  display: none;
  gap: 8px;
  margin-top: 0;
  padding: 9px;
  border: 1px solid rgba(214, 168, 94, 0.24);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(65, 42, 21, 0.64), rgba(28, 18, 10, 0.64));
  box-shadow:
    inset 0 1px 0 rgba(255, 232, 179, 0.05),
    0 10px 18px rgba(0, 0, 0, 0.14);
}

.map-draw-panel-section.active {
  display: grid;
  flex: 1 1 auto;
  box-sizing: border-box;
}

.map-draw-panel-section[data-map-edit-section="overlay"].active {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.map-draw-panel-section[data-map-edit-section="terrain"].active {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-content: stretch;
  overflow: hidden;
}

.map-draw-panel-section[data-map-edit-section="features"].active {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-content: start;
  overflow: hidden;
}

.map-draw-panel-section[data-map-edit-section="generation"].active {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-content: start;
  overflow: hidden;
}

.map-draw-panel-section[data-map-edit-section="pois"].active {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-content: start;
  overflow: hidden;
}

.map-generation-scroll {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.map-generation-subsection {
  display: none;
}

.map-generation-subsection.active {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
}

.map-generation-actions {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(214, 168, 94, 0.22);
  background: linear-gradient(180deg, rgba(31, 20, 11, 0.12), rgba(20, 13, 8, 0.24));
}

.map-generation-section-actions {
  flex: 0 0 auto;
  margin-top: 8px;
}

.map-generation-section-actions .map-generation-actions {
  display: none;
}

.map-generation-section-actions .map-generation-actions.active {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.map-generation-section-actions .map-generation-actions[data-generation-action-panel="overlays"].active {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.map-generation-section-actions .map-generation-actions[data-generation-action-panel="regions"].active {
  grid-template-columns: minmax(0, 1fr);
}

.map-generation-actions button {
  min-height: 31px;
}

.map-generation-footer-actions {
  display: flex !important;
  flex: 0 0 auto;
  align-items: end;
  gap: 6px;
}

.map-generation-shared-controls {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1.85fr) minmax(132px, 0.85fr);
  align-items: end;
  gap: 7px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(214, 168, 94, 0.22);
  background: linear-gradient(180deg, rgba(31, 20, 11, 0.12), rgba(20, 13, 8, 0.24));
}

.map-generation-footer-actions button {
  min-height: 34px;
  white-space: nowrap;
}

.map-generation-shared-controls .map-draw-route-name-row {
  min-width: 0;
}

.map-poi-generation-footer {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.map-poi-generation-shared-controls {
  margin-top: 0;
}

.map-draw-panel-section[data-map-edit-section="terrain"],
.map-draw-panel-section[data-map-edit-section="features"] {
  gap: 5px;
  padding: 6px;
}

.map-draw-panel-section[data-map-edit-section="nuke"].active {
  flex: 0 0 auto;
  align-content: start;
}

.map-draw-panel-section[data-map-edit-section="regions"].active {
  min-height: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-content: start;
}

.map-draw-panel-section[data-map-edit-section="pois"] .map-draw-range-row,
.map-draw-panel-section[data-map-edit-section="pois"] .map-draw-tool-row,
.map-draw-panel-section[data-map-edit-section="pois"] .map-draw-option-row,
.map-draw-panel-section[data-map-edit-section="pois"] .map-poi-generation-footer,
.map-draw-panel-section[data-map-edit-section="pois"] .map-generation-shared-controls {
  flex: 0 0 auto;
}

.map-draw-panel-section[data-map-edit-section="pois"] .map-draw-clear {
  margin-top: 0;
  align-self: stretch;
}

.map-draw-panel-section[data-map-edit-section="regions"] .map-draw-tool-row button {
  min-height: 44px;
}

.map-region-purge-block {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 11px;
  border-top: 1px solid rgba(214, 168, 94, 0.22);
}

.map-draw-panel-section:first-of-type {
  margin-top: 0;
}

.map-draw-section-title {
  flex: 0 0 auto;
  color: rgba(255, 232, 179, 0.94);
  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.map-draw-section-title-with-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.map-editor-help-wrap {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.map-editor-help-button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(214, 168, 94, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 20%, rgba(242, 211, 123, 0.18), transparent 52%),
    linear-gradient(180deg, rgba(78, 52, 27, 0.86), rgba(33, 22, 13, 0.96));
  color: rgba(255, 232, 179, 0.94);
  font: inherit;
  font-size: 0.68rem;
  line-height: 1;
  cursor: help;
}

.map-editor-help-tooltip {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 5;
  display: none;
  width: min(232px, calc(100vw - 48px));
  padding: 8px 9px;
  border: 1px solid rgba(214, 168, 94, 0.34);
  border-radius: 7px;
  background:
    radial-gradient(circle at top, rgba(112, 72, 28, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(42, 27, 14, 0.98), rgba(18, 12, 7, 0.99));
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.42);
  color: rgba(244, 223, 175, 0.88);
  font-family: 'Spectral', Georgia, serif;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.22;
  text-transform: none;
}

.map-editor-help-wrap:hover .map-editor-help-tooltip,
.map-editor-help-wrap:focus-within .map-editor-help-tooltip {
  display: block;
}

.map-editor-help-tooltip > span {
  display: block;
}

.map-editor-help-tooltip > span + span {
  margin-top: 6px;
}

.map-draw-subsection-title {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(214, 168, 94, 0.18);
}

.map-draw-tool-row {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.map-draw-tool-row-paired {
  grid-template-columns: repeat(2, 1fr);
}

.map-draw-tool-row-compact {
  grid-template-columns: repeat(2, 1fr);
}

.map-draw-tool-row-single {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.map-terrain-mobile-tabs {
  display: none;
}

.map-draw-tool-row button,
.map-draw-style-row select,
.map-draw-route-name-row input,
.map-draw-region-row select,
.map-draw-political-region-row select,
.map-terrain-elevation-row input,
.map-terrain-elevation-row select {
  border: 1px solid rgba(214, 168, 94, 0.32);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(78, 52, 27, 0.82), rgba(33, 22, 13, 0.94));
  color: #f4dfaf;
  font: inherit;
}

.map-draw-tool-row button {
  min-height: 38px;
  padding: 7px 6px;
  min-width: 0;
  white-space: normal;
  line-height: 1.12;
  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.map-draw-panel-section[data-map-edit-section="terrain"] .map-draw-tool-row button,
.map-draw-panel-section[data-map-edit-section="features"] .map-draw-tool-row button {
  min-height: 27px;
  padding: 3px 5px;
  font-size: 0.66rem;
  line-height: 1.05;
}

.map-draw-panel-section[data-map-edit-section="features"] .map-draw-section-title + .map-draw-tool-row,
.map-draw-panel-section[data-map-edit-section="terrain"] .map-draw-section-title + .map-draw-tool-row {
  margin-top: -3px;
}

.map-draw-panel-section[data-map-edit-section="features"] .map-draw-tool-row {
  align-items: start;
  flex: 0 0 auto;
}

.map-draw-panel-section[data-map-edit-section="features"] .map-draw-tool-row button {
  align-self: start;
}

.map-edit-history-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 26px;
  align-items: center;
  gap: 6px;
  margin-top: 0;
}

.map-edit-apply-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
}

.map-edit-history-help {
  justify-content: center;
}

.map-edit-history-help .map-editor-help-tooltip {
  right: 0;
  bottom: calc(100% + 8px);
  top: auto;
}

.map-draw-no-tool,
.map-draw-undo,
.map-draw-redo,
.map-draw-clear {
  width: 100%;
  margin-top: 0;
  min-height: 36px;
  padding: 7px 6px;
  border: 1px solid rgba(214, 168, 94, 0.34);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(78, 52, 27, 0.82), rgba(33, 22, 13, 0.94));
  color: #f4dfaf;
  font: inherit;
  font-family: 'Marcellus SC', Georgia, serif;
  cursor: pointer;
}

.map-draw-no-tool.active {
  border-color: rgba(242, 211, 123, 0.72);
  color: #fff2c8;
  box-shadow:
    0 10px 16px rgba(0, 0, 0, 0.22),
    inset 0 0 14px rgba(242, 211, 123, 0.14);
}

.map-draw-clear {
  align-self: end;
  margin-top: auto;
  border-color: rgba(230, 103, 79, 0.44);
  color: #f0b19d;
}

.map-chaos-toggle-row {
  margin-top: auto;
}

.map-draw-undo:disabled,
.map-draw-redo:disabled,
.map-draw-clear:disabled {
  cursor: default;
  opacity: 0.45;
}

.codex-dialog-root {
  position: fixed;
  inset: 0;
  z-index: 30000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #f4dfaf;
}

.codex-dialog-root.hidden {
  display: none;
}

.codex-dialog-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 40%, rgba(135, 92, 35, 0.16), transparent 36%),
    rgba(8, 7, 6, 0.76);
  backdrop-filter: blur(4px);
}

.codex-dialog-card {
  position: relative;
  width: min(460px, 100%);
  padding: 22px 24px 20px;
  border: 1px solid rgba(214, 168, 94, 0.48);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(62, 42, 24, 0.98), rgba(24, 16, 10, 0.99)),
    radial-gradient(circle at 32% 0%, rgba(242, 211, 123, 0.2), transparent 44%);
  box-shadow:
    0 28px 54px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 224, 153, 0.06);
}

.codex-dialog-kicker {
  margin-bottom: 7px;
  color: rgba(244, 223, 175, 0.66);
  font: 0.74rem/1.2 'Marcellus SC', Georgia, serif;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.codex-dialog-card h2 {
  margin: 0 0 10px;
  font: 1.34rem/1.15 'Marcellus SC', Georgia, serif;
  color: #fff0c6;
}

.codex-dialog-card p {
  margin: 0;
  color: rgba(244, 223, 175, 0.86);
  font: 0.98rem/1.45 Georgia, serif;
  white-space: pre-line;
}

.codex-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.codex-dialog-button {
  min-width: 92px;
  border: 1px solid rgba(214, 168, 94, 0.46);
  border-radius: 999px;
  padding: 9px 15px;
  background:
    linear-gradient(180deg, rgba(71, 47, 25, 0.96), rgba(33, 22, 14, 0.98));
  color: #f4dfaf;
  font: 0.82rem/1 'Marcellus SC', Georgia, serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.codex-dialog-button:hover,
.codex-dialog-button:focus-visible {
  outline: none;
  border-color: rgba(242, 211, 123, 0.82);
  color: #fff4cc;
  box-shadow: 0 0 16px rgba(242, 211, 123, 0.16);
}

.codex-dialog-button-primary {
  background:
    linear-gradient(180deg, rgba(121, 81, 35, 0.98), rgba(65, 38, 20, 0.98));
}

.codex-dialog-button-danger {
  border-color: rgba(230, 103, 79, 0.58);
  color: #ffd1c4;
}

.codex-dialog-button-danger:hover,
.codex-dialog-button-danger:focus-visible {
  border-color: rgba(244, 143, 112, 0.82);
  box-shadow: 0 0 16px rgba(230, 103, 79, 0.18);
}

.map-editor-intro-modal {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(9, 8, 7, 0.72);
  backdrop-filter: blur(3px);
}

.map-editor-intro-modal.hidden {
  display: none;
}

.map-editor-intro-panel {
  width: min(520px, 100%);
  padding: 20px 22px 18px;
  border: 1px solid rgba(214, 168, 94, 0.42);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(60, 39, 22, 0.96), rgba(25, 17, 11, 0.98));
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 224, 153, 0.05);
  color: #f4dfaf;
}

.map-editor-intro-kicker {
  margin-bottom: 6px;
  color: rgba(244, 223, 175, 0.68);
  font: 0.76rem/1.2 'Marcellus SC', Georgia, serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.map-editor-intro-panel h2 {
  margin: 0 0 10px;
  font: 1.32rem/1.15 'Marcellus SC', Georgia, serif;
  color: #fff0c6;
}

.map-editor-intro-body {
  display: grid;
  gap: 10px;
  color: rgba(244, 223, 175, 0.88);
  font-size: 0.94rem;
  line-height: 1.45;
}

.map-editor-intro-body p {
  margin: 0;
}

.map-editor-intro-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.map-editor-intro-actions button {
  min-width: 126px;
}

.map-edit-empty-note {
  margin: 0;
  color: rgba(244, 223, 175, 0.66);
  font-size: 0.86rem;
  line-height: 1.25;
}

.map-edit-warning-note {
  color: rgba(240, 177, 157, 0.92);
}

.map-feature-brush-note {
  margin: -2px 0 1px;
  padding: 5px 7px;
  border: 1px solid rgba(214, 168, 94, 0.18);
  border-radius: 6px;
  background: rgba(255, 238, 190, 0.055);
  color: rgba(244, 223, 175, 0.78);
  font-size: 0.68rem;
  line-height: 1.18;
}

.map-draw-layer-toggles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.map-draw-layer-toggles label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid rgba(214, 168, 94, 0.20);
  border-radius: 6px;
  background: rgba(255, 245, 220, 0.04);
  color: rgba(244, 223, 175, 0.90);
  font-size: 0.76rem;
}

.map-draw-layer-toggles input {
  accent-color: #f2d37b;
}

.map-nuke-action-list {
  display: grid;
  gap: 7px;
}

.map-nuke-region-note {
  margin: 5px 0 0;
}

@media (max-width: 520px), (max-height: 560px) {
  #map-view-button {
    width: 88px;
    height: 40px;
    font-size: 0.68rem;
  }

  #map-view-button {
    bottom: 44px;
    left: 128px;
  }

  #map-draw-button {
    bottom: 122px;
    left: 16px;
    width: 96px;
    height: 96px;
    background-size: 90px 90px;
  }

  #map-draw-button::before {
    font-size: 1.45rem;
    letter-spacing: 0.16em;
  }

  .map-view-panel {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    z-index: calc(var(--map-control-z-index) + 3);
    transform: translate(-50%, -50%);
    width: min(310px, calc(100vw - 28px));
    max-height: calc(100vh - 64px);
  }

  .map-control-panel:not(.map-view-panel) {
    left: 4px;
    right: 4px;
    bottom: 4px;
    width: auto;
    max-height: calc(100vh - 8px);
  }

  .map-draw-panel {
    display: block;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: auto;
    overflow: visible;
  }

  .map-edit-pane {
    position: fixed;
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 96px;
    width: auto;
    height: min(58vh, 430px);
    padding: 9px;
  }

  .map-edit-pane-header {
    padding: 6px 8px;
  }

  .map-draw-panel-title {
    font-size: 1.02rem;
  }

  .map-edit-pane-body {
    margin-top: 7px;
  }

  .map-edit-collapse-button {
    display: block;
  }

  .map-draw-panel.map-edit-left-collapsed .map-edit-pane {
    top: auto;
    bottom: 96px;
    width: auto;
    height: auto;
    min-height: 0;
    padding: 8px;
    overflow: hidden;
  }

  .map-draw-panel.map-edit-left-collapsed .map-edit-pane > :not(.map-edit-utility-pane) {
    display: none;
  }

  .map-edit-section-menu {
    left: 8px;
    right: 8px;
    bottom: 8px;
    grid-template-columns: 1fr;
    gap: 6px;
    min-height: 64px;
    padding: 8px;
  }

  .map-edit-rail-utility,
  .map-edit-rail-main[data-map-tool-mode-panel="chooser"],
  .map-edit-rail-main[data-map-tool-mode-panel="surveyor"],
  .map-edit-rail-main[data-map-tool-mode-panel="cartographer"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-edit-rail-utility {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-generation-popout {
    left: 8px;
    right: 8px;
    bottom: 90px;
    min-height: 42px;
    grid-template-columns: 112px repeat(2, minmax(0, 1fr));
  }

  .map-generation-popout.map-generation-popout-three {
    grid-template-columns: 112px repeat(3, minmax(0, 1fr));
  }

  .map-generation-popout button {
    min-height: 42px;
    font-size: 0.66rem;
  }

.map-edit-section-menu button {
    min-height: 42px;
    padding: 5px 3px 6px;
    font-size: 0.66rem;
  }

.map-edit-mode-icon {
    font-size: 0.82rem;
  }

  .map-edit-mode-label {
    font-size: 0.62rem;
  }

  .map-terrain-mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    flex: 0 0 auto;
    gap: 5px;
  }

  .map-terrain-mobile-tabs button {
    min-height: 32px;
    padding: 5px 3px;
    border: 1px solid rgba(214, 168, 94, 0.30);
    border-radius: 6px;
    background:
      linear-gradient(180deg, rgba(78, 52, 27, 0.82), rgba(33, 22, 13, 0.94));
    color: rgba(244, 223, 175, 0.86);
    font-family: 'Marcellus SC', Georgia, serif;
    font-size: 0.64rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  .map-terrain-mobile-tabs button.active {
    border-color: rgba(242, 211, 123, 0.72);
    color: #fff2c8;
    box-shadow: inset 0 0 14px rgba(242, 211, 123, 0.14);
  }

  .map-draw-panel-section[data-map-edit-section="terrain"].active [data-terrain-mobile-group] {
    display: none;
  }

  .map-draw-panel-section[data-map-edit-section="terrain"].mobile-terrain-tab-tools [data-terrain-mobile-group="tools"],
  .map-draw-panel-section[data-map-edit-section="terrain"].mobile-terrain-tab-base [data-terrain-mobile-group="base"],
  .map-draw-panel-section[data-map-edit-section="terrain"].mobile-terrain-tab-elevation [data-terrain-mobile-group="elevation"] {
    display: grid;
  }

  .map-draw-panel-section[data-map-edit-section="terrain"].mobile-terrain-tab-base .map-terrain-base-options,
  .map-draw-panel-section[data-map-edit-section="features"].active .map-terrain-feature-options {
    border: 1px solid rgba(214, 168, 94, 0.18);
    border-radius: 7px;
    background: rgba(12, 8, 5, 0.22);
  }

  .map-draw-panel-section[data-map-edit-section="overlay"].active {
    justify-content: start;
    overflow-y: auto;
    padding-bottom: 12px;
  }

  .map-draw-panel-section[data-map-edit-section="generation"].active {
    justify-content: start;
    overflow: hidden;
  }

  .map-draw-panel-section[data-map-edit-section="overlay"] .map-draw-tool-row,
  .map-draw-panel-section[data-map-edit-section="overlay"] .map-draw-style-row,
  .map-draw-panel-section[data-map-edit-section="overlay"] .map-draw-option-row,
  .map-draw-panel-section[data-map-edit-section="overlay"] .map-draw-range-row,
  .map-draw-panel-section[data-map-edit-section="overlay"] .map-draw-route-name-row,
  .map-draw-panel-section[data-map-edit-section="overlay"] .map-draw-clear {
    flex: 0 0 auto;
  }
}

.map-draw-tool-row button.active {
  border-color: rgba(242, 211, 123, 0.72);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 213, 120, 0.24), transparent 42%),
    linear-gradient(180deg, rgba(129, 88, 34, 0.92), rgba(66, 43, 16, 0.98));
  color: #fff2c8;
  box-shadow:
    0 12px 18px rgba(0, 0, 0, 0.24),
    inset 0 0 14px rgba(242, 211, 123, 0.12);
}

.map-terrain-base-options,
.map-terrain-feature-options {
  display: grid;
  gap: 6px;
}

.map-terrain-base-options {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  flex: 0 0 auto;
  padding-right: 0;
  overflow: visible;
}

.map-terrain-feature-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  padding-right: 2px;
  overflow-y: auto;
}

.map-terrain-base-option,
.map-terrain-feature-option {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 38px;
  padding: 6px;
  border: 1px solid rgba(214, 168, 94, 0.28);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(75, 49, 24, 0.74), rgba(31, 21, 13, 0.92));
  color: #f4dfaf;
  font: inherit;
}

.map-terrain-base-option[hidden],
.map-feature-brush-option[hidden] {
  display: none !important;
}

.map-terrain-base-option {
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 66px;
  cursor: pointer;
}

.map-terrain-base-option.active,
.map-feature-brush-option.active {
  border-color: rgba(242, 211, 123, 0.80);
  color: #fff2c8;
  box-shadow:
    0 10px 18px rgba(0, 0, 0, 0.18),
    inset 0 0 18px rgba(242, 211, 123, 0.14);
}

.map-terrain-swatch {
  width: 31px;
  height: 27px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 240, 190, 0.50);
  border-radius: 0;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.20);
}

.map-terrain-swatch-chaos {
  background:
    linear-gradient(120deg, #245f82, #dbc487, #4e7b45, #b88955, #dce5e6, #756e66, #7d4335);
  background-size: 420% 420%;
  animation: map-terrain-chaos-cycle 2600ms linear infinite;
}

@keyframes map-terrain-chaos-cycle {
  0% {
    background-position: 0% 50%;
  }

  100% {
    background-position: 100% 50%;
  }
}

.map-terrain-label {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  white-space: normal;
  color: rgba(244, 223, 175, 0.95);
  font-size: 0.6rem;
  line-height: 1.05;
  text-align: center;
}

.map-terrain-feature-option input {
  accent-color: #f2d37b;
}

.map-terrain-feature-option {
  min-height: 34px;
  padding: 6px 7px;
  font-size: 0.76rem;
  cursor: pointer;
}

.map-feature-brush-option {
  justify-content: center;
}

.map-terrain-elevation-row {
  display: grid;
  flex: 0 0 auto;
  gap: 4px;
}

.map-terrain-elevation-row input,
.map-terrain-elevation-row select {
  min-height: 34px;
  padding: 6px 8px;
}

.map-draw-style-row,
.map-draw-option-row,
.map-draw-range-row,
.map-draw-route-name-row,
.map-draw-region-row,
.map-draw-political-region-row {
  display: grid;
  gap: 4px;
  margin-top: 0;
}

.map-region-select-plus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 34px;
  gap: 6px;
}

.map-draw-style-row[hidden],
.map-draw-option-row[hidden],
.map-draw-range-row[hidden],
.map-draw-route-name-row[hidden],
.map-draw-region-row[hidden],
.map-draw-political-region-row[hidden] {
  display: none;
}

.map-draw-range-row {
  color: rgba(244, 223, 175, 0.88);
  font-size: 0.76rem;
}

.map-draw-range-row span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.map-draw-range-row strong {
  color: #fff2c8;
  font-weight: 700;
}

.map-draw-range-row input {
  width: 100%;
  accent-color: #f2d37b;
}

.map-draw-option-row {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  color: rgba(244, 223, 175, 0.88);
  font-size: 0.76rem;
}

.map-draw-option-row input {
  accent-color: #f2d37b;
}

.map-draw-style-row select,
.map-draw-route-name-row input,
.map-draw-region-row select,
.map-draw-political-region-row select {
  min-height: 34px;
  padding: 6px 8px;
}

.map-draw-route-name-row {
  color: rgba(244, 223, 175, 0.88);
  font-size: 0.76rem;
}

.map-draw-route-name-row input {
  border: 1px solid rgba(214, 168, 94, 0.32);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(78, 52, 27, 0.82), rgba(33, 22, 13, 0.94));
  box-sizing: border-box;
  color: #f4dfaf;
  font: inherit;
  outline: none;
  width: 100%;
}

.map-draw-route-name-row input::placeholder {
  color: rgba(244, 223, 175, 0.46);
}

.map-draw-route-name-row input:focus {
  border-color: rgba(242, 211, 123, 0.74);
  box-shadow: 0 0 0 2px rgba(242, 155, 64, 0.18), inset 0 0 14px rgba(242, 155, 64, 0.12);
}

.map-draw-secondary-button {
  min-height: 34px;
  width: 100%;
  border: 1px solid rgba(214, 168, 94, 0.34);
  border-radius: 7px;
  background:
    radial-gradient(circle at 50% 0%, rgba(242, 211, 123, 0.18), transparent 46%),
    linear-gradient(180deg, rgba(78, 52, 27, 0.86), rgba(33, 22, 13, 0.96));
  color: #f4dfaf;
  font: inherit;
  cursor: pointer;
}

.map-draw-secondary-button:hover,
.map-draw-secondary-button:focus-visible {
  border-color: rgba(242, 211, 123, 0.72);
  box-shadow: 0 0 12px rgba(242, 155, 64, 0.18);
}

.map-named-routes-anchor {
  margin-top: auto;
}

.map-named-routes-menu {
  position: fixed;
  z-index: 12000;
  left: 50%;
  top: 50%;
  width: min(560px, calc(100vw - 28px));
  max-height: min(680px, calc(100vh - 36px));
  overflow: auto;
  transform: translate(-50%, -50%);
  padding: 18px;
  border: 1px solid rgba(222, 174, 91, 0.52);
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 0%, rgba(242, 211, 123, 0.14), transparent 36%),
    linear-gradient(180deg, rgba(53, 32, 16, 0.98), rgba(20, 13, 8, 0.98));
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.58);
  color: #f4dfaf;
}

.map-named-routes-menu.hidden {
  display: none;
}

.map-named-routes-menu h2 {
  margin: 0 0 6px;
  font-family: 'Marcellus SC', Georgia, serif;
  letter-spacing: 0.06em;
}

.map-named-routes-copy {
  margin: 0 0 14px;
  color: rgba(244, 223, 175, 0.72);
}

.map-named-routes-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.map-named-route-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid rgba(214, 168, 94, 0.24);
  border-radius: 8px;
  background: rgba(31, 20, 12, 0.74);
}

.map-named-route-item strong,
.map-named-route-item span {
  display: block;
}

.map-named-route-item span {
  color: rgba(244, 223, 175, 0.64);
  font-size: 0.78rem;
}

.map-named-routes-menu button,
.map-named-route-edit-form input,
.map-named-route-edit-form select {
  border: 1px solid rgba(214, 168, 94, 0.34);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(78, 52, 27, 0.86), rgba(33, 22, 13, 0.96));
  color: #f4dfaf;
  font: inherit;
}

.map-named-routes-menu button {
  min-height: 32px;
  padding: 6px 10px;
  cursor: pointer;
}

.map-named-route-edit-form {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(214, 168, 94, 0.22);
  border-radius: 9px;
  background: rgba(14, 9, 6, 0.42);
}

.map-named-route-edit-form[hidden] {
  display: none;
}

.map-named-route-edit-form label {
  display: grid;
  gap: 4px;
}

.map-named-route-edit-form input,
.map-named-route-edit-form select {
  min-height: 34px;
  padding: 6px 8px;
}

.map-named-routes-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.map-region-color-input,
.map-add-region-button {
  min-height: 34px;
}

.map-region-color-control {
  min-width: 34px;
}

.map-region-color-input {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 3px;
  border: 1px solid rgba(214, 168, 94, 0.34);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 213, 120, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(78, 52, 27, 0.86), rgba(33, 22, 13, 0.96));
  cursor: pointer;
  box-sizing: border-box;
}

.map-region-color-input .color-picker-trigger-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(7, 4, 2, 0.76);
  border-radius: 4px;
  box-sizing: border-box;
  box-shadow: inset 0 0 0 1px rgba(255, 246, 203, 0.22);
}

.map-region-color-input:hover,
.map-region-color-input:focus-visible {
  border-color: rgba(242, 211, 123, 0.72);
  box-shadow: inset 0 0 14px rgba(242, 211, 123, 0.14);
}

.map-region-color-input:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.color-picker-popover {
  position: fixed;
  z-index: 7000;
  width: min(276px, calc(100vw - 16px));
  padding: 10px;
  border: 1px solid rgba(196, 148, 74, 0.78);
  border-radius: 9px;
  background:
    radial-gradient(circle at top, rgba(138, 91, 35, 0.22), transparent 30%),
    linear-gradient(180deg, rgba(55, 36, 18, 0.98), rgba(21, 13, 7, 0.99));
  color: #f4dfaf;
  box-shadow:
    0 24px 52px rgba(0, 0, 0, 0.48),
    inset 0 0 0 1px rgba(252, 221, 154, 0.08);
}

.color-picker-popover-head {
  display: block;
  align-items: center;
  color: #f2d37b;
  font-family: 'Marcellus SC', Georgia, serif;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.color-picker-close,
.color-picker-confirm {
  border: 1px solid rgba(214, 168, 94, 0.34);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 213, 120, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(78, 52, 27, 0.86), rgba(33, 22, 13, 0.96));
  color: #f2d37b;
  cursor: pointer;
}

.color-picker-close,
.color-picker-confirm {
  width: 34px;
  height: 34px;
  line-height: 1;
}

.color-picker-confirm {
  color: #fff2c8;
}

.color-picker-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.color-picker-actions .color-picker-close,
.color-picker-actions .color-picker-confirm {
  width: 100%;
}

.color-picker-spectrum {
  position: relative;
  height: 158px;
  margin-top: 10px;
  border: 1px solid rgba(7, 4, 2, 0.76);
  border-radius: 7px;
  background:
    linear-gradient(180deg, transparent, #000),
    linear-gradient(90deg, #fff, transparent),
    var(--picker-hue-color, #ffd84d);
  cursor: crosshair;
  box-shadow:
    inset 0 0 0 1px rgba(255, 246, 203, 0.22),
    0 8px 16px rgba(0, 0, 0, 0.20);
}

.color-picker-spectrum-target {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid #fff8db;
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.62),
    0 2px 6px rgba(0, 0, 0, 0.38);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.color-picker-hue-row {
  margin-top: 10px;
}

.color-picker-hue {
  width: 100%;
  accent-color: #f2d37b;
}

.color-picker-preview-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: end;
  gap: 10px;
  margin-top: 8px;
}

.color-picker-preview {
  height: 38px;
  border: 1px solid rgba(7, 4, 2, 0.76);
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(255, 246, 203, 0.22);
}

.color-picker-hex-row,
.color-picker-slider-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 0;
  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.color-picker-hex-input {
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid rgba(214, 168, 94, 0.34);
  border-radius: 6px;
  background: rgba(255, 246, 220, 0.9);
  color: #24160a;
  font: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.color-picker-slider-list {
  display: grid;
  gap: 2px;
  margin-top: 4px;
}

.color-picker-slider-row {
  grid-template-columns: 20px minmax(0, 1fr) 34px;
  margin-top: 5px;
}

.color-picker-slider {
  accent-color: #f2d37b;
}

.color-picker-slider-row output {
  color: rgba(244, 223, 175, 0.82);
  font-size: 0.68rem;
  text-align: right;
}

.map-add-region-button {
  border: 1px solid rgba(214, 168, 94, 0.34);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 213, 120, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(78, 52, 27, 0.86), rgba(33, 22, 13, 0.96));
  color: #f2d37b;
  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.map-add-region-button:hover,
.map-add-region-button:focus-visible {
  border-color: rgba(242, 211, 123, 0.72);
  color: #fff2c8;
  box-shadow: inset 0 0 14px rgba(242, 211, 123, 0.14);
}

@media (max-width: 520px), (max-height: 560px) {
  .map-generation-shared-controls {
    grid-template-columns: 1fr;
  }

  .map-generation-footer-actions {
    width: 100%;
  }

  .map-generation-footer-actions button {
    width: 100%;
  }

  .map-terrain-base-options {
    grid-auto-flow: column;
    grid-auto-columns: minmax(72px, 78px);
    grid-template-columns: none;
    grid-template-rows: repeat(2, 70px);
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    align-content: start;
    box-sizing: border-box;
    padding: 6px 2px 8px 6px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .map-terrain-feature-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    align-content: start;
    box-sizing: border-box;
    padding: 6px 2px 8px 6px;
    overflow-y: auto;
  }

  .map-terrain-base-option {
    min-height: 64px;
    padding: 5px;
  }

  .map-draw-style-row,
  .map-draw-option-row,
  .map-draw-range-row,
  .map-draw-route-name-row,
  .map-draw-region-row,
  .map-draw-political-region-row {
    flex: 0 0 auto;
  }

  .map-draw-clear {
    margin-top: 0;
  }

  .map-terrain-elevation-row {
    align-content: start;
    gap: 8px;
  }

  .map-terrain-elevation-row select {
    min-height: 42px;
    font-size: 1rem;
  }
}

/* Hex Popup Preview */

.leaflet-popup-content-wrapper {
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;

  padding: 0 !important;

  overflow: visible !important;
}

.leaflet-popup-content,
.generated-map-popup-content {
  position: relative;

  margin: 0 !important;
  padding: 22px 26px !important;

  min-width: 190px;

  color: #3a2614;

  font-family: 'Spectral', Georgia, serif !important;
  font-size: 16px;
  line-height: 1.35;

  text-align: center;

  z-index: 1;
}

.leaflet-popup-content::before,
.generated-map-popup-content::before {
  content: "";

  position: absolute;

  top: -18px;
  bottom: -18px;
  left: -18px;
  right: -18px;

  background-image: url("../assets/codex/Mobile_Panel.png");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;

  opacity: 0.96;

  z-index: -1;
  pointer-events: none;
}

.leaflet-popup-tip-container {
  display: none !important;
}

.leaflet-popup-close-button {
  display: none !important;
}

.mobile-hex-popup-card {
  min-width: 0;
}

.mobile-hex-popup-title {
  margin: 0 0 5px;

  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 1rem;
  line-height: 1.05;
  letter-spacing: 0.065em;
  text-transform: uppercase;

  color: #2f1d10;
}

.mobile-hex-popup-title::after {
  content: "";

  display: block;

  width: 78%;
  height: 1px;

  margin: 8px auto 0;

  background: linear-gradient(
    to right,
    transparent,
    rgba(72, 43, 18, 0.48),
    transparent
  );
}

.mobile-hex-popup-terrain {
  margin-top: 8px;

  font-family: 'Spectral', Georgia, serif;
  font-size: 0.98rem;
  line-height: 1.2;
  color: #2f1d10;
}

.mobile-hex-popup-region {
  margin-top: 8px;

  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 0.82rem;
  letter-spacing: 0.055em;
  line-height: 1.12;
  text-transform: uppercase;

  color: rgba(47, 29, 16, 0.82);
}

.mobile-hex-popup-political-region {
  margin-top: 3px;

  font-family: 'Spectral', Georgia, serif;
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.12;

  color: rgba(47, 29, 16, 0.70);
}

.mobile-hex-popup-political-region + .mobile-hex-popup-terrain {
  margin-top: 4px;
}

.mobile-hex-popup-elevation {
  margin-top: 2px;

  font-family: 'Spectral', Georgia, serif;
  font-size: 0.82rem;
  line-height: 1.15;

  color: rgba(47, 29, 16, 0.66);
}

.mobile-hex-popup-meta {
  margin-top: 5px;

  font-family: 'Spectral', Georgia, serif;
  font-size: 0.86rem;
  line-height: 1.2;
  opacity: 0.78;
}

.mobile-hex-popup-pois {
  margin-top: 9px;
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
}

.mobile-hex-popup-pois-label {
  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(47, 29, 16, 0.76);
}

.mobile-hex-popup-poi-list {
  display: grid;
  gap: 4px;
  justify-items: center;
  width: 100%;
}

.mobile-hex-popup-poi-link,
.mobile-hex-popup-poi-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  color: #2f1d10;
  font-family: 'Spectral', Georgia, serif !important;
  font-size: 0.92rem !important;
  line-height: 1.2 !important;
  letter-spacing: 0 !important;
  text-align: center;
}

.mobile-hex-popup-poi-link {
  text-decoration: underline;
  text-decoration-color: rgba(72, 43, 18, 0.34);
  text-underline-offset: 2px;
}

.mobile-hex-popup-poi-link:hover,
.mobile-hex-popup-poi-link:focus-visible {
  color: rgba(47, 29, 16, 0.84) !important;
  text-decoration-color: rgba(72, 43, 18, 0.56);
}

.mobile-hex-popup-poi-more,
.mobile-hex-popup-pois-empty {
  color: rgba(47, 29, 16, 0.68);
  font-family: 'Spectral', Georgia, serif;
  font-size: 0.8rem;
  line-height: 1.2;
}

.generated-hex-coordinate-label {
  display: none;
  pointer-events: none;
}

#map.generated-coordinate-labels-visible .generated-hex-coordinate-label {
  display: block;
}

.generated-hex-coordinate-label span {
  display: block;
  width: 42px;

  color: rgba(0, 0, 0, 0.52);

  font-family: 'Spectral', Georgia, serif;
  font-size: 7px;
  line-height: 1;
  text-align: center;

  user-select: none;
}

#generated-map-renderer {
  position: absolute;
  inset: 0;
  z-index: 650;

  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

#generated-map-renderer.generated-map-is-loading {
  position: fixed;
  z-index: calc(var(--map-control-z-index) + 20);
}

#generated-map-renderer:active {
  cursor: grabbing;
}

#generated-map-renderer.generated-map-wall-brush-active,
#generated-map-renderer.generated-map-wall-brush-active:active {
  cursor: none;
}

.generated-map-terrain-canvas,
.generated-map-grid-overlay {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;
}

.generated-map-grid-overlay {
  pointer-events: none;
}

.generated-map-grid-lines {
  fill: none;
  stroke: rgba(0, 0, 0, 0.22);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.generated-map-region-border-glow {
  fill: none;
  stroke-linecap: round;
  stroke-width: 9;
  opacity: 0.38;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.generated-map-region-borders {
  fill: none;
  stroke-linecap: round;
  stroke-width: 5.5;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.generated-map-geographic-region-fill {
  opacity: 0.25;
  pointer-events: none;
}

.generated-map-geographic-region-outline {
  fill: none;
  stroke-width: 4.8;
  stroke-dasharray: 5 5;
  stroke-linecap: round;
  opacity: 0.92;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.generated-map-region-label {
  pointer-events: none;
  user-select: none;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke fill;
  filter:
    drop-shadow(0 0 2px rgba(238, 211, 158, 0.46))
    drop-shadow(0 0 4px rgba(238, 211, 158, 0.24));
}

.generated-map-political-region-label {
  fill: rgba(47, 29, 16, 0.90);
  stroke: rgba(238, 211, 158, 0.92);

  font-family: 'Marcellus SC', Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.generated-map-geographic-region-label {
  fill: rgba(47, 29, 16, 0.76);
  stroke: rgba(238, 211, 158, 0.86);

  font-family: 'Spectral', Georgia, serif;
  font-style: italic;
  letter-spacing: 0.02em;
}

.generated-map-drawn-road,
.generated-map-drawn-river,
.generated-map-drawn-path,
.generated-map-drawing-pending,
.generated-map-drawing-edge-preview,
.generated-map-erase-preview {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.generated-map-drawn-road {
  stroke-width: 6;
}

.generated-map-drawn-wall {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.generated-map-drawn-path {
  stroke-width: 3.5;
  stroke-dasharray: 7 5;
}

.generated-map-drawn-river {
  stroke: #37b8e8;
  stroke-width: 6;
  filter: drop-shadow(0 0 4px rgba(55, 184, 232, 0.36));
}

.generated-map-drawn-wall-base {
  stroke: #252522;
  stroke-width: 9;
}

.generated-map-drawn-wall-body {
  stroke: #46443d;
  stroke-width: 6;
}

.generated-map-drawn-wall-crenellations {
  stroke: #7b7668;
  stroke-width: 3;
  stroke-dasharray: 2 8;
  stroke-linecap: butt;
}

.generated-map-drawn-wall-palisade-shadow {
  stroke: #1d120b;
  stroke-width: 7;
  stroke-linecap: round;
}

.generated-map-drawn-wall-palisade-rail {
  stroke: #8a4f27;
  stroke-width: 3;
  stroke-linecap: round;
}

.generated-map-drawn-wall-palisade-stakes {
  stroke: #d29a57;
  stroke-width: 3;
  stroke-linecap: square;
}

.generated-map-wall-variant {
  fill: none;
  stroke-linejoin: round;
  pointer-events: none;
}

.generated-map-wall-variant-stone {
  stroke: #d9c087;
  stroke-width: 4;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px rgba(32, 24, 15, 0.55));
}

.generated-map-wall-variant-palisade {
  stroke: #f0bc72;
  stroke-width: 3.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 2px rgba(29, 18, 11, 0.55));
}

.generated-map-wall-variant-sluice {
  stroke: #9fe7f7;
}

.generated-map-wall-variant-stone.generated-map-wall-variant-gate {
  stroke: #9d9685;
  stroke-width: 7;
  stroke-linecap: butt;
  filter:
    drop-shadow(0 0 2px rgba(24, 22, 18, 0.70))
    drop-shadow(0 0 5px rgba(238, 218, 166, 0.22));
}

.generated-map-wall-variant-broken {
  stroke-dasharray: 4 4;
  opacity: 0.9;
}

.generated-map-drawing-pending {
  stroke: #55e6ff;
  stroke-width: 3;
  stroke-dasharray: 6 4;
}

.generated-map-drawing-edge-preview {
  stroke: #55e6ff;
  stroke-width: 7;
  opacity: 0.78;
}

.generated-map-wall-brush-cursor {
  fill: #55e6ff;
  stroke: rgba(13, 40, 48, 0.88);
  stroke-width: 2;
  opacity: 0.95;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.generated-map-erase-preview {
  stroke: rgba(255, 215, 136, 0.95);
  stroke-width: 10;
  stroke-dasharray: 8 5;
  opacity: 0.92;
  filter:
    drop-shadow(0 0 4px rgba(255, 60, 42, 0.88))
    drop-shadow(0 0 10px rgba(255, 214, 122, 0.44));
}

.generated-map-erase-preview-path {
  stroke-width: 7;
}

.generated-map-erase-preview-river {
  stroke-width: 11;
}

.generated-map-erase-preview-wall {
  stroke-width: 12;
}

.generated-map-erase-preview-mist {
  fill: rgba(240, 240, 232, 0.24);
  stroke-width: 4;
}

.generated-map-mist-brush-preview {
  fill: rgba(240, 240, 232, 0.20);
  stroke: rgba(255, 245, 210, 0.86);
  stroke-width: 3;
  stroke-dasharray: 5 4;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
  filter:
    drop-shadow(0 0 4px rgba(255, 245, 210, 0.42))
    drop-shadow(0 0 10px rgba(240, 240, 232, 0.18));
}

.generated-map-editor-brush-preview {
  stroke-width: 3;
  stroke-dasharray: 5 4;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.generated-map-terrain-brush-preview {
  fill: rgba(242, 211, 123, 0.16);
  stroke: rgba(255, 225, 150, 0.9);
  filter:
    drop-shadow(0 0 4px rgba(255, 225, 150, 0.38))
    drop-shadow(0 0 10px rgba(143, 93, 35, 0.18));
}

.generated-map-feature-brush-preview {
  fill: rgba(129, 194, 112, 0.16);
  stroke: rgba(193, 238, 154, 0.88);
  filter:
    drop-shadow(0 0 4px rgba(193, 238, 154, 0.34))
    drop-shadow(0 0 10px rgba(48, 97, 42, 0.18));
}

.generated-map-region-brush-preview {
  fill: rgba(242, 211, 123, 0.10);
  stroke: rgba(255, 216, 77, 0.92);
  filter:
    drop-shadow(0 0 4px rgba(255, 216, 77, 0.42))
    drop-shadow(0 0 10px rgba(143, 93, 35, 0.22));
}

.generated-map-route-label {
  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  pointer-events: none;
  user-select: none;
  text-transform: uppercase;
}

.generated-map-route-label-road {
  fill: #f1d58a;
  stroke: rgba(54, 31, 14, 0.88);
  stroke-width: 4;
}

.generated-map-route-label-river,
.generated-map-route-label-sea_route {
  fill: #d9f5ff;
  stroke: rgba(13, 51, 66, 0.88);
  stroke-width: 4;
  font-style: italic;
}

.generated-map-route-label-sea_route {
  fill: #efe4b0;
  stroke: rgba(35, 58, 76, 0.9);
}

.generated-map-route-icon {
  pointer-events: none;
  opacity: 0.88;
  paint-order: stroke fill;
  filter:
    drop-shadow(0 0 2px rgba(42, 25, 12, 0.62))
    drop-shadow(0 0 5px rgba(255, 232, 174, 0.18));
}

.generated-map-route-icon path,
.generated-map-route-icon polygon,
.generated-map-route-icon circle,
.generated-map-route-icon rect,
.generated-map-route-icon ellipse,
.generated-map-route-icon line,
.generated-map-route-icon polyline {
  fill: currentColor;
  stroke: var(--route-icon-outline, rgba(35, 23, 14, 0.86));
  stroke-width: 18px;
  stroke-linejoin: round;
  stroke-linecap: round;
  paint-order: stroke fill;
}

.generated-map-route-icon-road {
  color: #f1d58a;
  --route-icon-outline: rgba(54, 31, 14, 0.88);
}

.generated-map-route-icon-river {
  color: #d9f5ff;
  --route-icon-outline: rgba(13, 51, 66, 0.88);
}

.generated-map-route-icon-sea_route {
  color: #efe4b0;
  --route-icon-outline: rgba(35, 58, 76, 0.9);
}

.generated-map-path-reveal {
  opacity: 0.86;
  filter: drop-shadow(0 0 5px rgba(255, 232, 179, 0.28));
}

.generated-map-coord-label {
  fill: rgba(244, 238, 222, 0.96);
  stroke: rgba(17, 12, 9, 0.9);
  stroke-width: 1.9px;
  paint-order: stroke fill;
  stroke-linejoin: round;

  font-family: 'Spectral', Georgia, serif;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;

  pointer-events: none;
  user-select: none;
}

.generated-map-poi-marker {
  pointer-events: none;
}

.generated-map-poi-bg {
  fill: rgba(255, 255, 255, 0.8);
  stroke: rgba(16, 11, 7, 0.96);
  stroke-width: 2.25;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.generated-map-poi-bg-dungeon-complex {
  stroke-width: 2.5;
}

.generated-map-poi-symbol {
  fill: #120d09;

  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;

  pointer-events: none;
  user-select: none;
}

.generated-map-poi-icon {
  color: #120d09;
  overflow: visible;
  pointer-events: none;
}

.generated-map-poi-icon path,
.generated-map-poi-icon polygon,
.generated-map-poi-icon circle,
.generated-map-poi-icon rect,
.generated-map-poi-icon ellipse,
.generated-map-poi-icon line,
.generated-map-poi-icon polyline {
  vector-effect: non-scaling-stroke;
}

.generated-map-poi-count-bg {
  fill: rgba(255, 255, 255, 0.98);
  stroke: rgba(16, 11, 7, 0.96);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.generated-map-poi-count {
  fill: #120d09;
  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}

.generated-map-hovered-hex,
.generated-map-selected-hex {
  fill: none;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.generated-map-hovered-hex {
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 2;
}

.generated-map-selected-hex {
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 3;
}

.generated-map-popup {
  position: absolute;
  z-index: 2;

  transform: translate(-50%, -100%);
  pointer-events: auto;
}

.generated-map-loading-veil {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: grid;
  place-items: center;

  background:
    radial-gradient(circle at center, rgba(25, 17, 10, 0.74), rgba(8, 6, 4, 0.90));

  pointer-events: auto;
}

.generated-map-loading-veil[hidden] {
  display: none;
}

.generated-map-loading-message {
  padding: clamp(16px, 3vw, 28px) clamp(22px, 5vw, 46px);
  border: 1px solid rgba(242, 211, 123, 0.42);
  border-radius: 4px;

  background: rgba(24, 18, 10, 0.72);
  color: #f2d37b;

  font-family: 'Marcellus SC', Georgia, serif;
  font-size: clamp(1.35rem, 5vw, 3rem);
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;

  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.42),
    inset 0 0 18px rgba(242, 211, 123, 0.10);
}

.leaflet-popup-content button,
.generated-map-popup-content button {
  appearance: none;
  -webkit-appearance: none;

  border: 1px solid rgba(72, 43, 18, 0.24);
  border-radius: 3px;

  background: rgba(246, 232, 196, 0.42);
  color: #2f1d10;

  font-family: 'Marcellus SC', Georgia, serif;
  font-size: 0.88rem;
  line-height: 1;
  letter-spacing: 0.035em;

  box-shadow: none;
  cursor: pointer;
}

.leaflet-popup-content button:hover,
.leaflet-popup-content button:focus-visible,
.generated-map-popup-content button:hover,
.generated-map-popup-content button:focus-visible {
  background: rgba(94, 55, 22, 0.10);
  border-color: rgba(72, 43, 18, 0.38);
  outline: none;
}

.leaflet-popup-content .popup-action-row,
.generated-map-popup-content .popup-action-row {
  display: grid;
  grid-template-columns: minmax(84px, 0.9fr) minmax(108px, 1.3fr) 54px;
  gap: 8px;

  margin-top: 12px;

  border-top: 1px solid rgba(72, 43, 18, 0.16);
  padding-top: 10px;
}

.generated-map-popup-content .popup-action-row-editor-preview {
  grid-template-columns: minmax(108px, 1fr) 54px;
}

.leaflet-popup-content .popup-action-row button,
.generated-map-popup-content .popup-action-row button {
  width: 100%;

  margin: 0;
  padding: 9px 10px;
}

.leaflet-popup-content .popup-close-details,
.generated-map-popup-content .popup-close-details {
  font-size: 1.06rem;
  line-height: 1;
}
