:root {
  --ink: #17313a;
  --muted: #5d6b70;
  --paper: #fff9ee;
  --panel: #ffffff;
  --sea: #126d8f;
  --sea-dark: #0a4963;
  --coral: #bb3725;
  --gold: #f4bd4f;
  --line: rgba(23, 49, 58, 0.16);
  --shadow: 0 22px 70px rgba(12, 43, 58, 0.22);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #eef9fb 0%, #fff7ea 52%, #f4ead9 100%);
}

button, input { font: inherit; }

.app-shell {
  width: min(1500px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

body.popup-open .app-shell {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 2px 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--sea-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1, h2, p { overflow-wrap: anywhere; }

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.6vw, 2.5rem);
  line-height: 1.12;
}

.overview-button {
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255,255,255,.92);
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  box-shadow: 0 10px 24px rgba(12, 43, 58, 0.22);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}

.overview-button.playing {
  background: var(--sea-dark);
  outline: 4px solid rgba(244, 189, 79, .75);
}

.map-panel {
  border: 1px solid var(--line);
  background: #cbeaf0;
  box-shadow: 0 18px 56px rgba(18, 109, 143, 0.18);
  overflow: hidden;
}

.map-frame {
  position: relative;
  width: 100%;
  isolation: isolate;
}

.tour-map {
  display: block;
  width: 100%;
  height: auto;
}

.markers {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.map-marker {
  position: absolute;
  width: clamp(42px, 4.2vw, 64px);
  height: clamp(42px, 4.2vw, 64px);
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: transparent;
  box-shadow: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: 950;
  line-height: 1;
  padding: 0;
}

.map-marker.reference {
  background: transparent;
  color: transparent;
  cursor: default;
}

.map-marker:hover,
.map-marker:focus-visible,
.stop-card:hover,
.stop-card:focus-visible {
  outline: 3px solid rgba(244, 189, 79, .92);
  outline-offset: 3px;
}

.stop-list-section { padding-top: 22px; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2,
.section-heading p { margin: 0; }

.section-heading p {
  color: var(--muted);
  font-size: .92rem;
}

.stop-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(252px, 1fr));
  gap: 10px;
}

.stop-card {
  min-height: 72px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  color: var(--ink);
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.stop-card.reference {
  cursor: default;
  background: rgba(255, 248, 225, .88);
}

.stop-badge,
.place-number {
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 950;
}

.reference .stop-badge { background: var(--gold); color: #3c2a12; }

.stop-badge { width: 34px; height: 34px; }
.stop-name { display: block; font-weight: 900; line-height: 1.18; }
.stop-zh { display: block; color: var(--muted); margin-top: 3px; font-size: .92rem; }
.stop-note { display: block; color: var(--sea-dark); margin-top: 3px; font-size: .82rem; font-weight: 850; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(7, 37, 49, .45);
}

.overlay[hidden] { display: none; }

.popup {
  position: relative;
  width: min(1040px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  border: 1px solid rgba(255,255,255,.7);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.close-button {
  position: sticky;
  top: 10px;
  z-index: 4;
  float: right;
  margin: 10px 10px 0 0;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: var(--sea-dark);
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
}

.popup-image {
  width: 100%;
  aspect-ratio: 3 / 1.45;
  object-fit: cover;
  display: block;
  background: #cbeaf0;
}

.popup-body { padding: 16px 18px 20px; clear: both; }

.place-heading {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
}

.place-number { width: 46px; height: 46px; }
.place-heading h2 { margin: 0; font-size: 1.35rem; line-height: 1.16; }
.place-heading p { margin: 3px 0 0; color: var(--muted); font-weight: 800; }

.picture-header {
  margin: 14px 0;
  color: var(--sea-dark);
  font-size: 1.06rem;
  font-weight: 850;
  line-height: 1.48;
}

.audio-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.78);
}

.play-button {
  min-height: 42px;
  border: 0;
  background: var(--coral);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.audio-main { min-width: 0; }
.progress { width: 100%; accent-color: var(--coral); }
.time-row { display: flex; justify-content: space-between; color: var(--muted); font-size: .86rem; }

.description {
  margin: 14px 0 10px;
  font-size: 1.04rem;
  line-height: 1.72;
}

@media (max-width: 760px) {
  .app-shell { width: 100%; padding: 12px 10px 34px; }
  .topbar { align-items: start; }
  .overview-button { width: 46px; height: 46px; flex: 0 0 auto; }
  .map-panel { overflow-x: auto; }
  .map-frame { min-width: 820px; }
  .stop-list { grid-template-columns: 1fr; }
  .section-heading { align-items: start; flex-direction: column; }
  .overlay { align-items: stretch; padding: max(4px, env(safe-area-inset-top)) 6px max(8px, env(safe-area-inset-bottom)); }
  .popup { height: 100%; max-height: none; }
  .close-button { position: fixed; right: max(13px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); width: 38px; height: 38px; }
  .popup-image { aspect-ratio: 4 / 3; }
  .popup-body { padding: 12px 10px 18px; }
  .audio-card { grid-template-columns: 70px 1fr; gap: 8px; padding: 8px; }
}
