.story-map {
  margin-bottom: 28px;
  overflow: hidden;
  border: 1px solid #d4cba7;
  border-radius: 19px;
  background: #fffaf0;
  box-shadow: 0 5px 0 #c8caaa55, 0 16px 35px #6c75431a;
}

.story-map-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 23px 17px;
  border-bottom: 1px solid #daca9d;
  background: linear-gradient(110deg, #fffdf1, #f5efd9);
}

.story-map-heading .eyebrow { margin-bottom: 5px; color: #988052; }
.story-map-heading h2 { color: #52624a; font-size: 22px; }
.story-map-progress { width: 142px; text-align: right; color: #827755; font-size: 11px; }
.story-map-progress strong { color: #4d7d65; font-size: 17px; }
.story-map-progress progress { display: block; appearance: none; width: 100%; height: 5px; margin-top: 8px; overflow: hidden; border: 0; border-radius: 8px; background: #e2dac0; }
.story-map-progress progress::-webkit-progress-bar { background: #e2dac0; border-radius: 8px; }
.story-map-progress progress::-webkit-progress-value { background: #629472; border-radius: 8px; }
.story-map-progress progress::-moz-progress-bar { background: #629472; border-radius: 8px; }

.story-map-stage {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 5 / 3;
  background-color: #e9ddaf;
  background-image: url('/assets/environment/story-map.png'), radial-gradient(ellipse at 20% 70%, #8dac7966, transparent 37%), radial-gradient(ellipse at 78% 25%, #799d8570, transparent 35%), linear-gradient(145deg, #f6ecca, #d9c99b);
  background-position: center;
  background-size: cover;
}

.story-map-stage::after {
  content: '';
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(0deg, #61491418, transparent 25%, transparent 75%, #fdf2d934);
  box-shadow: inset 0 0 40px #6c532328;
}

.map-paper-edge { position: absolute; z-index: 1; inset: 12px; border: 1px solid #765e3938; border-radius: 6px; pointer-events: none; }
.story-map-routes { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.map-route-shadow, .map-route { fill: none; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.map-route-shadow { stroke: #fff4d99c; stroke-width: 8px; }
.map-route { stroke: #8a724f; stroke-width: 3px; stroke-dasharray: 7 9; }
.map-route.done { stroke: #4c7d5f; stroke-width: 4px; }
.map-route.open { stroke: #b58036; stroke-width: 4px; }

.story-map-chapter {
  position: absolute;
  z-index: 2;
  top: 11%;
  padding: 7px 13px;
  border: 1px solid #b89b5c77;
  border-radius: 4px 11px 4px 11px;
  background: #fff5d9e0;
  box-shadow: 0 2px 5px #6c53231f;
  color: #70633f;
  font-family: Georgia, serif;
  font-size: clamp(11px, 1.4vw, 17px);
  font-weight: 700;
  letter-spacing: .3px;
  transform: rotate(-2deg);
}

.story-map-chapter.chapter-1 { left: 8%; }
.story-map-chapter.chapter-2 { right: 9%; transform: rotate(2deg); }
.map-compass { position: absolute; z-index: 1; left: 7%; top: 28%; width: 7%; color: #836f4166; pointer-events: none; }
.map-compass svg { display: block; width: 100%; }

.map-node {
  --medal-size: clamp(40px, 4.7vw, 58px);
  position: absolute;
  z-index: 3;
  left: var(--map-x);
  top: var(--map-y);
  display: grid;
  place-items: center;
  width: var(--medal-size);
  height: var(--medal-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #fffaf0;
  transform: translate(-50%, -50%);
  transition: filter .18s;
}

.map-node-halo { position: absolute; inset: -5px; border: 1px solid #fff7d9b5; border-radius: 50%; background: #fff6d747; box-shadow: 0 3px 10px #5147281f; }
.map-node-medal { position: relative; display: grid; place-items: center; width: 100%; height: 100%; border: 3px solid #fff0c4; border-radius: 50%; background: #58826c; box-shadow: inset 0 -4px 0 #244d3a38, 0 3px 0 #7c7750; }
.map-node-medal b { font-size: clamp(15px, 1.9vw, 23px); font-family: Georgia, serif; }
.map-node-medal svg { width: 48%; height: 48%; }
.map-node.done .map-node-medal { background: #3d7962; border-color: #e9f0d4; }
.map-node.current .map-node-medal { background: #edac45; border-color: #fff6c9; color: #63451e; box-shadow: inset 0 -4px 0 #a977303f, 0 3px 0 #9b773f; }
.map-node.current .map-node-halo { inset: -9px; border: 2px solid #ffe9a7; box-shadow: 0 0 0 4px #ffe29a39, 0 3px 14px #7357213d; }
.map-node.locked { opacity: 1; }
.map-node.locked .map-node-medal { background: #d6cbb0; color: #70634b; border-color: #f5e9ca; box-shadow: inset 0 -3px 0 #7b6a4020, 0 3px 0 #988969; }
.map-node.locked .map-node-halo { border-color: #f6ebcb88; background: #f6ebcb35; }
.map-node:not(:disabled):hover { z-index: 4; filter: brightness(1.07); }
.map-node:not(:disabled):hover .map-node-medal { transform: scale(1.08); }
.map-node:focus-visible { z-index: 4; outline: 3px solid #2f8085; outline-offset: 9px; }
.map-node-medal { transition: transform .18s; }

.map-node-copy {
  position: absolute;
  left: 50%;
  display: block;
  width: max-content;
  max-width: 152px;
  min-width: 93px;
  padding: 7px 10px 6px;
  border: 1px solid #bca3688a;
  border-radius: 7px;
  background: #fff9e8f5;
  box-shadow: 0 3px 6px #59432120;
  color: #4b5140;
  text-align: center;
  white-space: normal;
  pointer-events: none;
  transform: translateX(-50%);
}

.label-above .map-node-copy { bottom: calc(100% + 11px); }
.label-below .map-node-copy { top: calc(100% + 11px); }
.map-node-copy strong { display: block; font-size: clamp(10px, 1.2vw, 13px); font-weight: 750; line-height: 1.35; }
.map-node-copy small { display: block; margin-top: 3px; color: #89764c; font-size: 9px; line-height: 1.3; }
.map-node.done .map-node-copy small { color: #4c7d5e; }
.map-node.current .map-node-copy { border-color: #c19a50; background: #fff9dc; }
.map-node.locked .map-node-copy { color: #746b56; background: #f4eddbec; }
.map-node.locked .map-node-copy small { color: #837861; }

.story-map-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 22px; border-top: 1px solid #d8ca9b; background: #faf5e5; color: #7c775c; font-size: 11px; }
.map-legend { display: flex; align-items: center; gap: 17px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.map-legend i { display: inline-block; width: 9px; height: 9px; border: 1px solid #78735444; border-radius: 50%; }
.map-legend .done { background: #4b8267; }
.map-legend .open { background: #e6ac4d; }
.map-legend .locked { background: #c9bda0; }

@media (max-width: 820px) {
  .story-map-heading { padding: 15px 17px; }
  .map-node { --medal-size: 40px; }
  .map-node-copy { min-width: 78px; max-width: 112px; padding: 5px 7px; }
  .map-node-copy strong { font-size: 10px; }
  .map-node-copy small { font-size: 8px; }
  .story-map-footer { padding: 12px 16px; font-size: 10px; }
  .map-legend { gap: 12px; }
}

@media (max-width: 600px) {
  .story-map { margin-bottom: 20px; border-radius: 14px; }
  .story-map-heading { padding: 13px 14px; }
  .story-map-heading h2 { font-size: 18px; }
  .story-map-heading .eyebrow { font-size: 8px; }
  .story-map-progress { width: 100px; font-size: 9px; }
  .story-map-progress strong { font-size: 14px; }
  .map-paper-edge { inset: 7px; }
  .map-node { --medal-size: 31px; min-width: 31px; min-height: 31px; }
  .map-node::before { content: ''; position: absolute; inset: -7px; border-radius: 50%; }
  .map-node-medal { border-width: 2px; }
  .map-node-medal b { font-size: 13px; }
  .map-node-halo { inset: -3px; }
  .map-node.current .map-node-halo { inset: -5px; border-width: 1px; box-shadow: 0 0 0 2px #ffe29a39; }
  .map-node-copy { width: 70px; min-width: 0; max-width: 70px; padding: 3px 4px; border-radius: 4px; }
  .map-node-copy strong { font-size: 8px; line-height: 1.25; }
  .map-node-copy small { display: none; }
  .label-above .map-node-copy { bottom: calc(100% + 5px); }
  .label-below .map-node-copy { top: calc(100% + 5px); }
  .story-map-chapter { top: 7%; padding: 3px 6px; font-size: 8px; border-radius: 3px 7px 3px 7px; }
  .story-map-chapter.chapter-1 { left: 7%; }
  .story-map-chapter.chapter-2 { right: 7%; }
  .map-compass { top: 24%; }
  .map-route-shadow { stroke-width: 5px; }
  .map-route, .map-route.done, .map-route.open { stroke-width: 2px; stroke-dasharray: 4 6; }
  .story-map-footer { align-items: flex-start; padding: 10px 12px; font-size: 8px; gap: 8px; }
  .story-map-footer p { max-width: 112px; line-height: 1.5; }
  .map-legend { gap: 8px; }
  .map-legend span { gap: 4px; }
  .map-legend i { width: 7px; height: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .map-node, .map-node-medal { transition: none; }
}
