:root {
  --ink: #20242a;
  --ink-soft: #4c5560;
  --paper: rgba(252, 250, 246, 0.94);
  --accent: #0f7b6c;
  --accent-deep: #0a5a4f;
  --ring: rgba(15, 123, 108, 0.35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #0b1c22;
  overflow: hidden;
}
#map { position: fixed; inset: 0; z-index: 0; }
.leaflet-container { background: #0b1c22; font: inherit; }

#brand {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 18px; z-index: 20;
  pointer-events: none;
}
.brand-title {
  font-size: 14px; font-weight: 600; letter-spacing: 0.02em;
  color: #f3efe7; opacity: 0.85; text-shadow: 0 1px 8px rgba(0,0,0,0.55);
}

.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(8, 18, 24, 0.45);
  backdrop-filter: blur(3px);
  transition: opacity 0.45s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.card {
  width: min(420px, calc(100vw - 40px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--paper);
  border-radius: 18px;
  padding: 28px 26px 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.intro-card h1 {
  font-size: 34px; line-height: 1.12; letter-spacing: -0.01em;
  margin-bottom: 12px;
}
.lede { font-size: 15px; line-height: 1.5; color: var(--ink-soft); margin-bottom: 20px; }
.hint-line { margin-top: 14px; font-size: 12.5px; color: var(--ink-soft); opacity: 0.8; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  min-width: 44px; min-height: 44px;
  padding: 12px 20px; border-radius: 999px;
  font: inherit; font-size: 15px; font-weight: 600;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s, box-shadow 0.25s;
}
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--accent); color: #f6fbf9; box-shadow: 0 6px 18px var(--ring); }
.btn.primary:hover { background: var(--accent-deep); }
.btn.ghost { background: transparent; color: var(--ink-soft); padding: 12px 14px; }
.btn.ghost:hover { color: var(--ink); }
.btn:focus-visible, .icon-btn:focus-visible, .resume:focus-visible, .vchip:focus-visible {
  outline: 3px solid var(--ring); outline-offset: 2px;
}

.caption {
  position: fixed; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(560px, calc(100vw - 28px));
  background: var(--paper);
  border-radius: 16px;
  padding: 14px 18px 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.3, 0.5, 1);
}
.caption.hidden { opacity: 0; transform: translateX(-50%) translateY(24px); pointer-events: none; }
.cap-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.cap-chapter {
  font-size: 12.5px; font-weight: 700;
  color: var(--accent);
}
.cap-level { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.cap-text {
  font-size: 16.5px; line-height: 1.45; margin: 6px 0 10px;
  min-height: 2.4em;
}
.cap-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cap-controls .btn.primary { padding: 10px 18px; min-height: 44px; font-size: 14.5px; }
.dots.fraction { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }

.vintage { display: flex; gap: 8px; margin-bottom: 8px; }
.vintage.hidden { display: none; }
.vchip {
  appearance: none; border: 1px solid rgba(255,255,255,0.28);
  min-height: 36px; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600;
  background: rgba(16, 28, 34, 0.6); color: #f3efe7;
  backdrop-filter: blur(4px);
  transition: background 0.25s, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.vchip:active { transform: scale(0.94); }
.vchip.on { background: var(--accent); border-color: transparent; }

.resume {
  position: fixed; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 8px);
  min-height: 44px; padding: 10px 22px;
  border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600;
  background: var(--paper); color: var(--accent-deep);
  box-shadow: 0 10px 26px rgba(0,0,0,0.35);
  transition: opacity 0.35s, transform 0.35s cubic-bezier(0.34, 1.3, 0.5, 1);
}
.resume.hidden { opacity: 0; transform: translateX(-50%) translateY(16px); pointer-events: none; }

.icon-btn {
  position: fixed; z-index: 30;
  right: 16px; top: max(14px, env(safe-area-inset-top));
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(16, 28, 34, 0.55);
  color: #f3efe7;
  display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(4px);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s;
}
.icon-btn:hover { background: rgba(16, 28, 34, 0.75); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.src { top: calc(max(14px, env(safe-area-inset-top)) + 54px); }
.icon-btn .mut { display: none; }
.icon-btn[aria-pressed="false"] .wave { display: none; }
.icon-btn[aria-pressed="false"] .mut { display: block; }

.src-card h2 { font-size: 20px; margin-bottom: 10px; }
.src-note { font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); margin-bottom: 12px; }
.src-card ul { margin: 0 0 14px 18px; }
.src-card li { font-size: 13.5px; margin-bottom: 6px; }
.src-card a { color: var(--accent-deep); }

@media (max-width: 520px) {
  .intro-card h1 { font-size: 28px; }
  .cap-text { font-size: 15.5px; }
  .card { padding: 24px 20px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .caption, .resume, .overlay, .icon-btn, .vchip, .vintage { transition: none !important; }
}

.leaflet-top.leaflet-left .leaflet-control-attribution {
  margin-top: 30px; max-width: calc(100vw - 150px);
  background: rgba(16, 28, 34, 0.45); color: rgba(243, 239, 231, 0.75);
  font-size: 10px; line-height: 1.4; border-radius: 8px 0 0 0; padding: 2px 6px;
}
.leaflet-top.leaflet-left .leaflet-control-attribution a { color: rgba(243, 239, 231, 0.9); }
