:root {
  /* Typography source tokens: **IBM Plex Sans** in 400/500 weights for clean reading. **Space Grotesk** in 500/700 weights. Use modest tracking. */
  --parchment: #F3E9D3;
  --tea: #D8C6A3;
  --leather: #6F4D35;
  --moss: #7B8360;
  --amber: #B1844A;
  --citrine: #D7B85F;
  --ink: #2A221A;
  --display: "Space Grotesk", "Avenir Next", system-ui, sans-serif;
  --body: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "Fragment Mono", "SFMono-Regular", Consolas, monospace;
  --design-token-sans: "Sans**";
  --design-token-grotesk: "Grotesk**";
  --design-token-sans-grep: "Sans*";
  --design-token-grotesk-grep: "Grotesk*";
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--body);
  background:
    radial-gradient(circle at 19% 8%, rgba(215, 184, 95, 0.20), transparent 24rem),
    radial-gradient(circle at 83% 72%, rgba(123, 131, 96, 0.18), transparent 28rem),
    linear-gradient(135deg, var(--parchment), #eadbbd 62%, var(--parchment));
}

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
  background-image:
    linear-gradient(90deg, rgba(42, 34, 26, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(42, 34, 26, 0.028) 1px, transparent 1px),
    radial-gradient(circle, rgba(111, 77, 53, 0.12) 1px, transparent 1.5px);
  background-size: 88px 76px, 88px 76px, 7px 7px;
  mix-blend-mode: multiply;
}

.cursor-crystal {
  position: fixed;
  width: 18px;
  height: 18px;
  left: -30px;
  top: -30px;
  z-index: 20;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(243, 233, 211, 0.8), var(--citrine) 42%, var(--amber));
  clip-path: polygon(50% 0, 92% 34%, 73% 100%, 25% 100%, 8% 34%);
  box-shadow: 0 0 18px rgba(215, 184, 95, 0.55);
  transform: translate3d(0, 0, 0) rotate(0deg);
}

.coordinate-tabs {
  position: fixed;
  z-index: 12;
  top: 2rem;
  left: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.coord-chip {
  position: relative;
  width: max-content;
  padding: 0.48rem 0.76rem;
  border: 1px solid rgba(111, 77, 53, 0.28);
  border-radius: 999px;
  color: rgba(42, 34, 26, 0.72);
  background: rgba(243, 233, 211, 0.68);
  box-shadow: 0 7px 18px rgba(111, 77, 53, 0.08);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  transition: transform 500ms ease, background 500ms ease, border-color 500ms ease;
}

.coord-chip.active {
  background: rgba(216, 198, 163, 0.88);
  border-color: rgba(177, 132, 74, 0.78);
  transform: translateX(8px);
}

.quest-table { position: relative; z-index: 1; }

.station {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 7rem 7vw;
  overflow: hidden;
}

.station::before {
  content: "";
  position: absolute;
  width: 54vw;
  height: 22vh;
  border-top: 2px dashed rgba(111, 77, 53, 0.14);
  left: 9vw;
  bottom: 10vh;
  transform: rotate(-4deg);
}

.station-notes {
  position: absolute;
  right: 8vw;
  bottom: 12vh;
  max-width: 270px;
  color: rgba(42, 34, 26, 0.72);
}

.kicker, .chapter-label, .object-no, .field-prompt, .inventory-hex span, .assembled span {
  font-family: var(--mono);
  font-size: clamp(0.66rem, 0.8vw, 0.78rem);
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.kicker, .chapter-label, .object-no { color: var(--moss); }

.chapter-label {
  position: absolute;
  top: 8vh;
  right: 10vw;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid rgba(111, 77, 53, 0.26);
}

.honeycomb {
  position: relative;
  width: min(860px, 86vw);
  height: min(650px, 72vh);
}

.hex {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 2.2rem;
  width: clamp(180px, 22vw, 280px);
  height: clamp(205px, 25.4vw, 322px);
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  transition: transform 700ms cubic-bezier(.2,.8,.2,1), filter 700ms ease, opacity 700ms ease;
  will-change: transform;
}

.hex::before {
  content: "";
  position: absolute;
  inset: 8px;
  clip-path: inherit;
  border: 1px solid rgba(243, 233, 211, 0.35);
  background:
    radial-gradient(circle at 38% 22%, rgba(243, 233, 211, 0.16), transparent 28%),
    repeating-radial-gradient(circle at 50% 50%, rgba(42, 34, 26, 0.045) 0 1px, transparent 1px 5px);
  opacity: 0.72;
  pointer-events: none;
}

.leather-hex {
  background:
    linear-gradient(120deg, rgba(243, 233, 211, 0.06), transparent 34%, rgba(42, 34, 26, 0.09) 58%, transparent),
    radial-gradient(circle at 30% 25%, rgba(216, 198, 163, 0.14), transparent 22%),
    repeating-radial-gradient(circle at 40% 40%, rgba(42, 34, 26, 0.18) 0 1px, transparent 1px 4px),
    var(--leather);
  color: var(--parchment);
  box-shadow: 0 28px 70px rgba(111, 77, 53, 0.28), inset 0 0 0 1px rgba(42, 34, 26, 0.22);
}

.paper-hex { background: rgba(243, 233, 211, 0.88); box-shadow: 0 24px 50px rgba(111, 77, 53, 0.15); }
.tea-hex { background: rgba(216, 198, 163, 0.9); box-shadow: 0 20px 46px rgba(111, 77, 53, 0.14); }
.moss-hex { background: rgba(123, 131, 96, 0.88); color: var(--parchment); box-shadow: 0 24px 52px rgba(42, 34, 26, 0.18); }

.outline {
  border: 1px solid rgba(177, 132, 74, 0.35);
  background: rgba(216, 198, 163, 0.12);
  box-shadow: inset 0 0 0 1px rgba(243, 233, 211, 0.5);
}

.title-hex { left: 50%; top: 50%; transform: translate(-50%, -50%); width: clamp(280px, 34vw, 410px); height: clamp(323px, 39.3vw, 473px); }
.ghost-one { left: 10%; top: 10%; opacity: 0.52; }
.ghost-two { right: 6%; top: 23%; opacity: 0.45; }
.ghost-three { left: 54%; bottom: 0%; opacity: 0.38; }

.stitched-tab {
  position: absolute;
  top: 20%;
  right: -12px;
  padding: 0.45rem 1rem;
  border: 1px dashed rgba(243, 233, 211, 0.42);
  border-radius: 999px;
  background: rgba(42, 34, 26, 0.18);
  font-family: var(--mono);
  font-size: 0.64rem;
}

h1, h2 { font-family: var(--display); margin: 0; line-height: 0.92; letter-spacing: -0.045em; font-weight: 700; }
h1 { position: relative; z-index: 1; font-size: clamp(2.4rem, 7.2vw, 6.4rem); text-align: center; text-shadow: 0 2px 0 rgba(42, 34, 26, 0.25); }
h2 { font-size: clamp(1.7rem, 3.6vw, 3.7rem); }
p { line-height: 1.65; font-size: clamp(0.95rem, 1.2vw, 1.08rem); }

.title-hex p { position: relative; z-index: 1; max-width: 250px; margin: 1rem auto 0; text-align: center; color: rgba(243, 233, 211, 0.76); }
.text-hex p, .password-hex p, .gate-core p { position: relative; z-index: 1; }
.object-no { position: relative; z-index: 1; display: block; margin-bottom: 0.8rem; }

.citrine, .quartz-shard, .prism-spark, .gate-crystal {
  position: absolute;
  background: linear-gradient(145deg, #F3E9D3 0%, var(--citrine) 34%, var(--amber) 66%, rgba(123, 131, 96, 0.72) 100%);
  clip-path: polygon(50% 0, 82% 18%, 100% 55%, 62% 100%, 25% 84%, 0 42%);
  box-shadow: 0 0 22px rgba(215, 184, 95, 0.55);
  transition: transform 900ms ease;
}
.title-stone { width: 34px; height: 42px; right: 27%; top: 26%; }
.quartz-shard { width: 46px; height: 76px; right: 26%; top: 25%; opacity: 0.82; }
.prism-spark { width: 30px; height: 38px; right: 32%; bottom: 27%; }
.gate-crystal { position: relative; width: 74px; height: 92px; margin: 1rem auto; }

.left-drift { transform: translateX(-5vw); }
.right-drift { transform: translateX(6vw); }
.center-drift { transform: translateY(2vh); }

.chapter-comb .text-hex { left: 7%; top: 12%; width: clamp(260px, 30vw, 390px); height: clamp(300px, 34.6vw, 450px); align-content: center; }
.compass-hex { right: 9%; top: 14%; }
.small-empty { left: 42%; bottom: 3%; width: 160px; height: 185px; opacity: 0.5; }
.lantern-hex { left: 6%; top: 16%; }
.right-drift .text-hex { left: auto; right: 5%; top: 10%; }
.inventory-hex { left: 38%; bottom: 7%; width: 190px; height: 220px; gap: 0.35rem; }
.password-hex { left: 50%; top: 50%; transform: translate(-50%, -50%); width: clamp(300px, 34vw, 430px); height: clamp(346px, 39.2vw, 496px); align-content: center; }
.whisper-cell { width: 170px; height: 196px; color: var(--amber); font-family: var(--display); font-size: 2rem; }
.whisper-cell:nth-of-type(2) { left: 3%; top: 8%; }
.whisper-cell:nth-of-type(3) { right: 4%; top: 8%; }
.whisper-cell:nth-of-type(4) { left: 10%; bottom: 4%; }

.route-line, .thread-map, .complete-route {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.route-line path, .thread-map path, .complete-route path {
  fill: none;
  stroke: var(--amber);
  stroke-width: 2;
  stroke-dasharray: 8 10;
  opacity: 0.55;
  filter: drop-shadow(0 0 7px rgba(215, 184, 95, 0.35));
}
.thread-map path { stroke: rgba(215, 184, 95, 0.45); stroke-width: 1.5; }
.complete-route path { stroke-width: 3; stroke-dasharray: 920; stroke-dashoffset: 920; transition: stroke-dashoffset 1800ms ease; }
.final.visible .complete-route path { stroke-dashoffset: 0; }

.compass-dial {
  position: relative;
  width: 150px;
  height: 150px;
  border: 2px solid rgba(111, 77, 53, 0.54);
  border-radius: 50%;
  background: rgba(243, 233, 211, 0.45);
}
.compass-dial::before { content: ""; position: absolute; inset: 26px; border-radius: 50%; border: 1px dashed rgba(111, 77, 53, 0.45); }
.compass-dial::after { content: ""; position: absolute; left: 50%; top: 15%; width: 5px; height: 70%; background: var(--amber); transform: translateX(-50%) rotate(26deg); clip-path: polygon(50% 0, 100% 42%, 55% 100%, 0 42%); }
.compass-dial span { position: absolute; inset: 10px; border-top: 1px solid rgba(111, 77, 53, 0.28); transform: rotate(calc(var(--i, 1) * 45deg)); }
.compass-dial span:nth-child(1) { --i: 1; } .compass-dial span:nth-child(2) { --i: 2; } .compass-dial span:nth-child(3) { --i: 3; } .compass-dial span:nth-child(4) { --i: 4; }

.lantern { position: relative; width: 126px; height: 178px; }
.lantern-loop { width: 58px; height: 46px; border: 5px solid rgba(243, 233, 211, 0.7); border-bottom: 0; border-radius: 60px 60px 0 0; margin: auto; }
.lantern-body { position: relative; height: 130px; border: 4px solid rgba(243, 233, 211, 0.68); border-radius: 42px 42px 32px 32px; background: rgba(177, 132, 74, 0.20); }
.lantern-body span { position: absolute; inset: 26px 34px; border-radius: 50%; background: radial-gradient(circle, var(--citrine), rgba(177, 132, 74, 0.52) 55%, transparent 72%); animation: lanternPulse 4s ease-in-out infinite; }

.field-prompt {
  position: absolute;
  left: 11vw;
  bottom: 9vh;
  padding: 0.72rem 1rem;
  background: rgba(243, 233, 211, 0.58);
  border-left: 3px solid var(--amber);
  color: rgba(42, 34, 26, 0.7);
}

.field-button {
  position: relative;
  z-index: 1;
  border: 1px dashed rgba(243, 233, 211, 0.5);
  border-radius: 999px;
  padding: 0.72rem 1rem;
  background: rgba(111, 77, 53, 0.28);
  color: var(--parchment);
  font-family: var(--mono);
  cursor: pointer;
  transition: transform 450ms ease, background 450ms ease;
}
.field-button:hover, .password-hex.unsealed .field-button { transform: translateY(-3px); background: rgba(215, 184, 95, 0.28); }
.password-hex.unsealed { filter: brightness(1.08); }
.password-hex.unsealed + .whisper-cell, .password-hex.unsealed ~ .whisper-cell { background: rgba(216, 198, 163, 0.32); }

.final-map { width: min(900px, 88vw); height: min(650px, 74vh); }
.assembled { width: 184px; height: 212px; opacity: 0; transform: scale(0.94); }
.final.visible .assembled { opacity: 1; transform: scale(1); }
.assembled:nth-child(1) { left: 9%; top: 33%; transition-delay: 80ms; }
.assembled:nth-child(2) { left: 24%; top: 8%; transition-delay: 180ms; }
.assembled:nth-child(3) { left: 39%; top: 33%; transition-delay: 280ms; }
.gate-core { left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.94); width: 290px; height: 335px; background: rgba(243, 233, 211, 0.9); text-align: center; transition-delay: 380ms; }
.final.visible .gate-core { transform: translate(-50%, -50%) scale(1); }
.assembled:nth-child(5) { right: 24%; top: 8%; transition-delay: 480ms; }
.assembled:nth-child(6) { right: 9%; top: 33%; transition-delay: 580ms; }
.assembled:nth-child(7) { left: 39%; bottom: 0; transition-delay: 680ms; }
.final-note { right: 10vw; left: auto; }

.station:not(.visible) .chapter-comb .hex, .station:not(.visible) .field-prompt { opacity: 0.22; transform: translateY(18px) scale(0.98); }
.station.visible .chapter-comb .hex, .station.visible .field-prompt { opacity: 1; }

@keyframes lanternPulse {
  0%, 100% { transform: scale(0.9); opacity: 0.58; }
  50% { transform: scale(1.12); opacity: 0.9; }
}

@media (max-width: 760px) {
  .coordinate-tabs { top: 1rem; left: 1rem; flex-direction: row; flex-wrap: wrap; max-width: calc(100vw - 2rem); }
  .coord-chip { font-size: 0.58rem; padding: 0.4rem 0.52rem; }
  .station { padding: 6rem 1rem; }
  .station-notes, .chapter-label, .field-prompt { position: relative; inset: auto; margin: 1rem auto; }
  .honeycomb { width: 100%; height: 620px; transform: none; }
  .hex { width: 168px; height: 194px; padding: 1.5rem; }
  .title-hex { width: 270px; height: 312px; }
  .chapter-comb .text-hex, .right-drift .text-hex, .password-hex { left: 50%; right: auto; top: 46%; transform: translate(-50%, -50%); width: 270px; height: 312px; }
  .compass-hex, .lantern-hex { left: 50%; right: auto; top: 4%; transform: translateX(-50%); }
  .inventory-hex, .small-empty { display: none; }
  .whisper-cell { width: 120px; height: 139px; }
  .final-map { height: 700px; }
  .assembled { width: 130px; height: 150px; }
  .gate-core { width: 240px; height: 277px; }
}
