:root {
  --lab-gold: #f4cf8b;
  --lab-gold-bright: #ffe9bd;
  --lab-gold-deep: #c79a4f;
  --lab-gold-dim: #9c8a63;
  --lab-ink: #15090a;
  --lab-edge: rgba(244, 207, 139, 0.42);
  --lab-edge-soft: rgba(244, 207, 139, 0.14);
  --lab-good: #79d39b;
  --lab-warn: #ecbc5b;
  --lab-bad: #e57373;
  --lab-glass-a: rgba(40, 24, 47, 0.90);
  --lab-glass-b: rgba(15, 8, 19, 0.94);
  --lab-shadow: 0 14px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.45);
}

/* The open list of a <select>, the number-input spinners, and the scrollbar that runs down a long
   dropdown are all painted by the browser, outside the reach of our CSS. color-scheme is the only
   lever on them: without it a fully themed select still drops open a white list with a light
   scrollbar. Declared on the page so every control on it, present and future, inherits. */
body.map-page { color-scheme: dark; }

.lab-mode #map-ui-controls,
.lab-mode #map-drawer-toggle,
.lab-mode #map-drawer-scrim { display: none !important; }

.lab-panel {
  position: relative;
  background:
    linear-gradient(158deg, var(--lab-glass-a), var(--lab-glass-b));
  border: 1px solid var(--lab-edge);
  border-radius: 14px;
  box-shadow: var(--lab-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  font-family: 'Raleway', sans-serif;
  color: var(--lab-gold);
}

.lab-panel::before {
  content: "";
  position: absolute;
  left: 12px; right: 12px; top: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, rgba(244, 207, 139, 0.55) 18%, rgba(255, 233, 189, 0.85) 50%,
    rgba(244, 207, 139, 0.55) 82%, transparent);
  pointer-events: none;
}

.lab-svg { display: block; width: 100%; height: 100%; }
.lab-svg * { vector-effect: non-scaling-stroke; }

#lab-ribbon {
  position: fixed;
  top: 88px; right: 18px;
  z-index: 9000;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 9px 8px;
  animation: lab-fade 0.45s ease both;
}

/* No-nation prompt occupies the same top slot as the stats ribbon. */
#lab-found-nation {
  position: fixed;
  top: 88px; right: 18px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px 9px 13px;
  animation: lab-fade 0.45s ease both;
}
#lab-found-nation .lfn-crest { display: inline-flex; color: var(--lab-gold); flex: 0 0 auto; }
#lab-found-nation .lfn-crest svg { width: 24px; height: 24px; }
#lab-found-nation .lfn-text { display: flex; flex-direction: column; line-height: 1.2; }
#lab-found-nation .lfn-title { font-size: 0.86rem; font-weight: 700; letter-spacing: 0.02em; color: var(--lab-gold-bright); }
#lab-found-nation .lfn-sub { font-size: 0.72rem; color: var(--lab-gold-dim); }
#lab-found-nation .lfn-btn {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; cursor: pointer;
  padding: 8px 14px; border-radius: 9px; color: #1a1008; font-weight: 700; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.04em;
  background: linear-gradient(180deg, var(--lab-gold-bright), var(--lab-gold-deep));
  transition: filter 0.15s ease, transform 0.05s ease;
}
#lab-found-nation .lfn-btn svg { width: 15px; height: 15px; }
#lab-found-nation .lfn-btn:hover { filter: brightness(1.08); }
#lab-found-nation .lfn-btn:active { transform: translateY(1px); }
@media (max-width: 820px) {
  #lab-found-nation { top: 74px; left: 12px; right: 12px; justify-content: space-between; }
}

.lab-statgroup {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 2px 18px;
  position: relative;
}
.lab-statgroup + .lab-statgroup::before {
  content: "";
  position: absolute;
  left: 0; top: 14%; bottom: 14%;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--lab-edge-soft) 30%, var(--lab-edge-soft) 70%, transparent);
}

.lab-stat {
  display: flex;
  align-items: center;
  gap: 9px;
  position: relative;
  cursor: default;
}
.lab-stat .lab-ico {
  width: 21px; height: 21px;
  color: var(--lab-gold-deep);
  flex: 0 0 auto;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
  transition: color 0.16s ease;
}
.lab-stat:hover .lab-ico { color: var(--lab-gold); }
.lab-stat .lab-val {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--lab-gold-bright);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.lab-stat.is-good .lab-val { color: var(--lab-good); }
.lab-stat.is-warn .lab-val { color: var(--lab-warn); }
.lab-stat.is-bad  .lab-val { color: var(--lab-bad); }

#lab-alert-group { padding: 2px 6px 2px 16px; align-items: center; }
.lab-alert-btn {
  position: relative;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(64, 42, 70, 0.55), rgba(22, 13, 26, 0.7));
  border: 1px solid var(--lab-edge-soft);
  border-radius: 11px;
  color: var(--lab-gold);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.lab-alert-btn:hover {
  border-color: var(--lab-gold);
  background: linear-gradient(180deg, rgba(244, 207, 139, 0.18), rgba(60, 40, 66, 0.5));
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.4);
}
.lab-alert-btn .lab-ico { width: 21px; height: 21px; }
.lab-alert-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  display: none;
  align-items: center; justify-content: center;
  background: var(--lab-bad);
  color: #fff;
  font-size: 0.64rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 8px rgba(229, 115, 115, 0.6);
}
.lab-alert-badge.show { display: flex; }

#lab-alert-pop {
  position: absolute;
  top: 56px; right: 0;
  width: 272px;
  max-height: 340px;
  overflow-y: auto;
  padding: 10px;
  display: none;
}
#lab-alert-pop.open { display: block; }
.lab-alert-pop-title {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lab-gold-dim);
  padding: 4px 6px 9px;
  border-bottom: 1px solid var(--lab-edge-soft);
  margin-bottom: 6px;
}
.lab-alert-empty {
  padding: 16px 6px;
  text-align: center;
  color: var(--lab-gold-dim);
  font-size: 0.82rem;
}

#lab-corner {
  position: fixed;
  left: 18px; bottom: 76px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 11px;
  animation: lab-fade 0.45s ease both;
}

#lab-nation {
  width: 300px;
  padding: 14px 15px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lab-nation-head { display: flex; align-items: center; gap: 13px; }
.lab-crest {
  flex: 0 0 auto;
  width: 50px; height: 58px;
  position: relative;
  display: grid; place-items: center;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.55));
}
.lab-crest svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.lab-crest .lab-crest-letter {
  position: relative;
  font-size: 1.34rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}
.lab-nation-id { min-width: 0; }
.lab-nation-name {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--lab-gold-bright);
  line-height: 1.15;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lab-nation-sub {
  margin-top: 3px;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--lab-gold-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lab-demo-tag {
  margin-left: 7px;
  padding: 1px 6px;
  font-size: 0.56rem;
  letter-spacing: 0.14em;
  border: 1px solid var(--lab-edge-soft);
  border-radius: 999px;
  color: var(--lab-gold-dim);
  text-transform: uppercase;
}
.lab-nation-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding-top: 11px;
  border-top: 1px solid var(--lab-edge-soft);
}

#lab-mapctl {
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.lab-ctl-row { display: flex; align-items: center; gap: 8px; }
.lab-ctl-label {
  width: 58px;
  flex: 0 0 auto;
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lab-gold-dim);
}
.lab-ctl-btns { display: flex; gap: 7px; flex-wrap: wrap; }
.lab-zoom { margin-left: auto; display: flex; gap: 7px; }

@media (pointer: fine) {
  .lab-zoom-row { display: none; }
}

.lab-sq {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(64, 42, 70, 0.5), rgba(22, 13, 26, 0.66));
  border: 1px solid var(--lab-edge-soft);
  border-radius: 10px;
  color: var(--lab-gold);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease,
              color 0.16s ease, transform 0.1s ease, box-shadow 0.16s ease;
}
.lab-sq .lab-ico { width: 22px; height: 22px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45)); }
.lab-sq:hover {
  border-color: var(--lab-gold);
  background: linear-gradient(180deg, rgba(244, 207, 139, 0.16), rgba(60, 40, 66, 0.5));
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.42);
}
.lab-sq:active { transform: translateY(0); }
.lab-sq.is-active {
  background: linear-gradient(180deg, var(--lab-gold-bright), var(--lab-gold-deep));
  border-color: #ffe9bd;
  color: var(--lab-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5),
              0 0 0 1px rgba(244, 207, 139, 0.3),
              0 4px 14px rgba(244, 207, 139, 0.28);
}

.lab-tip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  white-space: nowrap;
  padding: 5px 10px;
  background: linear-gradient(180deg, #2a1830, #160b1b);
  border: 1px solid var(--lab-edge);
  border-radius: 8px;
  color: var(--lab-gold-bright);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.55);
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 5;
}
.lab-tip::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #160b1b;
}
.lab-sq:hover .lab-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.lab-stat .lab-tip,
.lab-alert-btn .lab-tip,
.lab-res-btn .lab-tip {
  bottom: auto;
  top: calc(100% + 10px);
  transform: translateX(-50%) translateY(-4px);
}
.lab-stat .lab-tip::after,
.lab-alert-btn .lab-tip::after,
.lab-res-btn .lab-tip::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #160b1b;
}
.lab-stat:hover .lab-tip,
.lab-alert-btn:hover .lab-tip,
.lab-res-btn:hover .lab-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.lab-stat-click { cursor: pointer; }
.lab-stat-click:hover .lab-val { text-decoration: underline; text-decoration-color: var(--lab-edge); text-underline-offset: 3px; }

.lab-crest.lab-crest-coa svg { width: 100%; height: 100%; }

.lab-pop-title {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lab-gold-dim);
  padding: 4px 6px 9px;
  border-bottom: 1px solid var(--lab-edge-soft);
  margin-bottom: 6px;
}
#lab-happy-pop {
  position: fixed;
  z-index: 9600;
  width: 196px;
  padding: 10px 12px 8px;
  display: none;
  animation: lab-pop 0.13s ease both;
}
#lab-happy-pop.open { display: block; }
.lab-happy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px;
}
.lab-happy-cls {
  font-size: 0.84rem;
  color: var(--lab-gold);
  letter-spacing: 0.02em;
}
.lab-happy-val {
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--lab-gold-bright);
}
.lab-happy-val.is-good { color: var(--lab-good); }
.lab-happy-val.is-warn { color: var(--lab-warn); }
.lab-happy-val.is-bad  { color: var(--lab-bad); }

#lab-pop-pop {
  position: fixed;
  z-index: 9600;
  width: 210px;
  padding: 10px 12px 8px;
  display: none;
  animation: lab-pop 0.13s ease both;
}
#lab-pop-pop.open { display: block; }
.lab-pop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 2px;
}
.lab-pop-race {
  flex: 1 1 auto;
  font-size: 0.84rem;
  color: var(--lab-gold);
  letter-spacing: 0.02em;
}
.lab-pop-amt {
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--lab-gold-bright);
}
.lab-pop-pct {
  min-width: 36px;
  text-align: right;
  font-size: 0.74rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--lab-gold-dim);
}

#lab-sustenance-pop {
  position: fixed;
  z-index: 9600;
  width: 184px;
  padding: 10px 12px 8px;
  display: none;
  animation: lab-pop 0.13s ease both;
}
#lab-sustenance-pop.open { display: block; }
.lab-sus-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px;
}
.lab-sus-ico { width: 18px; height: 18px; color: var(--lab-gold-deep); flex: 0 0 auto; }
.lab-sus-name { flex: 1; font-size: 0.84rem; color: var(--lab-gold); }
.lab-sus-amt {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--lab-gold-bright);
  font-variant-numeric: tabular-nums;
}

.lab-ctx-act {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 9px 9px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--lab-gold);
  font-family: 'Raleway', sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.13s ease, color 0.13s ease;
}
.lab-ctx-act:hover { background: rgba(244, 207, 139, 0.14); color: var(--lab-gold-bright); }
.lab-ctx-act .lab-ico { width: 19px; height: 19px; color: var(--lab-gold-deep); flex: 0 0 auto; }
.lab-ctx-act:hover .lab-ico { color: var(--lab-gold); }

#lab-claim-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background: rgba(8, 4, 11, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: lab-fade 0.25s ease both;
}
#lab-claim-modal {
  width: 460px;
  max-width: calc(100vw - 40px);
  padding: 30px 32px 26px;
  text-align: center;
  animation: lab-pop 0.22s ease both;
}
.lab-claim-emblem {
  width: 72px; height: 72px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--lab-ink);
  background: radial-gradient(circle at 50% 35%, var(--lab-gold-bright), var(--lab-gold-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 6px 20px rgba(244, 207, 139, 0.3);
}
.lab-claim-ico { width: 36px; height: 36px; }
.lab-claim-title {
  margin: 0 0 12px;
  font-family: 'Raleway', sans-serif;
  font-size: 1.42rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--lab-gold-bright);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.lab-claim-text {
  margin: 0 0 24px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: #d8c9a8;
}
.lab-claim-text strong { color: var(--lab-gold-bright); font-weight: 700; }
.lab-claim-actions { display: flex; gap: 12px; justify-content: center; }
.lab-btn {
  padding: 11px 22px;
  font-family: 'Raleway', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.lab-btn:active { transform: translateY(1px); }
.lab-btn-primary {
  border: 1px solid #ffe9bd;
  color: var(--lab-ink);
  background: linear-gradient(180deg, var(--lab-gold-bright), var(--lab-gold-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 5px 16px rgba(244, 207, 139, 0.3);
}
.lab-btn-primary:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 7px 20px rgba(244, 207, 139, 0.42); }
.lab-btn-ghost {
  border: 1px solid var(--lab-edge);
  color: var(--lab-gold);
  background: rgba(244, 207, 139, 0.05);
}
.lab-btn-ghost:hover { background: rgba(244, 207, 139, 0.14); border-color: var(--lab-gold); }

#lab-action-menu {
  position: fixed;
  z-index: 9600;
  width: 218px;
  padding: 8px;
  display: none;
  animation: lab-pop 0.13s ease both;
}
#lab-action-menu.open { display: block; }

.lab-act-sep {
  align-self: stretch;
  width: 1px;
  margin: 2px 4px;
  background: linear-gradient(180deg, transparent, var(--lab-edge-soft) 25%, var(--lab-edge-soft) 75%, transparent);
  flex: 0 0 auto;
}

@keyframes lab-fade {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes lab-pop {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.lab-notif-list { display: flex; flex-direction: column; gap: 2px; }
.lab-notif {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.13s ease;
}
.lab-notif:hover { background: rgba(244, 207, 139, 0.1); }
.lab-notif-ico {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--lab-gold);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--lab-edge-soft);
}
.lab-notif-ico i, .lab-notif-ico svg { width: 17px; height: 17px; }
.lab-notif-war   { color: var(--lab-bad); border-color: rgba(229,115,115,0.4); }
.lab-notif-alert { color: var(--lab-warn); border-color: rgba(236,188,91,0.4); }
.lab-notif-fall {
  color: var(--lab-bad);
  border-color: rgba(229,115,115,0.75);
  background: rgba(229,115,115,0.14);
}
.lab-notif-summons { color: var(--lab-warn); border-color: rgba(236,188,91,0.6); }
.lab-notif-main { min-width: 0; flex: 1; }
.lab-notif-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--lab-gold-bright);
  line-height: 1.2;
}
.lab-notif-msg {
  margin-top: 2px;
  font-size: 0.74rem;
  line-height: 1.35;
  color: #cdbf9f;
}
.lab-notif-time {
  margin-top: 3px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lab-gold-dim);
}
.lab-notif-x {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--lab-gold-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.13s ease, background 0.13s ease;
}
.lab-notif-x:hover { color: var(--lab-bad); background: rgba(229, 115, 115, 0.14); }

#lab-res-group { position: relative; padding: 2px 14px; }
.lab-res-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: linear-gradient(180deg, rgba(64, 42, 70, 0.5), rgba(22, 13, 26, 0.66));
  border: 1px solid var(--lab-edge-soft);
  border-radius: 11px;
  color: var(--lab-gold);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.lab-res-btn:hover {
  border-color: var(--lab-gold);
  background: linear-gradient(180deg, rgba(244, 207, 139, 0.16), rgba(60, 40, 66, 0.5));
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.4);
}
.lab-res-btn .lab-ico { width: 20px; height: 20px; color: var(--lab-gold-deep); }
.lab-res-btn .lab-val { font-size: 0.98rem; font-weight: 700; color: var(--lab-gold-bright); font-variant-numeric: tabular-nums; }

#lab-res-pop {
  position: absolute;
  top: 52px; right: 0;
  width: 248px;
  max-height: 360px;
  overflow-y: auto;
  padding: 10px;
  display: none;
}

/* The scrollbars these popovers used to name one id at a time now come from the canonical
   .lab-panel rule in lab_hub.css; every one of them is built as a .lab-panel, so they are already
   covered. (#lab-event-modal, also listed here, had not existed for some time.) */
#lab-res-pop.open { display: block; }
.lab-res-list { display: flex; flex-direction: column; gap: 1px; }
.lab-res-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  transition: background 0.13s ease;
}
.lab-res-row:hover { background: rgba(244, 207, 139, 0.09); }
.lab-res-img { width: 22px; height: 22px; object-fit: contain; flex: 0 0 auto; }
.lab-res-name { flex: 1; min-width: 0; font-size: 0.84rem; color: var(--lab-gold); }
.lab-res-amt {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--lab-gold-bright);
  font-variant-numeric: tabular-nums;
}

#lab-page-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: grid;
  place-items: center;
  background: rgba(8, 4, 11, 0.66);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: lab-fade 0.22s ease both;
}
#lab-page-modal {
  width: 94vw;
  height: 90vh;
  max-width: 1280px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  animation: lab-pop 0.2s ease both;
}
.lab-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--lab-edge-soft);
  flex: 0 0 auto;
}
.lab-page-title {
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--lab-gold-bright);
}
.lab-page-close {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--lab-edge-soft);
  border-radius: 8px;
  color: var(--lab-gold);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}
.lab-page-close:hover { border-color: var(--lab-bad); color: var(--lab-bad); background: rgba(229, 115, 115, 0.12); }
.lab-page-body { flex: 1; min-height: 0; background: #0d0710; }
#lab-page-frame { width: 100%; height: 100%; border: 0; display: block; }

#lab-event-overlay {
  position: fixed;
  inset: 0;
  z-index: 10002;
  display: grid;
  place-items: center;
  background: rgba(8, 4, 11, 0.68);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: lab-fade 0.25s ease both;
}
#lab-event-modal {
  width: 540px;
  max-width: calc(100vw - 40px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 30px 32px 28px;
  text-align: center;
  animation: lab-pop 0.22s ease both;
}
.lab-ev-emblem {
  width: 70px; height: 70px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--lab-ink);
  background: radial-gradient(circle at 50% 35%, #ffd98a, #c98a2f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 6px 20px rgba(236, 176, 75, 0.35);
}
.lab-ev-title {
  margin: 0 0 12px;
  font-size: 1.34rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--lab-gold-bright);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.lab-ev-text {
  margin: 0 0 22px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #d8c9a8;
}
.lab-ev-choices { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.lab-ev-choice {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(64, 42, 70, 0.45), rgba(22, 13, 26, 0.6));
  border: 1px solid var(--lab-edge-soft);
  border-radius: 10px;
  color: var(--lab-gold);
  font-family: 'Raleway', sans-serif;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.lab-ev-choice:hover { border-color: var(--lab-gold); background: rgba(244, 207, 139, 0.12); transform: translateY(-1px); }
.lab-ev-choice.is-default { border-color: var(--lab-edge); }
.lab-ev-choice strong { display: block; margin-bottom: 3px; color: var(--lab-gold-bright); font-size: 0.95rem; }
.lab-ev-desc { display: block; font-size: 0.8rem; line-height: 1.4; color: #c2b186; }
.lab-ev-cost { display: block; margin-top: 5px; font-size: 0.76rem; font-weight: 600; color: var(--lab-bad); }

.lab-mode select {
  background-color: #2a1830;
  color: var(--lab-gold);
}
.lab-mode select option,
.lab-mode select optgroup {
  background-color: #1f1226;
  color: var(--lab-gold);
}
.lab-mode select optgroup {
  color: var(--lab-gold-dim);
  font-style: normal;
}
.lab-mode select option:checked,
.lab-mode select option:hover {
  background-color: #3a2342;
  color: var(--lab-gold-bright);
}

.lab-mode #tile-browser-panel {
  top: 152px;
  right: 18px;
  width: 372px;
  max-height: calc(100vh - 172px);
  background: linear-gradient(158deg, var(--lab-glass-a), var(--lab-glass-b));
  border: 1px solid var(--lab-edge);
  border-radius: 14px;
  box-shadow: var(--lab-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  color: var(--lab-gold);
  overflow: hidden;
}
.lab-mode #tile-browser-panel::before {
  content: "";
  position: absolute;
  left: 12px; right: 12px; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 207, 139, 0.55) 18%, rgba(255, 233, 189, 0.85) 50%, rgba(244, 207, 139, 0.55) 82%, transparent);
  pointer-events: none;
  z-index: 3;
}

.lab-mode .tb-header { padding: 12px 14px; border-bottom: 1px solid var(--lab-edge-soft); }
.lab-mode .tb-header h2 { color: var(--lab-gold-bright); font-size: 0.92rem; letter-spacing: 0.1em; }
.lab-mode .tb-close-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--lab-edge-soft);
  border-radius: 8px;
  font-size: 1.3rem;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}
.lab-mode .tb-close-btn:hover { color: var(--lab-bad); border-color: var(--lab-bad); background: rgba(229, 115, 115, 0.12); }

.lab-mode .tb-controls { border-bottom: 1px solid var(--lab-edge-soft); }
.lab-mode #tb-search,
.lab-mode .tb-control select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--lab-edge-soft);
  border-radius: 8px;
  color: var(--lab-gold);
}
.lab-mode #tb-search:focus,
.lab-mode .tb-control select:focus { border-color: var(--lab-gold); }
.lab-mode #tb-search::placeholder { color: var(--lab-gold-dim); }
.lab-mode .tb-control-label { color: var(--lab-gold-dim); letter-spacing: 0.1em; }
.lab-mode .tb-search-clear { background: rgba(244, 207, 139, 0.15); color: var(--lab-gold); }
.lab-mode .tb-search-clear:hover { background: var(--lab-gold); color: var(--lab-ink); }
.lab-mode .tb-mini-btn {
  background: linear-gradient(180deg, rgba(64, 42, 70, 0.5), rgba(22, 13, 26, 0.66));
  border: 1px solid var(--lab-edge-soft);
  border-radius: 8px;
  color: var(--lab-gold);
}
.lab-mode .tb-mini-btn:hover { background: rgba(244, 207, 139, 0.16); border-color: var(--lab-gold); color: var(--lab-gold-bright); }

.lab-mode .tb-overview { border-bottom: 1px solid var(--lab-edge-soft); }
.lab-mode .tb-chip {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--lab-edge-soft);
  border-radius: 999px;
}
.lab-mode .tb-chip-val { color: var(--lab-gold-bright); }
.lab-mode .tb-showing { color: var(--lab-gold-dim); border-bottom: 1px solid var(--lab-edge-soft); }

.lab-mode .tb-region-header {
  background: linear-gradient(180deg, rgba(34, 20, 40, 0.98), rgba(24, 14, 28, 0.98));
  border-bottom: 1px solid var(--lab-edge-soft);
  border-radius: 8px;
  color: var(--lab-gold);
}
.lab-mode .tb-region-header:hover { color: var(--lab-gold-bright); }
.lab-mode .tb-region-header .tb-region-count {
  background: rgba(244, 207, 139, 0.15);
  border: 1px solid var(--lab-edge-soft);
  color: var(--lab-gold-bright);
}

.lab-mode .tb-tile-entry { border-radius: 8px; }
.lab-mode .tb-tile-entry:hover { background: rgba(244, 207, 139, 0.1); }
.lab-mode .tb-tile-id { color: var(--lab-gold-dim); }
.lab-mode .tb-city-tag { color: var(--lab-gold-bright); border-color: var(--lab-edge); background: rgba(244, 207, 139, 0.15); }
.lab-mode .tb-btn {
  border: 1px solid var(--lab-edge-soft);
  border-radius: 7px;
  color: var(--lab-gold);
}
.lab-mode .tb-btn:hover { background: var(--lab-gold); color: var(--lab-ink); border-color: var(--lab-gold); }

.lab-mode .tb-loading,
.lab-mode .tb-empty { color: var(--lab-gold-dim); }

.lab-mode .tb-tile-list::-webkit-scrollbar-thumb { background: var(--lab-gold-deep); border-radius: 3px; }
.lab-mode .tb-tile-list::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }

@media (max-width: 820px) {
  .lab-mode #tile-browser-panel { top: 148px; width: calc(100vw - 36px); max-height: 56vh; }
}

.lab-mode #unit-command-bar {
  background: linear-gradient(158deg, var(--lab-glass-a), var(--lab-glass-b));
  border: 1px solid var(--lab-edge);
  border-radius: 14px;
  box-shadow: var(--lab-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
}
.lab-mode #unit-command-bar::before {
  height: 1px;
  left: 14px; right: 14px;
  background: linear-gradient(90deg, transparent, rgba(244, 207, 139, 0.55) 18%, rgba(255, 233, 189, 0.85) 50%, rgba(244, 207, 139, 0.55) 82%, transparent);
}
.lab-mode #movement-panel { background: rgba(0, 0, 0, 0.22); }
.lab-mode #unit-command-divider { background: linear-gradient(180deg, transparent, var(--lab-edge-soft), transparent); }

.lab-mode .ucb-crest {
  background: radial-gradient(circle at 32% 26%, #5a3f6a, #1c1024);
  border: 1px solid var(--lab-edge);
  color: var(--lab-gold-bright);
  border-radius: 10px;
}
.lab-mode .ucb-name { color: var(--lab-gold-bright); }
.lab-mode .ucb-sub { color: var(--lab-gold-dim); }
.lab-mode .ucb-mp { color: var(--lab-gold); }
.lab-mode .ucb-upk-v { color: var(--lab-gold); }
.lab-mode .ucb-select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--lab-edge-soft);
  border-radius: 8px;
  color: var(--lab-gold);
}
.lab-mode .ucb-select:focus { border-color: var(--lab-gold); }
.lab-mode .ucb-disband {
  border: 1px solid rgba(229, 115, 115, 0.4);
  border-radius: 8px;
  color: var(--lab-bad);
}
.lab-mode .ucb-disband:hover { background: rgba(229, 115, 115, 0.16); color: #fff; }

.lab-mode #regiment-strip {
  border-top: 1px solid var(--lab-edge-soft);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.1));
  scrollbar-color: var(--lab-gold-deep) transparent;
}
.lab-mode #regiment-strip::-webkit-scrollbar-thumb { background: var(--lab-gold-deep); border-radius: 4px; }
.lab-mode .rg-loading { color: var(--lab-gold-dim); }

.lab-mode .rg-card {
  background: linear-gradient(180deg, rgba(54, 34, 62, 0.85), rgba(22, 13, 26, 0.9));
  border: 1px solid var(--lab-edge-soft);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.lab-mode .rg-card:hover { border-color: var(--lab-gold); transform: translateY(-2px); }
.lab-mode .rg-card.is-cmd {
  background: linear-gradient(180deg, rgba(86, 60, 30, 0.85), rgba(34, 22, 12, 0.92));
  border-color: var(--lab-edge);
}
.lab-mode .rg-glyph {
  color: var(--lab-ink);
  background: linear-gradient(180deg, var(--lab-gold-bright), var(--lab-gold-deep));
  border-radius: 5px;
}
.lab-mode .rg-tier { color: var(--lab-gold-dim); }
.lab-mode .rg-name { color: var(--lab-gold-bright); }
.lab-mode .rg-sub { color: var(--lab-gold-dim); }
.lab-mode .rg-cmd { color: var(--lab-ink); background: linear-gradient(180deg, var(--lab-gold-bright), var(--lab-gold-deep)); }
.lab-mode .rg-rng { color: #bcd0e6; background: rgba(70, 100, 140, 0.32); }
.lab-mode .rg-troops { color: var(--lab-gold); }
.lab-mode .rg-ad { color: var(--lab-gold-dim); }
.lab-mode .rg-hp { background: rgba(0, 0, 0, 0.4); border-radius: 999px; }
.lab-mode .rg-hp-fill { background: linear-gradient(90deg, #4a8f3a, #7bd861); }
.lab-mode .rg-card.rg-empty {
  background: rgba(0, 0, 0, 0.22);
  border: 1px dashed var(--lab-edge-soft);
  border-radius: 10px;
  color: var(--lab-gold-dim);
}
.lab-mode .rg-card.rg-empty:hover { color: var(--lab-gold); border-color: var(--lab-gold); background: rgba(244, 207, 139, 0.1); }

.lab-mode #recruit-flyout {
  background: linear-gradient(158deg, var(--lab-glass-a), var(--lab-glass-b));
  border: 1px solid var(--lab-edge);
  border-radius: 12px;
  box-shadow: var(--lab-shadow);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}
.lab-mode .rf-title { color: var(--lab-gold-bright); }
.lab-mode .rf-close { color: var(--lab-gold-dim); }
.lab-mode .rf-close:hover { color: var(--lab-gold-bright); }
.lab-mode .rf-design {
  border: 1px solid var(--lab-edge-soft);
  border-radius: 8px;
  color: var(--lab-gold);
  background: linear-gradient(180deg, rgba(64, 42, 70, 0.5), rgba(22, 13, 26, 0.66));
}
.lab-mode .rf-design.alt { color: var(--lab-gold); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--lab-edge-soft); }
.lab-mode .rf-design:hover { border-color: var(--lab-gold); background: rgba(244, 207, 139, 0.14); }
.lab-mode .rf-label { color: var(--lab-gold-dim); }
.lab-mode .rf-tpl {
  border: 1px solid var(--lab-edge-soft);
  border-radius: 8px;
}
.lab-mode .rf-tpl:hover { border-color: var(--lab-gold); background: rgba(244, 207, 139, 0.1); }
.lab-mode .rf-tpl-name { color: var(--lab-gold-bright); }
.lab-mode .rf-tpl-meta { color: var(--lab-gold-dim); }
.lab-mode .rf-tpl-cost { color: var(--lab-gold); }
.lab-mode .rf-empty { color: var(--lab-gold-dim); }

.lab-mode #trade-route-panel {
  background: linear-gradient(158deg, var(--lab-glass-a), var(--lab-glass-b));
  border: 1px solid var(--lab-edge);
  border-radius: 14px;
  box-shadow: var(--lab-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  padding: 13px 18px;
  gap: 16px;
  color: var(--lab-gold);
}
.lab-mode #trade-route-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 207, 139, 0.55) 18%, rgba(255, 233, 189, 0.85) 50%, rgba(244, 207, 139, 0.55) 82%, transparent);
  pointer-events: none;
}
.lab-mode #trade-route-panel p {
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--lab-gold-dim);
  white-space: nowrap;
}
.lab-mode #trade-route-panel p span {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: normal;
  color: var(--lab-gold-bright) !important;
  font-variant-numeric: tabular-nums;
}
.lab-mode #trade-route-panel .btn {
  padding: 9px 16px;
  border-radius: 9px;
  font-family: 'Raleway', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: 1px solid #ffe9bd;
  color: var(--lab-ink);
  background: linear-gradient(180deg, var(--lab-gold-bright), var(--lab-gold-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 4px 12px rgba(244, 207, 139, 0.25);
  transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.lab-mode #trade-route-panel .btn:hover { filter: brightness(1.06); }
.lab-mode #trade-route-panel .btn:active { transform: translateY(1px); }
.lab-mode #trade-route-panel .btn-secondary {
  background: rgba(244, 207, 139, 0.06);
  border: 1px solid var(--lab-edge);
  color: var(--lab-gold);
  box-shadow: none;
}
.lab-mode #trade-route-panel .btn-secondary:hover { background: rgba(244, 207, 139, 0.14); border-color: var(--lab-gold); filter: none; }

.lab-mode #tile-info-modal {
  background: linear-gradient(158deg, var(--lab-glass-a), var(--lab-glass-b));
  border: 1px solid var(--lab-edge);
  border-radius: 14px;
  box-shadow: var(--lab-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  color: var(--lab-gold);
  padding: 14px 15px;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--lab-gold-deep) rgba(0, 0, 0, 0.2);
}
.lab-mode #tile-info-modal::before {
  content: "";
  position: absolute;
  top: 0; left: 14px; right: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 207, 139, 0.55) 18%, rgba(255, 233, 189, 0.85) 50%, rgba(244, 207, 139, 0.55) 82%, transparent);
  pointer-events: none;
}
.lab-mode #tile-info-modal h2 {
  font-size: 0.95rem;
  color: var(--lab-gold-bright);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--lab-edge-soft);
  padding-bottom: 9px;
  margin-bottom: 9px;
}
.lab-mode #tile-info-close {
  top: 10px; right: 10px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--lab-edge-soft);
  border-radius: 7px;
  color: var(--lab-gold);
  font-size: 1.2rem;
  transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}
.lab-mode #tile-info-close:hover { color: var(--lab-bad); border-color: var(--lab-bad); background: rgba(229, 115, 115, 0.12); }
.lab-mode #tile-info-modal .info-label { color: var(--lab-gold-dim); font-weight: 600; }
.lab-mode #tile-info-modal .info-value { color: var(--lab-gold-bright); }
.lab-mode #tile-info-modal::-webkit-scrollbar { width: 8px; }
.lab-mode #tile-info-modal::-webkit-scrollbar-thumb { background: var(--lab-gold-deep); border-radius: 8px; border: 2px solid rgba(0, 0, 0, 0.25); background-clip: padding-box; }
.lab-mode #tile-info-modal::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); border-radius: 8px; }

.lab-mode #war-icon { display: none !important; }
.lab-mode #war-panel-modal { display: none !important; }

.lab-mode #war-goal-panel {
  top: 158px;
  right: 20px;
  width: 290px;
  padding: 16px 17px 17px;
  background: linear-gradient(160deg, var(--lab-glass-a), var(--lab-glass-b));
  border: 1px solid var(--lab-edge);
  border-radius: 14px;
  color: var(--lab-gold);
  box-shadow: var(--lab-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 9500;
}
.lab-mode #war-goal-panel h3 {
  margin: 0 0 12px;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lab-gold-bright);
  border-bottom: 1px solid var(--lab-edge-soft);
  padding-bottom: 10px;
}
.lab-mode #war-goal-panel .wg-target { color: var(--lab-gold-bright); font-weight: 700; }
.lab-mode #war-goal-panel .wg-goal-row { gap: 9px; margin: 12px 0 5px; }
.lab-mode #war-goal-panel .wg-goal-row label {
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--lab-gold-dim);
}
.lab-mode #war-goal-panel .wg-goal-row select {
  appearance: none;
  -webkit-appearance: none;
  padding: 7px 28px 7px 11px;
  background: #2a1830 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23f4cf8b' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>") no-repeat right 9px center;
  border: 1px solid var(--lab-edge-soft);
  border-radius: 9px;
  color: var(--lab-gold-bright);
  font-size: 0.82rem;
}
.lab-mode #war-goal-panel .wg-goal-row select:focus { outline: none; border-color: var(--lab-gold); }
.lab-mode #war-goal-panel .wg-goal-desc { font-size: 0.72rem; color: var(--lab-gold-dim); margin: 0 0 10px; line-height: 1.4; }
.lab-mode #war-goal-panel .wg-count {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.82rem; color: var(--lab-gold);
  padding: 7px 11px; margin: 6px 0;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--lab-edge-soft);
  border-radius: 9px;
  font-variant-numeric: tabular-nums;
}
.lab-mode #war-goal-panel .wg-count.over { color: var(--lab-bad); border-color: rgba(229, 115, 115, 0.4); }
.lab-mode #war-goal-panel .wg-hint { font-size: 0.72rem; color: var(--lab-gold-dim); margin: 10px 0 13px; line-height: 1.45; }
.lab-mode #war-goal-panel .wg-actions { display: flex; gap: 8px; }
.lab-mode #war-goal-panel button {
  flex: 1;
  padding: 9px;
  border-radius: 9px;
  border: 1px solid var(--lab-edge-soft);
  background: linear-gradient(180deg, rgba(64, 42, 70, 0.55), rgba(22, 13, 26, 0.7));
  color: var(--lab-gold);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.lab-mode #war-goal-panel button:hover { transform: translateY(-1px); }
.lab-mode #war-goal-panel .wg-cancel:hover { border-color: var(--lab-gold); color: var(--lab-gold-bright); }
.lab-mode #war-goal-panel .wg-declare {
  border-color: rgba(229, 115, 115, 0.45);
  background: linear-gradient(180deg, rgba(229, 115, 115, 0.28), rgba(150, 50, 50, 0.32));
  color: #ffd9d9;
}
.lab-mode #war-goal-panel .wg-declare:hover {
  border-color: var(--lab-bad);
  background: linear-gradient(180deg, rgba(229, 115, 115, 0.42), rgba(150, 50, 50, 0.45));
  color: #fff;
}

/* ============================================================
   Create Force modal (Create Regiment / Create Fleet) gold-glass
   ============================================================ */
#create-force-modal.modal-overlay {
  position: fixed; inset: 0; z-index: 100000;
  display: none; align-items: center; justify-content: center;
  background: rgba(8, 4, 10, 0.66); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  font-family: 'Raleway', sans-serif;
}
#create-force-modal.modal-overlay.active { display: flex; }
#create-force-modal .modal-content {
  position: relative;
  width: 460px; max-width: 94vw; max-height: 90vh; overflow-y: auto;
  padding: 22px 24px;
  background: linear-gradient(180deg, var(--lab-glass-a), var(--lab-glass-b));
  border: 1px solid var(--lab-edge);
  border-radius: 16px;
  box-shadow: var(--lab-shadow);
  color: var(--lab-gold);
  animation: lab-pop 0.16s ease;
}
#create-force-modal .modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--lab-edge-soft); border-radius: 9px;
  color: var(--lab-gold); font-size: 1.2rem; line-height: 1; cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}
#create-force-modal .modal-close:hover { border-color: var(--lab-bad); color: var(--lab-bad); background: rgba(229, 115, 115, 0.12); }
#create-force-modal h2 { font-size: 1.3rem; font-weight: 800; color: var(--lab-gold-bright); margin: 0 0 6px; padding-right: 30px; }
#create-force-modal h3 { font-size: 0.78rem !important; letter-spacing: 0.08em; text-transform: uppercase; color: var(--lab-gold-dim) !important; margin: 0 0 8px !important; }
#create-force-modal hr { border: 0 !important; border-top: 1px solid var(--lab-edge-soft) !important; margin: 16px 0 !important; }
#create-force-modal #create-force-cost-hint,
#create-force-modal #create-force-city-hint,
#create-force-modal #create-force-designer-note { color: var(--lab-gold-dim) !important; font-size: 0.8rem !important; line-height: 1.45; }
#create-force-modal .form-group { margin-bottom: 13px; }
#create-force-modal .form-group label { display: block; font-size: 0.74rem; letter-spacing: 0.04em; color: var(--lab-gold); margin-bottom: 5px; }
#create-force-modal input[type="text"],
#create-force-modal input[type="number"],
#create-force-modal select {
  width: 100%; padding: 9px 11px;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--lab-edge-soft); border-radius: 9px;
  color: var(--lab-gold-bright); font-family: inherit; font-size: 0.88rem;
}
#create-force-modal input:focus, #create-force-modal select:focus { outline: none; border-color: var(--lab-gold); }
#create-force-modal input::placeholder { color: var(--lab-gold-dim); opacity: 0.7; }
#create-force-modal .form-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
#create-force-modal .btn {
  flex: 1 1 auto; padding: 10px 14px; border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: 0.86rem; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid var(--lab-edge);
  background: linear-gradient(180deg, rgba(244, 207, 139, 0.26), rgba(199, 154, 79, 0.32));
  color: var(--lab-gold-bright);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
#create-force-modal .btn:hover { background: linear-gradient(180deg, rgba(244, 207, 139, 0.4), rgba(199, 154, 79, 0.42)); transform: translateY(-1px); }
#create-force-modal .btn.btn-secondary {
  flex: 0 0 auto; background: transparent; color: var(--lab-gold-dim); border-color: var(--lab-edge-soft);
}
#create-force-modal .btn.btn-secondary:hover { color: var(--lab-gold); border-color: var(--lab-gold); background: rgba(244, 207, 139, 0.08); }

/* ============================================================
   Nation color picker modal gold-glass (on the map lab)
   ============================================================ */
#color-picker-modal.modal-overlay {
  z-index: 100000;
  background: rgba(8, 4, 10, 0.66);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-family: 'Raleway', sans-serif;
}
#color-picker-modal .modal-content {
  position: relative;
  width: 440px; max-width: 94vw;
  padding: 22px 24px;
  background: linear-gradient(180deg, var(--lab-glass-a), var(--lab-glass-b));
  border: 1px solid var(--lab-edge);
  border-radius: 16px;
  box-shadow: var(--lab-shadow);
  color: var(--lab-gold);
  animation: lab-pop 0.16s ease;
}
#color-picker-modal h2 {
  font-size: 1.3rem; font-weight: 800; color: var(--lab-gold-bright);
  margin: 0 0 16px; padding: 0 30px 12px 0;
  border-bottom: 1px solid var(--lab-edge-soft);
}
#color-picker-modal .modal-close {
  position: absolute; top: 14px; right: 14px; float: none; margin: 0;
  width: 30px; height: 30px; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--lab-edge-soft); border-radius: 9px;
  color: var(--lab-gold); font-size: 1.2rem; line-height: 1; cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}
#color-picker-modal .modal-close:hover { border-color: var(--lab-bad); color: var(--lab-bad); background: rgba(229, 115, 115, 0.12); }
#color-picker-modal .form-group { margin-bottom: 4px; }
#color-picker-modal .form-group label {
  display: block; font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--lab-gold-dim); margin-bottom: 9px;
}
#color-picker-modal .color-picker-wrapper { gap: 12px; }
#color-picker-modal input[type="color"] {
  flex: 1 1 auto; height: 46px; padding: 4px;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--lab-edge-soft); border-radius: 10px; cursor: pointer;
}
#color-picker-modal input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
#color-picker-modal input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
#color-picker-modal input[type="color"]::-moz-color-swatch { border: none; border-radius: 6px; }
#color-picker-modal .color-preview {
  width: 46px; height: 46px; border: 1px solid var(--lab-edge); border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
#color-picker-modal .form-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
#color-picker-modal .btn {
  padding: 10px 24px; border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: 0.86rem; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid var(--lab-edge);
  background: linear-gradient(180deg, rgba(244, 207, 139, 0.26), rgba(199, 154, 79, 0.32));
  color: var(--lab-gold-bright);
  transition: background 0.15s ease, transform 0.1s ease;
}
#color-picker-modal .btn:hover { background: linear-gradient(180deg, rgba(244, 207, 139, 0.4), rgba(199, 154, 79, 0.42)); transform: translateY(-1px); }

/* ============================================================
   Generic gold-glass for EVERY map action modal (.modal-overlay):
   Found City, Found Colony, Create Region, Resource Manager, and any
   future one. The specific #id blocks above refine individual modals;
   this is the shared base so no action panel falls back to the old
   flat purple style. Scoped to .map-page so it can't leak elsewhere.
   ============================================================ */
.map-page .modal-overlay {
  z-index: 100000;
  background: rgba(8, 4, 10, 0.66);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-family: 'Raleway', sans-serif;
}
.map-page .modal-overlay .modal-content {
  position: relative;
  padding: 22px 24px;
  background: linear-gradient(180deg, var(--lab-glass-a), var(--lab-glass-b));
  border: 1px solid var(--lab-edge);
  border-radius: 16px;
  box-shadow: var(--lab-shadow);
  color: var(--lab-gold);
  animation: lab-pop 0.16s ease;
}
.map-page .modal-overlay .modal-content h2 {
  font-size: 1.3rem; font-weight: 800; color: var(--lab-gold-bright);
  margin: 0 0 16px; padding: 0 34px 12px 0;
  border-bottom: 1px solid var(--lab-edge-soft);
}
.map-page .modal-overlay .modal-content h3 {
  font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--lab-gold-dim); margin: 14px 0 8px; border: 0;
}
.map-page .modal-overlay .modal-close {
  position: absolute; top: 14px; right: 14px; float: none; margin: 0;
  width: 30px; height: 30px; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--lab-edge-soft); border-radius: 9px;
  color: var(--lab-gold); font-size: 1.2rem; line-height: 1; cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}
.map-page .modal-overlay .modal-close:hover { border-color: var(--lab-bad); color: var(--lab-bad); background: rgba(229, 115, 115, 0.12); }
.map-page .modal-overlay .form-group { margin-bottom: 13px; }
.map-page .modal-overlay .form-group > label {
  display: block; font-size: 0.74rem; letter-spacing: 0.05em;
  color: var(--lab-gold); margin-bottom: 6px;
}
.map-page .modal-overlay input[type="text"],
.map-page .modal-overlay input[type="number"],
.map-page .modal-overlay input[type="password"],
.map-page .modal-overlay select,
.map-page .modal-overlay textarea {
  width: 100%; padding: 9px 11px; box-sizing: border-box;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--lab-edge-soft); border-radius: 9px;
  color: var(--lab-gold-bright); font-family: inherit; font-size: 0.88rem;
}
.map-page .modal-overlay textarea { resize: vertical; min-height: 66px; }
.map-page .modal-overlay input:focus,
.map-page .modal-overlay select:focus,
.map-page .modal-overlay textarea:focus { outline: none; border-color: var(--lab-gold); }
.map-page .modal-overlay input::placeholder,
.map-page .modal-overlay textarea::placeholder { color: var(--lab-gold-dim); opacity: 0.7; }
.map-page .modal-overlay .form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.map-page .modal-overlay .btn {
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: 0.86rem; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid var(--lab-edge);
  background: linear-gradient(180deg, rgba(244, 207, 139, 0.26), rgba(199, 154, 79, 0.32));
  color: var(--lab-gold-bright);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.map-page .modal-overlay .btn:hover { background: linear-gradient(180deg, rgba(244, 207, 139, 0.4), rgba(199, 154, 79, 0.42)); transform: translateY(-1px); }
.map-page .modal-overlay .btn.btn-secondary { background: transparent; color: var(--lab-gold-dim); border-color: var(--lab-edge-soft); }
.map-page .modal-overlay .btn.btn-secondary:hover { color: var(--lab-gold); border-color: var(--lab-gold); background: rgba(244, 207, 139, 0.08); }
/* Cost blocks + info rows shared by Found City / Found Colony */
.map-page .modal-overlay .modal-cost,
.map-page .modal-overlay .modal-rows {
  padding: 12px 14px; margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--lab-edge-soft); border-radius: 12px;
}
.map-page .modal-overlay .modal-cost-title {
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--lab-gold-dim); margin-bottom: 9px;
}
.map-page .modal-overlay .modal-cost-title .mc-sub { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--lab-gold-dim); }
.map-page .modal-overlay .modal-cost-big { font-size: 1.15rem; font-weight: 800; color: var(--lab-gold-bright); }
.map-page .modal-overlay .modal-cost-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.map-page .modal-overlay .modal-cost-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  background: rgba(244, 207, 139, 0.08); border: 1px solid var(--lab-edge-soft);
  color: var(--lab-gold-bright); font-size: 0.82rem;
}
.map-page .modal-overlay .modal-cost-chip img { width: 16px; height: 16px; object-fit: contain; }
.map-page .modal-overlay .modal-cost-note { color: var(--lab-gold-dim); font-size: 0.82rem; margin-top: 4px; }
.map-page .modal-overlay .modal-note { color: var(--lab-gold-dim); font-size: 0.82rem; line-height: 1.45; margin-bottom: 14px; }
.map-page .modal-overlay .modal-rows { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; align-items: center; }
.map-page .modal-overlay .mr-label { font-size: 0.78rem; color: var(--lab-gold-dim); }
.map-page .modal-overlay .mr-value { font-size: 0.86rem; color: var(--lab-gold-bright); text-align: right; font-weight: 600; }
.map-page .modal-overlay .mr-value.good { color: var(--lab-good); }

/* Nation rename (pencil beside the corner nation name) */
.lab-nation-name-row { display: flex; align-items: center; gap: 6px; }
.lab-nation-edit {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 22px; height: 22px; padding: 0;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--lab-gold-dim); cursor: pointer; opacity: 0.7;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.lab-nation-edit:hover { opacity: 1; color: var(--lab-gold-bright); background: rgba(244, 207, 139, 0.12); border-color: var(--lab-edge-soft); }
.lab-nation-name-input {
  width: 100%; min-width: 0; padding: 3px 8px;
  background: rgba(0, 0, 0, 0.32); border: 1px solid var(--lab-gold); border-radius: 7px;
  color: var(--lab-gold-bright); font-family: inherit; font-weight: 700; font-size: 1.02rem;
}
.lab-nation-name-input:focus { outline: none; }

/* The unit/officer designer modal is gold-glass via its own self-contained stylesheet
   (nation_dashboard/unit_designer.css), loaded by every host page including the map. */

/* ===== Nation Output page ===== */
.lo-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 14px; }
.lo-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.lo-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--lab-edge-soft);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.24));
  font-size: 0.8rem; color: var(--lab-gold);
}
.lo-badge-ico { width: 17px; height: 17px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }
.lo-badge-lucide { width: 14px; height: 14px; color: var(--lab-gold-dim); }
.lo-badge-v { font-weight: 700; color: var(--lab-gold-bright); font-variant-numeric: tabular-nums; }
.lo-badge-k { color: rgba(244, 207, 139, 0.72); font-size: 0.74rem; }
.lo-badge-k em { font-style: normal; color: var(--lab-gold-dim); }
.lo-badges-sm .lo-badge { padding: 4px 10px; font-size: 0.74rem; }
.lo-badges-sm .lo-badge-ico { width: 14px; height: 14px; }
.lo-empty { font-size: 0.8rem; color: var(--lab-gold-dim); font-style: italic; padding: 4px 2px; }
.lo-cities { display: flex; flex-direction: column; gap: 12px; }
.lo-city {
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--lab-edge-soft);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.2));
  display: flex; flex-direction: column; gap: 8px;
}
.lo-city-head { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.lo-city-name { font-family: 'Cinzel', serif; font-weight: 700; font-size: 0.95rem; color: var(--lab-gold-bright); }
.lo-city-tier {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--lab-edge-soft); color: var(--lab-gold);
}
.lo-city-gar { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-size: 0.74rem; color: var(--lab-gold-dim); }
.lo-flag-ico { width: 12px; height: 12px; }

.lo-tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.lo-tier {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 8px; border-radius: 12px;
  border: 1px solid var(--lab-edge-soft);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.2));
}
.lo-tier-label { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--lab-gold-dim); }
.lo-tier-count { display: inline-flex; align-items: baseline; gap: 5px; font-size: 1.15rem; color: var(--lab-gold-bright); }
.lo-tier-count strong { color: var(--lab-gold-bright); }
.lo-tier-tag { font-size: 0.66rem; color: var(--lab-gold-dim); }
.lo-tier-full { border-color: rgba(230, 150, 90, 0.55); background: linear-gradient(160deg, rgba(230, 150, 90, 0.12), rgba(0, 0, 0, 0.2)); }
.lo-tier-full .lo-tier-tag { color: #e6a35a; }

.lo-tier-deltas { display: inline-flex; align-items: center; gap: 4px; }
.lo-tier-delta {
  position: relative; cursor: help;
  font-size: 0.72rem; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: 999px; border: 1px solid transparent;
}
.lo-delta-in { color: #7fd68d; background: rgba(127, 214, 141, 0.12); border-color: rgba(127, 214, 141, 0.3); }
.lo-delta-out { color: #e79079; background: rgba(231, 144, 121, 0.12); border-color: rgba(231, 144, 121, 0.3); }
.lo-tier-delta .lab-tip { white-space: normal; width: max-content; max-width: 180px; text-align: center; font-weight: 600; }
.lo-tier-delta .lab-tip em { font-style: normal; color: var(--lab-gold); }
.lo-tier-delta:hover .lab-tip { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Treasury & Finances page (read-only ledger) ───────────────────────── */
.fin-headline { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; align-items: start; }
.fin-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 2px; border-bottom: 1px solid var(--lab-edge-soft); font-size: 0.86rem; }
.fin-row:last-child { border-bottom: none; }
.fin-row-l { color: var(--lab-gold-dim); }
.fin-row-v { color: var(--lab-gold-bright); font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.fin-sub { border-top: 1px dashed var(--lab-edge-soft); }
.fin-sub .fin-row-l, .fin-sub .fin-row-v { color: var(--lab-gold); font-style: italic; font-weight: 500; }
.fin-total { margin-top: 3px; border-top: 1px solid var(--lab-edge); border-bottom: none; }
.fin-total .fin-row-l { color: var(--lab-gold-bright); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; font-size: 0.76rem; }
.fin-total .fin-row-v { font-size: 1.02rem; font-weight: 800; }
.fin-subhead { margin: 11px 0 3px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--lab-gold); }
.fin-mod .fin-row-v.is-good, .fin-total.is-good .fin-row-v { color: #7fd68d; }
.fin-mod .fin-row-v.is-bad, .fin-total.is-bad .fin-row-v { color: var(--lab-bad); }
.fin-intro { color: var(--lab-gold-dim); font-size: 0.84rem; margin-bottom: 14px; }
.fin-row-v.is-bad { color: var(--lab-bad); }
.fin-split-note .fin-row-v { text-transform: none; font-weight: 600; letter-spacing: 0; }
.fin-larder { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--lab-edge-soft); border-radius: 9px; background: rgba(0,0,0,0.18); }
.fin-larder + .fin-larder { margin-top: 8px; }
.fin-larder-h { display: flex; align-items: center; gap: 7px; font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--lab-gold-bright); margin-bottom: 2px; }
.fin-larder-h svg { width: 15px; height: 15px; flex: 0 0 auto; stroke-width: 2; opacity: 0.9; }
.fin-larder-bones { border-color: rgba(201,180,232,0.28); }
.fin-larder-bones .fin-larder-h { color: #d6c7ef; }
.fin-count {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  font-size: 0.66rem; font-weight: 700; line-height: 1.3;
  color: var(--lab-gold); background: rgba(244, 207, 139, 0.08);
  border: 1px solid var(--lab-edge-soft); border-radius: 999px;
  font-variant-numeric: tabular-nums; vertical-align: 1px;
}
.fin-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; margin-left: 6px; vertical-align: 1px;
  font-size: 0.6rem; font-weight: 800; font-style: italic; line-height: 1;
  color: var(--lab-gold-dim); background: rgba(244, 207, 139, 0.07);
  border: 1px solid var(--lab-edge-soft); border-radius: 50%;
  cursor: help; user-select: none;
}
.fin-info:hover { color: var(--lab-gold-bright); border-color: var(--lab-edge); background: rgba(244, 207, 139, 0.14); }
.fin-tip-pop {
  position: fixed; z-index: 12000; pointer-events: none;
  max-width: 250px; padding: 8px 11px;
  background: linear-gradient(180deg, #2a1830, #160b1b);
  border: 1px solid var(--lab-edge); border-radius: 9px;
  color: var(--lab-gold-bright); font-size: 0.74rem; line-height: 1.45; font-weight: 500;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(244, 207, 139, 0.12);
  opacity: 0; transform: translateY(3px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.fin-tip-pop.is-on { opacity: 1; transform: translateY(0); }
.fin-note {
  margin-top: 12px; padding-top: 9px; border-top: 1px dashed var(--lab-edge-soft);
  color: var(--lab-gold-dim); font-size: 0.74rem; font-style: italic; line-height: 1.45;
}

/* ── National Upgrades page ────────────────────────────────────────────── */
.up-grid { margin-bottom: 18px; }
.up-desc { color: var(--lab-gold-dim); font-size: 0.78rem; line-height: 1.45; margin-bottom: 10px; }
.up-cur { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 2px; border-bottom: 1px solid var(--lab-edge-soft); }
.up-cur-l { color: var(--lab-gold-dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; }
.up-cur-v { color: var(--lab-gold-bright); font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.up-steprow { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.up-step-l { color: var(--lab-gold-dim); font-size: 0.78rem; font-weight: 600; }
.up-step { display: inline-flex; align-items: center; gap: 6px; }
.up-step-btn {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 800; line-height: 1; cursor: pointer;
  color: var(--lab-gold-bright); background: rgba(244, 207, 139, 0.08);
  border: 1px solid var(--lab-edge); border-radius: 8px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.up-step-btn:hover:not(:disabled) { background: rgba(244, 207, 139, 0.18); border-color: var(--lab-gold); }
.up-step-btn:disabled { opacity: 0.35; cursor: default; }
.up-step-v {
  min-width: 34px; text-align: center; color: var(--lab-gold-bright);
  font-weight: 800; font-variant-numeric: tabular-nums;
}
.up-step-input {
  width: 66px; padding: 5px 7px; text-align: center;
  color: var(--lab-gold-bright); font-weight: 700; font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--lab-edge); border-radius: 8px;
}
.up-step-input:focus { outline: none; border-color: var(--lab-gold); }
.up-new { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 2px 0; font-size: 0.82rem; }
.up-new-l { color: var(--lab-gold-dim); }
.up-new-v { color: var(--lab-gold-bright); font-weight: 700; font-variant-numeric: tabular-nums; }
.up-new-v.is-up { color: #7fd68d; }
.up-new-v .is-bad { color: var(--lab-bad); font-weight: 700; }
.up-new-v .is-good { color: #7fd68d; font-weight: 700; }
.up-taxrow { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; }
.up-slider { flex: 1; accent-color: var(--lab-gold); min-width: 0; }
.up-tax-num { width: 56px; }
.up-tax-pct { color: var(--lab-gold-bright); font-weight: 800; min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.up-mood {
  margin-top: 9px; padding: 8px 10px; border-radius: 9px;
  font-size: 0.76rem; line-height: 1.45; font-style: italic;
  color: var(--lab-gold-dim); background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--lab-edge-soft);
}
.up-mood-opportunity { color: #9fd6ab; border-color: rgba(127, 214, 141, 0.3); }
.up-mood-optimal { color: var(--lab-gold); }
.up-mood-grumbling { color: #e5d573; border-color: rgba(229, 213, 115, 0.3); }
.up-mood-evasion { color: #e5a973; border-color: rgba(229, 169, 115, 0.35); }
.up-mood-revolt { color: var(--lab-bad); border-color: rgba(231, 121, 121, 0.4); }
.up-foot {
  margin-top: 6px; padding: 14px 16px;
  background: linear-gradient(180deg, rgba(42, 24, 48, 0.9), rgba(22, 11, 27, 0.9));
  border: 1px solid var(--lab-edge); border-radius: 12px;
}
.up-foot-line { color: var(--lab-gold); font-size: 0.84rem; font-weight: 600; margin-bottom: 4px; }
.up-foot-warn { color: var(--lab-bad); font-size: 0.78rem; font-weight: 600; min-height: 1em; margin-bottom: 8px; }
.up-foot-btnrow { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.up-output {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: -6px 0 18px; padding: 9px 14px;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--lab-edge-soft); border-radius: 10px;
  font-size: 0.82rem; color: var(--lab-gold-dim);
}
.up-output-lbl { color: var(--lab-gold); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.up-output-v { color: var(--lab-gold-dim); font-variant-numeric: tabular-nums; }
.up-output-v b { color: var(--lab-gold-bright); font-weight: 700; }
.up-output-sep { color: var(--lab-edge); }
.up-output-strike { color: var(--lab-bad); font-style: italic; font-size: 0.76rem; }
.up-output .fin-info { margin-left: 0; }

/* ============================================================================
   MOBILE DRAWERS  (<= 820px ONLY)
   The top-right stats ribbon and the bottom-left management corner slide off
   screen and are revealed by an edge arrow tab, so the whole map stays visible
   and tappable on a phone. Everything here is gated behind the media query;
   the edge tabs are display:none at every width by default and only shown
   inside it, so the desktop/laptop layout is completely untouched.
   ============================================================================ */
.lab-draw-tab { display: none; }

@media (max-width: 820px) {
  /* ---- Left drawer: nation management (#lab-corner) ---- */
  #lab-corner {
    left: 0; bottom: auto; top: 60px;
    width: min(87vw, 344px);
    max-height: calc(100vh - 120px);
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px 12px 8px;
    gap: 9px;
    animation: none;
    transform: translateX(-108%);
    transition: transform 0.34s cubic-bezier(0.22, 0.61, 0.36, 1);
    z-index: 9100;
  }
  body.lab-draw-left-open #lab-corner { transform: translateX(0); }
  #lab-corner #lab-nation,
  #lab-corner #lab-mapctl { width: 100%; box-sizing: border-box; }

  /* ---- Right drawer: realm stats (#lab-ribbon) reflowed to a vertical stack ---- */
  #lab-ribbon {
    top: 60px; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: min(76vw, 264px);
    max-height: calc(100vh - 120px);
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 10px 10px 12px;
    animation: none;
    transform: translateX(108%);
    transition: transform 0.34s cubic-bezier(0.22, 0.61, 0.36, 1);
    z-index: 9100;
  }
  body.lab-draw-right-open #lab-ribbon { transform: translateX(0); }
  #lab-ribbon .lab-statgroup {
    border: 0; padding: 5px 3px;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  #lab-ribbon #lab-res-group,
  #lab-ribbon #lab-alert-group { flex-direction: column; align-items: stretch; }
  #lab-ribbon #lab-res-pop,
  #lab-ribbon #lab-alert-pop {
    position: static; right: auto; top: auto; left: auto;
    width: 100%; max-height: 44vh; margin-top: 6px;
  }

  /* ---- Edge arrow tabs ---- */
  .lab-draw-tab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; z-index: 9200;
    width: 30px; height: 60px;
    padding: 0; cursor: pointer;
    color: var(--lab-gold);
    background: linear-gradient(158deg, var(--lab-glass-a), var(--lab-glass-b));
    border: 1px solid var(--lab-edge);
    box-shadow: var(--lab-shadow);
    backdrop-filter: blur(14px) saturate(1.1);
    -webkit-backdrop-filter: blur(14px) saturate(1.1);
    transition: left 0.34s cubic-bezier(0.22, 0.61, 0.36, 1),
                right 0.34s cubic-bezier(0.22, 0.61, 0.36, 1);
  }
  .lab-draw-tab-left {
    left: 0; top: 42%;
    border-left: 0; border-radius: 0 13px 13px 0;
  }
  .lab-draw-tab-right {
    right: 0; top: 22%;
    border-right: 0; border-radius: 13px 0 0 13px;
  }
  body.lab-draw-left-open .lab-draw-tab-left { left: min(87vw, 344px); }
  body.lab-draw-right-open .lab-draw-tab-right { right: min(76vw, 264px); }

  body.lab-page-open .lab-draw-tab { display: none !important; }

  .lab-draw-chev {
    width: 0; height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    transition: transform 0.3s ease;
  }
  .lab-draw-tab-left .lab-draw-chev { border-left: 9px solid currentColor; margin-left: 2px; }
  .lab-draw-tab-right .lab-draw-chev { border-right: 9px solid currentColor; margin-right: 2px; }
  body.lab-draw-left-open .lab-draw-tab-left .lab-draw-chev { transform: rotate(180deg); }
  body.lab-draw-right-open .lab-draw-tab-right .lab-draw-chev { transform: rotate(180deg); }

  /* ---- Larger tap targets inside the drawers ---- */
  #lab-corner .lab-sq { min-height: 40px; min-width: 40px; }
  #lab-ribbon .lab-alert-btn,
  #lab-ribbon .lab-res-btn { min-height: 40px; }
}

/* ============================================================================
   REGION PAINTER (base-admin) — gold-glass on-map tool, right side.
   ============================================================================ */
#region-painter {
  position: fixed; top: 88px; right: 18px; z-index: 9500;
  width: 288px; max-height: calc(100vh - 120px); overflow-y: auto;
  padding: 12px 13px 13px; display: flex; flex-direction: column; gap: 9px;
}
.rp-head { display: flex; align-items: center; justify-content: space-between; }
.rp-title { font-weight: 700; font-size: 1rem; color: var(--lab-gold-bright); letter-spacing: 0.2px; }
.rp-x { width: 26px; height: 26px; border-radius: 7px; cursor: pointer; background: rgba(0,0,0,0.25); border: 1px solid var(--lab-edge-soft); color: var(--lab-gold); font-size: 1.05rem; line-height: 1; }
.rp-x:hover { border-color: var(--lab-bad); color: var(--lab-bad); }
.rp-sec { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--lab-gold-dim); margin-top: 3px; }
.rp-pal { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--lab-gold-deep) rgba(0, 0, 0, 0.2); }
.rp-pal::-webkit-scrollbar { width: 8px; }
.rp-pal::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); border-radius: 8px; margin: 2px 0; }
.rp-pal::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--lab-gold), var(--lab-gold-deep)); border-radius: 8px; border: 2px solid rgba(0, 0, 0, 0.25); background-clip: padding-box; }
.rp-pal::-webkit-scrollbar-thumb:hover { background: var(--lab-gold-bright); }
.rp-reg { display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; background: rgba(0,0,0,0.2); }
.rp-reg:hover { background: rgba(64,42,70,0.4); }
.rp-reg.is-sel { border-color: var(--lab-edge); background: rgba(64,42,70,0.55); }
.rp-sw { width: 15px; height: 15px; border-radius: 4px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,0.25); }
.rp-rname { flex: 1 1 auto; color: var(--lab-gold); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-mini { font-size: 0.66rem; padding: 3px 6px; border-radius: 6px; cursor: pointer; background: rgba(0,0,0,0.3); border: 1px solid var(--lab-edge-soft); color: var(--lab-gold-dim); }
.rp-mini:hover { color: var(--lab-gold-bright); border-color: var(--lab-edge); }
.rp-mini-del:hover { color: var(--lab-bad); border-color: var(--lab-bad); }
.rp-btn { padding: 8px 11px; border-radius: 8px; cursor: pointer; font-family: 'Raleway', sans-serif; font-size: 0.84rem; font-weight: 600; color: var(--lab-gold); background: linear-gradient(180deg, rgba(64,42,70,0.5), rgba(22,13,26,0.66)); border: 1px solid var(--lab-edge-soft); }
.rp-btn:hover { border-color: var(--lab-edge); color: var(--lab-gold-bright); }
.rp-btn:disabled { opacity: 0.45; cursor: default; }
.rp-btn-sm { padding: 6px 10px; font-size: 0.78rem; }
.rp-btn-primary { background: linear-gradient(180deg, rgba(244,207,139,0.22), rgba(120,90,40,0.3)); color: var(--lab-gold-bright); }
.rp-form { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.rp-in { flex: 1 1 auto; min-width: 0; padding: 6px 8px; background: rgba(0,0,0,0.4); border: 1px solid var(--lab-edge-soft); border-radius: 7px; color: var(--lab-gold-bright); font-family: 'Raleway', sans-serif; font-size: 0.82rem; }
.rp-in:focus { outline: none; border-color: var(--lab-edge); }
.rp-col { width: 34px; height: 30px; flex: 0 0 auto; padding: 0; border: 1px solid var(--lab-edge-soft); border-radius: 7px; background: transparent; cursor: pointer; }
.rp-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rp-tool { padding: 8px; border-radius: 8px; cursor: pointer; font-family: 'Raleway', sans-serif; font-size: 0.82rem; font-weight: 600; color: var(--lab-gold-dim); background: rgba(0,0,0,0.24); border: 1px solid var(--lab-edge-soft); }
.rp-tool:hover { color: var(--lab-gold); border-color: var(--lab-edge); }
.rp-tool.is-on { color: var(--lab-ink); background: linear-gradient(180deg, var(--lab-gold-bright), var(--lab-gold-deep)); border-color: var(--lab-gold-bright); }
.rp-brush { display: flex; align-items: center; gap: 9px; }
.rp-lab { font-size: 0.72rem; color: var(--lab-gold-dim); }
.rp-range { flex: 1 1 auto; accent-color: var(--lab-gold-deep); }
.rp-bval { color: var(--lab-gold-bright); font-weight: 700; width: 14px; text-align: center; }
.rp-go { display: flex; gap: 6px; }
.rp-goin { flex: 1 1 auto; min-width: 0; padding: 6px 8px; background: rgba(0,0,0,0.4); border: 1px solid var(--lab-edge-soft); border-radius: 7px; color: var(--lab-gold-bright); font-family: 'Raleway', sans-serif; font-size: 0.82rem; -moz-appearance: textfield; appearance: textfield; }
.rp-goin::-webkit-inner-spin-button, .rp-goin::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.rp-goin:focus { outline: none; border-color: var(--lab-edge); }
.rp-goin::placeholder { color: var(--lab-gold-dim); opacity: 0.7; }
.rp-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 9px; border-top: 1px solid var(--lab-edge-soft); flex-wrap: wrap; }
.rp-status { flex: 1 1 100%; font-size: 0.74rem; color: var(--lab-gold-dim); margin-bottom: 4px; }
.rp-target { margin-bottom: 5px; padding-bottom: 9px; border-bottom: 1px solid var(--lab-edge-soft); }
.rp-hint { font-size: 0.78rem; color: var(--lab-gold-dim); padding: 6px 2px; }

/* Touch-only press feedback: hover:none targets touch devices, so desktop hover
   states are never affected. Gives taps a visible response on phones/tablets. */
@media (hover: none) and (pointer: coarse) {
  .lab-sq:active,
  .lab-act-btn:active,
  .lab-alert-btn:active,
  .lab-res-btn:active,
  .lab-ctx-act:active,
  .lab-draw-tab:active { filter: brightness(1.28); }
}

/* ============================================================================
   BASE-ADMIN corner panel (staff account, no nation) — gold-glass, replaces the
   nation card. The View/Overlays control bar keeps its own styling below it.
   ============================================================================ */
#lab-admin { width: 300px; padding: 14px 15px 13px; display: flex; flex-direction: column; gap: 12px; }
.lab-admin-head { display: flex; align-items: center; gap: 11px; }
.lab-admin-mark {
  width: 42px; height: 42px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(244, 207, 139, 0.16), rgba(0, 0, 0, 0.3));
  border: 1px solid var(--lab-edge);
  color: var(--lab-gold-bright);
}
.lab-admin-mark [data-lucide] { width: 22px; height: 22px; }
.lab-admin-title { font-weight: 700; font-size: 1.02rem; color: var(--lab-gold-bright); letter-spacing: 0.2px; }
#lab-admin .lab-nation-actions { flex-wrap: wrap; }
/* Corner sits against the left edge; anchor the admin button tooltips to the button's
   left so long labels open rightward instead of spilling off the screen. */
#lab-admin .lab-sq .lab-tip { left: 0; transform: translateX(0) translateY(4px); }
#lab-admin .lab-sq:hover .lab-tip { transform: translateX(0) translateY(0); }
#lab-admin .lab-sq .lab-tip::after { left: 20px; }

/* ---- Resource Distribution lab page (.ar-*) ---- */
.ar-field { display: flex; flex-direction: column; gap: 5px; }
.ar-lab { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--lab-gold-dim); }
.ar-pool { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; margin-top: 4px; }
.ar-row {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 9px 11px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.24); border: 1px solid var(--lab-edge-soft);
  opacity: 0.62; transition: opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.ar-row.is-on { opacity: 1; border-color: var(--lab-edge); background: rgba(64, 42, 70, 0.34); }
.ar-toggle { display: flex; align-items: center; gap: 8px; flex: 1 1 100%; cursor: pointer; min-width: 0; margin-bottom: 2px; }
.ar-toggle input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 18px; height: 18px; flex: 0 0 auto; position: relative; cursor: pointer;
  border: 1px solid var(--lab-edge); border-radius: 5px;
  background: rgba(0, 0, 0, 0.42);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ar-toggle input[type="checkbox"]:hover { border-color: var(--lab-gold-deep); }
.ar-toggle input[type="checkbox"]:checked { background: linear-gradient(180deg, var(--lab-gold-bright), var(--lab-gold-deep)); border-color: var(--lab-gold-bright); }
.ar-toggle input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
  border: solid var(--lab-ink); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.ar-name { display: flex; align-items: center; gap: 6px; color: var(--lab-gold); font-size: 0.88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-cat { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; background: var(--lab-gold-dim); }
.ar-cat-common { background: #b7c0cc; }
.ar-cat-precious { background: var(--lab-gold); }
.ar-cat-special { background: var(--lab-good); }
.ar-tier { font-size: 0.68rem; color: var(--lab-gold-deep); font-weight: 700; }
.ar-mini { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--lab-gold-dim); }
.ar-num {
  width: 56px; flex: 0 0 auto; padding: 5px 7px;
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--lab-edge-soft); border-radius: 7px;
  color: var(--lab-gold-bright); font-family: 'Raleway', sans-serif; font-size: 0.82rem; text-align: right;
  -moz-appearance: textfield; appearance: textfield;
}
.ar-num::-webkit-inner-spin-button, .ar-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ar-num:disabled { opacity: 0.4; }
.ar-num:focus { outline: none; border-color: var(--lab-edge); }
.ar-foot { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--lab-edge-soft); }

/* ---- Per-tile deposit editor injected into the tile-info panel (admin) ---- */
.ate { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--lab-edge); }
.ate-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ate-head span { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--lab-gold-bright); }
.ate-list { display: flex; flex-direction: column; gap: 5px; }
.ate-empty { font-size: 0.8rem; color: var(--lab-gold-dim); padding: 3px 0; }
.ate-row { display: flex; align-items: center; gap: 7px; }
.ate-name { flex: 1 1 auto; color: var(--lab-gold); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ate-mini { font-size: 0.62rem; color: var(--lab-gold-dim); }
.ate-num { width: 60px; flex: 0 0 auto; padding: 5px 7px; background: rgba(0, 0, 0, 0.42); border: 1px solid var(--lab-edge-soft); border-radius: 7px; color: var(--lab-gold-bright); font-family: 'Raleway', sans-serif; font-size: 0.82rem; text-align: right; -moz-appearance: textfield; appearance: textfield; }
.ate-num::-webkit-inner-spin-button, .ate-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ate-num:focus { outline: none; border-color: var(--lab-edge); }
.ate-del { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 7px; cursor: pointer; background: rgba(229, 115, 115, 0.12); border: 1px solid var(--lab-edge-soft); color: var(--lab-bad); font-size: 1.05rem; line-height: 1; }
.ate-del:hover { border-color: var(--lab-bad); background: rgba(229, 115, 115, 0.22); }
.ate-add { display: flex; gap: 7px; margin-top: 9px; }
.ate-sel { flex: 1 1 auto; min-width: 0; }
.ate-btn { padding: 7px 13px; border-radius: 8px; cursor: pointer; font-family: 'Raleway', sans-serif; font-size: 0.82rem; font-weight: 600; color: var(--lab-gold); background: linear-gradient(180deg, rgba(64, 42, 70, 0.5), rgba(22, 13, 26, 0.66)); border: 1px solid var(--lab-edge-soft); }
.ate-btn:hover { border-color: var(--lab-edge); color: var(--lab-gold-bright); }
.ate-btn:disabled { opacity: 0.4; cursor: default; }
.ate-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 11px; }
.ate-save { background: linear-gradient(180deg, rgba(244, 207, 139, 0.22), rgba(120, 90, 40, 0.3)); color: var(--lab-gold-bright); }
.ate-status { font-size: 0.76rem; color: var(--lab-gold-dim); margin-right: auto; }
.ate-status.ok { color: var(--lab-good); }
.ate-status.err { color: var(--lab-bad); }

/* ---- Harvest modifiers grid (Resource Distribution menu) ---- */
.ar-mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 7px; margin-top: 4px; }
.ar-modrow {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 11px; border-radius: 9px;
  background: rgba(0, 0, 0, 0.24); border: 1px solid var(--lab-edge-soft);
  opacity: 0.72; transition: opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.ar-modrow.is-on { opacity: 1; border-color: var(--lab-edge); background: rgba(64, 42, 70, 0.34); }
.ar-modname { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; color: var(--lab-gold); font-size: 0.86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-modnum {
  width: 62px; flex: 0 0 auto; padding: 5px 7px;
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--lab-edge-soft); border-radius: 7px;
  color: var(--lab-gold-bright); font-family: 'Raleway', sans-serif; font-size: 0.82rem; text-align: right;
  -moz-appearance: textfield; appearance: textfield;
}
.ar-modnum::-webkit-inner-spin-button, .ar-modnum::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ar-modnum:focus { outline: none; border-color: var(--lab-edge); }
.ar-modpct { font-size: 0.72rem; color: var(--lab-gold-dim); flex: 0 0 auto; }

/* ---- Region deposit audit (Resource Distribution menu) ---- */
.ar-audit { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.ar-audit-empty { font-size: 0.82rem; color: var(--lab-gold-dim); padding: 4px 0; }
.ar-audit-sum { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 11px; margin-bottom: 4px; border-radius: 9px; background: rgba(64, 42, 70, 0.3); border: 1px solid var(--lab-edge-soft); font-size: 0.8rem; color: var(--lab-gold-bright); font-weight: 600; }
.ar-audit-row { display: flex; align-items: center; gap: 10px; padding: 6px 11px; border-radius: 8px; background: rgba(0, 0, 0, 0.2); }
.ar-audit-name { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; color: var(--lab-gold); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-audit-count { flex: 0 0 auto; font-size: 0.8rem; color: var(--lab-gold-dim); }
.ar-audit-yield { flex: 0 0 auto; font-size: 0.8rem; color: var(--lab-gold-deep); font-weight: 700; }

/* ---- Tile ownership override injected into the tile-info panel (admin) ---- */
.ato { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--lab-edge); }
.ato-head span { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--lab-gold-bright); }
.ato-cur { font-size: 0.84rem; color: var(--lab-gold-dim); margin: 7px 0; }
.ato-owner { font-weight: 700; }
.ato-row { display: flex; gap: 7px; }
.ato-sel { flex: 1 1 auto; min-width: 0; }
.ato-btn { padding: 7px 13px; border-radius: 8px; cursor: pointer; font-family: 'Raleway', sans-serif; font-size: 0.82rem; font-weight: 600; color: var(--lab-gold); background: linear-gradient(180deg, rgba(64, 42, 70, 0.5), rgba(22, 13, 26, 0.66)); border: 1px solid var(--lab-edge-soft); }
.ato-btn:hover { border-color: var(--lab-edge); color: var(--lab-gold-bright); }
.ato-btn:disabled { opacity: 0.4; cursor: default; }
.ato-save { background: linear-gradient(180deg, rgba(244, 207, 139, 0.22), rgba(120, 90, 40, 0.3)); color: var(--lab-gold-bright); }
.ato-status { font-size: 0.76rem; color: var(--lab-gold-dim); margin-top: 7px; min-height: 1em; }
.ato-status.ok { color: var(--lab-good); }
.ato-status.err { color: var(--lab-bad); }

/* ---- Terrain Studio (on-map gold-glass world builder) ---- */
#terrain-studio {
  position: fixed; top: 88px; right: 18px; z-index: 9500; width: 308px;
  max-height: calc(100vh - 120px); overflow-y: auto;
  padding: 14px 15px 16px; display: flex; flex-direction: column; gap: 7px;
  scrollbar-width: thin; scrollbar-color: var(--lab-gold-deep) rgba(0, 0, 0, 0.2);
}
#terrain-studio::-webkit-scrollbar { width: 8px; }
#terrain-studio::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); border-radius: 8px; margin: 4px 0; }
#terrain-studio::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--lab-gold), var(--lab-gold-deep)); border-radius: 8px; border: 2px solid rgba(0, 0, 0, 0.25); background-clip: padding-box; }
#terrain-studio::-webkit-scrollbar-thumb:hover { background: var(--lab-gold-bright); }
.ts-head { display: flex; align-items: center; justify-content: space-between; }
.ts-title { font-family: 'Cinzel', serif; font-size: 1.02rem; font-weight: 700; color: var(--lab-gold-bright); letter-spacing: 0.5px; }
.ts-x { width: 26px; height: 26px; border-radius: 7px; cursor: pointer; background: rgba(0,0,0,0.25); border: 1px solid var(--lab-edge-soft); color: var(--lab-gold); font-size: 1.05rem; line-height: 1; }
.ts-x:hover { border-color: var(--lab-bad); color: var(--lab-bad); }
.ts-sec { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--lab-gold-dim); padding-top: 9px; margin-bottom: 1px; border-top: 1px solid var(--lab-edge-soft); }
.ts-head + .ts-sec { padding-top: 0; border-top: none; }
.ts-list { display: flex; flex-direction: column; gap: 4px; max-height: 150px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--lab-gold-deep) rgba(0,0,0,0.2); }
.ts-list::-webkit-scrollbar { width: 8px; }
.ts-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 8px; }
.ts-list::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--lab-gold), var(--lab-gold-deep)); border-radius: 8px; border: 2px solid rgba(0,0,0,0.25); background-clip: padding-box; }
.ts-lm { display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; background: rgba(0,0,0,0.2); }
.ts-lm:hover { background: rgba(64,42,70,0.4); }
.ts-lm.is-sel { border-color: var(--lab-edge); background: rgba(64,42,70,0.55); }
.ts-lm-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; background: var(--lab-gold-dim); }
.ts-lm-dot.is-pub { background: var(--lab-good); box-shadow: 0 0 6px rgba(121,211,155,0.6); }
.ts-lm-name { flex: 1 1 auto; color: var(--lab-gold); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-lm-meta { color: var(--lab-gold-dim); font-size: 0.72rem; }
.ts-empty { font-size: 0.8rem; color: var(--lab-gold-dim); padding: 4px 2px; }
.ts-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ts-in { flex: 1 1 auto; min-width: 0; padding: 6px 8px; background: rgba(0,0,0,0.4); border: 1px solid var(--lab-edge-soft); border-radius: 7px; color: var(--lab-gold-bright); font-family: 'Raleway', sans-serif; font-size: 0.82rem; }
.ts-in:focus { outline: none; border-color: var(--lab-edge); }
.ts-settings { display: flex; flex-direction: column; gap: 8px; }
.ts-lab { font-size: 0.72rem; color: var(--lab-gold-dim); margin-top: 3px; }
.ts-toggle, .ts-race { display: flex; align-items: center; gap: 8px; cursor: pointer; min-height: 22px; }
.ts-toggle-lab { color: var(--lab-gold); font-size: 0.82rem; }
.ts-race { font-size: 0.8rem; color: var(--lab-gold); }
.ts-races { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.ts-toggle input[type="checkbox"], .ts-race input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; margin: 0; width: 17px; height: 17px; flex: 0 0 auto; position: relative; cursor: pointer;
  border: 1px solid var(--lab-edge); border-radius: 5px; background: rgba(0,0,0,0.42);
}
.ts-toggle input[type="checkbox"]:hover, .ts-race input[type="checkbox"]:hover { border-color: var(--lab-gold-deep); }
.ts-toggle input[type="checkbox"]:checked, .ts-race input[type="checkbox"]:checked { background: linear-gradient(180deg, var(--lab-gold-bright), var(--lab-gold-deep)); border-color: var(--lab-gold-bright); }
.ts-toggle input[type="checkbox"]:checked::after, .ts-race input[type="checkbox"]:checked::after { content: ""; position: absolute; left: 5px; top: 1px; width: 4px; height: 9px; border: solid var(--lab-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.ts-btn { padding: 8px 11px; border-radius: 8px; cursor: pointer; font-family: 'Raleway', sans-serif; font-size: 0.84rem; font-weight: 600; color: var(--lab-gold); background: linear-gradient(180deg, rgba(64,42,70,0.5), rgba(22,13,26,0.66)); border: 1px solid var(--lab-edge-soft); }
.ts-btn:hover { border-color: var(--lab-edge); color: var(--lab-gold-bright); }
.ts-btn:disabled { opacity: 0.45; cursor: default; }
.ts-btn-sm { padding: 6px 10px; font-size: 0.78rem; }
.ts-btn-primary { background: linear-gradient(180deg, rgba(244,207,139,0.22), rgba(120,90,40,0.3)); color: var(--lab-gold-bright); flex: 1 1 auto; }
.ts-btn-del { color: var(--lab-bad); }
.ts-btn-del:hover { border-color: var(--lab-bad); }
.ts-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.ts-tool { padding: 7px; border-radius: 8px; cursor: pointer; font-family: 'Raleway', sans-serif; font-size: 0.8rem; font-weight: 600; color: var(--lab-gold-dim); background: rgba(0,0,0,0.24); border: 1px solid var(--lab-edge-soft); }
.ts-tool:hover { color: var(--lab-gold); border-color: var(--lab-edge); }
.ts-tool.is-on { color: var(--lab-ink); background: linear-gradient(180deg, var(--lab-gold-bright), var(--lab-gold-deep)); border-color: var(--lab-gold-bright); }
.ts-slider { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.ts-slab { font-size: 0.72rem; line-height: 1.2; color: var(--lab-gold-dim); flex: 0 0 104px; }
.ts-range { flex: 1 1 auto; min-width: 0; accent-color: var(--lab-gold-deep); }
.ts-sval { color: var(--lab-gold-bright); font-weight: 700; font-size: 0.76rem; flex: 0 0 44px; text-align: right; }
.ts-biome-box { display: flex; flex-direction: column; gap: 6px; }
.ts-picker { display: flex; flex-wrap: wrap; gap: 5px; }
.ts-swatch { width: 24px; height: 24px; border-radius: 6px; cursor: pointer; border: 1px solid rgba(255,255,255,0.2); padding: 0; }
.ts-swatch:hover { border-color: var(--lab-gold); transform: translateY(-1px); }
.ts-swatch.is-on { border: 2px solid var(--lab-gold-bright); box-shadow: 0 0 6px rgba(244,207,139,0.5); }
.ts-biome-name { font-size: 0.74rem; color: var(--lab-gold-dim); }
.ts-biome-name strong { color: var(--lab-gold-bright); font-weight: 600; }

/* Floating variant of the lab tooltip: the studio panel scrolls, so biome tooltips
   are positioned against the viewport from <body> instead of inside the swatch. */
.ts-tip {
  position: fixed;
  bottom: auto;
  transform: translate(-50%, calc(-100% - 9px));
  z-index: 10000;
}
.ts-tip.is-on { opacity: 1; }
.ts-fsel { flex: 1 1 auto; }
.ts-toolhost { display: flex; flex-direction: column; gap: 7px; }
.ts-foot-sep { height: 0; border-top: 1px solid var(--lab-edge-soft); margin-top: 3px; padding-top: 0; }
.ts-hint { font-size: 0.74rem; color: var(--lab-gold-dim); line-height: 1.4; }
.ts-hint.ts-good { color: var(--lab-good); }
.ts-hint.ts-bad { color: var(--lab-bad); border-left: 2px solid var(--lab-bad); padding-left: 7px; }
.ts-hint.ts-faint { opacity: 0.72; }
.ts-hint.ts-warnline:not(:empty) { color: var(--lab-warn); }

/* Custom gold chevron for admin/studio selects (replaces the native OS arrow). */
.ate-sel, .ts-fsel {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding: 6px 26px 6px 9px; border-radius: 7px;
  background-color: rgba(0, 0, 0, 0.42); border: 1px solid var(--lab-edge-soft);
  color: var(--lab-gold-bright); font-family: 'Raleway', sans-serif; font-size: 0.82rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23f4cf8b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.ate-sel:focus, .ts-fsel:focus { outline: none; border-color: var(--lab-edge); }
.ate-sel option, .ts-fsel option { background: var(--lab-glass-b); color: var(--lab-gold-bright); }

/* ===== Realm View legend (Estates map layer) ===== */
#realm-legend {
  position: fixed;
  left: 14px;
  bottom: 16px;
  z-index: 60;
  width: 236px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 12px 13px 13px;
  border: 1px solid var(--lab-edge, #6b552a);
  border-radius: 13px;
  background: var(--lab-glass-b, rgba(18, 10, 22, 0.92));
  backdrop-filter: blur(9px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  font-size: 0.82rem;
  color: var(--lab-gold, #d9be86);
  display: none;
}
.rl-title { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--lab-gold-bright, #f4cf8b); margin-bottom: 8px; }
.rl-sec { margin: 10px 0 6px; font-size: 0.64rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--lab-gold-dim, #a98c52); }
.rl-row { display: flex; align-items: center; gap: 7px; padding: 3px 0; }
.rl-sw { flex: 0 0 auto; width: 13px; height: 13px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.rl-nm { color: var(--lab-gold-bright, #f4cf8b); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-star { color: #ffd76a; }
.rl-arrow { color: var(--lab-gold-dim, #a98c52); }
.rl-sub { margin-left: auto; color: var(--lab-gold-dim, #a98c52); font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 96px; }
.rl-more, .rl-empty { margin-top: 6px; font-size: 0.76rem; color: var(--lab-gold-dim, #a98c52); }
.rl-empty { line-height: 1.4; }
@media (max-width: 820px) {
  #realm-legend { left: 8px; bottom: 8px; width: 190px; max-height: 34vh; font-size: 0.78rem; }
}
