/* Local entrance prototype. Existing illustrations retain their proportions. */
body.jp-forest-ready::before{background-image:url("https://munky.munkystudio.games/media/assets/wheel-jungle-cartoon-v114-w1536-v771.webp")!important;background-position:center!important;background-size:cover!important}
body.jp-forest-running{overflow:hidden!important}
.jp-forest-entry{position:fixed;inset:0;z-index:100000;background:#010605;overflow:hidden;isolation:isolate;--travel:0;--light:0;--reveal:0;--near:1;--shade:.98;--arrival:0;--camera:.22}
.jp-forest-entry.jp-forest-leaving{opacity:0;transition:opacity 1.2s ease;pointer-events:none}
.jp-forest-background{position:absolute;inset:-5%;background:url("https://munky.munkystudio.games/media/assets/wheel-jungle-cartoon-v114-w1536-v771.webp") center/cover no-repeat;transform:scale(calc(1 + var(--travel)*.18));filter:brightness(.72);will-change:transform}
.jp-forest-aura{position:absolute;inset:0;opacity:var(--light);background:radial-gradient(ellipse at 50% 53%,#c6ed6335,transparent 50%),radial-gradient(ellipse at 25% 65%,#04b38c21,transparent 46%);mix-blend-mode:screen;pointer-events:none}
.jp-forest-rack{position:absolute;top:29%;left:12%;width:76%;height:48%;display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:2.5%;transform:translateY(calc((1 - var(--travel))*-12%)) scale(var(--camera));transform-origin:50% 42%;opacity:var(--reveal);will-change:transform,opacity}
.jp-forest-liana{position:absolute;left:-5%;top:0;width:110%;height:auto;z-index:2;pointer-events:none}
.jp-forest-pack{position:relative;min-width:0;align-self:start;margin-top:20%;padding-top:22%;transform-origin:50% 0;animation:jp-forest-sway 6s ease-in-out infinite;animation-delay:calc(var(--i)*-.85s)}
.jp-forest-pack::before{content:'';position:absolute;top:0;left:49%;width:2px;height:22%;background:linear-gradient(90deg,#486d25,#9d9855,#2e491c)}
.jp-forest-pack img{display:block;width:100%;height:auto;max-height:38vh;object-fit:contain;animation:jp-forest-pulse 3.8s ease-in-out infinite;animation-delay:calc(var(--i)*-.6s)}
.jp-forest-pack::after{content:'';position:absolute;inset:8% -50% -12%;z-index:-1;background:radial-gradient(ellipse,var(--glow),transparent 65%);opacity:calc(var(--light)*.45)}
.jp-forest-frond{position:absolute;bottom:-24%;width:43%;height:115%;object-fit:contain;pointer-events:none;filter:brightness(.28);opacity:var(--near);will-change:transform,opacity}
.jp-forest-frond.left{left:-13%;transform:translateX(calc(var(--travel)*-64%)) scale(calc(1 + var(--travel)*.8)) rotate(16deg)}
.jp-forest-frond.right{right:-13%;transform:translateX(calc(var(--travel)*64%)) scaleX(-1) scale(calc(1 + var(--travel)*.8)) rotate(16deg)}
.jp-forest-frond.front{width:58%;bottom:-48%;filter:brightness(.2)}
.jp-forest-frond.front.left{left:-24%;transform:translateX(calc(var(--travel)*-110%)) scale(calc(1 + var(--travel)*1.6)) rotate(35deg)}
.jp-forest-frond.front.right{right:-24%;transform:translateX(calc(var(--travel)*110%)) scaleX(-1) scale(calc(1 + var(--travel)*1.6)) rotate(35deg)}
.jp-forest-vignette{position:absolute;inset:0;background:radial-gradient(ellipse at 50% 49%,transparent 16%,#0007 76%,#000c);pointer-events:none}
.jp-forest-night{position:absolute;inset:0;background:#000;opacity:var(--shade);pointer-events:none}
.jp-fireflies{position:absolute;inset:0;pointer-events:none;overflow:hidden;opacity:var(--light,1)}
.jp-firefly{position:absolute;left:var(--x);top:var(--y);width:var(--size);height:var(--size);border-radius:50%;background:#edffbd;box-shadow:0 0 7px 2px #b9ef6a,0 0 22px 4px #9de65455;animation:jp-firefly-drift var(--duration) ease-in-out infinite alternate,jp-firefly-blink 3.1s ease-in-out infinite;animation-delay:var(--delay)}
.jp-forest-skip,.jp-forest-replay{font:600 13px/1.3 system-ui,sans-serif;color:#f3edc8;background:#092720d9;border:1px solid #ad985a99;border-radius:20px;padding:10px 18px;cursor:pointer}
.jp-forest-skip{position:absolute;right:24px;bottom:24px;z-index:5}
.jp-forest-replay{margin:8px 0 16px;display:block}
body.jp-forest-ready #pack-list .pack-art>img{filter:drop-shadow(0 0 8px color-mix(in srgb,var(--a) 50%,transparent)) drop-shadow(0 0 20px color-mix(in srgb,var(--a) 22%,transparent))}
.jp-forest-ambient{position:fixed;inset:0;z-index:0;opacity:.5;pointer-events:none}
@keyframes jp-forest-sway{0%,100%{transform:rotate(-1.5deg)}50%{transform:rotate(1.5deg)}}
@keyframes jp-forest-pulse{0%,100%{opacity:.78}50%{opacity:1}}
@keyframes jp-firefly-drift{from{transform:translate(-12px,15px)}to{transform:translate(25px,-28px)}}
@keyframes jp-firefly-blink{0%,100%{opacity:.12}45%,60%{opacity:1}}
@media(max-width:650px){.jp-forest-background{background-image:url("https://munky.munkystudio.games/media/assets/wheel-jungle-cartoon-mobile-v114-w1024-v771.webp")}.jp-forest-rack{left:9%;width:82%;top:25%;height:58%;grid-template-columns:repeat(3,minmax(0,1fr));gap:5% 10%;align-content:center}.jp-forest-pack{margin:0;padding-top:18%}.jp-forest-pack img{max-height:21vh}.jp-forest-liana{top:2%}.jp-forest-frond{width:75%;height:110%;bottom:-20%}.jp-forest-frond.left{left:-32%}.jp-forest-frond.right{right:-32%}.jp-forest-skip{bottom:18px;right:18px}body.jp-forest-ready::before{background-image:url("https://munky.munkystudio.games/media/assets/wheel-jungle-cartoon-mobile-v114-w1024-v771.webp")!important}}
@media(prefers-reduced-motion:reduce){.jp-forest-pack,.jp-forest-pack img,.jp-firefly{animation:none}.jp-forest-background,.jp-forest-frond,.jp-forest-rack{will-change:auto}}

.jp-forest-liana-second{display:none}
@media(max-width:650px){.jp-forest-liana-second{display:block;top:52%}}

@media(max-width:650px){.jp-forest-rack{grid-template-rows:repeat(2,minmax(0,1fr));align-content:start}.jp-forest-pack{padding-top:18%}.jp-forest-liana{top:0}.jp-forest-liana-second{top:52.5%}}

/* Packs fly freely during the approach, and settle only at arrival. */
.jp-forest-pack{animation:none;transform:translate(var(--fly-x,0px),var(--fly-y,0px)) rotate(var(--fly-turn,0deg)) scale(var(--fly-scale,1));will-change:transform}
.jp-forest-liana,.jp-forest-pack::before{opacity:var(--settle,0)}

/* No pack ties in the cinematic. Background monkeys are a separate distant plane. */
.jp-forest-entry .jp-forest-pack::before{content:none}
.jp-forest-monkeys{position:absolute;inset:0;overflow:hidden;pointer-events:none;opacity:.85;transform:scale(calc(.94 + var(--travel)*.08))}
.jp-forest-monkey{position:absolute;display:block;width:clamp(38px,6vw,110px);aspect-ratio:1;will-change:transform}
.jp-monkey-sprite{display:block;width:100%;height:100%;background:url("https://munky.munkystudio.games/media/assets/jp-monkey-silhouettes-v538-w1774-v771.webp") 0 0/400% 200% no-repeat;animation:jp-monkey-frames .56s steps(4) infinite;animation-delay:var(--monkey-delay)}
.jp-forest-monkey.running{top:calc(58% + var(--monkey-i)*5.5%);left:-25%;width:clamp(65px,calc(7vw + var(--monkey-i)*2.5vw),260px);opacity:calc(.42 + var(--monkey-i)*.16);animation:jp-monkey-run calc(12s - var(--monkey-i)*1.7s) linear infinite;animation-delay:var(--monkey-delay)}
.jp-forest-monkey.running:nth-child(even){animation-direction:reverse}
.jp-forest-monkey.running:nth-child(even) .jp-monkey-sprite{scale:-1 1}
.jp-forest-monkey.running:first-child{filter:blur(.6px)}
.jp-forest-monkey.swinging{--body-size:clamp(70px,calc(6vw + (var(--monkey-i) - 4)*2.5vw),200px);top:-20%;left:calc(29% + (var(--monkey-i) - 4)*19%);width:var(--body-size);height:calc(67% + (var(--monkey-i) - 4)*7%);aspect-ratio:auto;transform-origin:56% 0;opacity:calc(.5 + (var(--monkey-i) - 4)*.18);animation:jp-monkey-canopy calc(6.8s - (var(--monkey-i) - 4)*.7s) ease-in-out infinite;animation-delay:var(--monkey-delay)}
.jp-forest-monkey.swinging::before{content:'';position:absolute;left:56%;top:0;bottom:var(--body-size);width:3px;background:#071c12;opacity:.95;border-radius:50%}
.jp-forest-monkey.swinging .jp-monkey-sprite{position:absolute;bottom:0;left:0;height:var(--body-size);background-position:0 100%;animation:none}
@keyframes jp-monkey-frames{from{background-position-x:0}to{background-position-x:133.333333%}}
@keyframes jp-monkey-run{from{transform:translateX(-8vw)}to{transform:translateX(150vw)}}
/* A fixed grip and one rigid vine: no arbitrary sprite-pose changes in the air. */
@keyframes jp-monkey-canopy{0%,100%{transform:rotate(-67deg)}50%{transform:rotate(67deg)}}
@media(max-width:650px){.jp-forest-monkey.running{top:calc(64% + var(--monkey-i)*5%);width:calc(64px + var(--monkey-i)*16px)}.jp-forest-monkey.swinging{--body-size:calc(58px + (var(--monkey-i) - 4)*19px);top:-13%;height:calc(41% + (var(--monkey-i) - 4)*7%)}}
@media(prefers-reduced-motion:reduce){.jp-forest-monkey,.jp-monkey-sprite{animation:none;will-change:auto}}


/* Keep animated surfaces stable: static colour filters, gradient light pools,
   and one visible set of packs during the intro-to-catalogue handoff. */
.jp-forest-running #pack-list{visibility:hidden}
body.jp-forest-ready:not(.jp-forest-running) #pack-list{animation:jp-catalogue-arrive .35s ease-out both}
@keyframes jp-catalogue-arrive{from{opacity:0}to{opacity:1}}
@media(prefers-reduced-motion:reduce){body.jp-forest-ready:not(.jp-forest-running) #pack-list{animation:none}}

/* The final coordinates come from the live catalogue image boxes, including
   their frozen sway angle. Resize and mobile layout are measured every frame. */
.jp-forest-entry .jp-forest-rack{inset:0;width:100%;height:100%;display:block;transform:none;opacity:var(--reveal)}
.jp-forest-entry .jp-forest-pack{position:absolute;margin:0;padding:0;transform-origin:50% 50%;max-width:none}
.jp-forest-entry .jp-forest-pack img{width:100%;height:100%;max-height:none;animation:none;opacity:1}
.jp-forest-entry .jp-forest-pack::after{opacity:calc((1 - var(--settle))*var(--light)*.45)}
.jp-forest-running #pack-list .pack-art{animation-play-state:paused!important}
.jp-forest-handoff #pack-list{visibility:visible!important;animation:none!important}
body.jp-forest-ready:not(.jp-forest-running) #pack-list{animation:none}

/* Monkey silhouettes start at full depth opacity, above the opening night veil.
   Pack reveal is still independent; all characters remain behind the packs. */
.jp-forest-night{z-index:1}
.jp-forest-monkeys{z-index:2;filter:brightness(1.5)}
.jp-forest-rack{z-index:3}

/* Hide only the page scrollbar; wheel/touch/keyboard scrolling stays native.
   The cinematic additionally locks the root scroll container. */
html:has(body[data-pack-page="jp"]){scrollbar-width:none;scrollbar-gutter:auto}
html:has(body[data-pack-page="jp"])::-webkit-scrollbar{display:none;width:0;height:0}
html:has(body.jp-forest-running){overflow:hidden!important;overscroll-behavior:none}

/* Local V547: matching sprite frames keep the firefly rim on each monkey.
   Only the glow layer fades as the pack lights take over; filters stay static. */
.jp-forest-entry{--monkey-glow:1}
.jp-forest-monkey{isolation:isolate}
.jp-monkey-sprite{position:relative;z-index:1}
.jp-monkey-glow{position:absolute;inset:0;z-index:0;display:block;opacity:calc(var(--monkey-glow)*.68);filter:brightness(0) invert(1) sepia(1) saturate(2) hue-rotate(18deg) blur(.7px) drop-shadow(0 0 5px #e8ffb899) drop-shadow(0 0 15px #a5ec6555);pointer-events:none}
.jp-forest-monkey.swinging .jp-monkey-glow{inset:auto 0 0;height:var(--body-size)}
/* The atlas is not evenly padded: the hanging poses' hands begin at y425
   inside the runners' 443.5px row. Runners end at y377; crop the empty gap. */
.jp-forest-monkey.running .jp-monkey-sprite{clip-path:inset(0 0 10% 0)}

/* Place the feet in the open clearing, below the side rocks. Each depth has
   its own ground line; the crossing follows a shallow perspective diagonal. */
.jp-forest-monkey.running{--runner-size:clamp(65px,calc(7vw + var(--monkey-i)*2.5vw),260px);width:var(--runner-size);top:calc(84% + var(--monkey-i)*4% - var(--runner-size)*.84);animation-name:jp-monkey-ground-crossing}
@keyframes jp-monkey-ground-crossing{from{transform:translate(-8vw,2vh)}to{transform:translate(150vw,-2vh)}}
@media(max-width:650px){.jp-forest-monkey.running{--runner-size:calc(64px + var(--monkey-i)*16px);width:var(--runner-size);top:calc(83% + var(--monkey-i)*4% - var(--runner-size)*.84)}}

/* Solid silhouettes at every depth; only the separate light layer fades. */
.jp-forest-monkeys,.jp-forest-monkey.running,.jp-forest-monkey.swinging{opacity:1}
.jp-monkey-sprite{filter:url(#jp-monkey-solid-v552)}

/* Avoid viewport-sized filtered compositing layers during fullscreen resize. */
.jp-forest-background{filter:none;will-change:auto}
.jp-forest-background::after{content:'';position:absolute;inset:0;background:#000;opacity:.28;pointer-events:none}
.jp-forest-rack,.jp-forest-frond,.jp-forest-pack,.jp-forest-monkey{will-change:auto}
.jp-forest-monkeys{filter:none}
.jp-forest-monkey>.jp-monkey-sprite{filter:url(#jp-monkey-solid-v552) brightness(1.5)}
