:root {
  color-scheme: dark;
  --bg: #17120f;
  --panel: rgba(37, 28, 20, 0.92);
  --panel-border: rgba(219, 181, 115, 0.18);
  --panel-strong: rgba(250, 214, 147, 0.32);
  --text: #f5eddc;
  --muted: #c4b39b;
  --accent: #f2c76b;
  --accent-strong: #ffdc91;
  --danger: #ff8c69;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must always win, even against display rules on the
   same element (an element with both `hidden` and `display: flex` would
   otherwise stay visible - the alliance badge "--" bug). */
[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #120e0c;
  overscroll-behavior: none;
}

body {
  font-family: "Trebuchet MS", Verdana, sans-serif;
  color: var(--text);
  background-color: #120e0c;
  background:
    radial-gradient(circle at top, rgba(93, 71, 46, 0.45), transparent 40%),
    linear-gradient(180deg, #2f241a 0%, #17120f 45%, #120e0c 100%);
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
}

.map-shell {
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: 0 18px 50px var(--shadow);
  backdrop-filter: blur(10px);
}

.brand-panel,
.session-panel,
.details-panel {
  padding: 16px;
  width: 100%;
  min-width: 0;
  flex-shrink: 0;
}

.map-panel {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  --shadow: none;
  background:
    linear-gradient(180deg, rgba(24, 38, 24, 0.2), rgba(10, 14, 11, 0.65)),
    #111;
}

#map-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.map-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(18, 18, 18, 0.48);
  backdrop-filter: grayscale(0.35) blur(2px);
  color: var(--text);
  text-align: center;
  font-size: clamp(20px, 2.1vw, 30px);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  z-index: 6;
}

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

.map-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.08), transparent 58%),
    rgba(14, 12, 10, 0.26);
}

.map-overlay-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: min(640px, 100%);
  padding: 28px 32px;
  border-radius: 22px;
  background: rgba(56, 56, 56, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.38);
}

.map-overlay-progress {
  width: min(420px, 100%);
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

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

.map-overlay-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 220ms ease;
}

.map-coordinates {
  position: absolute;
  left: 18px;
  bottom: 18px;
  max-width: calc(100% - 36px);
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(14, 12, 10, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.04em;
  z-index: 2;
  transition: left 180ms ease, max-width 180ms ease;
}

.mobile-details-sheet {
  display: none;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--accent);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  font-size: 20px;
  line-height: 1.1;
}

.muted {
  color: var(--muted);
}

.notice {
  margin-top: 8px;
  color: #ffd8b4;
  font-size: 13px;
  line-height: 1.45;
}

.server-panel {
  display: grid;
  gap: 10px;
}

.server-custom-field span {
  font-size: 13px;
  color: var(--muted);
}

.server-select,
.server-custom-field input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(10, 9, 8, 0.55);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  touch-action: manipulation;
}

.server-custom-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
}

.server-custom-fields[hidden] {
  display: none !important;
}

.server-custom-field {
  display: grid;
  gap: 6px;
}

.session-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.login-form[hidden],
#session-status[hidden],
.secondary-button[hidden] {
  display: none !important;
}

.session-panel.signed-in .login-form,
.session-panel.signed-in #session-status {
  display: none;
}

#session-status {
  margin-top: 12px;
  line-height: 1.4;
}

.login-form {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.login-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.login-form input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(10, 9, 8, 0.55);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  touch-action: manipulation;
}

.map-tool-bar {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: calc(100% - 36px);
  z-index: 3;
}

.map-search-panel,
.map-filter-anchor {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(18, 13, 10, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.map-search-panel {
  position: relative;
  width: min(360px, calc(100vw - 180px));
  min-width: min(280px, calc(100vw - 120px));
}

.map-search-content {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.map-tool-toggle-button {
  display: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 14px;
  background: rgba(14, 12, 10, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  color: var(--text);
  touch-action: manipulation;
}

.map-tool-toggle-button:hover,
.map-tool-toggle-button:focus-visible {
  background: rgba(36, 28, 20, 0.96);
  border-color: rgba(255, 255, 255, 0.18);
}

.map-tool-toggle-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  display: block;
}

.map-filter-anchor {
  position: relative;
  width: 200px;
}

.filter-menu-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tool-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 45px;
  padding: 11px 12px;
  white-space: nowrap;
  touch-action: manipulation;
}

.filter-toggle-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

.tool-toggle-button.active {
  border-color: var(--panel-strong);
  background: rgba(242, 199, 107, 0.18);
}

.search-shell {
  position: relative;
  margin-top: 0;
}

.search-input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(10, 9, 8, 0.55);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  touch-action: manipulation;
}

.search-input:focus,
.search-input:focus-visible {
  outline: none;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.search-input:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(18, 13, 10, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.34);
  max-height: min(70vh, 640px);
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 6;
  opacity: 0;
  transform: translateY(-10px);
  transform-origin: top center;
  pointer-events: none;
  transition: opacity 160ms ease, transform 180ms ease, height 180ms ease;
}

.search-results.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.search-results.closing {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

.search-results[hidden],
.filter-menu[hidden] {
  display: none !important;
}

.filter-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(420px, calc(100vw - 36px));
  padding: 14px;
  border-radius: 16px;
  background: rgba(18, 13, 10, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.34);
  z-index: 5;
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 160ms ease, transform 180ms ease;
}

.filter-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.filter-menu.closing {
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  pointer-events: none;
}

.filter-section {
  margin-top: 14px;
}

.filter-section.disabled .filter-section-title {
  color: rgba(196, 179, 155, 0.62);
}

.filter-section-title {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
}

.filter-player-input {
  width: 100%;
}

.filter-player-shell {
  width: 100%;
}

.filter-player-shell.disabled,
.filter-options.disabled {
  opacity: 0.48;
}

.filter-player-results {
  z-index: 7;
  max-height: min(32vh, 320px);
}

.filter-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-level-range {
  display: grid;
  gap: 10px;
}

.filter-level-range.disabled {
  opacity: 0.48;
}

.filter-level-range-values {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.filter-level-range-value {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 12px;
}

.filter-level-range-track {
  position: relative;
  height: 24px;
}

.filter-level-range-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-50%);
}

.filter-level-range-fill {
  position: absolute;
  top: 50%;
  height: 4px;
  border-radius: 999px;
  background: rgba(242, 199, 107, 0.7);
  transform: translateY(-50%);
  pointer-events: none;
}

.filter-level-slider {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  pointer-events: none;
}

.filter-level-slider::-webkit-slider-runnable-track {
  height: 24px;
  background: transparent;
}

.filter-level-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border-radius: 999px;
  background: rgba(250, 214, 147, 0.95);
  border: 1px solid rgba(71, 49, 23, 0.82);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  pointer-events: auto;
}

.filter-level-slider::-moz-range-track {
  height: 24px;
  background: transparent;
  border: 0;
}

.filter-level-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(250, 214, 147, 0.95);
  border: 1px solid rgba(71, 49, 23, 0.82);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  pointer-events: auto;
}

.filter-menu-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.filter-match-count {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.filter-chip.disabled {
  opacity: 0.58;
  cursor: default;
}

.filter-chip input {
  margin: 0;
  accent-color: var(--accent);
}

.filter-chip.active {
  border-color: var(--panel-strong);
  background: rgba(242, 199, 107, 0.12);
}

.search-result {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.search-result:hover,
.search-result.active {
  border-color: var(--panel-strong);
  background: rgba(242, 199, 107, 0.12);
}

.search-result-icon {
  width: 52px;
  height: 52px;
  object-fit: contain;
  display: block;
}

.search-result-main {
  min-width: 0;
}

.search-result-name,
.search-result-meta {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-name {
  color: var(--text);
}

.search-result-meta,
.search-result-distance {
  color: var(--muted);
  font-size: 12px;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
}

.primary-button {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #24160a;
  font-weight: 700;
  padding: 11px 14px;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  padding: 9px 12px;
}

.map-controls {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 8px;
  z-index: 2;
}

.icon-button {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.map-control-button {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(14, 12, 10, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.map-control-button::before,
.map-control-button::after {
  position: absolute;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

.map-control-button::before {
  content: attr(data-tooltip);
  bottom: calc(100% + 12px);
  transform: translate(-50%, 6px);
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(20, 16, 12, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.map-control-button::after {
  content: "";
  bottom: calc(100% + 4px);
  transform: translate(-50%, 6px);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid rgba(20, 16, 12, 0.94);
}

.map-control-button:hover::before,
.map-control-button:hover::after,
.map-control-button:focus-visible::before,
.map-control-button:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

.map-control-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  display: block;
  margin: 0 auto;
}

.map-control-button.loading svg {
  animation: map-control-spin 1s linear infinite;
}

.map-control-cooldown {
  position: absolute;
  left: 50%;
  bottom: -6px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(242, 199, 107, 0.94);
  color: #24160a;
  opacity: 0;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transform: translate(-50%, 4px) scale(0.9);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 1;
}

.map-control-button.cooling-down:hover .map-control-cooldown,
.map-control-button.cooling-down:focus-visible .map-control-cooldown {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

@keyframes map-control-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.world-list,
.leaderboard-list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.leaderboard-panel {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.leaderboard-list {
  width: 100%;
  min-width: 0;
  gap: 6px;
  max-height: min(34vh, 360px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: none;
  align-content: start;
}

.leaderboard-list::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.world-card,
.leaderboard-row {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 10px 12px;
}

.world-card {
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.world-card.active {
  border-color: var(--panel-strong);
  background: rgba(242, 199, 107, 0.12);
}

.world-card.viewing {
  border-color: rgba(90, 169, 255, 0.55);
}

.world-card-meta {
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.world-card-meta.viewing {
  color: #7db9ff;
}

/* Signed-in identity block (replaces the account button when signed in) */
.session-signed-in {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* display:flex would otherwise defeat the hidden attribute, leaking the
   "Signed in as:" text and Log out button into the signed-out toolbar. */
.session-signed-in[hidden] {
  display: none;
}

.session-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.session-signed-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.session-name-display {
  font-weight: 700;
  color: var(--accent-strong);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-toast {
  position: fixed;
  top: 64px;
  right: 16px;
  z-index: 90;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(30, 25, 16, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.session-toast.visible {
  opacity: 1;
}

.session-toast.error {
  border-color: rgba(210, 84, 84, 0.5);
  color: #ffb59f;
}

/* Alliance panel: its menu is roomier than the standard toolbar popups. */
#menu-alliance {
  width: min(580px, 94vw);
  max-height: min(90vh, 940px);
}

.alliance-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.alliance-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.alliance-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-strong);
}

.alliance-member-count {
  margin: 2px 0 0;
  font-size: 12px;
}

.alliance-leave {
  flex-shrink: 0;
}

.alliance-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.alliance-tab {
  position: relative;
  flex: 1;
  padding: 7px 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.alliance-tab:hover {
  color: var(--text);
}

.alliance-tab.active {
  background: rgba(242, 199, 107, 0.16);
  color: var(--accent-strong);
  font-weight: 700;
}

.alliance-tab.unread::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.alliance-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alliance-section[hidden] {
  display: none;
}

.alliance-members {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(48vh, 420px);
  overflow-y: auto;
}

.alliance-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
}

.alliance-member-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.04);
}

.alliance-roster-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
}

.alliance-roster-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.04);
}

.alliance-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.alliance-identity-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}

.alliance-identity-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.alliance-rank-pill {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid;
  flex-shrink: 0;
}

.alliance-rank-pill.rank-leader {
  background: rgba(242, 199, 107, 0.18);
  border-color: rgba(242, 199, 107, 0.4);
  color: var(--accent-strong);
}

.alliance-rank-pill.rank-officer {
  background: rgba(122, 176, 255, 0.14);
  border-color: rgba(122, 176, 255, 0.4);
  color: #9cc3ff;
}

.alliance-rank-pill.rank-member {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.alliance-rank-pill.rank-recruit {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--muted);
}

.alliance-row-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.alliance-enemy-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(210, 84, 84, 0.1);
  border: 1px solid rgba(210, 84, 84, 0.3);
}

.alliance-enemy-group-title {
  color: var(--danger);
  font-weight: 700;
  font-size: 13px;
}

.alliance-badge[hidden] {
  /* The display rule below would otherwise override the hidden attribute,
     leaving an empty pill that reads as a "--" mark after unread clears. */
  display: none;
}

.alliance-badge {
  display: inline-block;
  min-width: 16px;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(242, 199, 107, 0.9);
  color: #241d10;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  vertical-align: 1px;
}

.alliance-badge.invite {
  background: #d25454;
  color: #fff;
}

.alliance-feed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(58vh, 520px);
  overflow-y: auto;
}

.alliance-feed-row {
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  cursor: pointer;
}

.alliance-feed-row:hover {
  background: rgba(255, 255, 255, 0.09);
}

.alliance-feed-row strong {
  color: var(--accent);
}

.alliance-feed-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.alliance-chat-meta {
  color: var(--muted);
  font-size: 11px;
}

.alliance-leader-tag {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(242, 199, 107, 0.18);
  border: 1px solid rgba(242, 199, 107, 0.4);
  color: var(--accent-strong);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.alliance-row-button {
  padding: 3px 10px;
  font-size: 12px;
  flex-shrink: 0;
}

.alliance-invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.alliance-invite-row span {
  flex: 1;
}

.alliance-pending,
.alliance-hint {
  margin: 0;
  font-size: 12px;
}

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

.alliance-form-row input {
  flex: 1;
  min-width: 0;
}

.alliance-chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: min(60vh, 560px);
  overflow-y: auto;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.alliance-chat-line strong {
  color: var(--accent);
}

.alliance-chat-time {
  margin-left: 6px;
  font-size: 11px;
  color: var(--muted);
}

.alliance-enemy-heading {
  margin-top: 6px;
  color: var(--danger);
}

.alliance-enemy-name {
  color: var(--danger);
}

.alliance-status {
  margin: 0;
  min-height: 1em;
  color: var(--danger);
}

/* Player profile photo */
.profile-photo {
  display: block;
  width: 72px;
  height: 72px;
  margin: 8px 0;
  border-radius: 12px;
  border: 1px solid var(--panel-strong);
  object-fit: cover;
  background: rgba(0, 0, 0, 0.3);
}

.leaderboard-row {
  display: grid;
  /* rank | jump | name | outposts */
  grid-template-columns: 28px 30px minmax(0, 1fr) 92px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: none;
}

.leaderboard-row > * {
  min-width: 0;
}

.leaderboard-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(56, 42, 29, 0.96);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.leaderboard-rank {
  text-align: center;
}

.leaderboard-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-count {
  text-align: right;
  white-space: nowrap;
}

.details-content {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.details-panel {
  overflow: hidden;
  transition: height 180ms ease;
}

.mobile-details-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mobile-details-close-button {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  background: rgba(14, 12, 10, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.mobile-details-close-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
}

.credits-panel {
  margin-top: auto;
}

.credits-copy {
  font-size: 13px;
  line-height: 1.5;
}

.credits-link {
  color: var(--accent-strong);
  text-decoration: none;
}

.credits-link:hover,
.credits-link:focus-visible {
  text-decoration: underline;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.detail-label {
  color: #e9c98a;
}

@media (max-width: 1000px) and (min-width: 901px) {
  .map-shell {
    padding: 18px;
  }

  .map-panel {
    min-height: 58vh;
  }

  .map-tool-bar {
    left: 18px;
    right: 18px;
    flex-direction: column;
    align-items: flex-end;
  }

  .map-search-panel,
  .map-filter-anchor {
    width: auto;
    min-width: 0;
  }

  .map-search-panel {
    width: min(360px, calc(100vw - 36px));
    min-width: min(280px, calc(100vw - 112px));
  }

  .map-filter-anchor {
    width: 200px;
    min-width: 200px;
  }

  .server-custom-fields {
    grid-template-columns: 1fr;
  }

  .filter-menu {
    width: min(420px, calc(100vw - 36px));
  }
}

@media (max-width: 900px) {
  .details-panel {
    display: none;
  }

  .map-shell {
    padding: 0;
  }

  .map-panel {
    min-height: 100%;
    border: 0;
    border-radius: 0;
  }

  .map-tool-bar {
    top: 16px;
    right: 16px;
    left: 16px;
    width: auto;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    max-width: none;
  }

  .map-search-panel,
  .map-filter-anchor {
    width: auto;
    min-width: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  .map-filter-anchor {
    transition: opacity 160ms ease, transform 180ms ease;
  }

  .map-search-panel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    min-height: 48px;
    overflow: visible;
  }

  .map-search-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(18, 13, 10, 0.92);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(8px);
    opacity: 0;
    transform: scaleX(0.14);
    transform-origin: top right;
    pointer-events: none;
    will-change: transform, opacity;
    transition: transform 180ms ease, opacity 120ms ease;
  }

  .map-search-content {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 58px;
    display: flex;
    align-items: center;
    pointer-events: none;
    opacity: 0;
    overflow: visible;
    transform: translateX(16px);
    will-change: opacity, transform;
    transition: opacity 160ms ease, transform 180ms ease;
  }

  #app.mobile-search-open .map-search-panel::before {
    opacity: 1;
    transform: scaleX(1);
  }

  #app.mobile-search-open .map-search-content {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  #app.mobile-search-open .map-filter-anchor {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(0.96);
  }

  .map-tool-toggle-button {
    display: inline-flex;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
  }

  .map-tool-toggle-button,
  .tool-toggle-button {
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background: rgba(14, 12, 10, 0.82);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  }

  .tool-toggle-button {
    gap: 0;
  }

  .tool-toggle-button.active {
    border-color: rgba(242, 199, 107, 0.34);
    background: rgba(32, 24, 18, 0.94);
    box-shadow:
      0 8px 24px rgba(0, 0, 0, 0.24),
      0 0 0 1px rgba(242, 199, 107, 0.08);
    color: rgba(250, 214, 147, 0.9);
  }

  .map-search-content .eyebrow,
  .map-filter-anchor > .eyebrow {
    display: none;
  }

  .map-search-panel .search-shell {
    width: 100%;
    position: static;
    height: 100%;
    display: flex;
    align-items: center;
  }

  .filter-player-shell {
    position: relative;
    display: block;
    height: auto;
  }

  .search-results {
    max-height: calc(100dvh - 168px - env(safe-area-inset-bottom, 0px));
    transform-origin: top right;
  }

  .map-control-button::before,
  .map-control-button::after,
  .map-coordinates {
    display: none !important;
  }

  .map-search-panel .search-input {
    height: 48px;
    padding-top: 0;
    padding-bottom: 0;
  }

  .filter-toggle-label {
    display: none;
  }

  .filter-menu {
    top: calc(100% + 8px);
    right: 0;
    width: min(420px, calc(100vw - 32px));
    max-height: calc(100dvh - 148px);
    overflow-y: auto;
  }

  .server-custom-fields {
    grid-template-columns: 1fr;
  }

  .server-select,
  .server-custom-field input,
  .login-form input {
    font-size: 16px;
  }

  .map-coordinates {
    bottom: 16px;
    max-width: calc(100% - 36px);
  }

  .map-controls {
    right: 16px;
    bottom: 16px;
  }

  .map-control-button {
    transition: opacity 160ms ease, transform 180ms ease;
  }

  .mobile-details-sheet {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    display: block;
    overflow: hidden;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    z-index: 4;
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(100% + 24px));
    transition: opacity 180ms ease, transform 220ms ease, height 220ms ease;
  }

  .mobile-details-content {
    max-height: min(42dvh, 360px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #app.mobile-details-open .mobile-details-sheet {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  #app.mobile-details-open #refresh-button,
  #app.mobile-details-open #find-home-button {
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.92);
  }

  #zoom-out-button,
  #zoom-in-button {
    display: none;
  }
}


/* --- Navigate / bookmarks / highlights panels --- */
.jump-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.jump-field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.jump-field input,
.bookmark-add-row input,
.highlight-field textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.24);
  color: inherit;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}

.jump-field input:disabled,
.bookmark-add-row input:disabled,
.highlight-field textarea:disabled {
  opacity: 0.5;
}

.jump-button {
  padding: 8px 14px;
}

.nav-help {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.bookmark-eyebrow {
  margin-top: 16px;
}

.bookmark-add-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.bookmark-list {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.bookmark-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: stretch;
}

.bookmark-jump {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.bookmark-jump:hover {
  background: rgba(255, 255, 255, 0.1);
}

.bookmark-jump .bookmark-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-jump .bookmark-coords {
  color: var(--muted);
  white-space: nowrap;
}

.bookmark-delete {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border-radius: 10px;
  padding: 0 10px;
  font: inherit;
  cursor: pointer;
}

.bookmark-delete:hover {
  background: rgba(255, 90, 70, 0.25);
  color: #ffd7d0;
}

.bookmark-empty {
  color: var(--muted);
  font-size: 12px;
}

.highlight-field {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.highlight-field textarea {
  resize: vertical;
  min-height: 44px;
}

.highlight-label {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.highlight-label-yellow {
  /* Allies: bright blue with a green tint */
  color: #4fdbe8;
}

.highlight-label-red {
  color: #ff5c4a;
}


/* --- Measure tool --- */
.measure-button {
  margin-top: 10px;
  width: 100%;
}

.measure-button.active {
  border-color: rgba(255, 170, 60, 0.8);
  color: #ffd9a0;
  background: rgba(255, 170, 60, 0.12);
}

/* --- World scan --- */
.scan-intro {
  margin-top: 8px;
}

.scan-panel .secondary-button {
  margin-top: 10px;
  width: 100%;
}

.scan-progress {
  margin-top: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.scan-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #58c7f0, #7be3a8);
  transition: width 0.25s ease;
}

/* --- Watchlist activity --- */
.watch-toggle {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.watch-toggle input {
  margin-top: 2px;
}

.watch-group {
  margin-top: 12px;
}

.watch-heading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.watch-heading-yellow {
  /* Allies: bright blue with a green tint */
  color: #4fdbe8;
}

.watch-heading-red {
  color: #ff5c4a;
}

.watch-subheading {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.watch-list {
  margin-top: 4px;
  display: grid;
  gap: 4px;
}

.watch-empty {
  font-size: 12px;
  color: var(--muted);
}

.watch-event {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.35;
}

.watch-event:hover {
  background: rgba(255, 255, 255, 0.09);
}

.watch-event .watch-time {
  color: var(--muted);
}

.watch-clear {
  margin-top: 12px;
  width: 100%;
}

/* --- Details panel actions + player profile --- */
.detail-actions {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.detail-actions .secondary-button {
  width: 100%;
}

.profile-back {
  margin-bottom: 10px;
}

.profile-base-list {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.profile-base {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.profile-base:hover {
  background: rgba(255, 255, 255, 0.1);
}

.profile-base .profile-base-meta {
  color: var(--muted);
  white-space: nowrap;
}

/* --- Fixed-server world display --- */
.world-name {
  margin-top: 6px;
  font-size: 18px;
  word-break: break-word;
}

.world-help {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
}

/* Status lines for the map search panel and filter menu footer. */
.search-status {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.filter-status {
  margin-bottom: 6px;
}

@media (max-width: 900px) {
  /* The mobile search panel is a single compact row; keep the status line
     out of it. */
  .map-search-content .search-status {
    display: none;
  }
}

/* =====================================================================
   TOOLBAR LAYOUT
   The chrome now lives in a top toolbar with dropdown menus; these rules
   supersede the old sidebar / floating-panel layout.
   ===================================================================== */

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 4px 8px;
  background: linear-gradient(180deg, rgba(34, 28, 18, 0.98), rgba(26, 21, 13, 0.98));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  z-index: 60;
}

.toolbar-brand {
  flex: 0 0 auto;
  display: flex;
  /* Title stacked over the server name, pinned to the far left */
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  padding: 0 12px 0 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.toolbar-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.4px;
  color: var(--text);
}

.toolbar-world {
  font-size: 11px;
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-scroll {
  display: flex;
  align-items: center;
  /* Middle zone: the groups sit centred between the brand (left) and the
     account cluster (right). Growing claims the space between them; the
     centring only shows once there is slack, so on narrow screens the row
     simply scrolls from the left as before. */
  justify-content: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
}

.tb-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

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

.tb-group + .tb-group {
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.toolbar-actions {
  /* Never let the action cluster be squeezed by flex layout */
  flex: 0 0 auto;
  /* Far right zone: session identity / log in / log out */
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.tb-item {
  position: relative;
  flex: none;
}

.tb-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 600 12.5px/1 "Segoe UI", sans-serif;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
}

.tb-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

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

.tb-button.active,
.tb-item.open > .tb-button {
  background: rgba(242, 199, 107, 0.22);
  border-color: rgba(242, 199, 107, 0.55);
}

.tb-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* flex items default to min-width:auto and can be crushed to glyph width;
     an explicit min-width is the guaranteed floor */
  flex: 0 0 56px;
  width: 56px;
  min-width: 56px;
  min-height: 40px;
  padding: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  position: relative;
}

.tb-icon-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.tb-account-button {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dropdown menus */
.tb-menu {
  display: none;
  position: fixed;
  width: 330px;
  max-height: min(72vh, 620px);
  overflow-y: auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(30, 25, 16, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  z-index: 70;
}

.tb-item.open > .tb-menu {
  display: block;
}

/* .tb-menu-right alignment is handled in JS (right edge under the button). */

/* Search menu: results flow in the menu itself so there is one large scroll
   area instead of a nested dropdown trapped in a small box. */
.map-search-panel > .tb-menu {
  width: 380px;
}

.map-search-panel .search-results {
  position: static;
  top: auto;
  left: auto;
  right: auto;
  max-height: none;
  overflow: visible;
  margin-top: 10px;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}

.tb-menu .eyebrow {
  margin-top: 0;
}

/* Loot menu (administrators only). */
#menu-loot {
  width: 220px;
}
.loot-check,
.loot-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 2px;
  font-size: 13px;
  color: #e8e2d4;
  cursor: pointer;
}
.loot-check input,
.loot-radio input {
  accent-color: #ffd97a;
  cursor: pointer;
  margin: 0;
}
.loot-resource-eyebrow {
  margin-top: 12px;
}
.loot-resource-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.leaderboard-eyebrow {
  margin-top: 14px;
}

/* Search + filter items live in the toolbar now: undo the old floating
   placement and let the shared dropdown styling take over. */
.toolbar .map-search-panel,
.toolbar .map-filter-anchor {
  /* CRITICAL: the legacy floating-panel rule applies backdrop-filter, and a
     backdrop-filter (or transform/filter) ancestor becomes the containing
     block for position:fixed descendants -- which re-clips the dropdowns
     inside the scrollable toolbar. These must stay disabled here. */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: none;
  filter: none;
  position: relative;
  inset: auto;
  top: auto;
  left: auto;
  right: auto;
  width: auto;
  max-width: none;
  /* The legacy floating-panel rules also set a min-width (280px for search,
     200px for the filter anchor at <=1200px) and a min-height. Left in place
     those stretch the toolbar item far past its button, which showed up as a
     dead gap between "Search" and the "| Alliance" group separator. */
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  background: none;
  border: 0;
  box-shadow: none;
  display: block;
}

.toolbar .map-filter-anchor > .eyebrow {
  display: none;
}

.toolbar .map-search-panel::before {
  content: none;
}

.toolbar .filter-menu {
  position: fixed;
  right: auto;
  width: 350px;
  max-height: min(72vh, 640px);
  overflow-y: auto;
  z-index: 70;
}

/* Session menu */
.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.session-panel.signed-in .login-form {
  display: none;
}

.credits-copy {
  margin-top: 12px;
  font-size: 11px;
}

/* Details card floats over the map, top-right */
.map-shell {
  flex: 1;
  min-height: 0;
  display: block;
  padding: 0;
}

.map-panel {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 0;
}

#map-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.map-panel .details-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 300px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  z-index: 40;
}

/* Watch scope */
.watch-scope-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.watch-scope-select {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
}

.profile-activity {
  margin-top: 6px;
}

.home-button {
  width: 100%;
  margin-bottom: 8px;
}

.bookmark-eyebrow {
  margin-top: 16px;
}

/* Mobile: toolbar scrolls horizontally; menus become full-width sheets */
@media (max-width: 900px) {
  .toolbar {
    padding: 6px;
    gap: 6px;
  }

  .toolbar-brand {
    display: none;
  }

  .tb-menu,
  .toolbar .filter-menu {
    position: fixed;
    top: 58px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: calc(100dvh - 74px);
  }

  .map-panel .details-panel {
    display: none;
  }
}

/* Announcement banner (set by administrators at /setup/) */
.announcement-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: rgba(242, 199, 107, 0.14);
  border-bottom: 1px solid rgba(242, 199, 107, 0.35);
  color: #f5dda6;
  font-size: 13px;
  z-index: 55;
}

/* The banner sets display:flex, which otherwise overrides the [hidden]
   attribute's default display:none - so hiding it from JS (banner.hidden =
   true, e.g. the dismiss X) would have no visible effect without this. */
.announcement-banner[hidden] {
  display: none;
}

.announcement-banner span {
  flex: 1;
}

.announcement-banner button {
  appearance: none;
  border: 0;
  background: none;
  color: inherit;
  font-size: 17px;
  cursor: pointer;
  padding: 0 4px;
}

/* Bottom-right corner buttons (help for everyone, settings for admins). */
.corner-buttons {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.corner-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--panel-strong);
  background: var(--panel);
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
}

.corner-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

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

.corner-button .map-control-cooldown {
  bottom: auto;
  top: 50%;
  left: -8px;
  transform: translate(-100%, -50%) scale(0.9);
}

.corner-button.cooling-down:hover .map-control-cooldown,
.corner-button.cooling-down:focus-visible .map-control-cooldown {
  opacity: 1;
  transform: translate(-100%, -50%) scale(1);
}

.corner-button:hover {
  background: rgba(58, 45, 30, 0.95);
}

.help-panel {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 7, 5, 0.6);
}

.help-panel-inner {
  width: min(640px, 92vw);
  max-height: min(84vh, 780px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-strong);
  border-radius: 12px;
  box-shadow: 0 10px 40px var(--shadow);
}

.help-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 8px;
}

.help-panel-header h2 {
  margin: 0;
}

.help-panel-body {
  padding: 0 18px 18px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.55;
}

.help-panel-body h3 {
  color: var(--accent);
  margin: 14px 0 4px;
  font-size: 13px;
}

.help-panel-body p {
  margin: 4px 0;
  color: var(--text);
}

#hide-request-reason {
  width: 100%;
  margin: 6px 0;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(20, 15, 11, 0.7);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.filter-inactivity-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
  margin-bottom: 6px;
  cursor: pointer;
}

/* Native select dropdowns: translucent backgrounds composite over the OS's
   white popup surface, producing light-on-light option lists. Opaque colors
   keep both the closed box and the options popup readable. */
select {
  background-color: #241c13;
  color: var(--text);
}

select option {
  background-color: #241c13;
  color: var(--text);
}


/* Alliance roster formatting */
.alliance-identity-name.enemy-name {
  color: #ff8d7d;
}

.alliance-identity-tag {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

/* Leaderboard jump buttons */
.leaderboard-jump {
  flex: none;
  width: 26px;
  height: 22px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
}

.leaderboard-jump:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.leaderboard-jump:disabled {
  opacity: 0.4;
  cursor: default;
}


/* Base viewer popup (View Yard / View Outpost) */
.base-view-backdrop {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
}

.base-view-window {
  /* Absolute so the user can drag and resize it; JS supplies the geometry
     (restored from the saved layout, else centred at 90vw x 90vh). */
  position: absolute;
  width: 90vw;
  height: 90vh;
  min-width: 360px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  background: #101c10;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.6);
}

/* Header doubles as the drag bar (buttons inside stay clickable) */
.base-view-header {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.base-view-window.dragging .base-view-header {
  cursor: grabbing;
}

.base-view-header-buttons,
.base-view-title {
  cursor: default;
}

/* Resize grips: edges and corners */
.base-view-resize {
  position: absolute;
  z-index: 3;
  touch-action: none;
}

.base-view-resize[data-dir="e"],
.base-view-resize[data-dir="w"] {
  top: 10px;
  bottom: 10px;
  width: 8px;
  cursor: ew-resize;
}

.base-view-resize[data-dir="n"],
.base-view-resize[data-dir="s"] {
  left: 10px;
  right: 10px;
  height: 8px;
  cursor: ns-resize;
}

.base-view-resize[data-dir="e"] { right: 0; }
.base-view-resize[data-dir="w"] { left: 0; }
.base-view-resize[data-dir="n"] { top: 0; }
.base-view-resize[data-dir="s"] { bottom: 0; }

.base-view-resize[data-dir="ne"],
.base-view-resize[data-dir="nw"],
.base-view-resize[data-dir="se"],
.base-view-resize[data-dir="sw"] {
  width: 16px;
  height: 16px;
}

.base-view-resize[data-dir="ne"] { top: 0; right: 0; cursor: nesw-resize; }
.base-view-resize[data-dir="nw"] { top: 0; left: 0; cursor: nwse-resize; }
.base-view-resize[data-dir="se"] { bottom: 0; right: 0; cursor: nwse-resize; }
.base-view-resize[data-dir="sw"] { bottom: 0; left: 0; cursor: nesw-resize; }

/* Visible grip in the bottom-right corner */
.base-view-resize[data-dir="se"]::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(255, 255, 255, 0.35);
  border-bottom: 2px solid rgba(255, 255, 255, 0.35);
  border-bottom-right-radius: 3px;
}

/* While dragging or resizing, the canvas must not swallow the pointer */
.base-view-window.dragging .base-view-canvas-shell,
.base-view-window.resizing .base-view-canvas-shell {
  pointer-events: none;
}

.base-view-reset-layout {
  flex: none;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font: 600 12px/1 "Segoe UI", sans-serif;
  white-space: nowrap;
  cursor: pointer;
}

.base-view-reset-layout:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.base-view-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  background: linear-gradient(180deg, rgba(34, 28, 18, 0.98), rgba(26, 21, 13, 0.98));
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.base-view-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.base-view-close {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.base-view-close:hover {
  background: rgba(255, 92, 74, 0.25);
  border-color: rgba(255, 92, 74, 0.5);
}

.base-view-canvas-shell {
  position: relative;
  flex: 1;
  min-height: 0;
}

.base-view-canvas {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: grab;
}

.base-view-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.base-view-status.error {
  color: #ff8d7d;
}


.base-view-header-buttons {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.base-view-anim-toggle {
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(242, 199, 107, 0.5);
  background: rgba(242, 199, 107, 0.18);
  color: var(--text);
  font: 600 12px/1 "Segoe UI", sans-serif;
  white-space: nowrap;
  cursor: pointer;
}

.base-view-anim-toggle.off {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.base-view-anim-toggle:hover {
  background: rgba(242, 199, 107, 0.3);
}

.base-view-anim-toggle.off:hover {
  background: rgba(255, 255, 255, 0.12);
}


/* ── Draggable cell panel ──────────────────────────────────────────────
   The panel starts docked top-right; dragging the handle switches it to
   explicit left/top coordinates (set inline by JS) and it stays where the
   user put it for the session. */
.details-drag-handle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -6px -6px 6px;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.details-drag-handle:hover {
  background: rgba(255, 255, 255, 0.05);
}

.details-panel.dragging .details-drag-handle {
  cursor: grabbing;
  background: rgba(242, 199, 107, 0.12);
}

.details-drag-grip {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background:
    repeating-linear-gradient(90deg,
      rgba(255, 255, 255, 0.25) 0 4px,
      transparent 4px 8px);
}

.details-reset {
  flex: none;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font: 600 10px/1 "Segoe UI", sans-serif;
  padding: 3px 7px;
  border-radius: 6px;
  cursor: pointer;
  visibility: hidden;
}

.details-panel.moved .details-reset {
  visibility: visible;
}

.details-reset:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

/* While dragging, the panel must not also scroll its own content */
.details-panel.dragging {
  overflow: hidden;
}
