:root {
  --map-bg: #080c12;
  --map-panel: #111822;
  --map-panel-2: #182230;
  --map-panel-3: #243448;
  --map-line: #304154;
  --map-text: #f2f6fb;
  --map-muted: #aab7c7;
  --map-violet: #7958be;
  --map-gold: #d79a31;
  --map-blue: #397fb5;
  --map-red: #9d4947;
  --map-green: #287456;
  --map-route: #70b8ff;
}

body.dq5-map-page,
body.dq5-map-page * {
  box-sizing: border-box;
}

body.dq5-map-page {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: radial-gradient(circle at 88% -10%, rgba(80, 170, 255, .13), transparent 34rem), var(--map-bg);
  color: var(--map-text);
}

body.dq5-map-page main {
  width: min(100%, 1640px);
  max-width: none;
  margin: 0 auto;
  padding: 30px clamp(16px, 3.5vw, 54px) 64px;
}

.map-page-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin: 0 0 20px;
}

.map-page-intro__kicker {
  margin: 0 0 5px;
  color: var(--map-muted);
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.map-page-intro h2 {
  margin: 0;
  color: var(--map-text);
  font-family: YuMincho, "Yu Mincho", serif;
  font-size: clamp(1.7rem, 3.4vw, 2.8rem);
  line-height: 1.25;
}

.map-page-intro__badge {
  flex: 0 0 auto;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--map-route);
  color: #071018;
  font-size: .85rem;
  font-weight: 900;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(220px, 284px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.map-index,
.map-card,
.map-detail-card,
.map-event-card {
  border: 1px solid var(--map-line);
  border-radius: 16px;
  background: var(--map-panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .2);
}

.map-index {
  max-height: none;
  overflow: visible;
  padding: 14px;
}

.map-index h3 {
  margin: 2px 4px 12px;
  color: var(--map-text);
  font-size: 1rem;
}

.map-index-list {
  display: grid;
  gap: 7px;
}

.map-nav-button {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid #44566d;
  border-radius: 9px;
  background: #101923;
  color: #e9f1fb;
  text-align: left;
  cursor: pointer;
}

.map-nav-button:hover,
.map-nav-button:focus-visible {
  border-color: #93bfe9;
  background: #1d2a39;
}

.map-nav-button[aria-current="page"] {
  border-color: var(--map-route);
  background: #23384c;
  box-shadow: inset 0 0 0 1px rgba(112, 184, 255, .3);
}

.map-nav-button__number {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 7px;
  background: #2b3d51;
  color: #dbeaff;
  font-size: .72rem;
  font-weight: 900;
}

.map-nav-button__label {
  min-width: 0;
  line-height: 1.35;
}

.map-nav-button__label strong,
.map-nav-button__label small {
  display: block;
}

.map-nav-button__label strong {
  overflow-wrap: anywhere;
  font-size: .86rem;
}

.map-nav-button__label small {
  color: var(--map-muted);
  font-size: .72rem;
}

.map-card {
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--map-line);
  background: var(--map-panel-2);
}

.map-route-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--map-text);
  font-size: .78rem;
  font-weight: 850;
  white-space: nowrap;
}

.map-route-key::before {
  width: 24px;
  height: 8px;
  border-radius: 999px;
  background: var(--map-route);
  content: "";
}

.map-controls {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.map-controls button,
.map-controls a,
.map-detail-action {
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 6px 12px;
  border: 1px solid #718297;
  border-radius: 8px;
  background: #101923;
  color: #eef5ff;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}

.map-controls button:hover,
.map-controls a:hover,
.map-detail-action:hover {
  border-color: #fff;
  background: var(--map-panel-3);
}

.map-controls button[aria-pressed="false"] {
  border-color: #9c7750;
  background: #3a2b20;
  color: #ffe2b8;
}

.map-controls button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.map-zoom-step {
  min-width: 42px;
  font-size: 1.15rem;
}

.map-fit {
  min-width: 78px;
}

.map-scale-note {
  flex-basis: 100%;
  margin: 0;
  color: #aebdcd;
  font-size: .76rem;
  line-height: 1.55;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--map-line);
  background: #0f1721;
}

.map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--map-muted);
  font-size: .78rem;
  font-weight: 700;
}

.map-legend-symbol,
.map-detail-token {
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  color: #fff;
  font-weight: 950;
  line-height: 1;
}

.map-legend-symbol {
  width: 30px;
  height: 30px;
  font-size: .76rem;
}

.is-treasure { border-radius: 7px; background: var(--map-gold); }
.is-connection { border-radius: 50%; background: var(--map-violet); }
.is-exit { border-radius: 7px; background: var(--map-blue); }
.is-event,
.is-special,
.is-symbol { border-radius: 50%; background: var(--map-red); }

.map-viewport {
  min-height: 580px;
  max-height: 78vh;
  display: grid;
  place-items: start center;
  overflow: auto;
  padding: clamp(16px, 3vw, 38px);
  background:
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px),
    #0b1119;
  background-size: 24px 24px;
  scrollbar-color: #52677e #0b1119;
}

.map-frame {
  position: relative;
  flex: 0 0 auto;
  width: 624px;
  max-width: none;
  line-height: 0;
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, .32));
  transform-origin: top center;
  transition: width .18s ease;
}

.map-frame > img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  background: #fff;
  user-select: none;
  -webkit-user-drag: none;
}

.map-pointer-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.map-pointer-lines line {
  stroke: #fff;
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 2px #071018);
}

.map-pointer-lines circle {
  fill: #fff;
  stroke: #071018;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.map-pin {
  position: absolute;
  z-index: 3;
  width: 42px;
  height: 42px;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 3px solid #fff;
  color: #fff;
  box-shadow: 0 0 0 2px #071018, 0 5px 14px rgba(0, 0, 0, .45);
  font-size: .86rem;
  font-weight: 950;
  line-height: 1;
  cursor: pointer;
}

.map-pin:hover,
.map-pin:focus-visible {
  z-index: 7;
  filter: brightness(1.14);
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.map-pin.is-selected {
  z-index: 6;
  outline: 4px solid var(--map-route);
  outline-offset: 3px;
}

.map-pin.is-collected::after {
  position: absolute;
  right: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--map-green);
  font-size: .72rem;
  content: "✓";
}

.map-pin-label {
  position: absolute;
  left: calc(100% + 9px);
  top: 50%;
  z-index: 9;
  display: none;
  width: max-content;
  max-width: min(270px, 58vw);
  padding: 5px 8px;
  transform: translateY(-50%);
  border: 1px solid #7e91a8;
  border-radius: 6px;
  background: #fff;
  color: #17233a;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
  font-size: .75rem;
  font-weight: 850;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
}

.map-pin:hover .map-pin-label,
.map-pin:focus-visible .map-pin-label {
  display: block;
}

.map-frame[data-pointers="off"] .map-pointer-layer {
  display: none !important;
}

.map-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .86fr);
  gap: 16px;
  margin-top: 18px;
}

.map-detail-card {
  min-width: 0;
  padding: 19px;
}

.map-detail-card h3,
.map-event-card h3 {
  margin: 0 0 13px;
  color: var(--map-text);
  font-size: 1.05rem;
}

.map-point-detail {
  min-height: 128px;
  padding: 14px;
  border-radius: 11px;
  background: var(--map-panel-2);
  color: #e4ebf4;
  line-height: 1.75;
}

.map-point-detail p {
  margin: 7px 0;
}

.map-detail-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  color: var(--map-text);
  font-size: 1rem;
}

.map-detail-token {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  font-size: .76rem;
}

.map-connection-pill {
  display: inline-flex;
  margin: 6px 0 9px;
  padding: 6px 10px;
  border: 1px solid #6d628f;
  border-radius: 999px;
  background: #2b2540;
  color: #e5ddff;
  font-size: .76rem;
  font-weight: 800;
}

.map-collected {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  cursor: pointer;
}

.map-collected input {
  width: 20px;
  height: 20px;
  accent-color: var(--map-green);
}

.map-point-list {
  margin: 0;
  border: 1px solid #405269;
  border-radius: 11px;
  background: var(--map-panel-2);
}

.map-point-list summary {
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 850;
}

.map-point-list-body {
  padding: 0 12px 10px;
}

.map-point-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #34465a;
  padding: 8px 0;
}

.map-point-row button {
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  color: #eef5ff;
  text-align: left;
  line-height: 1.5;
  cursor: pointer;
}

.map-point-row button:hover,
.map-point-row button:focus-visible {
  color: #bdddff;
  outline: 2px solid #bdddff;
  outline-offset: 2px;
}

.map-point-row small {
  flex: 0 0 auto;
  color: var(--map-muted);
  font-size: .72rem;
}

.map-event-section {
  margin-top: 22px;
}

.map-event-section > h2 {
  margin: 0 0 12px;
  color: var(--map-text);
  font-size: 1.25rem;
}

.map-event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.map-event-card {
  padding: 17px;
}

.map-event-card p {
  margin: 0;
  color: #d5dee9;
}

.legacy-guide-section {
  margin-top: 24px;
}

.legacy-guide-section > h2 {
  margin: 0 0 12px;
  color: var(--map-text);
  font-size: 1.25rem;
}

.legacy-guide-grid,
.legacy-event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.legacy-guide-card,
.legacy-event-card {
  padding: 17px;
  border: 1px solid var(--map-line);
  border-radius: 14px;
  background: var(--map-panel);
}

.legacy-guide-card h3,
.legacy-event-card h3 {
  margin: 0 0 10px;
  color: var(--map-text);
  font-size: 1rem;
}

.legacy-guide-card p,
.legacy-event-card p {
  margin: 0;
  color: #d5dee9;
  line-height: 1.7;
}

.legacy-route-copy {
  margin-top: 10px !important;
  padding: 11px 12px;
  border-radius: 9px;
  background: var(--map-panel-2);
}

.legacy-event-card.is-boss {
  border-color: #6f4141;
}

.legacy-event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px !important;
}

.legacy-event-meta span {
  display: inline-flex;
  padding: 3px 8px;
  border: 1px solid #50647b;
  border-radius: 999px;
  color: #bed1e6;
  font-size: .7rem;
  font-weight: 850;
}

.legacy-event-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px !important;
}

.legacy-event-links a {
  color: #9fd2ff;
  font-size: .78rem;
  font-weight: 850;
}

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

.map-list-page {
  color: var(--map-text);
}

.map-list-lead {
  max-width: 980px;
  margin: 0 0 22px;
  color: #d5dee9;
}

.dungeon-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.dungeon-card {
  overflow: hidden;
  border: 1px solid var(--map-line);
  border-radius: 14px;
  background: var(--map-panel);
}

.dungeon-card__preview {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 12px;
  background: #0b1119;
}

.dungeon-card__preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dungeon-card__body {
  padding: 16px;
}

.dungeon-card h2 {
  margin: 0 0 8px;
  color: var(--map-text);
  font-size: 1.08rem;
}

.dungeon-card p {
  margin: 0 0 12px;
  color: var(--map-muted);
  font-size: .85rem;
}

.dungeon-card a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid #718297;
  border-radius: 8px;
  background: #172332;
  color: #eef5ff;
  font-weight: 850;
  text-decoration: none;
}

.dungeon-card a:hover,
.dungeon-card a:focus-visible {
  border-color: #fff;
  background: var(--map-panel-3);
}

@media (max-width: 980px) {
  .map-layout { grid-template-columns: 1fr; }
  .map-index { max-height: 310px; overflow: auto; }
  .map-index-list { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
  .map-details { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  body.dq5-map-page main { padding: 22px 12px 44px; }
  .map-page-intro { display: block; }
  .map-page-intro__badge { width: max-content; margin-top: 12px; }
  .map-toolbar { align-items: flex-start; padding: 12px; }
  .map-controls { width: 100%; margin-left: 0; }
  .map-controls button,
  .map-controls a { flex: 1 1 auto; padding: 6px 8px; font-size: .79rem; }
  .map-viewport { min-height: 360px; max-height: 72vh; padding: 12px; }
  .map-pin { width: 36px; height: 36px; font-size: .75rem; }
  .map-detail-card { padding: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .map-frame { transition: none; }
}

@media print {
  .map-index,
  .map-controls,
  .map-scale-note,
  .map-pointer-layer { display: none !important; }
  .map-layout,
  .map-details { display: block; }
  .map-viewport { min-height: 0; max-height: none; overflow: visible; background: #fff; }
  .map-frame { width: 100% !important; filter: none; }
  .map-card,
  .map-detail-card,
  .map-event-card { box-shadow: none; break-inside: avoid; }
}
