/* map.css — Keno Quest district map base; adventure-world.css supplies the Keno Quest art layer.
   Every rule is scoped to .candy-map / .map-* / #map* so board themes never leak in.
   Shared identity regardless of body[data-theme]. */

.candy-map, .map-button, .map-confirm, .map-sequence-status {
  --map-ink: #4a1f45;
  --map-ink-soft: #7a4a72;
  --map-cream: #fff7ec;
  --map-cream-2: #ffeede;
  --map-rasp: #e8457f;
  --map-rasp-dark: #a8174f;
  --map-tang: #ffa53d;
  --map-tang-dark: #c46a0c;
  --map-mint: #54cfa6;
  --map-mint-dark: #1f8e6a;
  --map-lilac: #b99cf2;
  --map-gold: #ffd84a;
  --map-focus: #2b1a5c;
  --map-font: "Fredoka FX", system-ui, -apple-system, "Segoe UI", sans-serif;
  --map-body: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- panel ---------- */
.candy-map {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--map-ink);
  font-family: var(--map-body);
  background: #fde7f0;
  background-image:
    radial-gradient(circle at 20% 10%, #fff3f8 0 20%, transparent 50%),
    radial-gradient(circle at 90% 90%, #e6ddff 0 25%, transparent 55%);
  overflow: hidden;
  isolation: isolate;
}
.candy-map[hidden], section#districtMap.candy-map[hidden] { display: none !important; }
section#districtMap.candy-map:not([hidden]) {
  position: fixed !important; inset: 0 !important; display: flex !important; width: auto !important; max-width: none !important;
  margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  background-color: #fde7f0 !important; color: var(--map-ink) !important; transform-origin: 50% 0;
}
body.map-open { overflow: hidden !important; overscroll-behavior: none; }
.candy-map * { box-sizing: border-box; }
.candy-map :where(h1, h2, h3, p) { margin: 0; }

/* toolbar: a frosted cream counter with a scalloped icing edge */
.candy-map .map-toolbar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 12px;
  background: linear-gradient(180deg, #fffaf3, #ffefe0);
  box-shadow: 0 2px 0 #f6c7d6;
}
.candy-map .map-toolbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -10px;
  height: 11px;
  background: radial-gradient(circle at 10px -2px, #ffefe0 0 10px, transparent 10.5px) 0 0 / 20px 11px repeat-x;
  filter: drop-shadow(0 2px 0 #f6c7d6);
  pointer-events: none;
}
.candy-map #mapBack {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 14px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #ffe3ee);
  color: var(--map-rasp-dark);
  font-family: var(--map-font);
  font-weight: 700;
  font-size: .95rem;
  box-shadow: 0 3px 0 #eaa2bd, 0 6px 12px rgba(120, 20, 70, .12);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.candy-map #mapBack:hover { transform: translateY(-1px); }
.candy-map #mapBack:active { transform: translateY(2px) !important; box-shadow: 0 1px 0 #eaa2bd; }
.candy-map #mapDistrictLabel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-family: var(--map-font);
  font-weight: 700;
  font-size: clamp(1.02rem, 3.8vw, 1.35rem);
  color: var(--map-ink);
  letter-spacing: .01em;
}
.candy-map #mapBalance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #8e3974, #6a2356);
  border: 2px solid #f6c9e3;
  color: #fff8e6;
  font-family: var(--map-font);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .25);
  white-space: nowrap;
}
.candy-map #mapBalance svg { width: 22px; height: 22px; flex: none; }

/* host & scroller */
.candy-map #mapHost, .candy-map .map-host {
  position: relative;
  /* Keep mascot/fog depth inside the scene, below sibling guidance and controls. */
  isolation: isolate;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent;
}
.map-root { position: absolute; inset: 0; }
.map-root.is-paused *, .map-root.is-paused *::before, .map-root.is-paused *::after { animation-play-state: paused !important; }
.map-viewport {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  outline: none;
  background:
    radial-gradient(circle, rgba(232, 69, 127, .09) 1.5px, transparent 2px) 0 0 / 22px 22px,
    linear-gradient(180deg, #f3e8ff, #ffe7f0);
}
.map-world {
  position: relative;
  margin: 0 auto;
  overflow: visible;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .5), 0 0 60px rgba(123, 45, 107, .18);
}
.map-world-cap {
  position: absolute; left: 0; right: 0; top: 0; height: 150px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #efe6ff, rgba(255, 255, 255, .8));
  -webkit-mask: radial-gradient(circle at 20px 150px, transparent 22px, #000 22.5px) 0 0 / 40px 100%;
}
.map-world-cap-text {
  padding: 6px 16px; border-radius: 999px; background: #fff; color: var(--map-ink-soft);
  font-family: var(--map-font); font-weight: 600; font-size: .85rem; box-shadow: 0 3px 0 #dcd0f3;
}
.map-world-start {
  position: absolute; left: 0; right: 0; bottom: 0; height: 96px; z-index: 2;
  display: flex; justify-content: center; align-items: flex-start; padding-top: 22px;
}
.map-world-entrance { position: absolute; left: 0; right: 0; overflow: hidden; pointer-events: none; }
.map-world-entrance-ground, .map-world-entrance-trees { position: absolute; left: 0; right: 0; top: 0; }
.map-world-entrance-ground svg { display: block; width: 100%; height: 100%; transform: scaleY(-1); }
.map-world-entrance-trees svg { display: block; overflow: visible; }
.map-world-start span {
  padding: 5px 18px; border-radius: 12px; background: var(--map-rasp); color: #fff;
  font-family: var(--map-font); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem;
  box-shadow: 0 3px 0 var(--map-rasp-dark);
}

/* ---------- district ---------- */
.map-district {
  position: absolute;
  left: 0;
  overflow: hidden;
  contain: layout paint;
}
.map-scenery, .map-ground, .map-ground svg { position: absolute; inset: 0; pointer-events: none; }
.map-ground svg { width: 100%; height: 100%; display: block; }
.map-layer-bg, .map-layer-fg { position: absolute; left: 0; right: 0; pointer-events: none; will-change: transform; }
.map-layer-fg { top: 0; bottom: 0; z-index: 4; }
.map-layer-bg svg, .map-layer-fg svg { display: block; overflow: visible; }
.map-path-svg { position: absolute; left: 0; top: 0; z-index: 1; overflow: visible; pointer-events: none; }
.map-path-shadow { fill: none; stroke: var(--d-deep); stroke-opacity: .2; stroke-width: 38; stroke-linecap: round; transform: translateY(6px); }
.map-path-track { fill: none; stroke: var(--d-cream); stroke-width: 30; stroke-linecap: round; }
.map-path-dash { fill: none; stroke: var(--d-accent); stroke-opacity: .28; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 2 16; }
.map-path-paint { fill: none; stroke: var(--d-accent); stroke-width: 20; stroke-linecap: round; }
.map-path-gloss { fill: none; stroke: #fff; stroke-opacity: .55; stroke-width: 5; stroke-linecap: round; transform: translate(-3px, -4px); }

.map-buildings { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.map-building { position: absolute; transform-origin: 50% 88%; }
.map-building-art, .map-scaffold { position: absolute; inset: 0; }
.map-building-art svg, .map-scaffold svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 6px 5px rgba(74, 31, 69, .16)); }
.map-scaffold[hidden] { display: none !important; }
.map-building.is-empty .map-building-art svg { filter: none; opacity: .92; }
.map-plaque {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  min-width: 86px;
  max-width: 130%;
  padding: 3px 10px 4px;
  border-radius: 10px;
  background: var(--map-cream);
  border: 2px solid var(--d-cream);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--d-deep) 55%, transparent), 0 6px 10px rgba(74, 31, 69, .12);
  line-height: 1.1;
  text-align: center;
}
.map-plaque-name { font-family: var(--map-font); font-weight: 600; font-size: .72rem; color: var(--d-deep-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.map-plaque-level { font-family: var(--map-font); font-weight: 700; font-size: .64rem; color: var(--d-accent-dark); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.map-building.is-max .map-plaque { background: linear-gradient(180deg, #fff9d6, #ffe38c); border-color: #fff4b8; }
.map-building.is-max .map-plaque-level { color: #9a5a06; }
.map-art-sparkle { transform-box: fill-box; transform-origin: center; animation: mapTwinkle 2.4s ease-in-out infinite; }
.map-art-sparkle:nth-of-type(2n) { animation-delay: -1.1s; }
.map-art-sails { transform-box: view-box; transform-origin: 60px 58px; animation: mapSpin 9s linear infinite; }
.map-art-puff { animation: mapPuff 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

.map-district-sign {
  position: absolute;
  z-index: 3;
  display: grid;
  gap: 1px;
  padding: 7px 14px 8px;
  border-radius: 14px 14px 14px 4px;
  background: linear-gradient(180deg, #fffdf8, var(--d-cream));
  border: 3px solid #fff;
  box-shadow: 0 4px 0 var(--d-deep), 0 10px 18px rgba(74, 31, 69, .18);
  transform: rotate(-3deg);
  pointer-events: none;
  max-width: 46%;
}
.map-district-sign.is-left { left: 6%; }
.map-district-sign.is-right { right: 6%; transform: rotate(3deg); border-radius: 14px 14px 4px 14px; }
.map-district-sign-kicker { font-size: .62rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--d-accent-dark); }
.map-district-sign-name { font-family: var(--map-font); font-weight: 700; font-size: 1.05rem; line-height: 1.05; color: var(--d-deep-dark); }

/* gate */
.map-gate {
  position: absolute;
  z-index: 3;
  width: 128px;
  height: 110px;
  margin: -96px 0 0 -64px;
  pointer-events: none;
}
.map-gate-arch { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.map-gate-doors { position: absolute; left: 22px; right: 22px; top: 36px; bottom: 6px; display: flex; perspective: 260px; }
.map-gate-door { flex: 1; height: 100%; transition: transform .7s cubic-bezier(.34, 1.4, .64, 1), opacity .5s ease; }
.map-gate-door svg { width: 100%; height: 100%; display: block; }
.map-gate-door.is-left { transform-origin: 0 50%; }
.map-gate-door.is-right { transform-origin: 100% 50%; }
.map-gate.is-open .map-gate-door.is-left { transform: rotateY(-78deg); opacity: .85; }
.map-gate.is-open .map-gate-door.is-right { transform: rotateY(78deg); opacity: .85; }
.map-gate.is-open .map-gate-doors { background: radial-gradient(ellipse at 50% 60%, rgba(255, 248, 200, .95), rgba(255, 230, 150, 0) 70%); }

/* ---------- nodes ---------- */
.map-nodes { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.candy-map .map-node {
  position: absolute;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  pointer-events: auto;
  outline: none;
  transition: none;
  -webkit-tap-highlight-color: transparent;
}
.candy-map .map-node:active { transform: scale(.94) !important; }
.candy-map .map-node[aria-disabled="true"] { cursor: default; }
.candy-map .map-node:focus-visible,
body[data-theme] .candy-map .map-node:focus-visible { outline: 4px solid var(--map-focus); outline-offset: 5px; box-shadow: 0 0 0 9px #fff; }
.map-node-bead {
  position: absolute;
  inset: 3px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 35% 28%, #ffffff, #efeaf1 45%, #cfc8d6);
  border: 3px solid #fff;
  box-shadow: 0 5px 0 #a79db0, 0 8px 12px rgba(60, 40, 70, .22);
  transition: box-shadow .2s ease;
}
.map-node-liquid {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--d-accent) 70%, #fff), var(--d-accent) 45%, var(--d-accent-dark));
  transform-origin: 50% 100%;
  transform: scaleY(0);
}
.map-node-wave {
  position: absolute; left: -20%; right: -20%; top: -4px; height: 8px; border-radius: 50%;
  background: rgba(255, 255, 255, .55);
}
.map-node-shine {
  position: absolute; left: 18%; top: 12%; width: 34%; height: 22%; border-radius: 50%;
  background: rgba(255, 255, 255, .75); transform: rotate(-25deg); z-index: 2; pointer-events: none;
}
.map-node-num {
  position: relative; z-index: 3;
  font-family: var(--map-font); font-weight: 700; font-size: 1.05rem; line-height: 1;
  color: #8e8697; font-variant-numeric: tabular-nums;
}
.map-node-gate-mark {
  position: relative; z-index: 3; width: 22px; height: 18px;
  border: 3.5px solid currentColor; border-bottom: 0; border-radius: 12px 12px 0 0; color: #8e8697;
}
.map-node .map-icon { position: absolute; pointer-events: none; }
.map-node-lock { width: 22px; height: 22px; right: -4px; bottom: -3px; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .2)); }
.map-node-star { width: 22px; height: 22px; right: -5px; top: -6px; opacity: 0; transform: scale(.4); }
.map-node-sparkle { width: 14px; height: 14px; left: -3px; top: 2px; opacity: 0; }
.map-node-halo {
  position: absolute; inset: -9px; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, color-mix(in srgb, var(--d-accent) 0%, transparent) 50%, color-mix(in srgb, var(--d-accent) 45%, transparent) 62%, transparent 72%);
}
.map-node-tag {
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  display: none;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 5px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf6, #ffe7a3);
  border: 2px solid #fff;
  color: #6b3a04;
  font-family: var(--map-font);
  font-weight: 700;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 3px 0 #d69a2a, 0 6px 10px rgba(107, 58, 4, .2);
  pointer-events: none;
}
.map-node-tag::before, .map-node-tag::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 12px;
  height: 18px;
  margin-top: -9px;
  background: #ffd46a;
}
.map-node-tag::before { right: 100%; margin-right: -1px; clip-path: polygon(100% 22%, 0 0, 30% 50%, 0 100%, 100% 78%); }
.map-node-tag::after { left: 100%; margin-left: -1px; clip-path: polygon(0 22%, 100% 0, 70% 50%, 100% 100%, 0 78%); }
.map-node-tag .map-icon { position: static; width: 17px; height: 17px; flex: none; }

/* locked */
.map-node.is-locked .map-node-bead { filter: saturate(.2); }
/* available */
.map-node.is-available .map-node-bead {
  background: radial-gradient(circle at 35% 28%, #ffffff, var(--d-cream) 50%, color-mix(in srgb, var(--d-accent) 35%, var(--d-cream)));
  border-color: #fff;
  box-shadow: 0 5px 0 var(--d-accent-dark), 0 0 0 4px color-mix(in srgb, var(--d-accent) 40%, #fff), 0 10px 16px rgba(74, 31, 69, .25);
  animation: mapBounce 1.5s cubic-bezier(.34, 1.56, .64, 1) infinite;
}
.map-node.is-available .map-node-num, .map-node.is-available .map-node-gate-mark { color: var(--d-accent-dark); }
.map-node.is-available .map-node-halo { opacity: 1; animation: mapHalo 1.8s ease-out infinite; }
.map-node.is-available .map-node-lock { display: none; }
.map-node.is-available .map-node-tag { display: inline-flex; }
/* purchased */
.map-node.is-purchased .map-node-liquid { transform: scaleY(1); }
.map-node.is-purchased .map-node-bead { box-shadow: 0 5px 0 var(--d-deep-dark), 0 8px 12px rgba(74, 31, 69, .22); }
.map-node.is-purchased .map-node-num, .map-node.is-purchased .map-node-gate-mark { color: #fff; text-shadow: 0 2px 0 var(--d-accent-dark); }
.map-node.is-purchased .map-node-lock { display: none; }
.map-node.is-purchased .map-node-star { opacity: 1; transform: scale(1) rotate(12deg); }
.map-node.is-purchased .map-node-sparkle { animation: mapTwinkle 2.6s ease-in-out infinite; }
.map-node.is-purchased:nth-child(3n) .map-node-sparkle { animation-delay: -.9s; }
.map-node.is-purchased:nth-child(3n+1) .map-node-sparkle { animation-delay: -1.7s; }
.map-node.is-gate .map-node-bead { inset: -1px; }
.map-node.is-gate.is-purchased .map-node-bead { background: radial-gradient(circle, #fff6c2, #ffd84a); }

/* ---------- mascot ---------- */
.map-mascot {
  position: absolute;
  z-index: 30;
  width: 50px;
  height: 54px;
  margin: -78px 0 0 -25px;
  pointer-events: none;
}
.map-mascot-flip, .map-mascot-bob { width: 100%; height: 100%; }
.map-mascot-flip { transition: transform .22s cubic-bezier(.34, 1.56, .64, 1); }
.map-mascot.is-facing-left .map-mascot-flip { transform: scaleX(-1); }
.map-mascot-bob { transform-origin: 50% 100%; animation: mapBob 2.2s ease-in-out infinite; }
.map-mascot-svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 4px 3px rgba(74, 31, 69, .25)); }
.map-mascot-eyes { transform-box: fill-box; transform-origin: center; animation: mapBlink 4.6s infinite; }
.map-mascot-shadow { display: none; }

/* ---------- fog ---------- */
.map-fog { position: absolute; inset: 0; z-index: 40; pointer-events: none; }
.map-fog.is-clear { display: none; }
.map-fog-half { position: absolute; top: 0; bottom: 0; width: 50%; }
.map-fog-half.is-left { left: 0; }
.map-fog-half.is-right { right: 0; }
.map-fog-half svg { width: 100%; height: 100%; display: block; }
.map-fog.is-opaque { pointer-events: auto; }
.map-fog.is-clouds .map-fog-half { opacity: 1; }
.map-fog.is-clouds .map-fog-half svg rect:first-child { opacity: .18; }
.map-fog-label {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  max-width: min(86%, 320px);
  padding: 10px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 4px 0 #d9ccf2, 0 10px 20px rgba(80, 50, 130, .15);
  color: var(--map-ink-soft);
  font-family: var(--map-font);
  font-weight: 600;
  font-size: .92rem;
  text-align: center;
}

/* ---------- first-visit village tip ---------- */
.candy-map .map-guide-help {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 7;
  width: 44px;
  height: 44px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--map-cream);
  color: var(--map-rasp-dark);
  font: 700 1.25rem var(--map-font);
  box-shadow: 0 3px 0 #eaa2bd, 0 6px 12px rgba(120, 20, 70, .15);
  cursor: pointer;
}
.candy-map .map-guide {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 60px);
  z-index: 7;
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - 170px);
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 3px solid #fff;
  border-radius: 20px;
  background: linear-gradient(180deg, #fffaf3, #ffeede);
  box-shadow: 0 4px 0 #eaa2bd, 0 12px 32px rgba(120, 30, 90, .2);
  color: var(--map-ink);
  line-height: 1.45;
}
.candy-map .map-guide[hidden] { display: none !important; }
.candy-map .map-guide:focus-visible { outline: 3px solid var(--map-focus); outline-offset: 3px; }
.candy-map #mapGuideTitle { font: 700 1.15rem var(--map-font); color: var(--map-rasp-dark); }
.candy-map #mapNextBuild { font-family: var(--map-font); font-weight: 700; font-size: .95rem; }
.candy-map :is(#mapModeNote, #mapGuideInstructions) { font-size: .82rem; font-weight: 500; color: var(--map-ink-soft); }
.candy-map .map-guide-actions { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }
.candy-map .map-guide-dismiss {
  min-height: 44px;
  padding: 8px 20px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--map-rasp);
  color: #fff;
  font: 700 .95rem var(--map-font);
  box-shadow: 0 3px 0 var(--map-rasp-dark);
  cursor: pointer;
}

/* ---------- sequence HUD ---------- */
.map-sequence-status {
  position: absolute;
  left: 50%;
  top: 76px;
  z-index: 60;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(74, 31, 69, .88);
  color: #fff7ec;
  font-family: var(--map-font);
  font-weight: 600;
  font-size: .86rem;
  box-shadow: 0 6px 16px rgba(40, 10, 40, .3);
  pointer-events: none;
  white-space: nowrap;
}
.map-sequence-status[hidden] { display: none !important; }

/* ---------- completed-building preview (read-only) ---------- */
.map-confirm {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(380px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 20px 20px 18px;
  border: 4px solid #fff;
  outline: 3px solid var(--map-rasp);
  outline-offset: -1px;
  border-radius: 28px;
  background: linear-gradient(170deg, #fffaf3 0%, #ffeef4 60%, #ffe0ec 100%);
  color: var(--map-ink);
  font-family: var(--map-body);
  box-shadow: 0 10px 0 var(--map-rasp-dark), 0 28px 50px rgba(60, 5, 50, .4);
  text-align: center;
  z-index: 9500;
}
.map-confirm::backdrop { background: rgba(66, 10, 60, .55); }
.map-confirm[open] { animation: mapPop .32s cubic-bezier(.34, 1.56, .64, 1) both; }
.map-confirm #mapConfirmTitle {
  margin: 0 0 10px;
  font-family: var(--map-font);
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1.1;
  color: var(--map-rasp-dark);
}
.map-confirm #mapBuildingPreview {
  position: relative;
  width: 180px;
  height: 172px;
  margin: 0 auto 12px;
  padding: 10px 14px 0;
  border-radius: 50% 50% 22px 22px;
  background:
    radial-gradient(circle at 50% 110%, rgba(255, 255, 255, .9) 0 30%, transparent 60%),
    repeating-conic-gradient(from 0deg at 50% 100%, #ffe0ec 0 10deg, #fff4f8 10deg 20deg);
  border: 3px solid #fff;
  box-shadow: inset 0 -8px 0 rgba(232, 69, 127, .12), 0 5px 0 #f3b3cb;
}
.map-confirm #mapBuildingPreview svg { width: 100%; height: 100%; display: block; overflow: visible; }
.map-confirm #mapConfirmCopy { margin: 0 0 12px; font-size: .95rem; line-height: 1.4; color: var(--map-ink); }
.map-confirm #mapConfirmCopy strong, .map-confirm #mapConfirmCopy b { font-family: var(--map-font); color: #9a5a06; }
.map-confirm .map-confirm-actions, .map-confirm menu, .map-confirm footer { display: flex; gap: 10px; margin: 0; padding: 0; }
.map-confirm #mapConfirmCancel {
  flex: 1;
  min-height: 48px;
  padding: 10px 12px;
  border: 3px solid #fff;
  border-radius: 16px;
  font-family: var(--map-font);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.map-confirm #mapConfirmCancel { background: linear-gradient(180deg, #fbf5fb, #eadff0); color: var(--map-ink); box-shadow: 0 4px 0 #cbbcd4; }
.map-confirm #mapConfirmCancel:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.04); }
.map-confirm #mapConfirmCancel:active:not(:disabled) { transform: translateY(3px) !important; box-shadow: 0 1px 0 #cbbcd4; }
.map-confirm #mapConfirmCancel:focus-visible,
body[data-theme] .map-confirm #mapConfirmCancel:focus-visible,
body[data-theme] .candy-map #mapBack:focus-visible,
.candy-map #mapBack:focus-visible { outline: 4px solid var(--map-focus); outline-offset: 3px; }

/* ---------- header map button ---------- */
#mapButton.map-button,
body[data-theme] #mapButton.map-button {
  position: relative;
  display: flex;
  /* The header stays narrow even on desktop: don't squeeze this into its wallet column. */
  grid-column: 1 / -1;
  justify-self: stretch;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 14px;
  border: 2px solid #fff;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff7fb, #ffe4ef);
  color: var(--map-rasp-dark);
  font-family: var(--map-font);
  font-weight: 700;
  font-size: 1rem;
  font-style: normal;
  line-height: 1.25;
  letter-spacing: normal;
  text-align: left;
  text-shadow: none;
  box-shadow: 0 3px 0 #da88a9, 0 5px 10px rgba(168, 23, 79, .12);
  cursor: pointer;
  white-space: normal;
}
#mapButton.map-button:hover { filter: brightness(1.05); }
#mapButton.map-button:active { box-shadow: 0 1px 0 var(--map-rasp-dark); }
#mapButton.map-button:focus-visible,
body[data-theme] #mapButton.map-button:focus-visible { outline: 4px solid var(--map-focus); outline-offset: 3px; }
#mapButton .map-button-copy {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 3px;
  text-align: left;
}
#mapButton .map-button-copy strong { display: block; font-size: 1rem; line-height: 1.25; overflow-wrap: anywhere; }
#mapButton .map-button-copy small {
  display: block;
  font-family: var(--map-body);
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--map-ink-soft);
  overflow-wrap: anywhere;
}
#mapButton .map-button-arrow { flex: none; font-size: 1.2rem; line-height: 1; }
#mapButton .map-progress-ring { width: 36px; height: 36px; flex: none; color: var(--map-rasp-dark); border-radius: 50%; background: #fff7ec; box-shadow: inset 0 -2px 0 #f3c3d6; overflow: visible; }
#mapButton .map-ring-track { fill: none; stroke: #ffd3e3; }
#mapButton #mapProgressRing { fill: none; stroke: var(--map-mint-dark); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.34, 1.3, .64, 1); }
#mapButton.map-button:disabled { filter: saturate(.35); opacity: .7; cursor: default; }

/* ---------- controller markup ---------- */
.candy-map .map-host[hidden], .candy-map .village-host[hidden] { display: none !important; }
.candy-map .village-host { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.map-confirm #mapBuildingPreview.village-previews {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  width: 100%; height: auto; padding: 0; background: none; border: 0; box-shadow: none;
}
.map-confirm .village-preview-stage {
  min-width: 0; padding: 6px 3px 9px; border: 2px solid #eedbea; border-radius: 14px;
  background: radial-gradient(90% 40% at 50% 92%, #f3e2cf 0 60%, transparent 62%), linear-gradient(180deg, #fff3e8, #fff9f2); text-align: center; color: var(--map-ink-soft);
}
.map-confirm #mapBuildingPreview.village-previews .village-preview-stage svg { display: block; width: 100%; height: 100px; }
.map-confirm #mapBuildingPreview.village-previews .cv-art {
  display: block; width: 100%; max-width: 124px; height: auto; aspect-ratio: 1; margin: 2px auto 6px;
}
.map-confirm .village-preview-stage > .village-preview-label { display: block; font: 600 .8rem/1.4 var(--map-font); }
.map-confirm .village-preview-stage small { display: block; font: 500 .65rem/1.4 var(--map-body); }
.map-confirm .village-preview-stage.is-target { border-color: var(--map-rasp); background: linear-gradient(180deg, #fff8e8, #ffe6f0); color: var(--map-rasp-dark); }
.map-confirm .village-preview-stage.is-built { border-color: var(--map-mint-dark); }
.map-node.is-gate .map-node-gate-mark {
  position: absolute; top: -9px; right: -6px; width: 16px; height: 19px;
  border-width: 2px; color: var(--d-deep); background: var(--d-cream); pointer-events: none;
}
.candy-map .map-toolbar { grid-template-columns: auto minmax(0, 1fr) auto; }
.candy-map .map-toolbar-title { min-width: 0; display: grid; justify-items: center; text-align: center; line-height: 1.1; }
.candy-map .map-toolbar-title h2, .candy-map #mapTitle { margin: 0; font-family: var(--map-font); font-weight: 700; font-size: clamp(1.05rem, 4vw, 1.4rem); color: var(--map-rasp-dark); }
.candy-map #mapDistrictLabel { font-size: .82rem; font-weight: 600; color: var(--map-ink-soft); max-width: 100%; }
.map-eyebrow { display: block; font-family: var(--map-body); font-size: .6rem; font-weight: 800; letter-spacing: .18em; color: var(--map-tang-dark); }
.candy-map .map-toolbar-actions { display: flex; align-items: center; gap: 8px; }
.candy-map .map-wallet { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 4px 12px 4px 6px; border-radius: 999px; background: linear-gradient(180deg, #8e3974, #6a2356); border: 2px solid #f6c9e3; box-shadow: inset 0 2px 4px rgba(0,0,0,.25); }
.candy-map .map-wallet svg { width: 22px; height: 22px; flex: none; }
.candy-map .map-wallet #mapBalance { min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; }
.candy-map .map-load-state { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; pointer-events: none;
  font-family: var(--map-font); font-weight: 600; color: var(--map-ink-soft);
  background: radial-gradient(circle, rgba(232,69,127,.1) 1.5px, transparent 2px) 0 0 / 22px 22px, linear-gradient(180deg, #f3e8ff, #ffe7f0); }
.candy-map .map-load-state[hidden] { display: none !important; }
.candy-map .map-load-state > * { pointer-events: auto; }
.candy-map .map-load-state::before { content: ""; width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #ff8fb8 50%, #c41f5d); box-shadow: 0 5px 0 #a8174f; animation: mapBounce 1.4s cubic-bezier(.34,1.56,.64,1) infinite; }
.candy-map :is(.map-retry, .map-current-button, .map-skip, .map-return-button) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 7px 16px;
  border: 2px solid #fff; border-radius: 999px; font-family: var(--map-font); font-weight: 700; font-size: .9rem; cursor: pointer;
  background: linear-gradient(180deg, #8ff0cf, var(--map-mint)); color: #0f4d39; box-shadow: 0 3px 0 var(--map-mint-dark);
}
.candy-map :is(.map-retry, .map-current-button, .map-skip, .map-return-button)[hidden] { display: none !important; }
.candy-map :is(.map-retry, .map-current-button, .map-skip, .map-return-button):active:not(:disabled) { transform: translateY(2px) !important; box-shadow: 0 1px 0 var(--map-mint-dark); }
.candy-map :is(.map-current-button, .map-return-button):disabled { opacity: .5; cursor: default; filter: saturate(.3); }
.candy-map :is(.map-retry, .map-current-button, .map-skip, .map-return-button, .map-back):focus-visible,
body[data-theme] .candy-map :is(button, select, summary, .map-node):focus-visible { outline: 4px solid var(--map-focus) !important; outline-offset: 3px !important; }
.candy-map .map-current-button { flex: none; }
.candy-map .map-feedback-wrap { position: relative; z-index: 60; flex: none; }
.candy-map .map-feedback:not(.sr-only) {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  padding: 8px 68px max(8px, env(safe-area-inset-bottom)) 12px;
  border-top: 3px solid #fff; border-radius: 20px 20px 0 0; background: #fff8f0;
}
.candy-map .map-announcements { font-size: .8rem; line-height: 1.4; font-weight: 600; color: var(--map-ink-soft); overflow-wrap: anywhere; }
.candy-map .map-announcements:empty { display: none; }
.candy-map .map-announcements > * { margin: 0 !important; padding: 0 !important; background: none !important; border: 0 !important; box-shadow: none !important; color: inherit !important; font: inherit !important; }
.candy-map .map-announcements:is([data-kind="shortfall"], [data-kind="unavailable"], [data-kind="error"]) {
  padding: 7px 10px; border: 2px solid #e6afc9; border-radius: 12px; background: #fff4f7; color: #681d49;
}
.candy-map .map-announcements[data-kind="error"] { border-color: #c45c7a; }
.candy-map .map-return-button { align-self: flex-start; min-height: 44px; margin-top: 3px; }
.candy-map .map-feedback-wrap .map-sequence-status { position: absolute; top: auto; bottom: calc(100% + 64px); max-width: calc(100% - 32px); margin: 0; white-space: normal; text-align: center; }
.candy-map .map-skip { position: absolute; right: 76px; bottom: calc(100% + 12px); z-index: 61; background: linear-gradient(180deg, #fff, #ffe3ee); color: var(--map-rasp-dark); box-shadow: 0 3px 0 #eaa2bd, 0 8px 16px rgba(120,20,70,.2); }
.map-confirm .map-preview-content { margin: 0; }
.map-confirm .map-eyebrow { margin-bottom: 4px; }
.map-confirm .map-confirm-disclosure { margin: 12px 0 0; font-size: .74rem; color: var(--map-ink-soft); }

/* ---------- keyframes ---------- */
@keyframes mapBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-7px) scale(1.03, .97); }
  55% { transform: translateY(0) scale(1.05, .94); }
  70% { transform: translateY(-2px) scale(.99, 1.01); }
}
@keyframes mapHalo { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes mapTwinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 45%, 60% { opacity: 1; transform: scale(1) rotate(25deg); } }
@keyframes mapBob { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-4px) scale(.97, 1.03); } }
@keyframes mapBlink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes mapSpin { to { transform: rotate(360deg); } }
@keyframes mapPuff { 0%, 100% { opacity: .75; transform: translateY(0); } 50% { opacity: .35; transform: translateY(-4px) scale(1.15); } }
@keyframes mapPop { 0% { opacity: 0; transform: scale(.82) translateY(12px); } 100% { opacity: 1; transform: none; } }

/* ---------- narrow screens ---------- */
@media (max-width: 480px) {
  .candy-map .map-toolbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; padding-inline: 8px; }
  .candy-map .map-toolbar-actions { flex-direction: column-reverse; gap: 4px; }
  .candy-map .map-wallet { min-height: 30px; font-size: .86rem; }
  .candy-map .map-eyebrow { display: none; }
  .candy-map #mapBack { padding: 6px 10px; font-size: .86rem; }
  .map-district-sign-name { font-size: .92rem; }
  .map-plaque { min-width: 72px; padding: 2px 7px 3px; }
  .map-plaque-name { font-size: .64rem; }
  .candy-map #mapNextBuild { font-size: .9rem; }
}

/* ---------- reduced motion / forced colors ---------- */
@media (prefers-reduced-motion: reduce) {
  .map-root *, .map-root *::before, .map-root *::after,
  .map-confirm, .map-confirm * { animation: none !important; transition: none !important; }
  .map-layer-bg, .map-layer-fg { transform: none !important; }
}
body.fx-reduced-motion :is(.candy-map, .map-confirm, .map-button) *,
body.fx-reduced-motion :is(.candy-map, .map-confirm) *::before,
body.fx-reduced-motion .map-confirm { animation: none !important; transition: none !important; }
body.fx-reduced-motion .map-layer-bg, body.fx-reduced-motion .map-layer-fg { transform: none !important; }
body.fx-paused .candy-map *, body.fx-paused .candy-map *::before { animation-play-state: paused !important; }
@media (forced-colors: active) {
  .map-scenery, .map-layer-fg, .map-path-shadow, .map-path-gloss, .map-node-halo { display: none; }
  .map-path-track { stroke: CanvasText; stroke-width: 4; }
  .map-path-paint { stroke: Highlight; stroke-width: 8; }
  .map-node-bead { forced-color-adjust: none; background: Canvas; border-color: CanvasText; }
  .map-node.is-available .map-node-bead { border-color: Highlight; border-width: 5px; }
  .map-node.is-purchased .map-node-liquid { background: Highlight; }
  .map-node-tag { forced-color-adjust: none; background: Canvas; color: CanvasText; border-color: CanvasText; }
  .candy-map .map-node:focus-visible { outline-color: Highlight; }
}

/* Persistent map stamp for saved completed villages (shown by .is-purchased). */
.map-node-complete {
  position: absolute; left: 50%; top: calc(100% + 4px); z-index: 2;
  display: none; padding: 1px 8px 2px; transform: translateX(-50%);
  border-radius: 6px; white-space: nowrap; pointer-events: none;
  font: 800 .64rem/1.2 var(--map-font, system-ui, sans-serif); letter-spacing: .07em; text-transform: uppercase;
  color: #fff; background: linear-gradient(180deg, #3fae7f, #23825b);
  border: 1.5px solid #e8fff2; box-shadow: 0 2px 0 #17583d, 0 3px 6px rgba(20, 60, 40, .25);
}
.map-node.is-purchased .map-node-complete { display: block; }
@media (forced-colors: active) {
  .map-node-complete { forced-color-adjust: none; background: Canvas; color: CanvasText; border-color: CanvasText; box-shadow: none; }
}
