/* Earth Server Squaremap chrome. Tokens from thegreatestmcservers.com/brand.css. */

html,
body.aipg-squaremap-brand {
  height: 100%;
  margin: 0;
}

body.aipg-squaremap-brand {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Full-bleed map — no AIPG top header on earth.thegreatestminecraftserver.com */
body.aipg-squaremap-brand #map {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: auto;
  height: auto;
}

/*
 * Motfe ocean under the tile stack (brand --map-ocean). Transparent #map over
 * page --bg (#0f0f0f) made every hairline / load gap read as a black seam
 * (map62 root-cause). Ocean-matched fill hides residual PNG edge darkening
 * and GPU hairlines without CSS tile +N overlap (forbidden forever).
 */
body.aipg-squaremap-brand #map,
body.aipg-squaremap-brand .leaflet-container,
body.aipg-squaremap-brand .leaflet-tile-pane {
  background-color: var(--map-ocean) !important;
  background-image: none !important;
}

/*
 * Subpixel Leaflet tile seams (1px dark lines that shift/vanish on drag/zoom).
 * NEVER enlarge tile CSS or canvas (+N overlap/bleed paints a glowing grid on
 * every tile edge — failure of record map49 / map55 TILE_DISPLAY_OVERLAP=1).
 * Date-line continuity is Motfe SPAN 36864 + wrap-ordered abut + Motfe PNG.
 *
 * map135 forced mix-blend-mode:normal on img+canvas to kill a bright date-line
 * fringe under plus-lighter. That left Chromium inland hairlines (operator
 * desert crosshair) — Leaflet #8907 uses plus-lighter on IMG only for gaps.
 * map154: restore plus-lighter on img.leaflet-tile; keep canvas.normal so
 * date-line wrap canvases do not double-brighten abut columns. Inland Motfe
 * tiles also get a 1px border flatten in createTile (baked edge darkening).
 */
body.aipg-squaremap-brand .leaflet-tile-pane .leaflet-tile {
  outline: none !important;
  border: none !important;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* Leaflet fadeAnimation leaves transparent tiles over --bg = cell gaps on zoom. */
  transition: none !important;
}
body.aipg-squaremap-brand .leaflet-tile-pane img.leaflet-tile {
  /* Leaflet 1.9.4+ Chromium gap fix — IMG only (not canvas wrap abut). */
  mix-blend-mode: plus-lighter;
}
body.aipg-squaremap-brand .leaflet-tile-pane canvas.leaflet-tile {
  mix-blend-mode: normal;
}

body.aipg-squaremap-brand header.top-bar {
  display: none !important;
}

/* Legacy: hide any stale model bar if an old JS blob injects one. */
.aipg-model-bar {
  display: none !important;
}

.aipg-spawn-marker {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  color: var(--accent-ink);
  background: var(--accent);
  border: 2px solid var(--panel);
  border-radius: var(--radius-pill);
  box-shadow: 0 0 0 2px var(--shadow-ink);
  line-height: 1;
}

.aipg-spawn-marker svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

.aipg-spawn-marker-shell[data-spawn-id="claude"] {
  transform: translate(-10px, 0);
}

.aipg-spawn-marker-shell[data-spawn-id="chatgpt"] {
  transform: translate(10px, 0);
}

.aipg-spawn-marker[data-spawn-id="claude"] {
  background: var(--model-claude);
}

.aipg-spawn-marker[data-spawn-id="chatgpt"] {
  background: var(--model-chatgpt);
}

.aipg-spawn-marker[data-spawn-id="kimi"] {
  background: var(--model-kimi);
}

/* Stock coords + link replaced by .aipg-map-join (info toggle → one card). */
body.aipg-squaremap-brand div.leaflet-control-layers.coordinates {
  display: none !important;
}

.aipg-map-join {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  width: max-content;
  max-width: min(360px, calc(100vw - 20px));
  font-family: var(--font-ui);
  pointer-events: none;
}

.aipg-map-join > * {
  pointer-events: auto;
}

.aipg-map-join__panel {
  width: max-content;
  max-width: min(360px, calc(100vw - 20px));
  margin: 0 0 6px;
  padding: 7px 9px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 0;
  box-shadow: none;
}

.aipg-map-join__panel[hidden] {
  display: none !important;
}

.aipg-map-join__row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 4px;
}

.aipg-map-join__row:last-child {
  margin-bottom: 0;
}

.aipg-map-join__edition {
  flex: 0 0 auto;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  color: var(--text);
  white-space: nowrap;
  line-height: 1.2;
}

.aipg-map-join__label {
  flex: 0 0 auto;
  width: 1.35rem;
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, var(--text-muted));
  font-weight: 600;
}

.aipg-map-join__copy {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.aipg-map-join__copy:focus-visible {
  outline: 1px solid var(--hairline);
  outline-offset: 2px;
}

.aipg-map-join__value {
  flex: 0 1 auto;
  min-width: 0;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  color: var(--text);
  white-space: nowrap;
  line-height: 1.2;
}

.aipg-map-join__icon {
  position: relative;
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  color: var(--muted, var(--text-muted));
}

.aipg-map-join__clip,
.aipg-map-join__check {
  position: absolute;
  inset: 0;
  display: block;
  transition: opacity 0.18s ease, transform 0.22s ease;
}

.aipg-map-join__clip {
  opacity: 1;
  transform: scale(1);
}

.aipg-map-join__check {
  opacity: 0;
  transform: scale(0.55);
  color: var(--text);
}

.aipg-map-join__copy.is-copied .aipg-map-join__clip {
  opacity: 0;
  transform: scale(0.55);
}

.aipg-map-join__copy.is-copied .aipg-map-join__check {
  opacity: 1;
  transform: scale(1);
}

/* Collapsed chrome = info button only (no always-on coords strip). */
.aipg-map-join__info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 0;
  background: var(--bg);
  color: var(--muted, var(--text-muted));
  cursor: pointer;
}

.aipg-map-join__info svg {
  width: 15px;
  height: 15px;
  display: block;
}

.aipg-map-join__info:hover {
  color: var(--text);
  opacity: 0.85;
}

.aipg-map-join__info[aria-expanded="true"] {
  color: var(--text);
  opacity: 1;
}

.aipg-map-join__info:focus-visible {
  outline: 1px solid var(--hairline);
  outline-offset: 1px;
}

@media (max-width: 719px) {
  .aipg-map-join {
    left: 8px;
    bottom: 8px;
  }
}

/* Right-click map menu — compact; Follow only when on a player.
   Set/Clear marker + Follow me still appear when me-token is in localStorage. */
.aipg-map-ctx {
  position: fixed;
  z-index: 10000;
  min-width: 0;
  width: max-content;
  max-width: min(220px, calc(100vw - 16px));
  padding: 4px 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 0;
  box-shadow: none;
}

.aipg-map-ctx[hidden] {
  display: none !important;
}

.aipg-map-ctx__title {
  font-family: var(--font-display);
  font-size: 9px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--text);
  margin: 0;
  padding: 2px 8px 3px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aipg-map-ctx__coords {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 0 8px 4px;
  border-bottom: 1px solid var(--hairline);
}

.aipg-map-ctx__coords-text {
  flex: 0 1 auto;
  min-width: 0;
  font-family: var(--font-mono, var(--font-ui));
  font-size: 0.68rem;
  line-height: 1.2;
  color: var(--muted, var(--text-muted));
  white-space: nowrap;
}

.aipg-map-ctx__copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted, var(--text-muted));
  cursor: pointer;
}

.aipg-map-ctx__copy:focus-visible {
  outline: 1px solid var(--hairline);
  outline-offset: 2px;
}

.aipg-map-ctx__btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 4px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  line-height: 1.25;
}

/* Author display:block must not override HTML hidden (Follow / me-gated rows). */
.aipg-map-ctx__btn[hidden] {
  display: none !important;
}

.aipg-map-ctx__btn:hover,
.aipg-map-ctx__btn:focus-visible {
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

/* Hide Squaremap permalink/share icon next to coordinates (bottom-left). */
body.aipg-squaremap-brand div.leaflet-control-layers.link {
  display: none !important;
}

body.aipg-squaremap-brand .leaflet-control {
  color: var(--text);
}

body.aipg-squaremap-brand .leaflet-control-layers {
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 0;
  box-shadow: none;
}

body.aipg-squaremap-brand .leaflet-control-layers-expanded {
  background: var(--bg);
  color: var(--text);
  padding: 0;
}

body.aipg-squaremap-brand .leaflet-control-layers-separator {
  border-top-color: var(--hairline);
}

body.aipg-squaremap-brand .leaflet-bar {
  border-color: var(--hairline);
  border-radius: 0;
}

body.aipg-squaremap-brand .leaflet-bar a,
body.aipg-squaremap-brand .leaflet-bar a:focus {
  background-color: var(--bg);
  color: var(--text);
  border-bottom-color: var(--hairline);
}

body.aipg-squaremap-brand .leaflet-bar a:hover {
  background-color: var(--surface-soft);
  color: var(--text);
}

body.aipg-squaremap-brand .leaflet-bar a.leaflet-disabled {
  background-color: var(--bg);
  color: var(--muted);
}

/* Filter + zoom live in bottom-right (right-hand reach). Filter above zoom. */
body.aipg-squaremap-brand .leaflet-bottom.leaflet-right {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 10px;
  margin: 0 12px 12px 0;
}

body.aipg-squaremap-brand .leaflet-bottom.leaflet-right .leaflet-control {
  margin: 0 !important;
  float: none;
  clear: none;
}

/* Filter = square sibling of zoom (+/−), Lucide funnel, click opens list upward. */
body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control {
  position: relative;
  width: 30px;
  min-width: 30px;
  overflow: visible;
  background: transparent;
  border: none;
  box-shadow: none;
}

body.aipg-squaremap-brand .leaflet-bar a,
body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control .leaflet-control-layers-toggle {
  width: 30px;
  height: 30px;
  line-height: 30px;
}

body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control .leaflet-control-layers-toggle {
  display: flex !important;
  align-items: center;
  justify-content: center;
  background-image: none !important;
  background-color: var(--bg) !important;
  background-size: unset !important;
  filter: none !important;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--hairline);
  box-sizing: border-box;
}

body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control .leaflet-control-layers-toggle:hover {
  background-color: var(--surface-soft) !important;
  color: var(--text);
}

body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control .leaflet-control-layers-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
  pointer-events: none;
}

body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
  display: flex !important;
}

body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control:not(.leaflet-control-layers-expanded) .leaflet-control-layers-list {
  display: none !important;
}

body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control.leaflet-control-layers-expanded .leaflet-control-layers-list {
  display: block !important;
  position: absolute;
  bottom: 100%;
  top: auto;
  right: 0;
  left: auto;
  margin: 0 0 4px 0;
  padding: 0.45rem 0.55rem 0.55rem;
  min-width: 9.5rem;
  background: var(--bg);
  border: 1px solid var(--hairline);
  color: var(--text);
  z-index: 1000;
}

body.aipg-squaremap-brand .leaflet-control-layers-list,
body.aipg-squaremap-brand .leaflet-control-layers label,
body.aipg-squaremap-brand .leaflet-control-layers-base,
body.aipg-squaremap-brand .leaflet-control-layers-overlays {
  color: var(--text);
  background: transparent;
}

body.aipg-squaremap-brand .leaflet-control-attribution,
body.aipg-squaremap-brand .leaflet-control-attribution a {
  background: var(--bg);
  color: var(--text-muted, var(--muted));
}

body.aipg-squaremap-brand .leaflet-control-attribution a:hover {
  color: var(--text);
}

/* Nation popups + player nameplates — dark panel (not Leaflet white).
   LOCKED: do not drop these when editing chrome CSS.
   Player nameplates stay compact; nation cards keep the richer card layout. */
body.aipg-squaremap-brand .leaflet-popup-content-wrapper {
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--panel-stroke-strong) !important;
  border-radius: var(--radius) !important;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent),
    0 16px 40px color-mix(in srgb, var(--shadow-ink) 55%, transparent) !important;
  padding: 0 !important;
}

/* Compact player name badges above the cursor (name only — no head/HP/armor). */
body.aipg-squaremap-brand .leaflet-tooltip {
  background: var(--bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--hairline) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 2px 6px !important;
  margin: 0 !important;
  min-width: 0 !important;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
}

body.aipg-squaremap-brand .leaflet-tooltip.aipg-player-nameplate,
body.aipg-squaremap-brand .leaflet-tooltip:not(:has(.aipg-nation-popup)):not(:has(.aipg-map-card)) {
  padding: 2px 6px !important;
}

/* Name badge sits tight above the cursor — no Leaflet tip triangle gap. */
body.aipg-squaremap-brand .leaflet-tooltip.aipg-player-nameplate:before {
  display: none !important;
}

body.aipg-squaremap-brand .leaflet-tooltip-top.aipg-player-nameplate {
  margin-top: 0 !important;
}

body.aipg-squaremap-brand .aipg-player-nameplate__stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1.2;
  text-align: center;
}

body.aipg-squaremap-brand .aipg-player-nameplate__title {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted, var(--muted));
  max-width: 140px;
  word-break: break-word;
}

body.aipg-squaremap-brand .aipg-player-nameplate__name {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  max-width: 140px;
  word-break: break-word;
}

/* Belt-and-suspenders: hide stock Squaremap nameplate chrome if it flashes. */
body.aipg-squaremap-brand .leaflet-tooltip:not(:has(.aipg-nation-popup)) img.head,
body.aipg-squaremap-brand .leaflet-tooltip:not(:has(.aipg-nation-popup)) img.health,
body.aipg-squaremap-brand .leaflet-tooltip:not(:has(.aipg-nation-popup)) img.armor {
  display: none !important;
}

body.aipg-squaremap-brand .leaflet-tooltip:not(:has(.aipg-nation-popup)) ul,
body.aipg-squaremap-brand .leaflet-tooltip:not(:has(.aipg-nation-popup)) li {
  display: inline !important;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

body.aipg-squaremap-brand .leaflet-popup-tip,
body.aipg-squaremap-brand .leaflet-tooltip-top:before,
body.aipg-squaremap-brand .leaflet-tooltip-bottom:before,
body.aipg-squaremap-brand .leaflet-tooltip-left:before,
body.aipg-squaremap-brand .leaflet-tooltip-right:before {
  background: var(--bg) !important;
  border: none !important;
  box-shadow: none !important;
}

body.aipg-squaremap-brand .leaflet-popup-tip {
  background: var(--panel) !important;
  color: var(--panel) !important;
}

/* Shared compact info cards (player click + nation hover/click). */
body.aipg-squaremap-brand .leaflet-tooltip:has(.aipg-nation-popup),
body.aipg-squaremap-brand .leaflet-popup:has(.aipg-nation-popup) .leaflet-popup-content-wrapper {
  background: var(--panel) !important;
  border: 1px solid var(--panel-stroke-strong) !important;
  border-radius: var(--radius) !important;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent),
    0 12px 28px color-mix(in srgb, var(--shadow-ink) 55%, transparent) !important;
  padding: 0 !important;
  min-width: 0 !important;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
}

body.aipg-squaremap-brand .leaflet-tooltip:has(.aipg-nation-popup):before {
  background: var(--panel) !important;
}

body.aipg-squaremap-brand .leaflet-popup-content {
  margin: 0 !important;
  min-width: 0;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.3;
  color: var(--text);
}

/* Click-off only — no X on map info cards. */
body.aipg-squaremap-brand .leaflet-popup-close-button {
  display: none !important;
}

body.aipg-squaremap-brand .aipg-nation-popup {
  padding: 8px 10px;
  background: transparent;
  min-width: 148px;
  max-width: 200px;
}

body.aipg-squaremap-brand .aipg-nation-popup__top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}

body.aipg-squaremap-brand .aipg-nation-popup__face {
  width: 28px !important;
  height: 28px !important;
  flex: 0 0 28px;
  display: block;
  image-rendering: pixelated;
  border: 1px solid var(--hairline);
  background: var(--bg);
}

body.aipg-squaremap-brand .aipg-nation-popup__swatch {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: block;
  border: 1px solid var(--hairline);
  background: var(--accent);
}

body.aipg-squaremap-brand .aipg-nation-popup__meta {
  min-width: 0;
  flex: 1 1 auto;
}

body.aipg-squaremap-brand .aipg-nation-popup__title {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted, var(--muted));
  margin: 0 0 2px;
  line-height: 1.25;
  word-break: break-word;
}

body.aipg-squaremap-brand .aipg-nation-popup__name {
  font-family: var(--font-display);
  font-size: 10px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--text);
  margin: 0;
  word-break: break-word;
}

body.aipg-squaremap-brand .aipg-nation-popup__title + .aipg-nation-popup__name {
  margin-top: 0;
}

body.aipg-squaremap-brand .aipg-nation-popup__gov {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  margin: 3px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

body.aipg-squaremap-brand .aipg-nation-popup__rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

body.aipg-squaremap-brand .aipg-nation-popup__row {
  display: grid;
  grid-template-columns: 4.75em 1fr;
  gap: 6px;
  align-items: baseline;
  margin: 0;
  font-size: 12px;
}

body.aipg-squaremap-brand .aipg-nation-popup__row:last-child {
  margin-bottom: 0;
}

body.aipg-squaremap-brand .aipg-nation-popup__k {
  color: var(--text-muted, var(--muted));
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 0;
}

body.aipg-squaremap-brand .aipg-nation-popup__v {
  color: var(--text);
  font-weight: 500;
  min-width: 0;
  word-break: break-word;
}

/* map113: snap pinned UI transforms ONLY — never blanket `.leaflet-zoom-animated`.
   map112 set `transition:none` on ALL `.leaflet-zoom-animated`, which includes
   Leaflet's tile pane / tile containers. That killed the stock
   `.leaflet-zoom-anim .leaflet-zoom-animated { transition: transform 0.25s }`
   zoom glide → instant zoom switch. Markers/nameplates still snap via the
   selectors below (higher specificity than Leaflet's zoom rule on icons). */
body.aipg-squaremap-brand .leaflet-marker-icon,
body.aipg-squaremap-brand .leaflet-marker-pane img,
body.aipg-squaremap-brand .leaflet-marker-pane svg,
body.aipg-squaremap-brand .leaflet-nameplate-pane,
body.aipg-squaremap-brand .leaflet-nameplate-pane *,
body.aipg-squaremap-brand .leaflet-nameplate-pane img,
body.aipg-squaremap-brand .leaflet-aipgPersonalPane-pane,
body.aipg-squaremap-brand .leaflet-aipgPersonalPane-pane *,
body.aipg-squaremap-brand .leaflet-tooltip.aipg-player-nameplate {
  transition: none !important;
}

/* Opacity-only fade when a nameplate is hidden for an open info card.
   Must NOT re-enable transform (stock Squaremap used transition: all). */
body.aipg-squaremap-brand .leaflet-tooltip.aipg-player-nameplate {
  transition: opacity 0.16s ease !important;
}

body.aipg-squaremap-brand .leaflet-tooltip.aipg-player-nameplate.aipg-nameplate-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Hide Squaremap world sidebar (Overworld / The End). Edge-hover slide-out
   is unused for AIPG — Nations live on Overworld only. */
body.aipg-squaremap-brand #sidebar {
  display: none !important;
}

/* Nations | Players — fixed top-right selector (matches zoom/filter square chrome) */
body.aipg-squaremap-brand .leaflet-control-layers-overlays label.aipg-hide-ai-spawns,
body.aipg-squaremap-brand .aipg-spawn-marker-shell {
  display: none !important;
}

.aipg-top-nations {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--font-ui);
  width: auto;
  max-width: min(260px, calc(100vw - 24px));
  pointer-events: none;
}

.aipg-top-nations > * {
  pointer-events: auto;
}

.aipg-top-nations__tabs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Same chrome as the old single toggle — separate pills, no accent green. */
.aipg-top-nations__tab {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--hairline);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: none;
  box-sizing: border-box;
}

.aipg-top-nations__tab:hover {
  background: var(--bg);
  color: var(--text);
  opacity: 0.82;
}

.aipg-top-nations__tab.is-active {
  background: var(--bg);
  color: var(--text);
  opacity: 1;
}

.aipg-top-nations__panel {
  margin-top: 4px;
  width: min(260px, calc(100vw - 24px));
  max-height: min(380px, calc(100vh - 140px));
  overflow: auto;
  border: 1px solid var(--hairline);
  border-radius: 0;
  background: var(--bg);
  box-shadow: none;
}

.aipg-top-nations__panel[hidden] {
  display: none;
}

.aipg-top-nations__empty,
.aipg-top-nations__err {
  margin: 0;
  padding: 0.55rem 0.65rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.aipg-top-nations__search {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.4rem 0.6rem;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.74rem;
  box-sizing: border-box;
}

.aipg-top-nations__search::placeholder {
  color: var(--muted);
}

.aipg-top-nations__search:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.aipg-top-nations__list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
}

.aipg-top-nations__item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.4rem 0.6rem;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.aipg-top-nations__item:last-child {
  border-bottom: 0;
}

.aipg-top-nations__item:hover,
.aipg-top-nations__item.is-selected {
  background: var(--surface-soft, var(--panel));
}

.aipg-top-nations__row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.aipg-top-nations__swatch,
.aipg-top-nations__head {
  flex: 0 0 auto;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 2px;
  border: 1px solid var(--hairline);
  image-rendering: pixelated;
  background: var(--panel, var(--bg));
  object-fit: cover;
}

.aipg-top-nations__swatch {
  width: 0.65rem;
  height: 0.65rem;
}

.aipg-top-nations__name {
  flex: 1 1 auto;
  font-size: 0.76rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aipg-top-nations__rank {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: var(--muted);
}

.aipg-top-nations__meta {
  margin: 0.2rem 0 0 1.1rem;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.35;
}

.aipg-top-nations__detail {
  margin: 0;
  padding: 0.65rem 0.75rem 0.75rem;
  border-top: 1px solid var(--hairline);
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
}

.aipg-top-nations__detail strong {
  color: var(--text);
  font-weight: 600;
}

/* Keep Squaremap's native top-right controls below the Nations|Players bar */
body.aipg-squaremap-brand .leaflet-top.leaflet-right {
  top: 52px;
}

@media (max-width: 719px) {
  .aipg-top-nations {
    top: 8px;
    right: 8px;
  }

  .aipg-top-nations__panel {
    width: min(260px, calc(100vw - 16px));
  }
}

/*
 * Embed mode (homepage Dual iframe): ?embed=1 or ?aipg_embed=1 sets html.aipg-embed
 * via AIPG_EMBED_BOOT_SCRIPT. Hide custom AIPG overlay chrome only — tiles/pins stay.
 * Bare /map/ (no query) is unchanged.
 */
html.aipg-embed .aipg-top-nations,
html.aipg-embed .aipg-map-join,
html.aipg-embed .leaflet-control-zoom,
html.aipg-embed .leaflet-control-layers.aipg-filter-control,
html.aipg-embed body.aipg-squaremap-brand .leaflet-bottom.leaflet-right {
  display: none !important;
}

/* ------------------------------------------------------------------
   Greatest MC brand soft chrome — UI only, never tiles / terrain.
   Tokens: https://thegreatestmcservers.com/brand.css
   ------------------------------------------------------------------ */
body.aipg-squaremap-brand .leaflet-bar,
body.aipg-squaremap-brand .leaflet-control-layers,
body.aipg-squaremap-brand .leaflet-control-layers-expanded,
body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control,
body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control .leaflet-control-layers-toggle,
.aipg-top-nations__tab,
.aipg-top-nations__panel,
.aipg-top-nations__search,
.aipg-map-join__panel,
.aipg-map-join__info,
.aipg-map-ctx,
.aipg-map-ctx__btn,
body.aipg-squaremap-brand .leaflet-popup-content-wrapper,
body.aipg-squaremap-brand .leaflet-tooltip:has(.aipg-nation-popup),
body.aipg-squaremap-brand .leaflet-popup:has(.aipg-nation-popup) .leaflet-popup-content-wrapper {
  border-radius: var(--radius-btn, 10px) !important;
}

body.aipg-squaremap-brand .leaflet-bar a:first-child {
  border-top-left-radius: var(--radius-btn, 10px) !important;
  border-top-right-radius: var(--radius-btn, 10px) !important;
}
body.aipg-squaremap-brand .leaflet-bar a:last-child {
  border-bottom-left-radius: var(--radius-btn, 10px) !important;
  border-bottom-right-radius: var(--radius-btn, 10px) !important;
}

/* Quiet solid fills — map stays visible underneath minimal chrome */
.aipg-top-nations__tab,
.aipg-top-nations__panel,
.aipg-top-nations__search,
.aipg-map-join__panel,
.aipg-map-join__info,
.aipg-map-ctx,
body.aipg-squaremap-brand .leaflet-bar a,
body.aipg-squaremap-brand .leaflet-bar a:focus,
body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control .leaflet-control-layers-toggle {
  background: var(--surface-solid, var(--panel, #0a0c0e)) !important;
  background-color: var(--surface-solid, var(--panel, #0a0c0e)) !important;
  color: var(--text, var(--ink, #f4f6fa)) !important;
  border-color: var(--hairline, var(--line)) !important;
  box-shadow: none !important;
  font-family: var(--font-ui) !important;
  font-weight: 600;
}

.aipg-top-nations__tab.is-active {
  background: var(--panel-2, var(--surface-raised, #12151a)) !important;
  background-color: var(--panel-2, var(--surface-raised, #12151a)) !important;
}

.aipg-map-ctx__title,
body.aipg-squaremap-brand .aipg-nation-popup__name,
.aipg-top-nations__name,
.aipg-player-nameplate__name {
  font-family: var(--font-display) !important;
}

/* Slight brightness hover — brand motion, not glow */
.aipg-top-nations__tab:hover,
.aipg-map-join__info:hover,
.aipg-map-ctx__btn:hover,
body.aipg-squaremap-brand .leaflet-bar a:hover,
body.aipg-squaremap-brand .leaflet-control-layers.aipg-filter-control .leaflet-control-layers-toggle:hover {
  filter: brightness(1.08);
  opacity: 1 !important;
}
