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

.map-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.map-head h2 {
  margin: 0;
  font-size: 18px;
  color: var(--paper);
  letter-spacing: 0.08em;
}

.map-head .meta {
  color: var(--muted);
  font-size: 12px;
}

.viewport {
  overflow: auto;
  max-height: min(72vh, 760px);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0e0b08;
}

.stage {
  position: relative;
  display: inline-block;
  min-width: 100%;
  vertical-align: top;
}

.stage img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.stage.wide img {
  width: auto;
  height: 280px;
  max-width: none;
}

.fallback {
  width: 100%;
  min-height: 280px;
  background:
    linear-gradient(rgba(201, 162, 39, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 162, 39, 0.12) 1px, transparent 1px),
    #1c1610;
  background-size: 40px 40px;
}

.stage.wide .fallback {
  width: 1400px;
  height: 280px;
  min-height: 280px;
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.grid {
  position: absolute;
  inset: 0;
  opacity: 0.55;
  background-image:
    repeating-linear-gradient(
      to right,
      rgba(244, 233, 212, 0.16) 0,
      rgba(244, 233, 212, 0.16) 1px,
      transparent 1px,
      transparent var(--gx)
    ),
    repeating-linear-gradient(
      to top,
      rgba(244, 233, 212, 0.16) 0,
      rgba(244, 233, 212, 0.16) 1px,
      transparent 1px,
      transparent var(--gy)
    );
  background-position: 0 100%;
}

.box {
  position: absolute;
  pointer-events: none;
}

.box.theory {
  border: 1.5px dashed rgba(201, 162, 39, 0.85);
  background: rgba(201, 162, 39, 0.08);
}

.box.combat {
  border: 2px solid var(--vermilion);
  background: var(--vermilion-dim);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25) inset;
}

.pin {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 2px solid #fff7ea;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(201, 162, 39, 0.28);
  transform: translate(-50%, -50%);
}

.pin::before,
.pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: #fff7ea;
}

.pin::before {
  width: 18px;
  height: 1px;
  transform: translate(-50%, -50%);
}

.pin::after {
  width: 1px;
  height: 18px;
  transform: translate(-50%, -50%);
}

.pin-label {
  position: absolute;
  transform: translate(-50%, calc(-100% - 10px));
  background: rgba(26, 20, 16, 0.88);
  color: #ffd56a;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.hover-tag {
  position: absolute;
  pointer-events: none;
  transform: translate(10px, -28px);
  background: rgba(26, 20, 16, 0.92);
  border: 1px solid var(--gold);
  color: var(--paper);
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 14px;
  height: 10px;
  margin-right: 5px;
  vertical-align: -1px;
  border-radius: 2px;
}

.legend .t {
  border: 1.5px dashed var(--gold);
  background: rgba(201, 162, 39, 0.12);
}

.legend .c {
  border: 2px solid var(--vermilion);
  background: var(--vermilion-dim);
}

.legend .p {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  border: 1px solid #fff;
}

@media (max-width: 1100px) {
  .stage.wide img {
    height: 200px;
  }
}
