:root {
  /* Typography compliance terms from DESIGN.md: Space Grotesk” Use concise tutorial paragraphs; IBM Plex Sans” Use small uppercase captions. */
  --coral: #FF5FA2;
  --cyan: #19D9FF;
  --lemon: #FFE85C;
  --seafoam: #42F5A7;
  --cream: #FFF3D6;
  --ink: #102033;
  --grape: #8B5CFF;
  --paper: #fff8e9;
  --display: "Bricolage Grotesque", sans-serif;
  --body: "Space Grotesk", sans-serif;
  --caption: "IBM Plex Sans", sans-serif;
  --spring: cubic-bezier(.18, 1.45, .34, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  background: var(--cream);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 14% 12%, rgba(25, 217, 255, .24), transparent 25%),
    radial-gradient(circle at 88% 18%, rgba(255, 95, 162, .20), transparent 24%),
    radial-gradient(circle at 72% 82%, rgba(66, 245, 167, .22), transparent 26%),
    linear-gradient(180deg, #FFF3D6 0%, #fff7e5 52%, #dffcff 100%);
  z-index: -3;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .52;
  z-index: 60;
  mix-blend-mode: multiply;
  background-image:
    radial-gradient(circle at 11% 12%, rgba(16, 32, 51, .12) 0 1px, transparent 1.4px),
    radial-gradient(circle at 63% 72%, rgba(16, 32, 51, .09) 0 1px, transparent 1.3px),
    radial-gradient(circle at 38% 42%, rgba(255, 95, 162, .13) 0 1px, transparent 1.5px),
    radial-gradient(circle at 83% 34%, rgba(25, 217, 255, .16) 0 1px, transparent 1.6px);
  background-size: 18px 18px, 23px 23px, 29px 29px, 35px 35px;
}

.lesson-strip {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 50;
  display: flex;
  gap: 10px;
  padding: 9px;
  border: 2px solid rgba(16, 32, 51, .22);
  border-radius: 999px;
  background: rgba(255, 243, 214, .78);
  backdrop-filter: blur(12px);
  box-shadow: 0 15px 35px rgba(16, 32, 51, .12);
}

.progress-bubble {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50% 46% 54% 42%;
  color: var(--ink);
  text-decoration: none;
  font: 700 9px/1 var(--caption);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: rgba(25, 217, 255, .22);
  border: 2px solid rgba(16, 32, 51, .2);
  transition: transform .45s var(--spring), background .3s ease, border-radius .45s var(--spring);
}

.progress-bubble:nth-child(2) { background: rgba(66, 245, 167, .30); }
.progress-bubble:nth-child(3) { background: rgba(255, 232, 92, .48); }
.progress-bubble:nth-child(4) { background: rgba(139, 92, 255, .22); }
.progress-bubble:nth-child(5) { background: rgba(255, 95, 162, .22); }
.progress-bubble.active, .progress-bubble:hover { transform: translateY(-7px) scale(1.1); background: var(--lemon); border-radius: 44% 56% 45% 55%; }

.panel {
  min-height: 100vh;
  position: relative;
  display: grid;
  align-items: center;
  padding: 86px clamp(18px, 4vw, 64px) 46px;
  isolation: isolate;
}

.pool-grid {
  width: min(1180px, 100%);
  min-height: calc(100vh - 132px);
  margin: 0 auto;
  display: grid;
  gap: clamp(16px, 2vw, 26px);
}

.module {
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(16, 32, 51, .85);
  box-shadow: 8px 10px 0 rgba(16, 32, 51, .14), inset 0 0 0 1px rgba(255,255,255,.38);
}

.module::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 18%, rgba(255,255,255,.52) 0 2px, transparent 2.6px),
    radial-gradient(circle at 75% 62%, rgba(16,32,51,.08) 0 1px, transparent 1.8px);
  background-size: 29px 29px, 21px 21px;
  opacity: .52;
}

.caption {
  margin: 0 0 10px;
  font-family: var(--caption);
  font-size: 12px;
  line-height: 1;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 700;
}

h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.045em; }
h1 { font-size: clamp(58px, 12vw, 168px); line-height: .78; }
h2 { font-size: clamp(34px, 5vw, 72px); line-height: .9; }
h3 { font-size: clamp(25px, 3vw, 42px); line-height: .92; }
p { font-size: clamp(16px, 1.35vw, 20px); line-height: 1.45; margin: 14px 0 0; }

.shell-grid { grid-template-columns: 1.45fr .72fr; grid-template-rows: 1fr auto; }
.conch-terminal {
  grid-row: 1 / span 2;
  min-height: 660px;
  padding: clamp(28px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 38% 62% 44% 56% / 50% 35% 65% 50%;
  background: var(--cream);
  transform: rotate(-1.5deg);
  animation: conchBreathe 6s ease-in-out infinite;
}

.shell-rings, .shell-rings::before, .shell-rings::after {
  position: absolute;
  border: 3px solid rgba(255, 95, 162, .42);
  border-radius: 50%;
  pointer-events: none;
}
.shell-rings { inset: 9% 4% 10% 18%; border-left-color: transparent; transform: rotate(-18deg); }
.shell-rings::before { content: ""; inset: 13% 10% 14% 16%; border-color: rgba(25, 217, 255, .5); border-bottom-color: transparent; }
.shell-rings::after { content: ""; inset: 28% 22% 30% 30%; border-color: rgba(139, 92, 255, .42); border-right-color: transparent; }

.terminal-copy { max-width: 620px; font-size: clamp(20px, 2vw, 28px); }
.begin-lesson {
  width: fit-content;
  margin-top: 28px;
  padding: 17px 26px;
  border: 2px solid var(--ink);
  border-radius: 999px 999px 999px 30px;
  background: var(--seafoam);
  color: var(--ink);
  font: 800 15px/1 var(--caption);
  text-transform: uppercase;
  letter-spacing: .08em;
  box-shadow: 5px 6px 0 rgba(16,32,51,.18);
  cursor: pointer;
  transition: transform .35s var(--spring), background .25s ease;
}
.begin-lesson:hover { transform: translateY(-5px) scale(1.04); background: var(--lemon); }

.bubble-field { position: relative; min-height: 360px; }
.term-bubble {
  position: absolute;
  left: calc(var(--x) * 1%);
  bottom: -10%;
  display: grid;
  place-items: center;
  width: clamp(78px, 9vw, 118px);
  height: clamp(78px, 9vw, 118px);
  border: 2px solid rgba(16,32,51,.65);
  border-radius: 50% 46% 54% 42%;
  font: 700 14px/1 var(--caption);
  text-transform: uppercase;
  background: rgba(255,255,255,.5);
  animation: riseBubble 8s var(--spring) infinite;
  animation-delay: var(--d);
}
.term-bubble.cyan { background: rgba(25,217,255,.52); }
.term-bubble.coral { background: rgba(255,95,162,.48); }
.term-bubble.lemon { background: rgba(255,232,92,.72); }
.term-bubble.seafoam { background: rgba(66,245,167,.55); }
.term-bubble.grape { background: rgba(139,92,255,.38); }

.shell-note { align-self: end; padding: 28px; border-radius: 33px 64px 29px 49px; background: var(--lemon); transform: rotate(2deg); }

.water-grid { grid-template-columns: .85fr 1.25fr; grid-template-rows: auto 1fr; }
.lesson-title { padding: clamp(24px, 3vw, 38px); border-radius: 38px 58px 34px 46px; }
.tile-cyan { background: var(--cyan); }
.tile-cream { background: var(--cream); }
.tile-lemon { background: var(--lemon); }
.tile-grape { background: var(--grape); color: white; text-shadow: 0 2px 0 rgba(16,32,51,.24); }
.tile-seafoam { background: var(--seafoam); }

.clearing-pool {
  grid-column: 2;
  grid-row: 1 / span 2;
  border-radius: 64px 38px 78px 42px;
  background: rgba(25,217,255,.32);
  min-height: 620px;
  display: grid;
  place-items: center;
}
.current-map { width: 100%; max-width: 900px; }
.ripple { fill: none; stroke: rgba(255,255,255,.9); stroke-width: 20; stroke-linecap: round; stroke-dasharray: 30 28; animation: dashSwim 5s linear infinite; }
.ripple.small { stroke-width: 11; opacity: .7; animation-duration: 7s; }
.current path, .snap-arrow { fill: none; stroke: var(--ink); stroke-width: 8; stroke-linecap: round; }
.current polygon { fill: var(--ink); }
.clearing-orb { fill: var(--seafoam); stroke: var(--ink); stroke-width: 4; animation: clearPulse 2.6s ease-in-out infinite; }
.current-map text { font-family: var(--caption); text-transform: uppercase; font-weight: 700; fill: var(--ink); font-size: 28px; letter-spacing: .07em; }
.order-bubbles { position: absolute; top: 8%; display: flex; flex-direction: column; gap: 14px; }
.left-orders { left: 6%; }.right-orders { right: 6%; top: 18%; }
.order-bubbles span { padding: 13px 16px; border: 2px solid var(--ink); border-radius: 999px; background: rgba(255,243,214,.74); font: 700 12px/1 var(--caption); text-transform: uppercase; animation: wiggle 2.7s ease-in-out infinite alternate; }
.order-bubbles span:nth-child(2) { animation-delay: .3s; }.order-bubbles span:nth-child(3) { animation-delay: .7s; }
.explanation { padding: 30px; border-radius: 54px 28px 34px 72px; transform: translate(20px, -10px) rotate(-1deg); }

.garden-grid { grid-template-columns: 1fr .78fr .78fr; grid-template-rows: auto 1fr; }
.garden-grid .lesson-title { grid-column: 1 / span 2; }
.tank-card { padding: 30px; border-radius: 34px 70px 44px 30px; background: var(--cream); transform: translateY(18px); }
.coral-tank { background: rgba(255, 95, 162, .78); transform: translateY(-12px) rotate(1.5deg); }
.liquidity-tank {
  height: 250px;
  margin: 20px 0;
  border: 3px solid var(--ink);
  border-radius: 36px 36px 22px 22px;
  background: rgba(255,255,255,.36);
  position: relative;
  overflow: hidden;
}
.liquidity-tank span {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--fill, 50%);
  background: var(--seafoam);
  border-top: 4px solid rgba(255,255,255,.85);
  animation: waterBob 3s ease-in-out infinite;
}
.coral-tank .liquidity-tank span { background: var(--lemon); }
.foam-map { grid-column: 3; grid-row: 1 / span 2; min-height: 620px; border-radius: 55px 33px 66px 44px; background: rgba(66,245,167,.35); }
.foam-island { position: absolute; display: grid; place-items: center; border: 2px solid var(--ink); font: 800 13px/1 var(--caption); text-transform: uppercase; background: var(--cream); box-shadow: 5px 7px 0 rgba(16,32,51,.12); }
.foam-island.a { width: 150px; height: 100px; border-radius: 58% 42% 47% 53%; left: 18%; top: 18%; background: var(--cyan); }
.foam-island.b { width: 190px; height: 130px; border-radius: 43% 57% 61% 39%; right: 10%; top: 38%; background: var(--lemon); }
.foam-island.c { width: 118px; height: 118px; border-radius: 50%; left: 14%; bottom: 18%; background: var(--coral); }
.foam-island.d { width: 150px; height: 86px; border-radius: 999px; right: 22%; bottom: 8%; background: var(--grape); color: white; }

.current-grid { grid-template-columns: .8fr 1fr; grid-template-rows: auto 1fr; }
.current-grid .lesson-title { grid-column: 1 / -1; }
.step-stack { display: grid; gap: 18px; }
.step-card { padding: 26px; border-radius: 34px 52px 30px 44px; background: var(--cream); cursor: pointer; transition: transform .45s var(--spring), background .3s ease, border-radius .45s var(--spring); }
.step-card:nth-child(2) { transform: translateX(34px); background: rgba(25,217,255,.42); }
.step-card:nth-child(3) { transform: translateX(10px) rotate(-1deg); background: rgba(255,232,92,.72); }
.step-card.active { background: var(--seafoam); transform: translateX(64px) scale(1.03); border-radius: 56px 34px 52px 28px; }
.snap-board { border-radius: 68px 38px 34px 74px; background: rgba(139,92,255,.18); display: grid; place-items: center; min-height: 520px; }
.snap-board svg { width: 80%; }
.spiral { fill: none; stroke: var(--coral); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 24 18; animation: dashSwim 8s linear infinite reverse; }
.snap-bubble { position: absolute; top: 18%; left: 12%; width: 150px; height: 150px; display: grid; place-items: center; padding: 20px; border-radius: 48% 52% 42% 58%; border: 2px solid var(--ink); background: var(--lemon); text-align: center; font: 800 14px/1.1 var(--caption); text-transform: uppercase; transition: transform .5s var(--spring), background .3s ease; }
.snap-bubble.pop { transform: translate(260px, 135px) scale(1.18); background: var(--coral); }

.sky-grid { grid-template-columns: 1fr 1.15fr; grid-template-rows: 1fr auto; }
.finale-copy { padding: clamp(28px, 5vw, 58px); border-radius: 70px 36px 58px 40px; background: var(--cream); align-self: center; z-index: 2; }
.sky-water { grid-column: 2; grid-row: 1 / span 2; position: relative; min-height: 680px; border-radius: 54px; background: linear-gradient(180deg, rgba(25,217,255,.20), rgba(255,243,214,.35) 54%, rgba(25,217,255,.45)); border: 2px solid rgba(16,32,51,.5); overflow: hidden; }
.sky-water::before { content: ""; position: absolute; left: -15%; right: -15%; bottom: 28%; height: 90px; background: rgba(255,255,255,.48); border-radius: 50%; animation: waterBob 5s ease-in-out infinite; }
.cloud-bubble { position: absolute; display: grid; place-items: center; border: 2px solid var(--ink); background: rgba(255,255,255,.68); font: 800 15px/1 var(--caption); text-transform: uppercase; box-shadow: 6px 8px 0 rgba(16,32,51,.1); animation: cloudFloat 7s ease-in-out infinite; }
.cloud-bubble.one { width: 150px; height: 118px; border-radius: 56% 44% 61% 39%; left: 18%; bottom: 18%; background: var(--cyan); }
.cloud-bubble.two { width: 188px; height: 128px; border-radius: 44% 56% 48% 52%; right: 12%; bottom: 40%; background: var(--seafoam); animation-delay: .8s; }
.cloud-bubble.three { width: 130px; height: 130px; border-radius: 50%; left: 42%; top: 14%; background: var(--lemon); animation-delay: 1.4s; }
.cloud-bubble.four { width: 210px; height: 126px; border-radius: 999px; left: 12%; top: 35%; background: var(--coral); animation-delay: 2s; }
.final-note { padding: 30px; border-radius: 38px 72px 30px 50px; transform: translate(30px, -28px) rotate(1deg); }

.is-visible .module { animation: snapIn .75s var(--spring) both; }

@keyframes conchBreathe { 0%,100% { border-radius: 38% 62% 44% 56% / 50% 35% 65% 50%; } 50% { border-radius: 45% 55% 52% 48% / 42% 50% 50% 58%; } }
@keyframes riseBubble { 0% { transform: translateY(110%) scale(.7); opacity: 0; filter: blur(1px); } 16% { opacity: 1; } 70% { opacity: .95; } 100% { transform: translateY(-420%) scale(1.04); opacity: 0; filter: blur(2px); } }
@keyframes dashSwim { to { stroke-dashoffset: -116; } }
@keyframes clearPulse { 0%,100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(66,245,167,.4)); } 50% { transform: scale(1.08); filter: drop-shadow(0 0 20px rgba(66,245,167,.8)); } }
@keyframes wiggle { to { transform: translate(16px, 8px) rotate(3deg); } }
@keyframes waterBob { 0%,100% { transform: translateY(0) skewY(-1deg); } 50% { transform: translateY(-14px) skewY(1deg); } }
@keyframes cloudFloat { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-28px) rotate(2deg); } }
@keyframes snapIn { 0% { transform: translateY(40px) scale(.94); opacity: .2; } 70% { transform: translateY(-8px) scale(1.02); opacity: 1; } 100% { opacity: 1; } }

@media (max-width: 860px) {
  .lesson-strip { top: auto; bottom: 14px; right: 50%; transform: translateX(50%); }
  .panel { padding: 38px 16px 86px; }
  .pool-grid, .shell-grid, .water-grid, .garden-grid, .current-grid, .sky-grid { display: flex; flex-direction: column; min-height: auto; }
  .conch-terminal, .clearing-pool, .foam-map, .snap-board, .sky-water { min-height: 520px; }
  .step-card:nth-child(n), .step-card.active, .explanation, .final-note, .tank-card, .coral-tank { transform: none; }
  .progress-bubble { width: 38px; height: 38px; }
  .progress-bubble span { font-size: 8px; }
}
