@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&family=Cinzel+Decorative:wght@700;900&family=Cormorant+Garamond:wght@500;600;700&family=Inter:wght@400;500;600;700;800&family=Kalam:wght@300;400;700&family=Macondo&family=UnifrakturCook:wght@700&display=swap');

:root {
  --bg: #060309;
  --bg2: #120814;
  --text: #fff6e8;
  --muted: rgba(255, 246, 232, .64);
  --dim: rgba(255, 246, 232, .38);
  --line: rgba(255, 246, 232, .16);
  --glass: rgba(255, 246, 232, .07);
  --gold: #f3c56e;
  --gold-dark: #916522;
  --burgundy: #740001; /* Colore tipico di Grifondoro */
  --rose: #ff7aaa;
  --violet: #a583ff;
  --green: #82ffb6;
  --ink: #2d1a16;
  --ink-soft: rgba(45, 26, 22, .75);
  --paper: #f1dfb9;
  --paper2: #d9bd85;
  --paper3: #fff0cf;
  --paper-shadow: #8d6a35;
  --cover: #251223;
  --cover2: #4d2138;
  --cover3: #140a14;
  --radius-xl: 34px;
  --radius-lg: 24px;
  --ease: cubic-bezier(.19, 1, .22, 1);
  --font-title: "Cormorant Garamond", Georgia, serif;
  --font-magic: "Macondo", "Cormorant Garamond", serif;
  --font-cover: "Cinzel Decorative", "Cormorant Garamond", serif;
  --font-hand: "Caveat", "Kalam", cursive;
  --book-w: min(82vw, 1120px);
  --book-h: min(72dvh, 740px);
}

* { box-sizing: border-box; }
html { height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 28% 15%, rgba(155, 122, 255, .24), transparent 28%),
    radial-gradient(circle at 82% 78%, rgba(255, 122, 170, .18), transparent 32%),
    linear-gradient(140deg, #060309, #120814 48%, #07040a);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
a { color: inherit; }

#nebula {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: .72;
  pointer-events: none;
}

.ambient-grain,
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.ambient-grain {
  opacity: .18;
  mix-blend-mode: soft-light;
  background-image:
    repeating-radial-gradient(circle at 20% 30%, rgba(255,255,255,.28) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(120deg, rgba(255,255,255,.08) 0 1px, transparent 1px 4px);
  filter: contrast(135%);
}

.vignette {
  background:
    radial-gradient(circle at 50% 42%, transparent 0 38%, rgba(0,0,0,.42) 72%, rgba(0,0,0,.78) 100%),
    linear-gradient(90deg, rgba(0,0,0,.38), transparent 22%, transparent 78%, rgba(0,0,0,.38));
}

.experience {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  isolation: isolate;
}

.prelude {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, rgba(243, 197, 110, .17), transparent 28%),
    radial-gradient(circle at 24% 76%, rgba(155, 122, 255, .18), transparent 24%),
    linear-gradient(180deg, rgba(5,3,8,.99), rgba(18,8,20,.98));
  transition: opacity .9s var(--ease), visibility .9s var(--ease), transform .9s var(--ease);
}

.experience[data-intro="off"] .prelude {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.025);
}

.film-mask span {
  position: absolute;
  left: 0;
  right: 0;
  height: 11dvh;
  background: rgba(0,0,0,.72);
  z-index: 3;
}
.film-mask span:first-child { top: 0; }
.film-mask span:last-child { bottom: 0; }

.prelude-glow {
  position: absolute;
  width: min(78vw, 780px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(243,197,110,.16), transparent 58%),
    conic-gradient(from 140deg, transparent, rgba(255,122,170,.12), transparent, rgba(155,122,255,.14), transparent);
  filter: blur(2px);
  animation: slowSpin 18s linear infinite;
}

@keyframes slowSpin { to { transform: rotate(360deg); } }

.prelude-status {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: clamp(16px, 4vw, 40px);
  right: clamp(16px, 4vw, 40px);
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,246,232,.62);
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: 10px;
  z-index: 4;
}
.prelude-status i { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(243,197,110,.5), transparent); }

.prelude-center {
  position: relative;
  z-index: 5;
  width: min(880px, 88vw);
  text-align: center;
  padding: clamp(24px, 4vw, 52px);
}

.prelude-kicker {
  margin: 0 0 18px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .28em;
  font-size: clamp(10px, 1.2vw, 12px);
}

.prelude-center h1 {
  margin: 0;
  font-family: var(--font-cover);
  font-size: clamp(2.2rem, 6.2vw, 6rem);
  line-height: .94;
  font-weight: 700;
  text-wrap: balance;
  letter-spacing: -.035em;
  text-shadow: 0 22px 60px rgba(0,0,0,.55);
}

.prelude-center p:last-child {
  margin: 22px auto 0;
  max-width: 560px;
  color: rgba(255,246,232,.72);
  font-family: var(--font-hand);
  font-size: clamp(1.35rem, 2.6vw, 2.2rem);
  line-height: 1.02;
}

.memory-rain {
  position: absolute;
  inset: -10vh -10vw;
  overflow: hidden;
  z-index: 2;
  pointer-events: none;
  mask-image: radial-gradient(circle at 50% 48%, rgba(0,0,0,.4), rgba(0,0,0,1) 26%, transparent 82%);
}

.memory-fragment {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(243,197,110,.22);
  border-radius: 999px;
  background: rgba(10, 5, 12, .52);
  box-shadow: 0 12px 40px rgba(0,0,0,.22);
  color: rgba(255,246,232,.74);
  font-family: var(--font-hand);
  font-size: clamp(1.05rem, 1.8vw, 1.8rem);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(40px) rotate(var(--r, 0deg));
  filter: blur(4px);
}

.memory-fragment small {
  font-family: Inter, sans-serif;
  font-size: 9px;
  color: rgba(243,197,110,.62);
  text-transform: uppercase;
  letter-spacing: .18em;
}

.prelude-lower {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 13dvh;
  height: 56px;
  overflow: hidden;
  opacity: .62;
  z-index: 2;
  border-block: 1px solid rgba(255,246,232,.08);
  background: rgba(0,0,0,.22);
}

.film-strip {
  display: flex;
  width: max-content;
  height: 100%;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  animation: filmMove 42s linear infinite;
}

.film-item {
  min-width: 160px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid rgba(243,197,110,.2);
  color: rgba(255,246,232,.54);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .18em;
}

@keyframes filmMove { to { transform: translateX(-50%); } }

.skip-intro {
  position: absolute;
  right: clamp(16px, 3vw, 34px);
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 5;
  border: 1px solid rgba(255,246,232,.14);
  border-radius: 999px;
  background: rgba(255,246,232,.07);
  color: rgba(255,246,232,.76);
  padding: 12px 15px;
  cursor: pointer;
  backdrop-filter: blur(14px);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 10px;
}

.prelude-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255,255,255,.08);
  z-index: 6;
}
.prelude-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--rose)); }

.book-header {
  position: relative;
  z-index: 8;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top)) clamp(12px, 3vw, 32px) 6px;
}

.chapter-badge {
  min-width: min(520px, 62vw);
  max-width: 720px;
  text-align: center;
  padding: 12px 20px;
  border: 1px solid rgba(243,197,110,.2);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,246,232,.09), rgba(255,246,232,.035));
  box-shadow: 0 20px 80px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.1);
  backdrop-filter: blur(18px);
}

.chapter-badge span {
  display: block;
  margin-bottom: 2px;
  color: rgba(243,197,110,.78);
  text-transform: uppercase;
  letter-spacing: .2em;
  font-size: 10px;
}
.chapter-badge strong {
  display: block;
  font-family: var(--font-title);
  font-size: clamp(1.05rem, 2.5vw, 1.75rem);
  line-height: 1;
}
.chapter-badge small { color: rgba(255,246,232,.56); font-size: 11px; }

.index-open {
  border: 1px solid rgba(243,197,110,.25);
  background: linear-gradient(135deg, rgba(243,197,110,.16), rgba(255,122,170,.1));
  border-radius: 999px;
  color: var(--text);
  padding: 14px 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,.26);
  cursor: pointer;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .11em;
  font-size: 11px;
}

.stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: clamp(14px, 2.5vw, 30px);
  align-items: center;
  padding: 8px clamp(12px, 3vw, 36px) 4px;
}

.index-backdrop { display: none; }
.index-panel {
  position: relative;
  z-index: 9;
  align-self: stretch;
  max-height: calc(100dvh - 150px);
  overflow: hidden;
  border: 1px solid rgba(243,197,110,.2);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(20, 10, 21, .88), rgba(8, 4, 11, .78)),
    radial-gradient(circle at 20% 0%, rgba(243,197,110,.12), transparent 40%);
  box-shadow: 0 28px 90px rgba(0,0,0,.38), inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter: blur(18px);
  padding: 16px;
}

.index-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.index-head span {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .2em;
  font-size: 11px;
  font-weight: 800;
}
.index-close {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,246,232,.14);
  border-radius: 50%;
  background: rgba(255,246,232,.08);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}
.index-intro {
  margin: 0 0 14px;
  color: rgba(255,246,232,.62);
  font-size: 13px;
  line-height: 1.5;
}

.chapter-list {
  display: grid;
  gap: 10px;
  max-height: calc(100dvh - 330px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(243,197,110,.5) transparent;
}

.chapter-item {
  position: relative;
  width: 100%;
  min-height: 74px;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 1px solid rgba(255,246,232,.11);
  border-radius: 20px;
  background: rgba(255,246,232,.045);
  color: var(--text);
  padding: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: transform .35s var(--ease), border-color .35s var(--ease), background .35s var(--ease);
}
.chapter-item::before {
  content: "";
  position: absolute;
  inset: -1px;
  background: radial-gradient(circle at var(--mx, 15%) var(--my, 20%), color-mix(in srgb, var(--mood, #f3c56e) 30%, transparent), transparent 48%);
  opacity: 0;
  transition: opacity .35s var(--ease);
}
.chapter-item:hover, .chapter-item.is-active {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--mood, #f3c56e) 55%, rgba(255,255,255,.12));
  background: rgba(255,246,232,.075);
}
.chapter-item:hover::before, .chapter-item.is-active::before { opacity: 1; }
.chapter-num {
  position: relative;
  z-index: 1;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--mood, #f3c56e) 55%, rgba(255,255,255,.12));
  color: var(--mood, #f3c56e);
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 18px;
  background: rgba(0,0,0,.22);
}
.chapter-text { position: relative; z-index: 1; min-width: 0; }
.chapter-text b {
  display: block;
  font-family: var(--font-title);
  font-size: 1.16rem;
  line-height: 1.02;
}
.chapter-text small {
  display: block;
  margin-top: 4px;
  color: rgba(255,246,232,.56);
  line-height: 1.25;
}

.index-note {
  margin-top: 14px;
  border-radius: 20px;
  padding: 14px;
  background: rgba(243,197,110,.09);
  border: 1px solid rgba(243,197,110,.18);
  color: rgba(255,246,232,.68);
  font-size: 13px;
  line-height: 1.45;
}
.index-note b { display: block; color: var(--gold); margin-bottom: 4px; }

.book-area {
  position: relative;
  z-index: 5;
  display: grid;
  justify-items: center;
  align-content: center;
  min-width: 0;
  height: 100%;
  min-height: 0;
  perspective: 1700px;
}

.book-light {
  position: absolute;
  border-radius: 50%;
  filter: blur(30px);
  opacity: .7;
  pointer-events: none;
}
.book-light--a { width: 220px; height: 220px; left: 12%; top: 20%; background: rgba(243,197,110,.18); }
.book-light--b { width: 300px; height: 300px; right: 10%; bottom: 12%; background: rgba(155,122,255,.16); }

.dust {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: .8;
}
.dust span {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(243,197,110,.62);
  box-shadow: 0 0 18px rgba(243,197,110,.6);
  animation: floatDust var(--d, 7s) linear infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes floatDust {
  0% { transform: translate3d(0, 40px, 0) scale(.4); opacity: 0; }
  15% { opacity: .9; }
  100% { transform: translate3d(var(--x, 40px), -150px, 0) scale(1); opacity: 0; }
}

.book-shell {
  position: relative;
  width: var(--book-w);
  height: var(--book-h);
  transform-style: preserve-3d;
  transition: transform .7s var(--ease), width .3s var(--ease), height .3s var(--ease);
}

.book {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(8deg) rotateY(-7deg) rotateZ(-1deg);
  transition: transform 1s var(--ease);
}
.experience[data-book-open="true"] .book { transform: rotateX(7deg) rotateY(0deg) rotateZ(-.4deg); }
.book.is-dragging { transition: none; }

.book-shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -10%;
  height: 24%;
  border-radius: 50%;
  background: rgba(0,0,0,.58);
  filter: blur(34px);
  transform: translateZ(-80px);
}

.book-spine {
  position: absolute;
  left: 48.6%;
  top: 4%;
  width: 3%;
  height: 92%;
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(62,36,20,.4), rgba(255,255,255,.18), rgba(50,25,20,.4));
  box-shadow: inset 0 0 22px rgba(0,0,0,.55);
  opacity: 0;
  transition: opacity .5s var(--ease);
  z-index: 2;
}
.experience[data-book-open="true"] .book-spine { opacity: 1; }

.page-stack {
  position: absolute;
  top: 5.5%;
  width: 45.8%;
  height: 89%;
  border-radius: 22px 10px 10px 22px;
  background: repeating-linear-gradient(0deg, #c7a66e 0 2px, #f4ddb2 2px 5px);
  filter: drop-shadow(0 18px 30px rgba(0,0,0,.28));
  opacity: 0;
}
.page-stack--left { left: 2.5%; transform: translateZ(-14px) rotateY(2deg); }
.page-stack--right { right: 2.5%; border-radius: 10px 22px 22px 10px; transform: translateZ(-14px) rotateY(-2deg); }
.experience[data-book-open="true"] .page-stack { opacity: .75; }

.book-fold {
  position: absolute;
  top: 6%;
  left: 49%;
  width: 2%;
  height: 88%;
  z-index: 8;
  opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(69, 42, 22, .28), rgba(255,255,255,.17), rgba(69,42,22,.34), transparent);
  pointer-events: none;
}
.experience[data-book-open="true"] .book-fold { opacity: 1; }

.closed-book {
  position: absolute;
  inset: 3% 18%;
  z-index: 20;
  transform-style: preserve-3d;
  transform-origin: left center;
  filter: drop-shadow(0 35px 70px rgba(0,0,0,.55));
  transition: transform 1.35s var(--ease), opacity .85s var(--ease), visibility .85s var(--ease);
}
.experience[data-book-open="true"] .closed-book {
  transform: rotateY(-145deg) translateX(-5%) rotateZ(-2deg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.cover-edge {
  position: absolute;
  inset: 3% -3% -3% 6%;
  border-radius: 18px 30px 30px 18px;
  background: repeating-linear-gradient(90deg, #d7b77b 0 3px, #f5ddb0 3px 7px);
  transform: translateZ(-20px);
}
.cover-face {
  position: absolute;
  inset: 0;
  border-radius: 22px 34px 34px 22px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(8px, 2vh, 18px);
  padding: clamp(18px, 4vw, 48px);
  text-align: center;
  background:
    radial-gradient(circle at 50% 34%, rgba(243,197,110,.22), transparent 26%),
    radial-gradient(circle at 16% 18%, rgba(255,255,255,.12), transparent 15%),
    repeating-linear-gradient(105deg, rgba(255,255,255,.035) 0 2px, transparent 2px 7px),
    linear-gradient(135deg, var(--cover2), var(--cover) 40%, var(--cover3));
  border: 1px solid rgba(243,197,110,.45);
  box-shadow:
    inset 0 0 0 9px rgba(0,0,0,.18),
    inset 0 0 0 11px rgba(243,197,110,.18),
    inset 0 0 45px rgba(0,0,0,.54),
    0 28px 70px rgba(0,0,0,.48);
  overflow: hidden;
}
.cover-face::before,
.cover-face::after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(243,197,110,.26);
  border-radius: 18px 28px 28px 18px;
  pointer-events: none;
}
.cover-face::after {
  inset: 30px;
  border-color: rgba(255,246,232,.09);
}
.cover-stars span {
  position: absolute;
  color: rgba(243,197,110,.46);
  font-size: clamp(20px, 3vw, 32px);
  text-shadow: 0 0 22px rgba(243,197,110,.4);
}
.cover-stars span:nth-child(1) { left: 16%; top: 18%; }
.cover-stars span:nth-child(2) { right: 15%; top: 21%; }
.cover-stars span:nth-child(3) { left: 14%; bottom: 19%; }
.cover-stars span:nth-child(4) { right: 14%; bottom: 18%; }
.cover-line {
  width: min(250px, 70%);
  height: 18px;
  opacity: .8;
  background:
    linear-gradient(90deg, transparent, rgba(243,197,110,.7), transparent),
    radial-gradient(circle at 50% 50%, rgba(243,197,110,.7), transparent 15%);
}
.cover-kicker {
  position: relative;
  z-index: 1;
  margin: 0;
  color: rgba(243,197,110,.82);
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: clamp(8px, 1.1vw, 11px);
}
.cover-face h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #fff3d3;
  font-family: var(--font-cover);
  font-size: clamp(2rem, 6vw, 5.6rem);
  line-height: .86;
  letter-spacing: -.04em;
  text-shadow: 0 3px 0 rgba(87,52,13,.5), 0 0 28px rgba(243,197,110,.28);
}
.cover-seal {
  position: relative;
  z-index: 1;
  width: clamp(62px, 10vw, 96px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255,255,255,.22), transparent 28%),
    linear-gradient(135deg, #f9d38a, #9f6b22 55%, #f0c56d);
  box-shadow: 0 0 36px rgba(243,197,110,.28), inset 0 0 18px rgba(0,0,0,.26);
  color: #321911;
  font-family: var(--font-cover);
  font-size: clamp(2rem, 4vw, 3.6rem);
}
.cover-subtitle {
  position: relative;
  z-index: 1;
  max-width: 460px;
  margin: 0;
  color: rgba(255,246,232,.7);
  font-family: var(--font-hand);
  font-size: clamp(1.25rem, 2.3vw, 2rem);
  line-height: 1.02;
}
.open-book {
  position: relative;
  z-index: 2;
  overflow: hidden;
  border: 1px solid rgba(243,197,110,.45);
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.28), transparent 34%),
    linear-gradient(135deg, #f8d68e, #9a6620);
  color: #2b140a;
  padding: 15px 22px;
  box-shadow: 0 18px 52px rgba(0,0,0,.42), 0 0 34px rgba(243,197,110,.18);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.open-book .spark {
  position: absolute;
  inset: -70% auto -70% -30%;
  width: 36%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.74), transparent);
  transform: skewX(-18deg);
  animation: shine 2.4s ease-in-out infinite;
}
@keyframes shine { 0%, 35% { left: -40%; } 70%, 100% { left: 110%; } }

.paper-page {
  position: absolute;
  top: 6%;
  width: 45.5%;
  height: 88%;
  padding: clamp(18px, 2.35vw, 34px);
  color: var(--ink);
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 15%, rgba(255,255,255,.42), transparent 23%),
    radial-gradient(circle at 87% 82%, rgba(130, 80, 30, .18), transparent 26%),
    linear-gradient(90deg, rgba(96, 60, 24, .1), transparent 12%, transparent 88%, rgba(96, 60, 24, .13)),
    repeating-linear-gradient(0deg, rgba(86, 54, 28, .055) 0 1px, transparent 1px 34px),
    linear-gradient(135deg, var(--paper3), var(--paper) 40%, var(--paper2));
  box-shadow:
    inset 0 0 0 1px rgba(94, 61, 26, .22),
    inset 0 0 34px rgba(117, 73, 28, .2),
    0 22px 46px rgba(0,0,0,.3);
  opacity: 0;
  visibility: hidden;
  transform-style: preserve-3d;
  transition: opacity .75s var(--ease), visibility .75s var(--ease), transform .75s var(--ease);
}
.experience[data-book-open="true"] .paper-page { opacity: 1; visibility: visible; }
.paper-page--left {
  left: 3.2%;
  border-radius: 25px 10px 10px 25px;
  transform: rotateY(2.2deg) translateZ(7px);
}
.paper-page--right {
  right: 3.2%;
  border-radius: 10px 25px 25px 10px;
  transform: rotateY(-2.2deg) translateZ(7px);
}
.paper-page::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(91, 57, 25, .22);
  border-radius: inherit;
  pointer-events: none;
}
.paper-page::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .18;
  mix-blend-mode: multiply;
  pointer-events: none;
  background-image:
    repeating-radial-gradient(circle at 22% 40%, rgba(57,34,10,.2) 0 1px, transparent 1px 4px),
    linear-gradient(120deg, transparent, rgba(255,255,255,.24), transparent);
}

.page-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vh, 14px);
  overflow: hidden;
}
.page-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(69,42,22,.36) transparent;
}
.page-kicker {
  margin: 0;
  color: rgba(72, 43, 20, .68);
  font-family: var(--font-magic);
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: clamp(9px, .9vw, 12px);
}
.page-title {
  margin: 0;
  color: #3d251b;
  font-family: var(--font-magic);
  font-size: clamp(1.55rem, 2.9vw, 3rem);
  line-height: .92;
  font-weight: 400;
  text-wrap: balance;
}
.page-lead {
  margin: 0;
  color: rgba(45,26,22,.82);
  font-family: var(--font-hand);
  font-size: clamp(1.25rem, 1.85vw, 2.05rem);
  line-height: .98;
}
.handwritten {
  font-family: var(--font-hand);
  font-size: clamp(1.15rem, 1.55vw, 1.75rem);
  line-height: 1.05;
  color: var(--ink-soft);
}
.handwritten p { margin: 0 0 .65em; }
.handwritten ul { margin: .4em 0 .6em; padding-left: 1.2em; }
.handwritten li { margin: .24em 0; }
.handwritten strong { color: #2e1512; font-weight: 700; }
.handwritten em { color: rgba(93,48,35,.85); }

.magic-note,
.author-note,
.warning-paper,
.contact-card,
.animal-card {
  position: relative;
  margin: 12px 0;
  border-radius: 18px;
  padding: 14px 15px;
  border: 1px solid rgba(92, 54, 18, .2);
  background: rgba(255, 247, 219, .52);
  box-shadow: 0 12px 24px rgba(85,48,18,.12), inset 0 1px 0 rgba(255,255,255,.3);
}
.author-note {
  transform: rotate(-1deg);
  background:
    linear-gradient(135deg, rgba(255, 252, 232, .72), rgba(234, 208, 156, .45));
  border-style: dashed;
}
.author-note::before {
  content: "appunto del custode";
  display: block;
  margin-bottom: 4px;
  color: rgba(80, 49, 20, .65);
  font-family: Inter, sans-serif;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .16em;
}
.warning-paper {
  background: rgba(255, 232, 198, .58);
  border-color: rgba(154, 91, 30, .26);
}
.magic-note::before {
  content: "✦";
  position: absolute;
  right: 13px;
  top: 8px;
  color: rgba(111, 67, 24, .34);
}
.animal-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
}
.animal-card .paw {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(102, 64, 24, .13);
  font-size: 22px;
}
.contact-card {
  text-align: center;
  background: linear-gradient(135deg, rgba(255,247,219,.74), rgba(222,188,119,.5));
}
.contact-actions {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.contact-actions a {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  border-radius: 999px;
  text-decoration: none;
  color: #2c150b;
  background: linear-gradient(135deg, #f8d68e, #9d6721);
  border: 1px solid rgba(78,45,12,.25);
  font-family: Inter, sans-serif;
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.contact-actions a:last-child { background: rgba(255,246,232,.55); }

.clue {
  display: inline;
  border: 0;
  background: linear-gradient(transparent 58%, rgba(243,197,110,.36) 58%);
  padding: 0 3px;
  color: #311510;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
}

.page-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(68, 39, 17, .48);
  font-family: var(--font-magic);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 10px;
  border-top: 1px solid rgba(68,39,17,.13);
  padding-top: 8px;
}

.page-turn {
  position: absolute;
  top: 6%;
  right: 3.2%;
  width: 45.5%;
  height: 88%;
  transform-origin: left center;
  transform-style: preserve-3d;
  z-index: 18;
  pointer-events: none;
  opacity: 0;
}
.page-turn__front,
.page-turn__back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 10px 25px 25px 10px;
  background: linear-gradient(135deg, var(--paper3), var(--paper), var(--paper2));
  box-shadow: 0 20px 50px rgba(0,0,0,.3), inset 0 0 32px rgba(111,74,28,.16);
}
.page-turn__back { transform: rotateY(180deg); border-radius: 25px 10px 10px 25px; }

.page-zone {
  position: absolute;
  top: 6%;
  height: 88%;
  width: 15%;
  z-index: 15;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.page-zone--prev { left: 0; }
.page-zone--next { right: 0; }

.chapter-interlude {
  position: absolute;
  inset: 8% 10%;
  z-index: 60;
  display: grid;
  place-items: center;
  border-radius: 34px;
  background:
    radial-gradient(circle at 50% 50%, rgba(243,197,110,.22), transparent 34%),
    linear-gradient(135deg, rgba(10,5,12,.94), rgba(35,16,36,.9));
  border: 1px solid rgba(243,197,110,.26);
  box-shadow: 0 34px 90px rgba(0,0,0,.55), inset 0 0 40px rgba(243,197,110,.06);
  opacity: 0;
  visibility: hidden;
  transform: scale(.95);
  pointer-events: none;
  overflow: hidden;
}
.chapter-interlude.is-visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition: opacity .45s var(--ease), visibility .45s var(--ease), transform .45s var(--ease);
}
.interlude-stars::before,
.interlude-stars::after {
  content: "✦ ✧ ☽ ✦ ✧ ☾";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120%;
  transform: translate(-50%, -50%) rotate(-12deg);
  color: rgba(243,197,110,.12);
  font-size: 5rem;
  letter-spacing: .32em;
  white-space: nowrap;
}
.interlude-stars::after { transform: translate(-50%, -50%) rotate(12deg); }
.interlude-copy {
  position: relative;
  z-index: 1;
  text-align: center;
  width: min(760px, 84%);
}
.interlude-copy small {
  display: block;
  margin-bottom: 12px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: 11px;
}
.interlude-copy strong {
  display: block;
  font-family: var(--font-title);
  font-size: clamp(2.1rem, 6vw, 5rem);
  line-height: .9;
  text-wrap: balance;
}
.interlude-copy em {
  display: block;
  margin-top: 12px;
  color: rgba(255,246,232,.66);
  font-family: var(--font-hand);
  font-size: clamp(1.4rem, 2.8vw, 2.4rem);
  font-style: normal;
}

.controls {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 10;
}
.control {
  min-width: 50px;
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid rgba(255,246,232,.14);
  background: rgba(255,246,232,.07);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 16px 42px rgba(0,0,0,.25);
  backdrop-filter: blur(14px);
}
.control--main {
  padding: 0 22px;
  border-color: rgba(243,197,110,.34);
  background: linear-gradient(135deg, rgba(243,197,110,.22), rgba(255,122,170,.13));
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
}

.gesture-help {
  margin: 10px 0 0;
  color: rgba(255,246,232,.48);
  font-size: 12px;
  text-align: center;
}

.footerbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px clamp(12px, 3vw, 34px) calc(12px + env(safe-area-inset-bottom));
  color: rgba(255,246,232,.48);
  font-size: 12px;
  z-index: 8;
}
.read-progress {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,246,232,.1);
}
.read-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--rose)); }
#pageLabel { min-width: 86px; text-align: right; }

.noscript {
  position: fixed;
  inset: 20px;
  z-index: 999;
  display: grid;
  place-items: center;
  text-align: center;
  background: #0b0610;
  color: #fff;
  border-radius: 20px;
}

@media (hover: hover) {
  .magnetic { transition: transform .25s var(--ease); }
  .magnetic:hover { transform: translateY(-2px); }
}

@media (max-width: 1080px) {
  :root { --book-w: min(92vw, 980px); --book-h: min(68dvh, 660px); }
  .stage { grid-template-columns: 1fr; padding-top: 4px; }
  .index-panel {
    position: fixed;
    z-index: 70;
    top: max(14px, env(safe-area-inset-top));
    left: 50%;
    width: min(92vw, 520px);
    max-height: min(86dvh, 760px);
    transform: translateX(-50%) translateY(-16px) scale(.96);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    padding: 18px;
    overflow: hidden;
  }
  .index-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0) scale(1);
    transition: opacity .28s var(--ease), transform .28s var(--ease), visibility .28s var(--ease);
  }
  .index-backdrop {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: block;
    background: rgba(0,0,0,.58);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s var(--ease), visibility .28s var(--ease);
  }
  .index-backdrop.is-open { opacity: 1; visibility: visible; }
  .index-close { display: grid; place-items: center; }
  .chapter-list { max-height: calc(min(86dvh, 760px) - 190px); padding-bottom: 8px; }
  .index-note { display: none; }
}

@media (max-width: 720px) {
  :root {
    --book-w: min(94vw, 430px);
    --book-h: min(68dvh, 610px);
  }
  body { overflow: hidden; }
  .book-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  .chapter-badge {
    min-width: 0;
    width: 100%;
    padding: 10px 14px;
  }
  .chapter-badge strong { font-size: clamp(1rem, 5vw, 1.35rem); }
  .chapter-badge small { display: none; }
  .index-open {
    width: 100%;
    min-height: 48px;
    font-size: 12px;
    background: linear-gradient(135deg, rgba(243,197,110,.28), rgba(255,122,170,.14));
    box-shadow: 0 0 0 1px rgba(243,197,110,.08), 0 16px 46px rgba(0,0,0,.3), 0 0 28px rgba(243,197,110,.12);
  }
  .stage { padding-inline: 8px; align-items: start; }
  .book-area { justify-content: center; align-content: start; padding-top: 0; }
  .book-shell { margin-top: 2px; }
  .book { transform: rotateX(6deg) rotateY(0deg) rotateZ(0deg); }
  .experience[data-book-open="true"] .book { transform: rotateX(5deg) rotateY(0deg) rotateZ(0deg); }
  .closed-book { inset: 2% 7%; }
  .cover-face { padding: 18px 18px; gap: 9px; }
  .cover-face h2 { font-size: clamp(2.15rem, 13vw, 4.5rem); }
  .cover-subtitle { font-size: clamp(1.2rem, 6vw, 1.8rem); }
  .open-book { padding: 14px 16px; font-size: 10px; max-width: 92%; }
  .book-spine, .book-fold, .page-stack--left { display: none; }
  .page-stack--right {
    left: 4%;
    right: 4%;
    width: auto;
    border-radius: 24px;
  }
  .paper-page--left {
    display: none;
  }
  .paper-page--right {
    left: 4.2%;
    right: 4.2%;
    width: auto;
    top: 4.5%;
    height: 91%;
    border-radius: 24px;
    padding: 22px 20px 18px;
    transform: translateZ(8px);
  }
  .paper-page::before { inset: 7px; }
  .page-title { font-size: clamp(1.85rem, 9.3vw, 2.95rem); }
  .page-lead { font-size: clamp(1.35rem, 7vw, 2rem); }
  .handwritten { font-size: clamp(1.2rem, 6.2vw, 1.65rem); line-height: 1.02; }
  .page-scroll { padding-right: 3px; }
  .page-foot { font-size: 9px; }
  .page-turn {
    top: 4.5%;
    left: 4.2%;
    right: 4.2%;
    width: auto;
    height: 91%;
  }
  .page-turn__front, .page-turn__back { border-radius: 24px; }
  .page-zone { width: 22%; top: 4.5%; height: 91%; }
  .controls { margin-top: 8px; }
  .control { min-height: 46px; min-width: 48px; }
  .gesture-help { display: none; }
  .footerbar { padding-top: 4px; font-size: 11px; }
  .prelude-center { width: 92vw; padding: 20px; }
  .prelude-center h1 { font-size: clamp(2rem, 12vw, 3.6rem); }
  .prelude-lower { bottom: 12dvh; }
  .memory-fragment { font-size: clamp(1rem, 6vw, 1.45rem); }
  .interlude-copy strong { font-size: clamp(2.1rem, 11vw, 3.4rem); }
  .chapter-interlude { inset: 11% 5%; border-radius: 26px; }
}

@media (max-width: 390px) {
  :root { --book-h: min(66dvh, 560px); }
  .paper-page--right { padding: 20px 17px 16px; }
  .page-title { font-size: clamp(1.65rem, 8.6vw, 2.55rem); }
  .handwritten { font-size: clamp(1.12rem, 5.9vw, 1.48rem); }
  .magic-note, .author-note, .warning-paper, .contact-card, .animal-card { padding: 12px; }
  .cover-face h2 { font-size: clamp(1.9rem, 12vw, 3.9rem); }
}

@media (max-height: 720px) and (max-width: 720px) {
  :root { --book-h: 60dvh; }
  .chapter-badge { padding: 8px 12px; }
  .index-open { min-height: 44px; }
  .footerbar { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}

@media (min-width: 1081px) and (min-height: 780px) {
  :root { --book-h: min(76dvh, 760px); }
  .stage { padding-top: 0; padding-bottom: 0; }
  .controls { margin-top: 8px; }
  .gesture-help { margin-top: 7px; }
}

.book-light--a { animation: lightPulseA 5.8s ease-in-out infinite alternate; }
.book-light--b { animation: lightPulseB 7.5s ease-in-out infinite alternate; }
@keyframes lightPulseA { to { transform: translate3d(28px, -18px, 0) scale(1.18); opacity: .95; } }
@keyframes lightPulseB { to { transform: translate3d(-22px, 16px, 0) scale(1.12); opacity: .88; } }

.experience[data-book-open="true"] .book-shell::before,
.experience[data-book-open="true"] .book-shell::after {
  content: "";
  position: absolute;
  inset: -8%;
  border-radius: 50%;
  pointer-events: none;
  opacity: .38;
  filter: blur(1px);
  transform: translateZ(-40px);
}
.experience[data-book-open="true"] .book-shell::before {
  background: conic-gradient(from 0deg, transparent, rgba(243,197,110,.16), transparent, rgba(165,131,255,.12), transparent);
  animation: slowSpin 26s linear infinite;
}
.experience[data-book-open="true"] .book-shell::after {
  inset: -4%;
  background: radial-gradient(circle, rgba(243,197,110,.18), transparent 62%);
  animation: breatheBook 4.8s ease-in-out infinite alternate;
}
@keyframes breatheBook { to { opacity: .65; transform: translateZ(-40px) scale(1.04); } }

.cover-face {
  animation: coverBreath 5.4s ease-in-out infinite alternate;
}
@keyframes coverBreath {
  to { box-shadow: inset 0 0 0 9px rgba(0,0,0,.2), inset 0 0 0 11px rgba(243,197,110,.25), inset 0 0 55px rgba(0,0,0,.5), 0 32px 84px rgba(0,0,0,.52), 0 0 42px rgba(243,197,110,.12); }
}
.cover-seal { animation: sealPulse 2.8s ease-in-out infinite alternate; }
@keyframes sealPulse { to { filter: brightness(1.12); transform: scale(1.035); } }

.paper-page {
  background:
    radial-gradient(circle at 18% 15%, rgba(255,255,255,.48), transparent 23%),
    radial-gradient(circle at 87% 82%, rgba(130, 80, 30, .2), transparent 26%),
    radial-gradient(circle at 12% 84%, rgba(106, 62, 24, .12), transparent 20%),
    linear-gradient(90deg, rgba(96, 60, 24, .13), transparent 13%, transparent 87%, rgba(96, 60, 24, .16)),
    repeating-linear-gradient(0deg, rgba(86, 54, 28, .05) 0 1px, transparent 1px 31px),
    linear-gradient(135deg, #fff3cf, #eed8a7 39%, #cfad70);
}
.paper-page::before {
  box-shadow: inset 0 0 30px rgba(92, 54, 18, .13);
}
.page-inner {
  gap: clamp(7px, 1vh, 12px);
}
.page-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 7px;
  overscroll-behavior: contain;
}
.page-scroll::-webkit-scrollbar { width: 5px; }
.page-scroll::-webkit-scrollbar-track { background: rgba(83, 49, 18, .07); border-radius: 99px; }
.page-scroll::-webkit-scrollbar-thumb { background: rgba(83, 49, 18, .28); border-radius: 99px; }

.handwritten { line-height: 1.08; }
.handwritten p { margin: 0 0 .55em; }
@media (min-width: 1081px) {
  .page-title { font-size: clamp(1.55rem, 2.35vw, 2.85rem); }
  .page-lead { font-size: clamp(1.2rem, 1.55vw, 1.85rem); }
  .handwritten { font-size: clamp(1.08rem, 1.3vw, 1.55rem); }
  .magic-note, .author-note, .warning-paper, .contact-card, .animal-card { padding: 12px 14px; margin: 9px 0; }
}

.chapter-item--special {
  border-color: rgba(243,197,110,.42);
  background:
    radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(243,197,110,.28), transparent 28%),
    linear-gradient(135deg, rgba(243,197,110,.2), rgba(165,131,255,.12));
  box-shadow: 0 14px 44px rgba(243,197,110,.1), inset 0 0 0 1px rgba(243,197,110,.1);
}
.chapter-item--special .chapter-num {
  background: linear-gradient(135deg, #fff1bd, #a67022);
  color: #2d1608;
  box-shadow: 0 0 26px rgba(243,197,110,.26);
}

.special-seven {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  margin: 10px 0 14px;
  padding: 14px;
  border-radius: 22px;
  border: 1px solid rgba(107, 62, 22, .25);
  background: radial-gradient(circle at 15% 50%, rgba(243,197,110,.32), transparent 36%), rgba(255,247,219,.58);
  box-shadow: inset 0 0 30px rgba(111, 67, 24, .08), 0 14px 30px rgba(83,49,18,.1);
}
.special-seven span {
  width: clamp(60px, 7vw, 88px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--font-cover);
  font-size: clamp(2.5rem, 5vw, 4.4rem);
  color: #2b1509;
  background: conic-gradient(from 140deg, #fff0b8, #a46b20, #f6cf75, #fff0b8);
  box-shadow: 0 0 34px rgba(243,197,110,.26), inset 0 0 18px rgba(0,0,0,.24);
  animation: sevenSeal 3.6s ease-in-out infinite alternate;
}
@keyframes sevenSeal { to { transform: rotate(4deg) scale(1.04); filter: brightness(1.1); } }
.seven-list {
  list-style: none;
  padding: 0 !important;
  margin: 0 0 12px !important;
  counter-reset: seven;
}
.seven-list li {
  counter-increment: seven;
  position: relative;
  padding-left: 34px;
  margin: .38em 0;
}
.seven-list li::before {
  content: counter(seven);
  position: absolute;
  left: 0;
  top: .08em;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(111,67,24,.13);
  font-family: var(--font-magic);
  font-size: .8em;
}
.page-inner--special .page-title {
  text-shadow: 0 0 18px rgba(243,197,110,.2);
}

.chapter-interlude {
  background:
    radial-gradient(circle at 50% 50%, rgba(243,197,110,.28), transparent 34%),
    radial-gradient(circle at 22% 22%, rgba(165,131,255,.18), transparent 30%),
    linear-gradient(135deg, rgba(10,5,12,.96), rgba(35,16,36,.92));
}
.chapter-interlude.is-visible .interlude-stars::before { animation: slowSpin 8s linear infinite; }
.chapter-interlude.is-visible .interlude-stars::after { animation: slowSpin 10s linear infinite reverse; }
.interlude-copy strong { text-shadow: 0 20px 70px rgba(0,0,0,.68), 0 0 28px rgba(243,197,110,.14); }

@media (max-width: 720px) {
  .index-panel {
    top: 50%;
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 24px);
    padding: 14px;
    border-radius: 24px;
    transform: translateX(-50%) translateY(calc(-50% - 12px)) scale(.96);
  }
  .index-panel.is-open {
    transform: translateX(-50%) translateY(-50%) scale(1);
  }
  .index-head { margin-bottom: 8px; }
  .index-intro { font-size: 12px; line-height: 1.35; margin-bottom: 10px; }
  .chapter-list { max-height: calc(100dvh - 190px); gap: 8px; }
  .chapter-item { padding: 10px; border-radius: 18px; }
  .chapter-num { width: 42px; height: 42px; }
  .chapter-text b { font-size: 13px; }
  .chapter-text small { font-size: 11px; }
  .special-seven { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .special-seven span { width: 74px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
  #nebula { display: none; }
}


/* BUG SOLVED: Nuove regole pulite e unificate per .floating-note e .note-close per evitare sovrapposizioni e troncamento dei testi */
.floating-note {
  position: fixed;
  z-index: 10000; /* Valore altissimo per forzare la visibilità sopra il canvas di Three.js e sopra il libro */
  left: 50%;
  top: 50%;
  bottom: auto !important;
  width: min(580px, calc(100vw - 28px));
  max-height: min(72dvh, 480px);
  overflow-y: auto;
  transform: translateX(-50%) translateY(calc(-50% + 18px)) scale(.96);
  padding: 24px 52px 24px 24px;
  border-radius: 26px;
  color: #32190f;
  background:
    radial-gradient(circle at 12% 0%, rgba(255,255,255,.58), transparent 34%),
    radial-gradient(circle at 88% 100%, rgba(147,83,24,.13), transparent 34%),
    linear-gradient(135deg, rgba(255, 246, 218, .985), rgba(226, 194, 128, .97));
  border: 1px solid rgba(102, 61, 20, .34);
  box-shadow: 0 34px 110px rgba(0,0,0,.68), 0 0 58px rgba(243,197,110,.16), inset 0 0 0 1px rgba(255,255,255,.32);
  font-family: var(--font-hand);
  font-size: clamp(1.25rem, 2.1vw, 1.85rem);
  line-height: 1.12;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}
.floating-note.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-50%) scale(1);
  transition: opacity .35s var(--ease), transform .42s var(--ease);
}
.floating-note span {
  display: block;
  max-width: 100%;
  padding-right: 2px;
}
.note-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(74, 41, 12, .22);
  border-radius: 50%;
  background: rgba(255,255,255,.34);
  color: #32190f;
  cursor: pointer;
  font-family: Inter, sans-serif;
  font-size: 21px;
  line-height: 1;
}
.note-close:active { transform: scale(.94); }

.page-inner {
  position: relative;
}
.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 29px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transform: translateX(-50%) translateY(8px);
  padding: 8px 12px;
  border-radius: 999px;
  color: rgba(55, 28, 13, .88);
  background: rgba(255, 239, 190, .82);
  border: 1px solid rgba(94, 54, 18, .22);
  box-shadow: 0 10px 25px rgba(88, 48, 16, .12), 0 0 18px rgba(243,197,110,.12);
  font-family: var(--font-magic);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .28s var(--ease), visibility .28s var(--ease), transform .28s var(--ease);
}
.scroll-cue b {
  font-family: Inter, sans-serif;
  font-size: 14px;
  animation: scrollCueArrow 1.15s ease-in-out infinite;
}
@keyframes scrollCueArrow {
  0%, 100% { transform: translateY(-2px); opacity: .55; }
  50% { transform: translateY(3px); opacity: 1; }
}
.page-inner.is-scrollable:not(.is-at-bottom) .scroll-cue {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.page-inner.is-scrollable .page-scroll {
  padding-bottom: 42px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 34px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 34px), transparent 100%);
}
.page-scroll {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 1081px) {
  :root { --book-h: min(80dvh, 820px); }
  .stage { padding-top: 4px; padding-bottom: 2px; }
  .paper-page { top: 4.8%; height: 90.5%; }
  .page-stack { top: 4.7%; height: 90.5%; }
  .book-spine, .book-fold { top: 4.9%; height: 90.2%; }
}

@media (max-width: 720px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }
  .experience {
    min-height: 100dvh;
    height: auto;
    grid-template-rows: auto auto auto;
  }
  .book-header {
    gap: 7px;
    padding: calc(7px + env(safe-area-inset-top)) 10px 5px;
  }
  .chapter-badge {
    padding: 8px 12px;
  }
  .chapter-badge span {
    font-size: 9px;
    margin-bottom: 1px;
  }
  .chapter-badge strong {
    font-size: clamp(1rem, 4.8vw, 1.28rem);
  }
  .index-open {
    min-height: 46px;
  }
  .stage {
    min-height: 0;
    height: auto;
    padding-inline: 7px;
  }
  .book-area {
    height: auto;
    min-height: 0;
    align-content: start;
  }
  :root {
    --book-w: min(97vw, 480px);
    --book-h: clamp(610px, 78dvh, 780px);
  }
  .book-shell {
    margin-top: 2px;
  }
  .paper-page--right {
    top: 3.2%;
    height: 93.2%;
    left: 3.2%;
    right: 3.2%;
    padding: 24px 22px 22px;
    border-radius: 26px;
  }
  .page-turn {
    top: 3.2%;
    left: 3.2%;
    right: 3.2%;
    height: 93.2%;
  }
  .page-zone {
    top: 3.2%;
    height: 93.2%;
  }
  .page-title {
    font-size: clamp(1.75rem, 8.6vw, 2.9rem);
  }
  .page-lead {
    font-size: clamp(1.28rem, 6.2vw, 2rem);
    line-height: 1.02;
  }
  .handwritten {
    font-size: clamp(1.18rem, 5.75vw, 1.7rem);
    line-height: 1.08;
  }
  .handwritten p { margin-bottom: .58em; }
  .page-scroll::-webkit-scrollbar { width: 7px; }
  .page-scroll::-webkit-scrollbar-thumb {
    background: rgba(74, 41, 12, .42);
    border-radius: 999px;
  }
  .page-scroll::-webkit-scrollbar-track {
    background: rgba(74, 41, 12, .08);
    border-radius: 999px;
  }
  .scroll-cue {
    bottom: 30px;
    font-size: 9px;
    padding: 8px 11px;
    background: rgba(255, 240, 196, .92);
  }
  .floating-note {
    width: calc(100vw - 22px);
    max-height: calc(100dvh - 92px);
    padding: 22px 48px 22px 20px;
    border-radius: 24px;
    font-size: clamp(1.3rem, 6.2vw, 1.78rem);
    line-height: 1.13;
  }
  .note-close {
    width: 36px;
    height: 36px;
    top: 9px;
    right: 9px;
  }
  .controls {
    margin-top: 7px;
  }
  .control {
    min-height: 44px;
  }
  .footerbar {
    padding-top: 4px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 390px) {
  :root { --book-h: clamp(570px, 76dvh, 720px); }
  .paper-page--right { padding: 22px 18px 20px; }
  .handwritten { font-size: clamp(1.12rem, 5.55vw, 1.55rem); }
  .page-title { font-size: clamp(1.58rem, 8vw, 2.45rem); }
}

@media (max-height: 720px) and (max-width: 720px) {
  :root { --book-h: clamp(540px, 76dvh, 660px); }
  .book-header { padding-top: calc(6px + env(safe-area-inset-top)); }
  .chapter-badge { padding: 7px 11px; }
  .index-open { min-height: 42px; }
  .controls { margin-top: 5px; }
  .footerbar { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}

/* Rifiniture v10: pagina più stabile e appunti sempre leggibili */
.floating-note {
  max-width: calc(100vw - 24px);
  overflow-x: hidden;
}
.floating-note span {
  white-space: normal;
  overflow-wrap: anywhere;
}
.page-scroll {
  min-height: 80px;
}
@media (min-width: 1081px) {
  :root { --book-h: min(84dvh, 860px); }
}
@media (max-width: 720px) {
  .scroll-cue span::after { content: " se il testo continua"; }
  .page-scroll { min-height: 120px; }
}
