.cine { position:fixed; inset:0; z-index:10000; overflow:hidden; isolation:isolate; }
.cine.is-revealing { opacity:0; transition:opacity .48s ease; pointer-events:none; }
.cine-opening.is-covered,.cine-exit.is-covered { background:#fff; }
.cine-paper { position:absolute; inset:0; background:#fff; }
.cine-title {
  position:absolute;
  left:50%; top:50%; translate:-50% -50%;
  margin:0;
  text-align:center;
  font:900 clamp(32px,7.2vw,94px)/1.27 FusionPixel,"Cubic 11",monospace !important;
  letter-spacing:.055em;
  white-space:nowrap;
  color:var(--letter,#54311f);
  text-shadow:2px 0 currentColor,-2px 0 currentColor,0 -2px currentColor,0 2px currentColor,
    4px 5px var(--letter-shadow,#edb45b);
}
.cine-title small {
  display:block; font-size:.2em; letter-spacing:.33em;
  margin-bottom:.55em; text-shadow:1px 1px currentColor;
}
.cine img { image-rendering:pixelated; }

/* Library: books fall toward the top-down camera, then one cover opens. */
[data-chapter="ch1"] { --letter:#ffe8aa; --letter-shadow:#3e2926; }
.cine-books { position:absolute; inset:0; animation:cine-book-zoom 2.6s both; }
.cine-book,.cine-cover-book {
  position:absolute;
  background:repeating-linear-gradient(90deg,transparent 0 86%,#fff3 86% 89%,transparent 89% 100%),var(--cover,#744c44);
  border:3px solid #392a29;
  box-shadow:inset 4px 0 #38262980,inset -2px 0 #fee3a87a,4px 6px #e6c89c,6px 8px #503c35,10px 14px #6d514148;
  border-radius:2px !important;
}
.cine-book { left:var(--x); top:var(--y); width:clamp(44px,10.2vw,150px); aspect-ratio:.79; animation:cine-book-drop .54s calc(var(--i)*15ms) both; }
.cine-book:nth-child(5n + 1) { --cover:#436b64; }
.cine-book:nth-child(5n + 2) { --cover:#b66a4b; }
.cine-book:nth-child(5n + 3) { --cover:#665783; }
.cine-book:nth-child(5n + 4) { --cover:#a5884b; }
.cine-book::before,.cine-book-flap::before {
  content:''; position:absolute; inset:13% 16%; border:2px solid #e8be7289;
  background:linear-gradient(transparent 20%,#f5d78a9f 20% 22%,transparent 22% 77%,#f5d78a9f 77% 79%,transparent 79%);
}
.cine-cover-book {
  left:50%; top:50%; width:min(71vw,840px); height:min(64vh,520px);
  perspective:980px; background:#f5e2ae;
  animation:cine-book-closeup 2.6s both;
}
.cine-pages {
  position:absolute; inset:0;
  background:repeating-linear-gradient(0deg,transparent 0 29px,#e4c48172 30px 31px),#fff3ce;
}
.cine-book-flap {
  position:absolute; inset:0; transform-origin:left center;
  background:linear-gradient(90deg,#42302a 0 7%,#664838 7% 9%,#506959 9%);
  animation:cine-book-flip 4.26s both;
}
.cine-cover-book .cine-title { z-index:1; animation:cine-book-title 4.26s both; }
@keyframes cine-book-drop { from { opacity:0; transform:translate(-42%,-145vh) rotate(-55deg) scale(1.9); } 69% { opacity:1; transform:translate(-49%,4%) rotate(var(--angle)) scale(1.04); } to { transform:translate(-50%,-50%) rotate(var(--angle)); } }
@keyframes cine-book-zoom { 0%,57% { transform:scale(1); } 84%,100% { transform:scale(2.8); } }
@keyframes cine-book-closeup { 0%,48% { opacity:0; transform:translate(-50%,-50%) scale(.12) rotate(-14deg); } 58% { opacity:1; } 80%,100% { opacity:1; transform:translate(-50%,-50%) scale(1); } }
@keyframes cine-book-title { 0%,36% { opacity:0; } 43%,85% { opacity:1; } 94%,100% { opacity:0; } }
@keyframes cine-book-flip { 0%,85% { transform:none; } 99%,100% { transform:rotateY(-147deg); } }

/* Café: the slice leaves the map, then the camera tracks its hops. */
[data-chapter="ch2"] { --letter:#9d3157; --letter-shadow:#f3bb9c; }
.cine-pin { position:absolute; left:var(--pin-x,47%); top:var(--pin-y,34%); z-index:2; animation:cine-pin-hop .78s both; }
.cine-cake { width:clamp(48px,12vw,163px); height:auto; filter:drop-shadow(4px 5px #a6785b5c); }
.cine-pin .cine-cake { width:clamp(40px,6vw,89px); }
[data-chapter="ch2"] > .cine-paper { animation:cine-white-in .25s .65s both; }
.cine-follow { position:absolute; inset:0; animation:cine-follow-track 1.32s .72s both; }
.cine-follow .cine-cake { position:absolute; left:50%; bottom:27%; animation:cine-cake-hop .38s steps(8,end) .79s 3 both; }
.cine-speed-lines { position:absolute; inset:40% -40% -55%; background:repeating-linear-gradient(90deg,transparent 0 19%,#f9dbdf 19% 19.4%,transparent 19.4% 27%); transform:perspective(260px) rotateX(45deg); opacity:.6; }
.cine-pastry-title { position:absolute; inset:0; animation:cine-pastry-pan .64s 1.84s both; }
.cine-pastry-title .cine-cake { position:absolute; left:65%; top:calc(50% - clamp(102px,17vh,174px)); width:clamp(47px,8.5vw,113px); transform:rotate(-12deg); }
.no-map .cine-pin { display:none; }
.no-map[data-chapter="ch2"] { background:#fff; }
@keyframes cine-pin-hop {
  0% { transform:translate(calc(0px - var(--pin-x,50vw) - 110px),-9vh) rotate(-16deg) scale(1.22); }
  48% { transform:translate(-77%,-240%) rotate(9deg); }
  90%,100% { transform:translate(-36%,-54%) scale(.18); opacity:.1; }
}
@keyframes cine-white-in { from { opacity:0; } to { opacity:1; } }
@keyframes cine-follow-track { 0% { opacity:0; transform:translate(14%,20%) scale(1.65); } 18% { opacity:1; } 79% { opacity:1; } 100% { opacity:0; transform:translate(-13%,-15%) scale(.55); } }
@keyframes cine-cake-hop { 0%,100% { transform:translate(-50%,0) scale(1.08,.88); } 46% { transform:translate(-50%,-12vh) scale(.94,1.07) rotate(5deg); } }
@keyframes cine-pastry-pan { from { opacity:0; transform:translate(14%,24%) scale(1.7); } to { opacity:1; transform:none; } }

/* Mountain: green leaves stay over the map until the foreground leaf fills the lens. */
[data-chapter="ch3"] { --letter:#f8f6c8; --letter-shadow:#2e6141; }
.cine-leaf {
  clip-path:polygon(48% 0,62% 13%,71% 10%,73% 31%,88% 27%,86% 45%,100% 42%,92% 67%,100% 75%,69% 87%,55% 83%,48% 100%,43% 97%,47% 84%,27% 89%,5% 72%,12% 62%,1% 36%,19% 44%,21% 26%,32% 35%,35% 14%,43% 21%);
  background:linear-gradient(35deg,transparent 46%,#d0db8e 46% 47.3%,transparent 47.3%),linear-gradient(28deg,#80a861 54%,#587d47 54%);
}
.cine-fall .cine-leaf { position:absolute; left:var(--x); top:-10%; width:clamp(16px,4.2vw,61px); aspect-ratio:1.17; animation:cine-green-fall 1.46s calc(var(--i)*-23ms) ease-in both; }
.cine-big-leaf { position:absolute; inset:0; animation:cine-leaf-camera 1.72s both; }
.cine-big-leaf > i { position:absolute; inset:-48%; }
.cine-big-leaf h1 { animation:cine-leaf-letter .42s 1.07s both; }
.no-map[data-chapter="ch3"] { background:#bcceb1; }
@keyframes cine-green-fall { from { transform:translate(-18vw,-15vh) rotate(var(--angle)); } to { transform:translate(25vw,115vh) rotate(280deg); } }
@keyframes cine-leaf-camera { 0%,27% { transform:translate(38vw,-65vh) rotate(36deg) scale(.09); opacity:0; } 35% {opacity:1;} 74%,100% { transform:none; } }
@keyframes cine-leaf-letter { from { opacity:0; } to { opacity:1; } }

/* Train crossover and an independent title that sits over live gameplay. */
[data-chapter="ch4"] { --letter:#ffdf94; --letter-shadow:#7b3c39; }
[data-chapter="ch4"].cine-opening .cine-paper { background:linear-gradient(165deg,#fac58f,#fce3bc 64%,#bf9aa0); animation:cine-white-in .52s .26s both; }
.no-map[data-chapter="ch4"] { background:#efd3a9; }
.cine-train { position:absolute; z-index:2; left:-35vw; top:7%; width:clamp(180px,37vw,580px); height:auto; animation:cine-train-right 1.22s linear both; }
.cine-travel-title { z-index:8; pointer-events:none; animation:cine-travel-fade 4.4s both; }
.cine-travel-title .cine-title { top:13%; font-size:clamp(26px,5.1vw,71px) !important; }
@keyframes cine-train-right { to { transform:translate(136vw,19vh) scale(1.47); } }
@keyframes cine-travel-fade { 0%,100% { opacity:0; } 11%,84% { opacity:1; } }

/* Research: slate on, clap, then the first take. */
[data-chapter="ch5"] { --letter:#fff0bd; --letter-shadow:#866ca5; }
[data-chapter="ch5"].cine-opening .cine-paper { background:radial-gradient(ellipse at 50% 44%,#735a86,#231c32 68%); }
.cine-board { position:absolute; width:min(77vw,800px); height:min(48vh,420px); left:50%; top:51%; transform:translate(-50%,-50%); animation:cine-slate-in .48s steps(12,end) both; }
.cine-clap { position:absolute; z-index:1; inset:0 0 auto; height:18%; border:5px solid #1f1828; background:repeating-linear-gradient(135deg,#efe2c2 0 40px,#242033 40px 81px); transform-origin:4% center; animation:cine-clap-down .62s both; }
.cine-board-body { position:absolute; inset:15% 0 0; background:#30293f; box-shadow:inset 0 0 0 5px #aa8cb2,8px 12px #1b152597; border:5px solid #1c182a; }
.cine-board-body p { position:absolute; inset:auto 7% 7%; display:flex; justify-content:space-between; padding-top:2%; border-top:2px solid #bda7c4; margin:0; color:#f2ddb0; font-size:clamp(10px,2vw,22px); }
.cine-board-body .cine-title { font-size:clamp(26px,6.5vw,88px) !important; }
[data-chapter="ch5"].is-covered .cine-board { visibility:hidden; }
.cine-loading {
  position:absolute;
  inset:50% 0 auto;
  margin:0;
  text-align:center;
  color:#fff0bd;
  font-size:clamp(15px,2vw,24px);
  visibility:hidden;
}
[data-chapter="ch5"].is-covered .cine-loading { visibility:visible; transition:visibility 0s .3s; }
[data-chapter="ch5"].is-revealing .cine-loading { visibility:hidden; transition:none; }
@keyframes cine-slate-in { from { opacity:0; transform:translate(-50%,-35%) rotate(-5deg) scale(.88); } }
@keyframes cine-clap-down { 0%,63% { transform:rotate(-15deg); } 85% { transform:rotate(2deg); } 100% { transform:none; } }

/* Finale: shooting stars fall on the map before the warm dining room. */
[data-chapter="ch6"] { --letter:#9b4b54; --letter-shadow:#e6ac88; }
.cine-meteors { position:absolute; inset:0; background:#231f505c; }
.cine-meteor { position:absolute; left:var(--x); top:var(--y); width:clamp(28px,11vw,159px); height:4px; background:linear-gradient(90deg,#ffe49f00,#fff2bc 86%,#fff); box-shadow:0 1px #c2a9ff94; animation:cine-meteor-go 1.19s calc(var(--i)*11ms) both; }
[data-chapter="ch6"].cine-opening .cine-paper { background:radial-gradient(ellipse at 50% 50%,#fff7e9,#f2c7ae); animation:cine-white-in .32s .96s both; }
.cine-feast-title { position:absolute; inset:0; animation:cine-white-in .23s 1.13s both; }
.no-map[data-chapter="ch6"] { background:#423751; }
[data-chapter="beach"].cine-opening .cine-paper { background:linear-gradient(165deg,#b5b0db,#ffccad); }
@font-face {
  font-family: Scroll Lettering;
  src: url(fonts/birthday-lettering.ttf) format('truetype');
  font-display:swap;
}
.cine-ink-paper {
  position:absolute; inset:0; background:repeating-linear-gradient(8deg,#9a74450c 0 1px,transparent 1px 5px),radial-gradient(ellipse,#fcf7e7,#e9d8b9);
  animation:cine-white-in .7s .14s both;
}
.cine-opening[data-chapter="beach"] { background:#fff; }
.cine-ink-wash {
  position:absolute; inset:19% 7%;
  background:radial-gradient(ellipse at 12% 66%,#35272542,transparent 46%),radial-gradient(ellipse at 87% 48%,#52412f50,transparent 45%);
  filter:blur(16px); animation:cine-ink-spread 1.8s .32s both;
}
.cine-ink-name {position:absolute; inset:0; animation:cine-ink-spread .92s .43s both;}
.cine-ink-name .cine-title {
  font:700 clamp(48px,14vw,165px)/1.12 Scroll Lettering,KaiTi,serif !important;
  color:#211d19; letter-spacing:.19em; text-shadow:2px 2px #604b35;
}
.cine-ink-name .cine-title small { font:400 .12em/1.45 FusionPixel,monospace; letter-spacing:.48em; }
.cine-ink-name > span {
  position:absolute; left:calc(50% + min(25vw,290px)); top:64%; padding:4px 5px;
  border:2px solid #a33831; color:#a33831; font:700 clamp(16px,2.5vw,29px) KaiTi,serif!important;
  transform:rotate(6deg);
}
@keyframes cine-ink-spread { from { opacity:0; transform:scale(.86); } to { opacity:1; transform:scale(1); } }
@keyframes cine-meteor-go { 0% { opacity:0; transform:translate(-15vw,-39vh) rotate(49deg); } 24%,65% { opacity:1; } 100% { opacity:0; transform:translate(29vw,27vh) rotate(49deg); } }

.cine-exit > .cine-paper { opacity:0; animation:cine-white-in .43s both; }
.cine-door-closeup { position:absolute; inset:0; animation:cine-door-zoom .55s ease-in both; background:url(cafe-afternoon-live.webp) center / var(--scene-w) var(--scene-h) no-repeat; transform-origin:var(--door-x) var(--door-y); }
.cine-door-closeup::before,.cine-door-closeup i {
  position:absolute; left:var(--panel-x); top:var(--panel-y);
  width:calc(var(--scene-w) * .078); height:calc(var(--scene-h) * .279);
}
.cine-door-closeup::before { content:''; background:#fff8d6; box-shadow:0 0 14px #ffe7ad; }
.cine-door-closeup i {
  background:url(cafe-afternoon-live.webp) calc(var(--scene-w) * -.727) calc(var(--scene-h) * -.072) / var(--scene-w) var(--scene-h) no-repeat;
  transform-origin:left center; animation:cine-door-open .43s .25s both;
  box-shadow:2px 0 #6a472d;
}
.cine-exit[data-chapter="ch2"] > .cine-paper { animation-delay:.42s; }
@keyframes cine-door-zoom { to { transform:scale(4.6); } }
@keyframes cine-door-open { to { transform:perspective(260px) rotateY(-89deg); } }
.cine-snow { position:absolute; inset:0; }
.cine-flake { position:absolute; left:var(--x); top:var(--y); width:clamp(6px,1.7vw,24px); height:clamp(5px,1.2vw,16px); background:#fff; box-shadow:0 0 0 3px #d9eafa9e; animation:cine-snow-spray .83s calc(var(--i)*3ms) both; }
.cine-exit[data-chapter="ch3"] > .cine-paper { animation-delay:.5s; }
@keyframes cine-snow-spray { from { opacity:0; transform:translate(35vw,65vh) rotate(var(--angle)) scale(.38); } 24% { opacity:1; } to { transform:translate(-23vw,-35vh) rotate(150deg) scale(7.4); } }
.cine-stamps { position:absolute; inset:0; display:grid; grid-template:repeat(7,1fr) / repeat(9,1fr); }
.cine-stamps i { display:grid; place-items:center; margin:-3px; text-align:center; color:#a42e28; background:#fff0d7; border:clamp(2px,.39vw,6px) double #a42e28; font:900 clamp(9px,2.0vw,36px)/1 FusionPixel,monospace; text-shadow:1px 1px currentColor; animation:cine-stamp-hit .22s calc(var(--i)*12ms) both; }
.cine-stamps i:nth-child(3n) { color:#bc4b3f; }
.cine-exit[data-chapter="ch5"].is-covered { background:#f4daba; }
@keyframes cine-stamp-hit { from { opacity:0; transform:rotate(var(--angle)) scale(2.1); } 60% { opacity:1; transform:rotate(var(--angle)) scale(1.1); } to { opacity:1; transform:rotate(var(--angle)); } }
.cine.cine-reduced { background:#fff6e9; }
.cine-reduced * { animation-duration:.12s !important; animation-delay:0s !important; animation-iteration-count:1 !important; }
.cine-reduced.is-revealing { transition-duration:.18s; }
.cine-reduced :is(.cine-book,.cine-green-fall,.cine-leaf,.cine-meteor,.cine-flake,.cine-door-closeup,.cine-speed-lines) { display:none; }
.cine-reduced .cine-cover-book .cine-title { animation:none !important; color:#475b48; }
