:root {
  color-scheme: light;
  --paper: #fbf8f0;
  --paper-deep: #f1eadc;
  --ink: #344b5d;
  --ink-soft: #6f7f84;
  --blue: #5c768d;
  --blue-deep: #415f75;
  --blue-pale: #dce7e7;
  --sage: #a8b8a7;
  --gold: #d2a15d;
  --gold-pale: #f3dfb8;
  --rose: #c9a6a1;
  --shadow: 0 24px 70px rgba(57, 74, 82, 0.2);
  --soft-shadow: 0 12px 32px rgba(56, 78, 99, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #dfe8e4;
}

body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  font-family: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  background:
    radial-gradient(circle at 15% 8%, rgba(255, 244, 207, 0.78), transparent 27rem),
    radial-gradient(circle at 88% 85%, rgba(118, 151, 159, 0.32), transparent 30rem),
    linear-gradient(145deg, #dfe9e4, #e9e7dc 48%, #d7e2e3);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    repeating-linear-gradient(17deg, rgba(63, 80, 87, 0.055) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(103deg, rgba(255, 255, 255, 0.24) 0 1px, transparent 1px 7px);
  mix-blend-mode: multiply;
  z-index: 50;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(210, 161, 93, 0.65);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.ambient-wash {
  position: fixed;
  width: 34rem;
  aspect-ratio: 1;
  border-radius: 45% 55% 62% 38%;
  filter: blur(34px);
  opacity: 0.22;
  pointer-events: none;
  animation: drift 18s ease-in-out infinite alternate;
}

.wash-one {
  top: -13rem;
  left: -12rem;
  background: #ffe5ad;
}

.wash-two {
  right: -15rem;
  bottom: -10rem;
  background: #81a9b2;
  animation-delay: -8s;
}

@keyframes drift {
  to { transform: translate3d(2.5rem, 1.5rem, 0) rotate(8deg) scale(1.08); }
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.4rem;
  color: var(--blue-deep);
  background: var(--paper);
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-screen p {
  margin: 0;
  letter-spacing: 0.1em;
  font-size: 0.92rem;
}

.loading-mark {
  display: flex;
  gap: 0.55rem;
  align-items: flex-end;
  height: 2.5rem;
}

.loading-mark span {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50% 50% 42% 58%;
  background: var(--gold);
  animation: leaf-breathe 1.15s ease-in-out infinite alternate;
}

.loading-mark span:nth-child(2) { animation-delay: 0.18s; background: var(--sage); }
.loading-mark span:nth-child(3) { animation-delay: 0.36s; background: var(--blue); }

@keyframes leaf-breathe {
  to { transform: translateY(-1.2rem) rotate(24deg) scale(0.72); opacity: 0.4; }
}

.book-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 760px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  background:
    linear-gradient(rgba(251, 248, 240, 0.92), rgba(251, 248, 240, 0.96)),
    repeating-linear-gradient(9deg, transparent 0 5px, rgba(92, 118, 141, 0.035) 6px);
  box-shadow: var(--shadow);
}

.book-shell.is-ready {
  opacity: 1;
  transform: none;
}

.screen-enter {
  animation: page-in 0.55s cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(12px); }
}

.start-screen {
  min-height: 100svh;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

.cover-card {
  position: relative;
  height: clamp(330px, 52svh, 490px);
  overflow: hidden;
  background: var(--blue-pale);
  isolation: isolate;
}

.cover-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.035);
  animation: cover-breathe 15s ease-in-out infinite alternate;
}

@keyframes cover-breathe {
  to { transform: scale(1.11) translate3d(-0.8%, -0.5%, 0); }
}

.cover-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(30, 50, 56, 0.04) 20%, rgba(36, 52, 58, 0.78) 100%);
}

.cover-vignette::before {
  content: "";
  position: absolute;
  inset: auto -3% -8% -3%;
  height: 28%;
  background: var(--paper);
  filter: blur(16px);
  clip-path: polygon(0 52%, 6% 38%, 13% 54%, 21% 36%, 31% 52%, 41% 31%, 52% 51%, 64% 34%, 74% 51%, 85% 30%, 100% 49%, 100% 100%, 0 100%);
}

.cover-copy {
  position: absolute;
  inset: auto 2rem 2.6rem;
  color: white;
  text-shadow: 0 2px 18px rgba(24, 39, 43, 0.55);
}

.eyebrow {
  display: block;
  margin-bottom: 0.55rem;
  color: inherit;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.cover-copy h1 {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 4.3rem);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.cover-copy p {
  margin: 0.45rem 0 0;
  font-size: 1.1rem;
  letter-spacing: 0.32em;
}

.cover-cat {
  position: absolute;
  right: 1.4rem;
  bottom: 4.8rem;
  width: 2.7rem;
  height: 2.7rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff5c8;
  background: rgba(75, 105, 119, 0.4);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 30px #ffe6a7;
  animation: glow 2.2s ease-in-out infinite alternate;
}

@keyframes glow { to { transform: translateY(-5px); box-shadow: 0 0 48px #fff1b9; } }

.start-content {
  position: relative;
  padding: 0.6rem clamp(1.2rem, 5vw, 2.5rem) 2rem;
}

.opening-line {
  max-width: 30rem;
  margin: 0.5rem auto 1.35rem;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.8;
}

.name-field {
  display: block;
  margin: 0 auto 1rem;
}

.name-field span {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.name-field input {
  width: 100%;
  min-height: 3.2rem;
  padding: 0.7rem 1rem;
  color: var(--ink);
  font-size: 1.05rem;
  border: 1px solid rgba(92, 118, 141, 0.22);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 1px 8px rgba(57, 74, 82, 0.04);
}

.start-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 3.35rem;
  border-radius: 1rem;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  border: 0;
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  box-shadow: 0 10px 24px rgba(65, 95, 117, 0.25);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.primary-button b {
  font-size: 1.35rem;
  transition: transform 0.22s ease;
}

.primary-button:hover b { transform: translateX(4px); }

.secondary-button {
  border: 1px solid rgba(92, 118, 141, 0.24);
  color: var(--blue-deep);
  background: rgba(255, 255, 255, 0.55);
  font-family: system-ui, sans-serif;
  font-weight: 650;
}

.text-button {
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(56, 78, 99, 0.18);
}

.collection-card {
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid rgba(92, 118, 141, 0.17);
  border-radius: 1.2rem;
  background: rgba(230, 237, 232, 0.62);
}

.collection-main {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.85rem 1rem;
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.collection-main strong,
.collection-main small { display: block; }
.collection-main strong { font-size: 0.95rem; }
.collection-main small { margin-top: 0.2rem; color: var(--ink-soft); font-size: 0.76rem; }
.collection-main > i { color: var(--gold); font-size: 1.6rem; font-style: normal; }

.progress-ring {
  --progress: 0deg;
  width: 3.1rem;
  height: 3.1rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--gold) var(--progress), rgba(92, 118, 141, 0.13) 0);
}

.progress-ring::before {
  content: "";
  grid-area: 1 / 1;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  background: #f7f7ef;
}

.progress-ring b {
  grid-area: 1 / 1;
  position: relative;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
}

.ending-count {
  display: flex;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  border-top: 1px dashed rgba(92, 118, 141, 0.2);
}

.ending-count strong { color: var(--blue-deep); }

.controls-note {
  margin: 0.45rem 0 0;
  color: rgba(56, 78, 99, 0.6);
  text-align: center;
  font-family: system-ui, sans-serif;
  font-size: 0.68rem;
}

.story-screen {
  min-height: 100svh;
  padding: 0 clamp(1rem, 4vw, 2.1rem) max(2rem, env(safe-area-inset-bottom));
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.story-screen.is-changing { opacity: 0.35; transform: translateX(-5px); }

.story-header {
  position: sticky;
  top: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem;
  align-items: center;
  min-height: 5.3rem;
  padding: max(0.5rem, env(safe-area-inset-top)) 0 0.55rem;
  background: linear-gradient(180deg, rgba(251, 248, 240, 0.98) 72%, rgba(251, 248, 240, 0));
}

.header-actions { display: flex; gap: 0.4rem; }

.icon-button {
  min-width: 3.2rem;
  min-height: 3.2rem;
  padding: 0.35rem 0.5rem;
  display: grid;
  place-items: center;
  gap: 0.08rem;
  border: 1px solid rgba(92, 118, 141, 0.14);
  border-radius: 0.95rem;
  color: var(--blue-deep);
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
}

.icon-button > span { font-family: system-ui, sans-serif; font-size: 0.74rem; font-weight: 700; }
.icon-button > small { color: var(--ink-soft); font-family: system-ui, sans-serif; font-size: 0.62rem; }
.icon-button[data-enabled="true"] { color: #7b5c2f; background: var(--gold-pale); }

.bookmark {
  min-width: 0;
  text-align: center;
}

.bookmark span,
.bookmark strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark span { color: var(--gold); font-family: system-ui, sans-serif; font-size: 0.68rem; font-weight: 750; letter-spacing: 0.16em; }
.bookmark strong { margin-top: 0.18rem; font-size: 1.02rem; letter-spacing: 0.08em; }

.node-progress {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin: -0.55rem 0 0.45rem;
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
  font-size: 0.68rem;
}

.node-progress strong { color: var(--blue); }

.scene-frame {
  position: relative;
  width: 100%;
  margin: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 0.55rem solid rgba(255, 255, 255, 0.7);
  border-radius: 1.45rem 1.25rem 1.55rem 1.15rem;
  background: #dde6df;
  box-shadow: var(--soft-shadow);
  transform: rotate(-0.2deg);
}

.scene-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 0.7s ease;
}

.scene-frame img.is-loaded {
  opacity: 1;
  animation: ken-burns 15s ease-in-out infinite alternate;
}

@keyframes ken-burns { to { transform: scale(1.085) translate3d(-0.6%, -0.5%, 0); } }

.image-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, #dfe7df 18%, #edf1e7 37%, #d9e3df 60%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}

.scene-frame:not(.is-loading) .image-skeleton { display: none; }

@keyframes shimmer { to { background-position-x: -220%; } }

.tape {
  position: absolute;
  top: -0.18rem;
  width: 3.7rem;
  height: 1rem;
  opacity: 0.58;
  background: #ead9b5;
  box-shadow: 0 1px 3px rgba(70, 57, 34, 0.12);
}

.tape-left { left: 8%; transform: rotate(-5deg); }
.tape-right { right: 8%; transform: rotate(5deg); }

.story-copy {
  position: relative;
  min-height: 8.7rem;
  margin: 1rem 0 0.75rem;
  padding: 1.15rem 1.25rem 1.4rem;
  border: 1px solid rgba(92, 118, 141, 0.12);
  border-radius: 1.2rem 1.45rem 1.1rem 1.35rem;
  background: rgba(255, 255, 255, 0.48);
  cursor: pointer;
}

.story-copy::before {
  content: "“";
  position: absolute;
  top: -0.3rem;
  left: 0.65rem;
  color: rgba(210, 161, 93, 0.28);
  font-size: 4rem;
  line-height: 1;
}

.story-copy p {
  position: relative;
  margin: 0;
  font-size: clamp(1rem, 2.8vw, 1.1rem);
  line-height: 1.95;
  letter-spacing: 0.035em;
}

.story-copy p.is-typing::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1.05em;
  margin-left: 0.15em;
  vertical-align: -0.12em;
  background: var(--gold);
  animation: cursor-blink 0.7s steps(1) infinite;
}

@keyframes cursor-blink { 50% { opacity: 0; } }

.text-hint {
  position: absolute;
  right: 1rem;
  bottom: 0.5rem;
  color: rgba(56, 78, 99, 0.54);
  font-family: system-ui, sans-serif;
  font-size: 0.65rem;
}

.question-block {
  padding: 0.4rem 0.2rem 0.7rem;
}

.question-label {
  margin: 0;
  color: var(--gold);
  font-family: system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.16em;
}

.question-block h2 {
  margin: 0.3rem 0 0;
  font-size: clamp(1.05rem, 3.4vw, 1.25rem);
  font-weight: 600;
  line-height: 1.55;
}

.choices {
  display: grid;
  gap: 0.7rem;
  padding-bottom: 1rem;
}

.choice-card {
  width: 100%;
  min-height: 4.75rem;
  padding: 0.75rem 0.85rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem;
  align-items: center;
  text-align: left;
  border: 1px solid rgba(92, 118, 141, 0.18);
  border-radius: 1.15rem 1.35rem 1.1rem 1.25rem;
  color: var(--ink);
  background: rgba(247, 247, 239, 0.82);
  box-shadow: 0 5px 15px rgba(56, 78, 99, 0.07);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.25s ease, border 0.25s ease, box-shadow 0.25s ease;
}

.choice-card.is-visible { opacity: 1; transform: none; }

.choice-card:hover {
  transform: translateY(-3px) rotate(-0.15deg);
  border-color: rgba(210, 161, 93, 0.55);
  box-shadow: 0 11px 28px rgba(56, 78, 99, 0.14);
}

.choice-number {
  width: 2.05rem;
  height: 2.05rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--blue);
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 750;
}

.choice-copy strong,
.choice-copy small { display: block; }
.choice-copy strong { font-size: 0.92rem; line-height: 1.5; }
.choice-copy small { margin-top: 0.17rem; color: var(--ink-soft); font-family: system-ui, sans-serif; font-size: 0.7rem; }
.choice-arrow { color: var(--gold); font-size: 1.25rem; }

.ending-panel {
  margin: 1rem 0 0;
  padding: 1.5rem 1.1rem;
  text-align: center;
  border: 1px solid rgba(210, 161, 93, 0.34);
  border-radius: 1.3rem;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 225, 164, 0.38), transparent 13rem),
    rgba(255, 253, 245, 0.73);
  box-shadow: 0 12px 34px rgba(92, 83, 58, 0.1);
  opacity: 0;
  transform: translateY(12px);
  transition: 0.5s ease;
}

.ending-panel.is-visible { opacity: 1; transform: none; }

.achievement {
  display: inline-flex;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  color: #765326;
  background: var(--gold-pale);
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 750;
}

.ending-panel h2 { margin: 0.9rem 0 0; font-size: 1.55rem; }
.ending-panel blockquote { margin: 1rem auto; max-width: 30rem; color: var(--blue-deep); font-size: 1.15rem; font-weight: 600; line-height: 1.75; }
.ending-panel > p { color: var(--ink-soft); font-family: system-ui, sans-serif; font-size: 0.76rem; }
.ending-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; margin-top: 1rem; }
.ending-actions .text-button { grid-column: 1 / -1; min-height: 2.5rem; }

.map-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding-top: max(1rem, env(safe-area-inset-top));
  background: rgba(48, 66, 76, 0.42);
  backdrop-filter: blur(9px);
}

.map-sheet {
  width: min(100%, 780px);
  height: min(92svh, 880px);
  padding: 1.2rem clamp(1rem, 4vw, 2rem) max(1rem, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  border-radius: 1.8rem 1.8rem 0 0;
  background:
    linear-gradient(rgba(251, 248, 240, 0.95), rgba(248, 245, 235, 0.98)),
    repeating-linear-gradient(12deg, transparent 0 7px, rgba(92, 118, 141, 0.04) 8px);
  box-shadow: 0 -20px 65px rgba(35, 50, 58, 0.26);
  animation: sheet-up 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes sheet-up { from { transform: translateY(35%); opacity: 0; } }

.map-header { display: flex; justify-content: space-between; align-items: flex-start; }
.map-header .eyebrow { color: var(--gold); }
.map-header h2 { margin: 0; font-size: 1.7rem; }

.close-button {
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid rgba(92, 118, 141, 0.15);
  border-radius: 50%;
  color: var(--blue-deep);
  background: rgba(255, 255, 255, 0.58);
  font-family: system-ui, sans-serif;
  font-size: 1.6rem;
  cursor: pointer;
}

.map-summary {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.42rem;
  margin: 0.7rem 0 0;
  padding: 0.65rem;
  border-radius: 1rem;
  background: rgba(222, 232, 227, 0.62);
  font-family: system-ui, sans-serif;
}

.map-summary strong { color: var(--blue-deep); font-size: 1.05rem; }
.map-summary span { color: var(--ink-soft); font-size: 0.72rem; }
.map-summary i { width: 1px; height: 1rem; margin: 0 0.5rem; background: rgba(92, 118, 141, 0.25); }
.map-note { margin: 0.55rem 0; color: var(--ink-soft); text-align: center; font-size: 0.75rem; }

.map-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border-block: 1px dashed rgba(92, 118, 141, 0.16);
}

.map-canvas {
  position: relative;
  min-width: 620px;
  min-height: 100%;
  padding: 1.2rem 1rem 2rem;
}

.map-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.map-lines path {
  fill: none;
  stroke: rgba(92, 118, 141, 0.18);
  stroke-width: 2;
  stroke-dasharray: 5 6;
}

.map-lines path.is-traveled {
  stroke: rgba(210, 161, 93, 0.78);
  stroke-width: 3;
  stroke-dasharray: none;
}

.map-levels { position: relative; z-index: 1; display: grid; gap: 2.1rem; }
.map-level { display: flex; justify-content: center; gap: 0.65rem; }

.map-node {
  width: 8.2rem;
  min-height: 3.65rem;
  padding: 0.52rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  align-items: center;
  text-align: left;
  border: 1px dashed rgba(92, 118, 141, 0.2);
  border-radius: 0.9rem 1.05rem 0.85rem 1rem;
  color: rgba(56, 78, 99, 0.45);
  background: rgba(237, 237, 228, 0.65);
  font-size: 0.74rem;
}

.map-node.is-unlocked {
  color: var(--ink);
  border-style: solid;
  border-color: rgba(92, 118, 141, 0.25);
  background: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  box-shadow: 0 5px 12px rgba(56, 78, 99, 0.08);
}

.map-node.is-current {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(210, 161, 93, 0.17);
}

.map-node.is-ending { border-radius: 1.4rem 0.9rem 1.4rem 0.9rem; }
.map-node.is-collected { background: #fff7e6; border-color: rgba(210, 161, 93, 0.54); }
.map-node-icon { width: 1.7rem; height: 1.7rem; display: grid; place-items: center; border-radius: 50%; color: white; background: rgba(92, 118, 141, 0.35); }
.map-node.is-unlocked .map-node-icon { background: var(--blue); }
.map-node.is-collected .map-node-icon { color: #704d1e; background: var(--gold-pale); }

.map-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.8rem; padding-top: 0.7rem; color: var(--ink-soft); font-family: system-ui, sans-serif; font-size: 0.68rem; }
.map-legend span { display: inline-flex; align-items: center; gap: 0.28rem; }
.dot { width: 0.56rem; height: 0.56rem; border-radius: 50%; background: #c8ceca; }
.dot.unlocked { background: var(--blue); }
.dot.current { background: white; border: 2px solid var(--gold); }
.dot.ending { background: var(--gold); transform: rotate(45deg); border-radius: 2px; }

.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  min-width: 10rem;
  padding: 0.75rem 1rem;
  text-align: center;
  color: white;
  border-radius: 999px;
  background: rgba(52, 75, 93, 0.92);
  box-shadow: 0 10px 28px rgba(34, 47, 55, 0.25);
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: 0.25s ease;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.error-state {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.8rem;
  padding: 2rem;
  text-align: center;
  background: var(--paper);
}

.error-state h1,
.error-state p { margin: 0; }
.error-state .primary-button { margin-top: 0.7rem; padding-inline: 2rem; }
.overlay-open { overflow: hidden; }

@media (min-width: 600px) {
  body { padding: 2.2rem 0; }
  .book-shell { min-height: calc(100vh - 4.4rem); border-radius: 1.8rem; overflow: hidden; }
  .start-screen,
  .story-screen { min-height: calc(100vh - 4.4rem); }
  .start-actions { grid-template-columns: 1.25fr 1fr; }
  .story-screen { padding-inline: 2.6rem; }
  .map-overlay { place-items: center; padding: 1rem; }
  .map-sheet { border-radius: 1.8rem; }
}

@media (max-width: 420px) {
  .cover-card { height: 42svh; min-height: 290px; }
  .cover-copy { inset-inline: 1.25rem; bottom: 2.1rem; }
  .start-content { padding-inline: 1rem; }
  .story-screen { padding-inline: 0.8rem; }
  .story-header { gap: 0.45rem; }
  .icon-button { min-width: 2.8rem; min-height: 2.8rem; padding-inline: 0.32rem; }
  .header-actions { gap: 0.25rem; }
  .bookmark strong { font-size: 0.88rem; }
  .scene-frame { border-width: 0.4rem; }
  .story-copy { min-height: 9.6rem; }
  .ending-actions { grid-template-columns: 1fr; }
  .ending-actions .text-button { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
