:root {
  --cream: #FFF1D8;
  --citrine: #FFD166;
  --plum: #2B123C;
  --amethyst: #160A2E;
  --emerald: #0FA36B;
  --ruby: #D7356A;
  --blush: #FF8FB7;
  --lapis: #23318C;
  --display: "Libre Baskerville", Georgia, serif;
  --accent: "Cormorant Garamond", Baskerville, Georgia, serif;
  --sans: "Nunito Sans", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 143, 183, .18), transparent 28rem),
    radial-gradient(circle at 82% 22%, rgba(35, 49, 140, .45), transparent 34rem),
    linear-gradient(145deg, var(--amethyst), var(--plum) 56%, #0d061f);
  font-family: var(--sans);
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  opacity: .3;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 241, 216, .22) 0 1px, transparent 1.5px),
    radial-gradient(circle at 62% 72%, rgba(43, 18, 60, .32) 0 1px, transparent 1.8px),
    radial-gradient(circle at 38% 42%, rgba(255, 209, 102, .16) 0 1px, transparent 1.4px);
  background-size: 22px 18px, 17px 21px, 31px 29px;
  animation: grainDrift 7s steps(6) infinite;
  mix-blend-mode: screen;
}

.bubble-field { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.bubble {
  position: absolute;
  display: block;
  border-radius: 50%;
  border: 2px solid rgba(255, 241, 216, .42);
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 241, 216, .88), transparent 16%),
    radial-gradient(circle at 62% 72%, rgba(255, 143, 183, .3), transparent 38%),
    rgba(255, 209, 102, .08);
  box-shadow: inset -12px -16px 28px rgba(35, 49, 140, .24), 0 0 24px rgba(255, 209, 102, .22);
  animation: bubbleRise 14s ease-in-out infinite;
}
.b1 { width: 76px; height: 76px; left: 7%; top: 72%; animation-delay: -2s; }
.b2 { width: 42px; height: 42px; left: 22%; top: 18%; animation-delay: -8s; }
.b3 { width: 112px; height: 112px; left: 80%; top: 58%; animation-delay: -4s; }
.b4 { width: 58px; height: 58px; left: 63%; top: 10%; animation-delay: -10s; }
.b5 { width: 32px; height: 32px; left: 90%; top: 22%; animation-delay: -1s; }
.b6 { width: 92px; height: 92px; left: 36%; top: 83%; animation-delay: -6s; }
.b7 { width: 52px; height: 52px; left: 51%; top: 35%; animation-delay: -12s; }

.chapter { position: relative; z-index: 3; }
.antechamber {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 6vw;
  isolation: isolate;
}

.antechamber:before {
  content: "";
  position: absolute;
  inset: 4vw;
  border: 2px solid rgba(255, 209, 102, .55);
  border-radius: 42px;
  box-shadow: inset 0 0 0 9px rgba(255, 241, 216, .05), 0 0 80px rgba(255, 143, 183, .16);
  background: linear-gradient(135deg, rgba(255, 241, 216, .03), transparent 42%, rgba(35, 49, 140, .12));
}

.ribbon-path {
  position: absolute;
  width: 70vw;
  height: 42vh;
  left: 4vw;
  bottom: 6vh;
  border-bottom: 18px solid var(--ruby);
  border-right: 16px solid var(--ruby);
  border-radius: 0 0 70% 0;
  filter: drop-shadow(0 12px 0 rgba(43, 18, 60, .55));
  opacity: .86;
  transform: rotate(-4deg);
}

.hero-plaque {
  width: min(900px, 92vw);
  position: relative;
  text-align: center;
  padding: clamp(2.4rem, 7vw, 5.8rem) clamp(1.2rem, 6vw, 4.5rem);
  border-radius: 46px 46px 36px 36px;
  background:
    linear-gradient(120deg, rgba(255, 209, 102, .18), transparent 28%, rgba(255, 143, 183, .14)),
    var(--plum);
  border: 3px double var(--citrine);
  box-shadow: 0 34px 90px rgba(0,0,0,.42), inset 0 0 0 14px rgba(255, 241, 216, .05);
}

.hero-plaque:before,
.hero-plaque:after {
  content: "✦";
  position: absolute;
  top: 26px;
  color: var(--citrine);
  font-size: 2rem;
  text-shadow: 0 0 22px var(--blush);
}
.hero-plaque:before { left: 32px; }
.hero-plaque:after { right: 32px; }

.eyebrow,
.chapter-label,
.tag {
  font-family: var(--accent);
  font-style: italic;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: lowercase;
}
.eyebrow { color: var(--citrine); font-size: clamp(1.15rem, 2vw, 1.45rem); margin: 0 0 1rem; }

h1, h2, h3 {
  font-family: var(--display);
  margin: 0;
  letter-spacing: -.045em;
}

h1 {
  font-size: clamp(3.1rem, 10vw, 9rem);
  line-height: .9;
  color: var(--cream);
  text-shadow: 0 5px 0 var(--lapis), 0 0 34px rgba(255, 143, 183, .44);
}

.hero-line {
  max-width: 650px;
  margin: 1.5rem auto 2rem;
  color: rgba(255, 241, 216, .82);
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.7;
}

.crown-seal,
.stamp,
.seal {
  border: 0;
  border-radius: 999px;
  background: var(--ruby);
  box-shadow: inset 0 -7px 0 rgba(43, 18, 60, .25), 0 12px 26px rgba(0,0,0,.24);
  color: var(--cream);
}
.crown-seal {
  cursor: pointer;
  display: inline-flex;
  gap: .65rem;
  align-items: center;
  padding: 1rem 1.45rem;
  font-family: var(--accent);
  font-style: italic;
  font-size: 1.22rem;
  animation: crownEnter 1.2s cubic-bezier(.18,1.65,.34,1) .45s both;
}
.crown-seal.unlocked { animation: stampThud .58s cubic-bezier(.2,1.7,.36,1) both; }
.crown { color: var(--citrine); font-size: 1.55rem; }

.chandelier {
  position: absolute;
  top: 6vh;
  width: min(460px, 62vw);
  height: 130px;
  border-top: 2px dashed rgba(255, 209, 102, .5);
}
.chandelier i {
  position: absolute;
  top: 28px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 28% 25%, var(--cream), var(--citrine) 34%, rgba(255,143,183,.5));
  box-shadow: 0 0 24px rgba(255,209,102,.7);
}
.chandelier i:nth-child(1){ left: 6%; top: 22px; }
.chandelier i:nth-child(2){ left: 26%; top: 68px; }
.chandelier i:nth-child(3){ left: 47%; top: 40px; }
.chandelier i:nth-child(4){ right: 24%; top: 76px; }
.chandelier i:nth-child(5){ right: 5%; top: 24px; }

.pearl-chain { position: absolute; top: 18%; bottom: 14%; width: 18px; background: radial-gradient(circle, var(--cream) 0 5px, transparent 6px) 0 0/18px 30px; opacity: .55; }
.chain-left { left: 5vw; }
.chain-right { right: 5vw; }

.quest-cabinet { padding: 7rem 5vw 5rem; }
.chapter-heading { max-width: 840px; margin-bottom: 2.4rem; }
.chapter-label { color: var(--citrine); font-size: 1.28rem; }
h2 { font-size: clamp(2.35rem, 5vw, 5.7rem); line-height: .98; text-shadow: 0 4px 0 rgba(35,49,140,.8); }
.chapter-heading p,
.map-fragment p,
.boss-door-panel p { color: rgba(255, 241, 216, .78); line-height: 1.75; font-size: 1.06rem; max-width: 670px; }

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 92px;
  gap: clamp(.9rem, 1.6vw, 1.45rem);
  align-items: stretch;
}

.quest-card {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  padding: 1.35rem;
  border-radius: 30px;
  border: 2px solid rgba(255, 241, 216, .28);
  box-shadow: 0 24px 48px rgba(0,0,0,.28), inset 0 0 0 8px rgba(255, 241, 216, .045);
  transform: translateY(38px) scale(.94);
  opacity: 0;
  transition: transform .45s cubic-bezier(.18,1.55,.34,1), box-shadow .3s ease, opacity .3s ease;
}
.quest-card.in-view { opacity: 1; transform: translateY(0) scale(1); transition-delay: var(--delay, 0ms); }
.quest-card:hover { transform: translateY(-10px) scale(1.025); box-shadow: 0 34px 64px rgba(0,0,0,.36), 0 0 0 6px rgba(255, 209, 102, .15); }
.quest-card:after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, transparent 12%, rgba(255,255,255,.22) 28%, transparent 44%);
  transform: translateX(-120%);
  transition: transform .7s ease;
}
.quest-card:hover:after { transform: translateX(120%); }
.quest-card h3 { position: relative; z-index: 1; font-size: clamp(1.45rem, 2.2vw, 2.2rem); line-height: 1.02; margin-top: .6rem; }
.quest-card p { position: relative; z-index: 1; line-height: 1.55; margin: .75rem 0 0; color: rgba(255,241,216,.82); }
.tag { position: relative; z-index: 1; color: var(--citrine); font-size: 1rem; }

.banner { grid-column: span 5; grid-row: span 4; }
.charm { grid-column: span 3; grid-row: span 3; }
.letter { grid-column: span 4; grid-row: span 3; }
.doorway { grid-column: span 4; grid-row: span 5; }
.lens { grid-column: span 4; grid-row: span 4; }
.tile { grid-column: span 4; grid-row: span 3; }
.note { grid-column: span 5; grid-row: span 3; }
.crown-card { grid-column: span 3; grid-row: span 4; }

.card-lapis { background: linear-gradient(145deg, var(--lapis), #1c1a66 60%, var(--plum)); }
.card-cream { background: linear-gradient(145deg, var(--cream), #ffdca0); color: var(--plum); }
.card-cream p { color: rgba(43,18,60,.75); }
.card-ruby { background: linear-gradient(145deg, var(--ruby), #8f1848 70%, var(--plum)); }
.card-amethyst { background: linear-gradient(145deg, #251047, var(--amethyst)); }
.card-blush { background: linear-gradient(145deg, var(--blush), var(--ruby)); color: var(--plum); }
.card-blush p { color: rgba(43,18,60,.78); }
.card-emerald { background: linear-gradient(145deg, var(--emerald), #075c47); }

.seal {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 66px;
  height: 66px;
  padding: 0 .75rem;
  border-radius: 50%;
  font-family: var(--accent);
  font-style: italic;
  font-weight: 700;
  transform: rotate(-10deg);
}
.seal.emerald { background: var(--emerald); }
.seal.blush { background: var(--blush); color: var(--plum); }
.orb, .sticker-crown, .key {
  position: absolute;
  right: 1.1rem;
  top: 1rem;
  font-size: 3rem;
  color: var(--citrine);
  text-shadow: 0 0 20px rgba(255,209,102,.65);
}
.lens-bubble {
  position: absolute;
  width: 145px;
  height: 145px;
  right: -20px;
  top: -25px;
  border-radius: 50%;
  border: 3px solid rgba(255,241,216,.62);
  background: radial-gradient(circle at 30% 24%, rgba(255,241,216,.75), rgba(255,209,102,.2) 26%, rgba(35,49,140,.18));
  transition: transform .36s cubic-bezier(.18,1.55,.34,1);
}
.lens:hover .lens-bubble { transform: scale(1.08, .86) rotate(8deg); }

.secret-route,
.boss-return { min-height: 78vh; padding: 6rem 5vw; display: grid; place-items: center; }
.map-fragment,
.boss-door-panel {
  position: relative;
  width: min(980px, 92vw);
  padding: clamp(2rem, 5vw, 4.5rem);
  border-radius: 38px;
  background: linear-gradient(135deg, rgba(255,241,216,.12), rgba(35,49,140,.2)), rgba(43,18,60,.78);
  border: 2px dashed rgba(255,209,102,.62);
  box-shadow: 0 30px 80px rgba(0,0,0,.34), inset 0 0 0 10px rgba(255,241,216,.04);
}
.map-fragment:before {
  content: "";
  position: absolute;
  inset: 1.2rem;
  border-radius: 28px;
  background: radial-gradient(circle, rgba(255,209,102,.52) 0 3px, transparent 4px) 0 0/48px 34px;
  opacity: .16;
}
.ribbon-button {
  position: relative;
  z-index: 1;
  cursor: pointer;
  margin-top: 1rem;
  padding: 1rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--ruby);
  box-shadow: inset 0 -8px 0 rgba(43,18,60,.25), 0 18px 34px rgba(0,0,0,.26);
  font-family: var(--accent);
  font-style: italic;
  font-weight: 700;
}
.ribbon-button.tug { animation: ribbonTug .56s cubic-bezier(.18,1.6,.34,1); }
.route-dots { display: flex; gap: 18px; margin-top: 2rem; transform: rotate(-4deg); }
.route-dots i { width: 15px; height: 15px; border-radius: 50%; background: var(--citrine); box-shadow: 0 0 18px rgba(255,209,102,.7); }
.diary-lock { position: absolute; right: 9vw; bottom: 10vh; width: 110px; height: 90px; border-radius: 22px; background: var(--citrine); box-shadow: inset 0 -12px 0 rgba(43,18,60,.18), 0 20px 30px rgba(0,0,0,.25); }
.diary-lock:before { content: ""; position: absolute; left: 25px; top: -45px; width: 60px; height: 58px; border: 12px solid var(--citrine); border-bottom: 0; border-radius: 60px 60px 0 0; }
.diary-lock span { position: absolute; inset: 32px 44px 22px; border-radius: 50% 50% 10px 10px; background: var(--plum); }

.stamp-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1.5rem; }
.stamp { cursor: pointer; min-width: 92px; aspect-ratio: 1; font-family: var(--accent); font-style: italic; font-weight: 700; font-size: 1.2rem; }
.stamp:nth-child(2) { background: var(--emerald); }
.stamp:nth-child(3) { background: var(--blush); color: var(--plum); }
.stamp.stamped { animation: stampThud .5s cubic-bezier(.18,1.65,.34,1); }

.memory-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: rgba(22, 10, 46, .72);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.memory-overlay.open { opacity: 1; pointer-events: auto; }
.memory-card {
  position: relative;
  width: min(650px, 94vw);
  min-height: 420px;
  padding: clamp(2rem, 5vw, 4rem);
  border-radius: 36px;
  color: var(--plum);
  background: var(--cream);
  border: 4px double var(--ruby);
  box-shadow: 0 36px 90px rgba(0,0,0,.44), inset 0 0 0 12px rgba(255,209,102,.22);
  transform: rotateX(16deg) scale(.82);
  transition: transform .45s cubic-bezier(.18,1.55,.34,1);
}
.memory-overlay.open .memory-card { transform: rotateX(0) scale(1); }
.memory-card h2 { color: var(--plum); text-shadow: 0 3px 0 rgba(255,143,183,.45); font-size: clamp(2.2rem, 5vw, 4.4rem); }
.memory-card p { font-size: 1.12rem; line-height: 1.75; color: rgba(43,18,60,.78); }
.close-memory { position: absolute; right: 1rem; top: 1rem; width: 46px; height: 46px; border: 0; border-radius: 50%; background: var(--plum); color: var(--cream); cursor: pointer; font-size: 1.8rem; }
.memory-foil { position: absolute; inset: auto 2rem 2rem; height: 48px; border-radius: 999px; background: linear-gradient(90deg, var(--ruby), var(--citrine), var(--emerald), var(--lapis), var(--blush)); opacity: .75; }

@keyframes grainDrift { 0%,100% { transform: translate(0,0); } 25% { transform: translate(-2%,1%); } 50% { transform: translate(1%,-2%); } 75% { transform: translate(2%,2%); } }
@keyframes bubbleRise { 0%,100% { transform: translate3d(0, 0, 0) scale(1); } 45% { transform: translate3d(22px, -54px, 0) scale(1.08, .94); } 70% { transform: translate3d(-12px, -82px, 0) scale(.94, 1.06); } }
@keyframes crownEnter { 0% { opacity: 0; transform: translateY(50px) scale(.35) rotate(-18deg); } 68% { opacity: 1; transform: translateY(-10px) scale(1.12) rotate(6deg); } 100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); } }
@keyframes stampThud { 0% { transform: scale(1) rotate(-4deg); } 45% { transform: scale(.82, 1.18) rotate(5deg); } 72% { transform: scale(1.12, .9) rotate(-2deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes ribbonTug { 0% { transform: translateX(0) scale(1); } 44% { transform: translateX(20px) scale(1.04, .96); } 100% { transform: translateX(0) scale(1); } }

@media (max-width: 850px) {
  .portfolio-grid { display: block; }
  .quest-card { min-height: 260px; margin-bottom: 1.1rem; }
  .antechamber { padding: 1rem; }
  .antechamber:before { inset: 1rem; border-radius: 28px; }
  .hero-plaque { border-radius: 30px; }
  .ribbon-path { width: 90vw; height: 28vh; left: -18vw; }
  .pearl-chain, .chandelier { opacity: .35; }
  .diary-lock { position: relative; right: auto; bottom: auto; margin-top: 2rem; }
  .secret-route { display: block; }
}
