.guidance-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 18rem);
  margin: 0.55rem auto 1rem;
  padding: 0.2rem;
  border: 1px solid rgba(185, 138, 45, 0.48);
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.74);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.guidance-mode-button {
  min-height: 2.45rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  font-family: var(--font-mincho);
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.guidance-mode-button[aria-pressed="true"] {
  background: linear-gradient(145deg, #bd2f29, var(--color-shu) 58%, var(--color-shu-dark));
  color: #fffaf0;
  box-shadow:
    0 5px 14px rgba(127, 18, 23, 0.14),
    inset 0 0 0 1px rgba(255, 231, 181, 0.22);
}

.guidance-mode-button:focus-visible {
  outline: 3px solid rgba(166, 32, 32, 0.22);
  outline-offset: 2px;
}

.guidance-mode-panel[hidden] {
  display: none !important;
}

.map-overview-panel {
  width: 100%;
  margin: 0.2rem 0 0.8rem;
}

.map-overview-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 1px solid rgba(185, 138, 45, 0.72);
  border-radius: 1.35rem;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.72), transparent 16rem),
    linear-gradient(180deg, rgba(255, 252, 244, 0.96), rgba(241, 233, 216, 0.92));
  box-shadow:
    var(--shadow-soft),
    inset 0 0 0 1px rgba(255, 255, 255, 0.74);
}

.map-overview-frame::before,
.map-overview-frame::after {
  content: '';
  position: absolute;
  z-index: 0;
  width: 8.5rem;
  height: 8.5rem;
  background: url('/assets/wagara-pattern.svg') center / cover no-repeat;
  opacity: 0.24;
  pointer-events: none;
}

.map-overview-frame::before {
  top: -3.4rem;
  right: -3rem;
}

.map-overview-frame::after {
  bottom: -3.2rem;
  left: -3.2rem;
}

.map-overview-canvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: clamp(18rem, 58vh, 27rem);
  min-height: 18rem;
  background: transparent;
  touch-action: pan-x pan-y;
}

/* The map is always north-up. Keep this orientation cue fixed to the viewport. */
.map-overview-canvas::before {
  content: '▲\A北';
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 1000;
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  border: 1px solid rgba(185, 138, 45, 0.72);
  border-radius: 50%;
  background: rgba(255, 252, 244, 0.9);
  color: var(--color-shu);
  font-family: var(--font-mincho);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  white-space: pre;
  box-shadow:
    0 4px 12px rgba(74, 56, 23, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  pointer-events: none;
}

.map-overview-caption {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0 0.15rem;
  color: var(--color-muted);
  font-size: 0.78rem;
}

.map-overview-caption span {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.map-overview-caption span::before {
  content: '';
  flex: 0 0 auto;
}

.map-overview-caption .map-key-current::before {
  width: 0.72rem;
  height: 0.72rem;
  border: 2px solid #fffaf0;
  border-radius: 50%;
  background: var(--color-wakakusa);
  box-shadow: 0 0 0 1px var(--color-wakakusa-dark);
}

.map-overview-caption .map-key-target::before {
  width: 0.68rem;
  height: 0.68rem;
  border: 2px solid #f5d78a;
  background: var(--color-shu);
  transform: rotate(45deg);
  box-shadow: 0 0 0 1px rgba(127, 18, 23, 0.35);
}

.map-overview-note {
  margin: 0.7rem 0 0;
  color: var(--color-muted);
  font-size: 0.76rem;
  line-height: 1.65;
  text-align: center;
}

.map-overview-source {
  margin: 0.35rem 0 0;
  color: rgba(74, 65, 50, 0.62);
  font-size: 0.66rem;
  line-height: 1.5;
  text-align: center;
}

/* Leaflet base adjustments. No raster tile layer is used. */
.map-overview-canvas .leaflet-container {
  background: transparent;
}

.map-overview-canvas .leaflet-pane,
.map-overview-canvas .leaflet-control {
  z-index: auto;
}

.map-overview-div-icon {
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  background: transparent !important;
}

/*
 * The Leaflet divIcon origin itself is the geographic coordinate.
 * Keep the marker dot/diamond centered on that origin, while positioning
 * the text label separately so its width can never shift the coordinate.
 */
.map-overview-marker {
  position: relative;
  display: block;
  width: 0;
  height: 0;
  white-space: nowrap;
}

.map-overview-marker-shape {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
}

.map-overview-marker-label {
  position: absolute;
  top: 0;
  left: 1.05rem;
  transform: translateY(-50%);
  padding: 0.12rem 0.45rem;
  border: 1px solid rgba(185, 138, 45, 0.42);
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.94);
  color: #3e3527;
  font-family: var(--font-mincho);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: 0 3px 9px rgba(74, 56, 23, 0.09);
}

.map-overview-marker--current .map-overview-marker-shape {
  width: 1.25rem;
  height: 1.25rem;
  border: 3px solid #fffaf0;
  border-radius: 50%;
  background: var(--color-wakakusa);
  box-shadow:
    0 0 0 2px rgba(95, 127, 43, 0.88),
    0 4px 12px rgba(95, 127, 43, 0.22);
  transform: translate(-50%, -50%);
}

.map-overview-marker--current .map-overview-marker-shape::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 50%;
  background: #fffaf0;
  transform: translate(-50%, -50%);
}

.map-overview-marker--target .map-overview-marker-shape {
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid #f0d58c;
  background: linear-gradient(145deg, #d94135, var(--color-shu-dark));
  box-shadow:
    0 0 0 2px rgba(255, 252, 244, 0.9),
    0 4px 12px rgba(127, 18, 23, 0.24);
  transform: translate(-50%, -50%) rotate(45deg);
}

.map-overview-marker--target .map-overview-marker-shape::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 50%;
  background: #f0d58c;
  transform: translate(-50%, -50%);
}

@media (max-width: 390px) {
  .map-overview-canvas {
    height: 20rem;
  }

  .map-overview-marker-label {
    max-width: 8.6rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (prefers-reduced-motion: reduce) {
  .guidance-mode-button {
    transition: none;
  }
}
