.map-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1rem;
  align-items: start;
}

.map-main {
  min-width: 0;
}

.map-canvas-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 12rem);
  min-height: 520px;
  overflow: hidden;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  touch-action: none;
}

.alliance-map-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.alliance-map-canvas:active {
  cursor: grabbing;
}

.map-tooltip {
  position: absolute;
  z-index: 2;
  max-width: 240px;
  pointer-events: none;
  background: rgba(13, 17, 23, 0.94);
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.map-panel {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 1rem;
  position: sticky;
  top: 1rem;
}

.map-panel-heading {
  margin-top: 1.2rem;
}

.map-panel-heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.map-panel-heading-row h2 {
  margin-bottom: 0;
}

.map-heading-action {
  color: #6e7681;
  cursor: pointer;
  font-size: 0.68rem;
  line-height: 1;
  user-select: none;
}

.map-heading-action:hover,
.map-heading-action:focus {
  color: #58a6ff;
  outline: none;
  text-decoration: underline;
}

.map-snapshot-field {
  margin-bottom: 0.8rem;
}

.map-snapshot-field select {
  width: 100%;
}

.map-snapshot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 220px;
  max-width: 100%;
}

.map-play-button {
  flex: 0 0 auto;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.35rem 0.55rem;
}

.map-play-button:hover:not(:disabled),
.map-play-button:focus:not(:disabled) {
  border-color: #58a6ff;
  color: #58a6ff;
  outline: none;
}

.map-play-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.map-slider-wrap {
  width: 220px;
  max-width: 100%;
  margin-top: 0.35rem;
}

.map-snapshot-slider {
  display: block;
  width: 100%;
}

.map-slider-ticks {
  position: relative;
  height: 0.45rem;
  margin: -0.1rem 6px 0;
}

.map-slider-ticks span {
  position: absolute;
  top: 0;
  width: 1px;
  height: 0.35rem;
  background: #6e7681;
  transform: translateX(-50%);
}

.map-slider-ticks span.live-mark {
  background: #58a6ff;
}

.map-snapshot-slider:disabled {
  opacity: 0.55;
}

.map-slider-label {
  margin-top: 0.3rem;
  color: #e6edf3;
  font-size: 0.82rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-field-help {
  font-size: 0.72rem;
  line-height: 1.35;
  margin-top: 0.3rem;
}

.map-stat {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid #21262d;
  padding: 0.45rem 0;
  font-size: 0.88rem;
}

.map-stat strong {
  color: #58a6ff;
}

.map-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.85rem;
  cursor: pointer;
  font-size: 0.84rem;
}

.map-toggle-row input {
  margin: 0;
}

.map-legend,
.map-filter-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 360px;
  overflow-y: auto;
  font-size: 0.84rem;
}

.map-filter-list {
  max-height: 140px;
}

.map-legend,
.map-filter-list {
  scrollbar-width: thin;
  scrollbar-color: #30363d #0d1117;
  padding-right: 0.35rem;
}

.map-legend::-webkit-scrollbar,
.map-filter-list::-webkit-scrollbar {
  width: 0.65rem;
}

.map-legend::-webkit-scrollbar-track,
.map-filter-list::-webkit-scrollbar-track {
  background: #0d1117;
  border-radius: 999px;
}

.map-legend::-webkit-scrollbar-thumb,
.map-filter-list::-webkit-scrollbar-thumb {
  background: #30363d;
  border: 2px solid #0d1117;
  border-radius: 999px;
}

.map-legend::-webkit-scrollbar-thumb:hover,
.map-filter-list::-webkit-scrollbar-thumb:hover {
  background: #6e7681;
}

.legend-row,
.filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.legend-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  column-gap: 0.5rem;
  row-gap: 0.25rem;
  align-items: center;
}

.legend-row .legend-metrics {
  grid-column: 3 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
}

.legend-row .only-link {
  grid-column: 4;
}

.legend-row input,
.filter-row input {
  margin: 0;
}

.filter-name {
  flex: 1 1 auto;
  min-width: 0;
}

.capture-count,
.holding-count {
  flex: 0 0 auto;
  border: 1px solid #30363d;
  border-radius: 999px;
  color: #58a6ff;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  padding: 0.18rem 0.34rem;
  white-space: nowrap;
}

.holding-count {
  color: #a5d6ff;
}

.only-link {
  flex: 0 0 auto;
  opacity: 0;
  pointer-events: none;
  color: #6e7681;
  font-size: 0.68rem;
  line-height: 1;
  cursor: pointer;
}

.legend-row:hover .only-link,
.filter-row:hover .only-link,
.only-link:focus {
  opacity: 1;
  pointer-events: auto;
}

.only-link:hover,
.only-link:focus {
  color: #58a6ff;
  text-decoration: underline;
}

.muted-row {
  opacity: 0.45;
}

.swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  flex: 0 0 auto;
}

#map-updated,
#map-selection {
  font-size: 0.82rem;
  line-height: 1.45;
  margin-top: 0.75rem;
}

.map-change-label {
  color: #ffd33d;
  font-weight: 600;
}

@media (max-width: 960px) {
  .map-page {
    grid-template-columns: 1fr;
  }

  .map-panel {
    position: static;
  }

  .map-canvas-wrap {
    height: 70vh;
    min-height: 420px;
  }
}
