:root {
  /* Typography compliance phrase: IBM Plex Mono` for tiny inventory coordinates. */
  --midnight: #17102F;
  --amethyst: #6D3BFF;
  --emerald: #00D084;
  --ruby: #E83F6F;
  --citrine: #FFD166;
  --teal: #073B4C;
  --lavender: #E9D8FF;
  --parchment: #FFE8D1;
  --scanline-opacity: .16;
  --horizon-depth: 42vh;
  --stage-rotation: -2.5deg;
  --glitch-offset: 8px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: hidden;
  font-family: "Nunito Sans", Inter, system-ui, sans-serif;
  color: var(--parchment);
  background:
    radial-gradient(circle at 12% 8%, rgba(109, 59, 255, .45), transparent 28rem),
    radial-gradient(circle at 86% 18%, rgba(232, 63, 111, .36), transparent 26rem),
    linear-gradient(135deg, #17102F 0%, #6D3BFF 45%, #E83F6F 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 59, 76, .08), rgba(23, 16, 47, .78));
  pointer-events: none;
  z-index: 0;
}

.scanlines, .pattern-overlay, .ribbon-field { position: fixed; inset: 0; pointer-events: none; }

.scanlines {
  z-index: 9;
  opacity: var(--scanline-opacity);
  background: repeating-linear-gradient(0deg, rgba(255, 232, 209, .16) 0 1px, transparent 1px 5px);
  mix-blend-mode: overlay;
}

.pattern-overlay {
  z-index: 3;
  opacity: .22;
  background:
    linear-gradient(63deg, transparent 0 48%, rgba(255, 209, 102, .45) 49% 50%, transparent 51% 100%),
    radial-gradient(circle, rgba(233, 216, 255, .32) 1px, transparent 2px);
  background-size: 260px 260px, 34px 34px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 4% 100%, 12% 68%, 0 52%);
}

.ribbon-field { z-index: 4; }
.ribbon {
  position: absolute;
  width: 180px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--citrine), var(--emerald), transparent);
  filter: blur(.4px) drop-shadow(0 0 16px rgba(0, 208, 132, .7));
  opacity: .72;
  transform-origin: center;
}

.quest-map { position: relative; z-index: 2; }

.stage {
  min-height: 100vh;
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(8, minmax(70px, 1fr));
  padding: clamp(24px, 4vw, 72px);
  overflow: hidden;
  isolation: isolate;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 8% 5%;
  border: 2px dashed rgba(255, 232, 209, .38);
  border-radius: 38px;
  clip-path: polygon(0 8%, 92% 0, 100% 79%, 12% 100%);
  transform: rotate(var(--stage-rotation));
  z-index: -1;
}

.stage::after {
  content: "";
  position: absolute;
  width: 42vw;
  height: 42vw;
  right: -16vw;
  top: 8vh;
  background: radial-gradient(circle, rgba(255, 209, 102, .18), transparent 62%);
  z-index: -2;
}

.quest-rail {
  position: fixed;
  left: clamp(10px, 2.2vw, 34px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 12;
  display: grid;
  gap: 18px;
  padding: 18px 10px;
}

.rail-label {
  writing-mode: vertical-rl;
  font: 600 10px "IBM Plex Mono", monospace;
  color: var(--citrine);
  letter-spacing: .22em;
  text-transform: uppercase;
}

.rail-dash {
  position: absolute;
  left: 26px;
  top: 64px;
  bottom: 18px;
  border-left: 2px dashed rgba(255, 232, 209, .55);
  z-index: -1;
}

.rail-token {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 232, 209, .55);
  border-radius: 50% 50% 50% 8px;
  transform: rotate(45deg);
  background: rgba(23, 16, 47, .72);
  color: var(--parchment);
  cursor: pointer;
  box-shadow: 0 0 18px rgba(109, 59, 255, .45);
}
.rail-token span { display: block; transform: rotate(-45deg); font: 600 10px "IBM Plex Mono", monospace; }
.rail-token.is-active { background: var(--emerald); color: var(--midnight); box-shadow: 0 0 24px var(--emerald); }

.mountain-scene, .summit-overlook {
  position: absolute;
  inset: 0;
  z-index: -3;
  background: linear-gradient(135deg, #17102F 0%, #6D3BFF 45%, #E83F6F 100%);
}

.sun-orb {
  position: absolute;
  width: min(32vw, 420px);
  height: min(32vw, 420px);
  left: 58%;
  top: 10%;
  border-radius: 50%;
  background: repeating-linear-gradient(0deg, var(--citrine) 0 12px, rgba(255, 209, 102, .35) 12px 22px);
  filter: drop-shadow(0 0 46px rgba(255, 209, 102, .55));
  opacity: .86;
}

.peaks, .summit-peaks { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: var(--horizon-depth); }
.peaks path, .summit-peaks path { stroke-width: 6; stroke-linejoin: round; }
.peaks-back path { fill: rgba(7, 59, 76, .38); stroke: rgba(233, 216, 255, .35); }
.peaks-mid path { fill: rgba(109, 59, 255, .45); stroke: var(--ruby); }
.peaks-front path { fill: rgba(23, 16, 47, .88); stroke: var(--emerald); }

.horizon-grid, .summit-grid {
  position: absolute;
  inset: auto -12% 0;
  height: 45vh;
  transform: perspective(360px) rotateX(62deg);
  transform-origin: bottom;
  background:
    linear-gradient(rgba(255, 209, 102, .38) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255, 209, 102, .34) 2px, transparent 2px);
  background-size: 58px 58px;
  box-shadow: inset 0 50px 80px rgba(232, 63, 111, .22);
}

.title-fragments {
  grid-column: 2 / 12;
  grid-row: 1 / 4;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(6px, 1.4vw, 22px);
  align-content: center;
  font-family: Bungee, Impact, sans-serif;
  font-size: clamp(3.8rem, 11vw, 12rem);
  line-height: .78;
  letter-spacing: -.08em;
  color: var(--parchment);
  text-shadow: 8px 0 0 rgba(232, 63, 111, .65), -8px 0 0 rgba(0, 208, 132, .48), 0 0 34px rgba(255, 209, 102, .46);
}
.title-fragments span { display: inline-block; transform: translateY(-80vh) rotate(-18deg); animation: snapIn .9s cubic-bezier(.2,1.3,.25,1) forwards; }
.title-fragments span:nth-child(2) { animation-delay: .12s; }
.title-fragments span:nth-child(3) { animation-delay: .24s; color: var(--citrine); }
.title-fragments span:nth-child(4) { animation-delay: .36s; }

@keyframes snapIn { to { transform: translateY(0) rotate(var(--piece-rot, 0deg)); } }

.quest-card, .map-tile, .dialogue-plaque, .inventory {
  position: relative;
  background: linear-gradient(135deg, rgba(255, 232, 209, .16), rgba(233, 216, 255, .07));
  border: 1px solid rgba(255, 232, 209, .42);
  box-shadow: 0 24px 80px rgba(7, 59, 76, .34), inset 0 0 36px rgba(109, 59, 255, .16);
  backdrop-filter: blur(14px);
}

.quest-card, .map-tile, .dialogue-plaque {
  padding: clamp(24px, 3vw, 48px);
  clip-path: polygon(0 6%, 94% 0, 100% 86%, 82% 100%, 5% 94%);
}

.intro-card { grid-column: 2 / 7; grid-row: 5 / 8; transform: rotate(-3deg); }
.tile-left { grid-column: 2 / 7; grid-row: 2 / 6; transform: rotate(2.5deg); }
.prop-card { grid-column: 7 / 12; grid-row: 2 / 6; transform: rotate(2deg); }
.dialogue-plaque { grid-column: 2 / 7; grid-row: 2 / 6; transform: rotate(-2deg); }
.reveal-card { grid-column: 2 / 7; grid-row: 2 / 7; transform: rotate(2deg); }

.kicker, .coord {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  color: var(--citrine);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .78rem;
}

h1, h2 { margin: .15em 0 .35em; font-family: "Cormorant Garamond", Georgia, serif; font-weight: 700; line-height: .95; }
h1 { font-size: clamp(2.6rem, 6vw, 6.6rem); }
h2 { font-size: clamp(2.2rem, 5vw, 5.2rem); }
p { font-size: clamp(1rem, 1.35vw, 1.22rem); line-height: 1.65; }

.inventory {
  padding: 18px;
  clip-path: polygon(8% 0, 100% 10%, 92% 100%, 0 88%);
  min-height: 136px;
  display: grid;
  gap: 8px;
}
.inventory b { font-family: Bungee, Impact, sans-serif; color: var(--emerald); font-weight: 400; }
.inventory em { font-family: "Cormorant Garamond", Georgia, serif; color: var(--lavender); font-size: 1.2rem; }
.shard-a { grid-column: 9 / 12; grid-row: 4 / 6; transform: rotate(6deg); }
.shard-b { grid-column: 8 / 11; grid-row: 6 / 8; transform: rotate(-5deg); }
.shard-c { grid-column: 3 / 6; grid-row: 6 / 8; transform: rotate(-7deg); }
.shard-d { grid-column: 8 / 11; grid-row: 5 / 7; transform: rotate(6deg); }
.shard-e { grid-column: 9 / 12; grid-row: 6 / 8; transform: rotate(-4deg); }

.spell {
  margin: 0;
  position: relative;
  font-family: Bungee, Impact, sans-serif;
  color: rgba(255, 232, 209, .28);
  text-transform: uppercase;
  line-height: .82;
  letter-spacing: -.04em;
  text-shadow: var(--glitch-offset) 0 rgba(232, 63, 111, .34), calc(var(--glitch-offset) * -1) 0 rgba(0, 208, 132, .28);
}
.spell-gate { grid-column: 6 / 12; grid-row: 7 / 9; font-size: clamp(2rem, 6vw, 6rem); transform: rotate(-4deg); }
.spell-pattern { grid-column: 6 / 12; grid-row: 1 / 3; font-size: clamp(2rem, 5vw, 5rem); transform: rotate(4deg); }
.spell-prop { grid-column: 1 / 7; grid-row: 1 / 3; font-size: clamp(2rem, 5vw, 5rem); transform: rotate(-5deg); }
.spell-persona { grid-column: 5 / 12; grid-row: 7 / 9; font-size: clamp(2rem, 5vw, 5rem); transform: rotate(3deg); }
.spell-summit { grid-column: 5 / 12; grid-row: 1 / 3; font-size: clamp(2rem, 5vw, 5rem); transform: rotate(-3deg); }

.costume-silhouette {
  position: relative;
  filter: drop-shadow(0 0 32px rgba(0, 208, 132, .42));
  animation: floatCostume 5.5s ease-in-out infinite;
}
.costume-silhouette::before, .costume-silhouette::after, .costume-silhouette span {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.costume-silhouette::before { top: 0; width: 58px; height: 58px; border-radius: 50%; background: var(--parchment); box-shadow: 0 0 0 10px rgba(232, 63, 111, .28); }
.costume-silhouette span { top: 58px; width: 124px; height: 170px; background: linear-gradient(160deg, var(--amethyst), var(--ruby)); clip-path: polygon(50% 0, 92% 100%, 8% 100%); }
.costume-silhouette::after { top: 82px; width: 230px; height: 178px; background: linear-gradient(135deg, rgba(0, 208, 132, .82), rgba(109, 59, 255, .5)); clip-path: polygon(50% 0, 100% 100%, 0 82%); z-index: -1; }
.cloak { grid-column: 7 / 10; grid-row: 4 / 7; }
.pattern-form { grid-column: 9 / 12; grid-row: 2 / 5; }
.prop-form { grid-column: 5 / 7; grid-row: 4 / 7; }
.persona-form { grid-column: 6 / 9; grid-row: 2 / 6; }
.is-glitching .costume-silhouette, .costume-silhouette:hover { animation: floatCostume 5.5s ease-in-out infinite, chroma .42s steps(2) infinite; }

@keyframes floatCostume { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-18px) rotate(2deg); } }
@keyframes chroma { 0%, 100% { filter: drop-shadow(8px 0 rgba(232,63,111,.7)) drop-shadow(-8px 0 rgba(0,208,132,.65)); } 50% { filter: drop-shadow(-12px 0 rgba(232,63,111,.72)) drop-shadow(12px 0 rgba(0,208,132,.62)); } }

.pattern-window { grid-column: 7 / 12; grid-row: 2 / 7; position: relative; }
.paper-card {
  position: absolute;
  padding: 26px;
  width: 56%;
  height: 38%;
  color: var(--teal);
  font: 600 .85rem "IBM Plex Mono", monospace;
  background: var(--parchment);
  border: 2px dashed var(--ruby);
  clip-path: polygon(0 0, 88% 8%, 100% 88%, 14% 100%);
  box-shadow: 0 18px 50px rgba(23, 16, 47, .38);
}
.card-one { left: 8%; top: 6%; transform: rotate(-8deg); }
.card-two { right: 2%; top: 30%; transform: rotate(7deg); background: var(--lavender); }
.card-three { left: 18%; bottom: 4%; transform: rotate(2deg); background: linear-gradient(135deg, var(--parchment), var(--citrine)); }

.prop-cavern { grid-column: 2 / 7; grid-row: 2 / 7; position: relative; border-radius: 45% 55% 36% 64%; background: radial-gradient(circle at 50% 42%, rgba(0,208,132,.3), rgba(7,59,76,.75)); box-shadow: inset 0 0 90px rgba(23,16,47,.7); }
.prop-svg { position: absolute; width: 48%; left: 27%; top: 14%; fill: rgba(255,232,209,.82); stroke: var(--citrine); stroke-width: 5; filter: drop-shadow(0 0 24px var(--citrine)); }
.gem { position: absolute; width: 44px; height: 44px; background: var(--emerald); clip-path: polygon(50% 0, 100% 35%, 78% 100%, 22% 100%, 0 35%); box-shadow: 0 0 24px var(--emerald); animation: orbit 8s linear infinite; }
.gem-one { left: 15%; top: 18%; } .gem-two { right: 16%; top: 30%; animation-delay: -2s; background: var(--ruby); } .gem-three { left: 45%; bottom: 14%; animation-delay: -4s; background: var(--citrine); }
@keyframes orbit { 50% { transform: translate(18px, -24px) rotate(180deg); } 100% { transform: translate(0,0) rotate(360deg); } }

.mask-cloud { grid-column: 7 / 12; grid-row: 1 / 6; position: relative; }
.mask { position: absolute; width: 170px; height: 92px; border-radius: 50%; background: linear-gradient(135deg, var(--lavender), var(--ruby)); clip-path: polygon(0 30%, 48% 0, 100% 30%, 88% 100%, 52% 58%, 12% 100%); box-shadow: 0 0 36px rgba(232,63,111,.55); animation: maskDrift 6s ease-in-out infinite; }
.mask::before, .mask::after { content: ""; position: absolute; width: 22px; height: 16px; top: 35px; border-radius: 50%; background: var(--midnight); }
.mask::before { left: 44px; } .mask::after { right: 44px; }
.mask-a { left: 8%; top: 12%; transform: rotate(-12deg); } .mask-b { right: 6%; top: 34%; transform: rotate(9deg); animation-delay: -2s; background: linear-gradient(135deg, var(--emerald), var(--amethyst)); } .mask-c { left: 30%; bottom: 8%; transform: rotate(18deg); animation-delay: -4s; background: linear-gradient(135deg, var(--citrine), var(--ruby)); }
@keyframes maskDrift { 50% { translate: 0 -22px; } }

.summit-overlook { background: radial-gradient(circle at 70% 20%, rgba(255,209,102,.4), transparent 20rem), linear-gradient(135deg, #17102F 0%, #6D3BFF 45%, #E83F6F 100%); }
.summit-peaks path { fill: rgba(7, 59, 76, .72); stroke: var(--emerald); }
.emblem { grid-column: 7 / 11; grid-row: 3 / 7; position: relative; width: min(36vw, 420px); aspect-ratio: 1; align-self: center; justify-self: center; filter: drop-shadow(0 0 44px rgba(255,209,102,.75)); animation: emblemRise 4s ease-in-out infinite; }
.emblem span, .emblem i, .emblem b { position: absolute; inset: 8%; display: block; }
.emblem span { background: linear-gradient(135deg, var(--citrine), var(--ruby)); clip-path: polygon(50% 0, 61% 34%, 98% 35%, 68% 56%, 80% 100%, 50% 70%, 20% 100%, 32% 56%, 2% 35%, 39% 34%); }
.emblem i { inset: 22%; background: var(--emerald); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); opacity: .82; }
.emblem b { inset: 34%; background: var(--parchment); border-radius: 50%; box-shadow: 0 0 30px var(--parchment); }
@keyframes emblemRise { 50% { transform: translateY(-18px) rotate(3deg) scale(1.03); } }

.choice-seal {
  margin-top: 10px;
  padding: 14px 22px;
  border: 1px solid var(--citrine);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,209,102,.18), rgba(0,208,132,.22));
  color: var(--parchment);
  font: 400 .88rem Bungee, Impact, sans-serif;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(255,209,102,.28);
}
.choice-seal.is-lit { background: var(--citrine); color: var(--midnight); box-shadow: 0 0 42px var(--citrine); }

.stage-pattern { background: linear-gradient(145deg, rgba(7,59,76,.48), rgba(109,59,255,.26)); }
.stage-prop { background: radial-gradient(circle at 20% 40%, rgba(0,208,132,.22), transparent 30rem); }
.stage-persona { background: radial-gradient(circle at 65% 22%, rgba(232,63,111,.24), transparent 28rem); }

.stage:not(.is-visible) .quest-card, .stage:not(.is-visible) .map-tile, .stage:not(.is-visible) .dialogue-plaque, .stage:not(.is-visible) .inventory { opacity: .42; transform: translateY(24px) rotate(var(--stage-rotation)); }
.quest-card, .map-tile, .dialogue-plaque, .inventory { transition: opacity .7s ease, transform .7s ease; }

@media (max-width: 820px) {
  .quest-rail { display: none; }
  .stage { display: block; padding: 30px 18px 80px; }
  .title-fragments { display: flex; margin-top: 8vh; }
  .quest-card, .map-tile, .dialogue-plaque, .inventory, .pattern-window, .prop-cavern, .mask-cloud, .emblem { margin: 24px 0; width: auto; min-height: 220px; }
  .costume-silhouette { height: 260px; margin: 34px auto; }
  .spell { font-size: 2.6rem; margin: 18px 0; }
  .paper-card { position: relative; display: inline-block; min-height: 150px; margin: 8px; }
}
