:root {
  /* Design typography tokens: Interface labels 3* 3** */
  --void: #090016;
  --plum: #1A0733;
  --magenta: #FF3FD1;
  --cyan: #39F5FF;
  --green: #B7FF3C;
  --petal: #FFF7FF;
  --violet: #6D2CFF;
  --peach: #FF9A5C;
  --heading: "Alegreya Sans", "Trebuchet MS", sans-serif;
  --body: "Source Sans 3", "Segoe UI", sans-serif;
  --label: "Atkinson Hyperlegible", "Verdana", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--petal);
  background:
    radial-gradient(circle at 18% 82%, rgba(255, 63, 209, .22), transparent 30%),
    radial-gradient(circle at 78% 15%, rgba(57, 245, 255, .18), transparent 28%),
    linear-gradient(135deg, var(--void), #140026 45%, var(--void));
  font-family: var(--body);
}

.crt-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 247, 255, .045) 1px, transparent 1px) 0 0 / 100% 5px,
    linear-gradient(90deg, rgba(57, 245, 255, .05) 1px, transparent 1px) 0 0 / 48px 48px;
  mix-blend-mode: screen;
  opacity: .55;
}

.quest-console {
  width: min(1720px, calc(100vw - 28px));
  height: min(980px, calc(100vh - 28px));
  margin: 14px auto;
  display: grid;
  grid-template-columns: 220px minmax(560px, 1fr) 300px;
  gap: 14px;
  position: relative;
}

.panel {
  border: 1px solid rgba(109, 44, 255, .72);
  background: linear-gradient(145deg, rgba(26, 7, 51, .88), rgba(9, 0, 22, .76));
  box-shadow: 0 0 32px rgba(109, 44, 255, .22), inset 0 0 28px rgba(57, 245, 255, .06);
  backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(18px) scale(.985);
  animation: bootPane .9s ease forwards;
}

.tutorial-stage { animation-delay: .18s; }
.specimen-tray { animation-delay: .34s; }

.tiny-label, .stage-panes span, .rail-coordinate, .tray-readout, button {
  font-family: var(--label);
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: 12px;
}

.lesson-rail {
  padding: 22px 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rail-brand { margin-bottom: 18px; }
.rail-brand strong {
  display: block;
  font-family: var(--heading);
  font-size: 54px;
  line-height: .85;
  color: var(--petal);
  text-shadow: 0 0 18px var(--magenta);
}

.growing-stem {
  position: absolute;
  left: 34px;
  top: 136px;
  bottom: 118px;
  width: 2px;
  background: rgba(57, 245, 255, .22);
}

.growing-stem span {
  display: block;
  width: 100%;
  height: 20%;
  background: linear-gradient(var(--green), var(--cyan), var(--magenta));
  box-shadow: 0 0 18px var(--green);
  transition: height .65s ease;
}

.rail-node {
  border: 1px solid rgba(57, 245, 255, .22);
  color: rgba(255, 247, 255, .66);
  background: rgba(9, 0, 22, .38);
  min-height: 70px;
  padding: 0 12px 0 34px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  cursor: pointer;
  transition: .35s ease;
}

.rail-node.active, .rail-node.resolved {
  color: var(--petal);
  border-color: var(--green);
  box-shadow: inset 0 0 24px rgba(183, 255, 60, .12), 0 0 18px rgba(183, 255, 60, .18);
}

.leaf-glyph {
  width: 22px;
  height: 34px;
  border: 1px solid currentColor;
  border-radius: 100% 0 100% 0;
  transform: rotate(-34deg);
  box-shadow: inset 0 0 10px currentColor;
}

.rail-coordinate { margin-top: auto; color: var(--cyan); }

.tutorial-stage {
  position: relative;
  overflow: hidden;
  padding: 28px;
}

.tutorial-stage::before, .specimen-tray::before, .lesson-rail::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(255, 63, 209, .18);
  pointer-events: none;
}

.route-vines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .72;
}

.route-path {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 2;
  stroke-dasharray: 980;
  stroke-dashoffset: 980;
  filter: drop-shadow(0 0 10px var(--cyan));
  transition: stroke-dashoffset 1.3s ease, stroke .5s ease;
}

.route-path.drawn { stroke-dashoffset: 0; }
.branch-route { stroke: var(--magenta); stroke-width: 1.4; }
.branch-route.secondary { stroke: var(--green); }

.corner-leaf {
  position: absolute;
  width: 80px;
  height: 120px;
  border: 1px solid var(--cyan);
  border-radius: 100% 0 100% 0;
  opacity: .2;
}
.top-left { left: 38px; top: 66px; transform: rotate(45deg); }
.bottom-right { right: 52px; bottom: 70px; transform: rotate(225deg); }

.stage-header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.stage-panes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stage-panes span {
  padding: 8px 10px;
  border: 1px solid rgba(57, 245, 255, .35);
  background: rgba(255, 63, 209, .07);
}

.chapter {
  position: absolute;
  inset: 96px 46px 92px;
  display: grid;
  align-content: center;
  gap: 22px;
  opacity: 0;
  transform: translateY(22px);
  pointer-events: none;
  transition: opacity .6s ease, transform .6s ease;
  z-index: 1;
}

.chapter.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.domain-glass, .chapter h1 {
  font-family: var(--heading);
  font-weight: 800;
  font-size: clamp(76px, 12vw, 170px);
  line-height: .82;
  letter-spacing: .035em;
  color: var(--petal);
  text-shadow: 0 0 8px var(--petal), 0 0 28px var(--magenta), 9px 7px 0 rgba(57, 245, 255, .18);
}

.quest-prompt, .chapter p {
  max-width: 720px;
  font-size: clamp(21px, 2.3vw, 34px);
  line-height: 1.13;
  margin: 0;
  color: rgba(255, 247, 255, .9);
}

.lesson-card {
  width: min(520px, 100%);
  padding: 20px;
  border: 1px solid var(--peach);
  background: rgba(255, 154, 92, .09);
  box-shadow: 0 0 26px rgba(255, 154, 92, .18);
}

.lesson-card p { font-size: 20px; line-height: 1.35; }
.annotation {
  justify-self: start;
  padding: 10px 14px;
  border-left: 2px solid var(--cyan);
  color: var(--cyan);
  background: rgba(57, 245, 255, .08);
  font-family: var(--label);
}

.route-map, .syntax-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.route-map span, .syntax-grid div, .resolve-seal {
  border: 1px solid rgba(183, 255, 60, .55);
  background: rgba(183, 255, 60, .08);
  padding: 18px;
  box-shadow: inset 0 0 20px rgba(183, 255, 60, .07);
}
.route-map i { width: 54px; height: 2px; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.syntax-grid div { min-width: 116px; display: grid; gap: 6px; }
.syntax-grid b { font-family: var(--heading); font-size: 42px; color: var(--magenta); }
.syntax-grid span { font-family: var(--label); color: var(--cyan); }

.flower-diagram {
  width: 310px;
  height: 310px;
  position: relative;
  display: grid;
  place-items: center;
  animation: acetate 7s ease-in-out infinite;
}
.flower-diagram span {
  position: absolute;
  width: 135px;
  height: 190px;
  border: 2px solid var(--magenta);
  border-radius: 90% 10% 90% 10%;
  box-shadow: inset 0 0 28px rgba(255, 63, 209, .14), 0 0 24px rgba(255, 63, 209, .26);
}
.flower-diagram span:nth-child(1) { transform: translateY(-52px) rotate(45deg); }
.flower-diagram span:nth-child(2) { transform: translateX(52px) rotate(135deg); border-color: var(--cyan); }
.flower-diagram span:nth-child(3) { transform: translateY(52px) rotate(225deg); border-color: var(--green); }
.flower-diagram span:nth-child(4) { transform: translateX(-52px) rotate(315deg); border-color: var(--peach); }
.flower-diagram b { z-index: 2; font-family: var(--label); color: var(--petal); }

.resolve-seal { width: 340px; display: grid; gap: 8px; }
.resolve-seal strong { font-family: var(--heading); font-size: 58px; color: var(--green); }

.stage-controls {
  position: absolute;
  right: 28px;
  bottom: 24px;
  z-index: 4;
  display: flex;
  gap: 10px;
}
button {
  border: 1px solid rgba(57, 245, 255, .55);
  background: rgba(9, 0, 22, .68);
  color: var(--petal);
  padding: 12px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--magenta); box-shadow: 0 0 16px rgba(255, 63, 209, .25); }

.specimen-tray {
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.specimen-card {
  position: absolute;
  inset: 72px 22px 72px;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity .55s ease, transform .55s ease;
}
.specimen-card.active { opacity: 1; transform: translateX(0); }
.specimen-card h2 {
  font-family: var(--heading);
  font-size: 36px;
  margin: 24px 0 8px;
  color: var(--petal);
}
.specimen-card p { font-size: 18px; color: rgba(255, 247, 255, .78); }

.botanical {
  width: 210px;
  height: 270px;
  margin: 16px auto 0;
  position: relative;
  border: 1px solid rgba(57, 245, 255, .32);
  background:
    linear-gradient(90deg, transparent 49%, rgba(57, 245, 255, .45) 50%, transparent 51%),
    radial-gradient(circle, rgba(255, 63, 209, .14), transparent 54%);
  animation: acetate 6s ease-in-out infinite;
}
.botanical::before, .botanical::after {
  content: "";
  position: absolute;
  border: 1px solid var(--cyan);
  box-shadow: 5px 5px 0 rgba(255, 63, 209, .22), inset 0 0 18px rgba(57, 245, 255, .12);
}
.botanical::before { width: 78px; height: 118px; left: 38px; top: 58px; border-radius: 100% 0; transform: rotate(-28deg); }
.botanical::after { width: 82px; height: 132px; right: 34px; top: 82px; border-radius: 0 100%; transform: rotate(24deg); }
.botanical.vine::before { height: 190px; border-radius: 48%; transform: rotate(38deg); }
.botanical.roots::after { top: 146px; height: 80px; border-radius: 0 0 80% 80%; border-color: var(--green); }
.botanical.orchid::before, .botanical.orchid::after { border-color: var(--magenta); border-radius: 80% 20% 80% 20%; }
.botanical.afterimage { opacity: .66; filter: saturate(.75); }

.tray-readout {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 24px;
  color: var(--green);
  border-top: 1px solid rgba(183, 255, 60, .35);
  padding-top: 16px;
}

.pulse { animation: resolvePulse .75s ease; }

@keyframes bootPane { to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes acetate { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(3deg); } }
@keyframes resolvePulse {
  0% { box-shadow: 0 0 32px rgba(109, 44, 255, .22), inset 0 0 28px rgba(57, 245, 255, .06); }
  45% { box-shadow: 0 0 58px rgba(183, 255, 60, .34), inset 0 0 42px rgba(255, 63, 209, .16); }
  100% { box-shadow: 0 0 32px rgba(109, 44, 255, .22), inset 0 0 28px rgba(57, 245, 255, .06); }
}

@media (max-width: 1020px) {
  body { overflow: auto; }
  .quest-console { height: auto; min-height: calc(100vh - 28px); grid-template-columns: 1fr; }
  .lesson-rail { min-height: 180px; }
  .growing-stem { display: none; }
  .tutorial-stage { min-height: 720px; }
  .specimen-tray { min-height: 520px; }
}
