.story-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px clamp(18px, 4vw, 58px) 28px;
  overflow: auto;
  color: #eef4ed;
  background:
    radial-gradient(1100px 540px at 18% -8%, rgba(140, 215, 197, 0.1), transparent),
    linear-gradient(180deg, rgba(10, 18, 16, 0.99), rgba(6, 10, 11, 0.99));
}

.story-screen.hidden {
  display: none;
}

.story-screen *,
.story-screen *::before,
.story-screen *::after,
.story-detail *,
.story-detail *::before,
.story-detail *::after {
  box-sizing: border-box;
}

.story-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.story-back {
  padding: 9px 16px;
  color: rgba(233, 240, 232, 0.86);
  font-size: 0.86rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  cursor: pointer;
}

.story-back:hover {
  background: rgba(255, 255, 255, 0.14);
}

.story-title span {
  display: block;
  margin-bottom: 3px;
  color: #8cd7c5;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.story-title h1 {
  margin: 0;
  font-size: 1.44rem;
  line-height: 1.2;
}

.story-head-side {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.story-progress-count {
  padding: 5px 12px;
  color: #0d1a14;
  font-size: 0.8rem;
  font-weight: 800;
  background: #8cd7c5;
  border-radius: 999px;
}

.story-reset {
  padding: 3px 8px;
  color: rgba(228, 238, 229, 0.44);
  font-size: 0.7rem;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.story-reset:hover {
  color: rgba(228, 238, 229, 0.8);
}

.story-map {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  gap: 8px;
  width: min(100%, 980px);
  min-height: 0;
  margin: 0 auto;
  overflow: visible;
}

.story-map-copy {
  display: grid;
  justify-items: center;
  gap: 3px;
  text-align: center;
}

.story-map-copy span {
  color: #8cd7c5;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.story-map-copy strong {
  font-size: 0.92rem;
}

.story-map-copy small {
  color: rgba(228, 238, 229, 0.5);
  font-size: 0.72rem;
}

.story-map-canvas {
  position: relative;
  width: clamp(260px, 25vw, 340px);
  aspect-ratio: 9 / 16;
  overflow: visible;
}

.story-map-silhouette,
.story-map-route {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.story-map-silhouette {
  border: 1px solid rgba(140, 215, 197, 0.12);
  border-radius: 12px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.34);
}

.story-route-segment {
  stroke: rgba(211, 220, 215, 0.24);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 6 8;
}

.story-route-segment.is-reached {
  stroke: #8fdcb0;
  stroke-width: 4;
  stroke-dasharray: none;
}

.story-map-node {
  position: absolute;
  left: var(--story-x);
  top: var(--story-y);
  z-index: 2;
  width: 44px;
  height: 44px;
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.story-map-node:disabled {
  cursor: not-allowed;
}

.story-node-marker {
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  color: #dfe8e4;
  background: #17211e;
  border: 2px solid rgba(220, 230, 224, 0.48);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(5, 10, 9, 0.72);
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.story-node-marker i {
  font-size: 0.58rem;
  font-style: normal;
  font-weight: 900;
}

.story-node-label {
  position: absolute;
  top: 50%;
  display: grid;
  gap: 1px;
  width: max-content;
  max-width: 156px;
  padding: 5px 8px 6px;
  text-align: left;
  background: rgba(7, 14, 12, 0.88);
  border: 1px solid rgba(168, 190, 178, 0.22);
  border-radius: 6px;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.3);
  transform: translateY(-50%);
  transition: opacity 0.14s ease, transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.story-map-node:not(.is-featured):not(.is-open) .story-node-label {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.story-map-node.is-label-right .story-node-label {
  left: 39px;
}

.story-map-node.is-label-left .story-node-label {
  right: 39px;
  text-align: right;
}

.story-node-label small {
  color: rgba(196, 211, 203, 0.58);
  font-size: 0.57rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.story-node-label strong {
  color: #f4f7f5;
  font-size: 0.74rem;
  line-height: 1.15;
}

.story-node-label em {
  display: none;
  color: #ffd166;
  font-size: 0.55rem;
  font-style: normal;
  font-weight: 800;
}

.story-map-node.is-open .story-node-marker {
  color: #241b08;
  background: #ffd166;
  border-color: #fff0bd;
  box-shadow: 0 0 0 5px rgba(255, 209, 102, 0.18), 0 0 22px rgba(255, 209, 102, 0.54);
  animation: story-node-pulse 1.7s ease-in-out infinite;
}

.story-map-node.is-open .story-node-label {
  background: rgba(31, 26, 13, 0.94);
  border-color: rgba(255, 209, 102, 0.58);
}

.story-map-node.is-open .story-node-label em,
.story-map-node.is-featured .story-node-label em {
  display: block;
}

.story-map-node.is-cleared .story-node-marker {
  color: #102018;
  background: #8fdcb0;
  border-color: #d8f5e4;
  box-shadow: 0 0 0 4px rgba(143, 220, 176, 0.17);
}

.story-map-node.is-locked .story-node-marker,
.story-map-node.is-locked .story-node-label {
  opacity: 0.48;
  filter: saturate(0.25);
}

.story-map-node.is-featured .story-node-marker {
  inset: 7px;
}

.story-map-node:not(:disabled):hover .story-node-marker,
.story-map-node:focus-visible .story-node-marker {
  transform: scale(1.14);
  border-color: #ffffff;
}

.story-map-node:not(:disabled):hover .story-node-label,
.story-map-node:focus-visible .story-node-label {
  visibility: visible;
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.7);
}

.story-map-node:disabled:hover .story-node-label {
  visibility: visible;
  opacity: 1;
}

.story-map-node:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
  border-radius: 50%;
}

.story-map-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  color: rgba(228, 238, 229, 0.56);
  font-size: 0.66rem;
  font-weight: 700;
}

.story-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.story-map-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5f6864;
}

.story-map-legend i.is-open {
  background: #ffd166;
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.5);
}

.story-map-legend i.is-cleared {
  background: #8fdcb0;
}

@keyframes story-node-pulse {
  0%, 100% { box-shadow: 0 0 0 5px rgba(255, 209, 102, 0.16), 0 0 18px rgba(255, 209, 102, 0.4); }
  50% { box-shadow: 0 0 0 9px rgba(255, 209, 102, 0.05), 0 0 27px rgba(255, 209, 102, 0.68); }
}

.story-detail {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 8, 8, 0.66);
}

.story-detail.hidden {
  display: none;
}

.story-detail-card {
  display: grid;
  gap: 14px;
  width: min(520px, calc(100vw - 40px));
  padding: 20px 22px 22px;
  color: #eef4ed;
  background: linear-gradient(180deg, rgba(15, 27, 24, 0.98), rgba(8, 13, 13, 0.98));
  border: 1px solid rgba(150, 180, 160, 0.3);
  border-radius: 10px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}

.story-detail-card header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.story-detail-card header span {
  display: block;
  margin-bottom: 3px;
  color: #8cd7c5;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.story-detail-card header strong {
  display: block;
  font-size: 1.3rem;
}

.story-detail-card header small {
  display: block;
  margin-top: 3px;
  color: rgba(228, 238, 229, 0.5);
  font-size: 0.72rem;
}

.story-detail-card header button {
  padding: 5px 11px;
  color: rgba(233, 240, 232, 0.82);
  font-size: 0.76rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  cursor: pointer;
}

.story-detail-art {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  color: rgba(228, 238, 229, 0.42);
  font-size: 0.76rem;
  background:
    linear-gradient(145deg, rgba(140, 215, 197, 0.12), rgba(20, 34, 30, 0.86)),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.025) 0 12px, transparent 12px 24px);
  border: 1px solid rgba(150, 180, 160, 0.2);
  border-radius: 7px;
}

.story-detail-art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-detail-art:not(.is-missing) span {
  display: none;
}

.story-briefing {
  margin: 0;
  color: rgba(228, 238, 229, 0.82);
  font-size: 0.92rem;
  line-height: 1.65;
}

.story-detail-meta {
  display: flex;
  gap: 8px;
}

.story-detail-meta span {
  padding: 4px 11px;
  color: rgba(233, 240, 232, 0.76);
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.story-detail-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 8px;
}

.story-detail-actions button {
  padding: 12px 10px;
  font-size: 0.92rem;
  font-weight: 800;
  border-radius: 7px;
  cursor: pointer;
  color: rgba(233, 240, 232, 0.85);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.story-detail-actions .story-start {
  color: #0d1a14;
  background: #8cd7c5;
  border-color: #8cd7c5;
}

.story-detail-actions .story-start:hover {
  background: #a5e6d6;
}

@media (max-width: 560px) {
  .story-head {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .story-head-side {
    grid-column: 1 / -1;
    justify-items: start;
  }

  .story-map-copy small {
    display: none;
  }

  .story-map-canvas {
    width: 260px;
  }

  .story-node-label {
    max-width: 112px;
    padding: 4px 6px 5px;
  }

  .story-node-label small {
    font-size: 0.52rem;
  }

  .story-node-label strong {
    font-size: 0.67rem;
  }

  .story-map-node.is-label-right .story-node-label {
    left: 35px;
  }

  .story-map-node.is-label-left .story-node-label {
    right: 35px;
  }
}

@media (max-height: 700px) and (min-width: 561px) {
  .story-screen {
    gap: 8px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .story-map-copy small {
    display: none;
  }

  .story-map-canvas {
    width: min(230px, 24vw);
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-map-node.is-open .story-node-marker {
    animation: none;
  }
}
