:root {
  /* Shared tokens keep the dark map UI and sheet controls visually consistent. */
  --land: #141414;
  --water: #0B1C2C;
  --road: #3D3D3D;
  --sheet: #292929;
  --ink: #ffffff;
  --muted: #D6D6D6;
  --subtle: #ADADAD;
  --brand: #115EA3;
  --brand-hover: #0F6CBD;
  --learn: #479EF5;
  --stroke: #3D3D3D;
  --map-w: 960px;
  --pin: clamp(32px, 9vw, 48px);
  --radius-btn: 4px;
  --radius-card: 8px;
  --pad-card: 24px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: "Segoe UI", "Segoe UI Variable", system-ui, sans-serif;
  color: var(--ink);
  background: var(--land);
}
button { font-family: inherit; touch-action: manipulation; }
img { max-width: 100%; display: block; }

/* Full-screen map canvas. */
.app {
  position: fixed;
  inset: 0;
  width: 100%;
  margin: 0;
}
.map-bleed {
  position: absolute;
  inset: 0;
  overflow: auto;
  background: var(--land);
  overscroll-behavior: none;
  scrollbar-width: none;
  cursor: grab;
  touch-action: pan-x pan-y;
}
.map-bleed.is-panning { cursor: grabbing; }
.map-bleed::-webkit-scrollbar { display: none; }
.map-stage {
  /* Keep the original 960x640 art ratio while allowing JS to scale the stage. */
  position: relative;
  --zoom: 1;
  width: calc(max(100vw, calc(100svh * 960 / 640)) * var(--zoom));
  height: auto;
  aspect-ratio: 960 / 640;
  overflow: visible;
  transform-origin: 0 0;
}
.map-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.map-art[hidden] { display: none !important; }

/* Brand and map heads-up display. */
.app-brand {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}
.app-mark {
  width: 32px;
  height: 32px;
  flex: none;
}

.map-hud { pointer-events: none; }
.hud-mode {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  padding: 3px;
  background: rgba(20, 20, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  pointer-events: auto;
}
.hud-mode button {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--subtle);
  border-radius: 6px;
  cursor: pointer;
}
.hud-mode button:hover { color: var(--ink); }
.hud-mode button.on {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.hud-scale {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  background: rgba(20, 20, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 10px 8px;
  backdrop-filter: blur(8px);
}
.hud-scale-labels {
  display: flex;
  justify-content: space-between;
  width: 148px;
  font-size: 10px;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.hud-scale-bar { display: block; margin-top: 3px; }
.hud-coords {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  background: rgba(20, 20, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.route {
  /* The completed route path sits above the map image but below the station pins. */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
#pins { position: absolute; inset: 0; z-index: 2; }

/* Station pins. */
.pin {
  position: absolute;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 2;
  overflow: visible;
}
.pin-slot {
  /* Center each pin on its exact hotspot without affecting the button's anchor. */
  position: absolute;
  left: 0;
  top: 0;
  width: var(--pin);
  height: var(--pin);
  transform: translate(-50%, -50%);
  container-type: size;
}
.pin-face {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--pin);
  height: var(--pin);
  border-radius: 50%;
  background: #141414;
  box-shadow: inset 0 0 0 2px var(--pin-color), 0 2px 8px rgba(0, 0, 0, 0.45);
  flex: none;
}
.pin-face.earned {
  background: var(--pin-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.pin-face::after {
  /* Fluent icons are painted as masks so the same SVG can inherit pin state color. */
  content: "";
  width: 24px;
  height: 24px;
  background: var(--pin-color);
  -webkit-mask: var(--glyph-reg-24, var(--glyph-reg)) center / contain no-repeat;
  mask: var(--glyph-reg-24, var(--glyph-reg)) center / contain no-repeat;
}
.pin-face.earned::after {
  background: #fff;
  -webkit-mask-image: var(--glyph-fill-24, var(--glyph-fill));
  mask-image: var(--glyph-fill-24, var(--glyph-fill));
}
.pin-face.pin-lg { width: 64px; height: 64px; }
.pin-face.pin-lg::after { width: 24px; height: 24px; }
.pin-face.pin-sm { width: 40px; height: 40px; }
.pin-face.pin-sm::after {
  width: 20px;
  height: 20px;
  -webkit-mask-image: var(--glyph-reg-20, var(--glyph-reg));
  mask-image: var(--glyph-reg-20, var(--glyph-reg));
}
.pin-face.pin-sm.earned::after {
  -webkit-mask-image: var(--glyph-fill-20, var(--glyph-fill));
  mask-image: var(--glyph-fill-20, var(--glyph-fill));
}
@container (max-width: 39.98px) {
  /* Small pins swap to the 20px icon artwork for cleaner edges. */
  .pin-face::after {
    width: 20px;
    height: 20px;
    -webkit-mask-image: var(--glyph-reg-20, var(--glyph-reg));
    mask-image: var(--glyph-reg-20, var(--glyph-reg));
  }
  .pin-face.earned::after {
    -webkit-mask-image: var(--glyph-fill-20, var(--glyph-fill));
    mask-image: var(--glyph-fill-20, var(--glyph-fill));
  }
}
.pin:focus-visible .pin-slot {
  outline: 2px solid var(--learn);
  outline-offset: 3px;
}
.pin.active { z-index: 4; }
.callout {
  position: absolute;
  left: 0;
  top: calc(var(--pin) / 2 + 4px);
  transform: translateX(-50%);
  background: var(--sheet);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 4px 8px;
  border-radius: var(--radius-btn);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

/* Shared icon masks for the primary navigation. */
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  background: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}
.icon-map { -webkit-mask-image: url("assets/fluent/map_20_regular.svg"); mask-image: url("assets/fluent/map_20_regular.svg"); }
.icon-sparkle { -webkit-mask-image: url("assets/fluent/sparkle_20_regular.svg"); mask-image: url("assets/fluent/sparkle_20_regular.svg"); }
.icon-check { -webkit-mask-image: url("assets/fluent/checkmark_20_regular.svg"); mask-image: url("assets/fluent/checkmark_20_regular.svg"); }
.icon-shield { -webkit-mask-image: url("assets/fluent/shield_20_regular.svg"); mask-image: url("assets/fluent/shield_20_regular.svg"); }
.chrome-bar button.on .icon-map { -webkit-mask-image: url("assets/fluent/map_20_filled.svg"); mask-image: url("assets/fluent/map_20_filled.svg"); }
.chrome-bar button.on .icon-sparkle { -webkit-mask-image: url("assets/fluent/sparkle_20_filled.svg"); mask-image: url("assets/fluent/sparkle_20_filled.svg"); }
.chrome-bar button.on .icon-check { -webkit-mask-image: url("assets/fluent/checkmark_20_filled.svg"); mask-image: url("assets/fluent/checkmark_20_filled.svg"); }
.chrome-bar button.on .icon-shield { -webkit-mask-image: url("assets/fluent/shield_20_filled.svg"); mask-image: url("assets/fluent/shield_20_filled.svg"); }

/* Primary navigation. */
.chrome-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--sheet);
  border-radius: var(--radius-btn);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35);
}
.chrome-bar button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.chrome-bar button:hover { background: #3d3d3d; color: var(--ink); }
.chrome-bar button.on {
  background: var(--brand);
  color: #fff;
}
.chrome-bar button.on:hover { background: var(--brand-hover); }


/* Reusable sheet for station, checklist, and source views. */
.sheet {
  position: fixed;
  top: 50%;
  left: 50%;
  bottom: auto;
  transform: translate(-50%, -46%);
  width: min(720px, calc(100% - 20px));
  max-height: min(72svh, 620px);
  overflow: auto;
  background: var(--sheet);
  border-radius: var(--radius-card);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.5);
  padding: 6px var(--pad-card) var(--pad-card);
  z-index: 6;
  color: var(--ink);
}
.sheet[hidden] { display: none !important; }
.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: #3d3d3d;
  margin: 8px auto 12px;
}
.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: 0;
  background: #3d3d3d;
  color: var(--ink);
  border-radius: var(--radius-btn);
  padding: 6px 12px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.sheet-close:hover { background: #505050; }
.sheet-hero {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 4px 4.5rem 8px 0;
}
.sheet-hero h1 { font-size: 1.25rem; margin: 0 0 4px; font-weight: 600; }
.sheet-hero p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.mark-btn {
  border: 0;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-btn);
  padding: 8px 14px;
  cursor: pointer;
  margin: 8px 0 16px;
}
.mark-btn:hover { background: var(--brand-hover); }
.mark-btn[disabled] { background: #3d3d3d; color: var(--subtle); }

/* Content cards inside the sheet. */
.card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius-card);
  padding: var(--pad-card);
  margin: 0 0 12px;
  background: #1f1f1f;
}
.card.for-you {
  box-shadow: inset 3px 0 0 var(--accent, var(--learn));
  background: #242424;
}
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent, var(--learn));
  color: #fff;
  border-radius: var(--radius-btn);
  padding: 2px 8px;
  margin-bottom: 8px;
}
.card h3 { margin: 0 8.5rem 8px 0; font-size: 1.05rem; font-weight: 600; }
.card header { position: relative; }
.learn {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--learn);
  border: 1px solid var(--learn);
  border-radius: var(--radius-btn);
  padding: 4px 8px;
  text-decoration: none;
  white-space: nowrap;
}
.learn:hover { background: rgba(71, 158, 245, 0.12); }
dl.rhythm { margin: 0; }
dl.rhythm dt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-top: 12px;
}
dl.rhythm dd { margin: 4px 0 0; line-height: 1.45; color: var(--muted); }
.preview { font-size: 12px; color: var(--subtle); }

.check-item { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 10px; color: var(--muted); }
.check-item input { margin-top: 4px; accent-color: var(--brand); }
.source-row { margin: 0 0 12px; }
.source-row a { color: var(--learn); font-weight: 600; text-decoration: none; }
.source-row a:hover { text-decoration: underline; }
.muted { color: var(--subtle); font-size: 13px; }

.station-list { display: grid; gap: 8px; }
.station-list button {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid var(--stroke);
  background: #1f1f1f;
  color: var(--ink);
  border-radius: var(--radius-card);
  padding: 12px;
  cursor: pointer;
}
.station-list button:hover { border-color: var(--learn); }
.station-list strong { display: block; font-weight: 600; }
.station-list span { color: var(--subtle); font-size: 13px; }

.sheet-body h1 { font-size: 1.25rem; margin: 0 4.5rem 8px 0; font-weight: 600; }
.sheet-body h2 { font-size: 1rem; margin: 18px 0 8px; font-weight: 600; }

@media (max-width: 820px) {
  /* On tablets and phones, navigation moves below the map and the sheet docks above it. */
  :root {
    --pad-card: 18px;
  }

  .app-brand {
    top: 12px;
    left: 12px;
    font-size: 18px;
    max-width: calc(100% - 160px);
  }

  .hud-mode {
    top: 12px;
    right: 12px;
  }

  .hud-scale,
  .hud-coords {
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }

  
  .chrome-bar {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    left: 10px;
    transform: none;
    width: auto;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(41, 41, 41, 0.94);
    backdrop-filter: blur(16px);
  }

  .chrome-bar button {
    flex: 1 1 0;
    justify-content: center;
    min-width: 0;
    padding: 9px 6px;
    font-size: 12px;
  }

  .chrome-bar button .icon {
    width: 18px;
    height: 18px;
  }


  .callout {
    top: calc(100% + 2px);
    font-size: 10px;
    padding: 3px 6px;
  }

  .sheet {
    position: fixed;
    top: auto;
    right: 0;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    left: 0;
    transform: none;
    width: 100%;
    max-height: min(72svh, 620px);
    border-radius: 14px 14px 0 0;
    padding: 6px 16px 18px;
  }

  .sheet-close {
    top: 10px;
    right: 14px;
  }

  .sheet-hero {
    margin: 4px 4rem 12px 0;
  }

  .sheet-hero h1,
  .sheet-body h1 {
    font-size: 1.12rem;
    line-height: 1.25;
  }

  .sheet-hero p {
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .card {
    padding: 16px;
  }

  .card h3 {
    margin: 0 0 10px;
    line-height: 1.3;
  }

  .card header {
    display: grid;
    gap: 8px;
  }

  .learn {
    position: static;
    justify-self: start;
    width: fit-content;
  }

  .station-list button {
    padding: 12px 10px;
  }

  }

@media (max-width: 480px) {
  /* Compact phones need stacked nav labels and a tighter sheet header. */
  :root {
    --pad-card: 16px;
  }

  .chrome-bar {
    gap: 2px;
    padding: 4px;
  }

  .chrome-bar button {
    flex-direction: column;
    gap: 3px;
    padding: 7px 4px;
    font-size: 11px;
    line-height: 1.1;
  }


  .sheet {
    max-height: 76svh;
    padding-right: 14px;
    padding-left: 14px;
  }

  .sheet-hero {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    margin-right: 3.5rem;
  }

  .pin-face.pin-lg {
    width: 48px;
    height: 48px;
  }

  .pin-face.pin-lg::after {
    width: 24px;
    height: 24px;
  }

  .sheet-body h1 {
    margin-right: 3.5rem;
  }

  .check-item {
    gap: 9px;
    line-height: 1.4;
  }
}

@media (max-width: 360px) {
  .chrome-bar button {
    font-size: 10px;
  }

  .chrome-bar button .icon {
    width: 17px;
    height: 17px;
  }
}
