/* =========================================================================
   Kebun Pupi v3 — design system
   Landscape stage 960x540 (wider on long phones), clay buttons, every
   coloured object lit from the top-left with gloss + drop shadow.
   ========================================================================= */
@font-face{font-family:Fredoka;src:url('../../assets/fredoka-latin-wght-kp.woff2') format('woff2');font-weight:300 700;font-style:normal;font-display:swap}

:root{
  --kp-font:Fredoka,'Nunito','Segoe UI',sans-serif;
  --kp-font-parent:Nunito,'Segoe UI',sans-serif;
  --kp-ink:#24401A;--kp-ink-2:#4A6A3A;--kp-ink-3:#7A8A6A;
  --kp-green:#22A447;--kp-green-d:#1E7B33;--kp-green-l:#8BF19B;
  --kp-sky-1:#BFEBFF;--kp-sky-2:#E6F8D8;
  --kp-cream:#FFFBF0;--kp-cream-2:#FFEFD2;--kp-clay-edge:#DDB477;
  --kp-purple:#8A5CFF;--kp-orange:#FF8A1A;--kp-pink:#FF4F93;--kp-yellow:#FFC21A;--kp-blue:#2F86E0;--kp-red:#E2302A;
  --kp-gloss:radial-gradient(circle at 32% 24%,rgba(255,255,255,.55),rgba(255,255,255,0) 46%),radial-gradient(circle at 68% 92%,rgba(0,0,0,.2),rgba(0,0,0,0) 58%);
  --kp-shadow:0 10px 18px rgba(60,40,10,.18);
  --stage-w:960px;--stage-h:540px;--s:1;--stage-x:0px;--stage-y:0px;
}

/* ---------- Stage ---------- */
html.kp-staged,html.kp-staged body{width:100%;height:100%;margin:0;overflow:hidden;overscroll-behavior:none}
html.kp-staged body{background:#7CC8F0 linear-gradient(180deg,#8FD3FF,#BFEAFF 55%,#7FCB63);font-family:var(--kp-font);-webkit-font-smoothing:antialiased}
/* --dy: half of the extra height on taller stages (16:10, 3:2, 4:3 tablets), 0 on every 16:9-or-wider phone. Screens
   whose main content is pinned near the top use it to sit in the middle instead of leaving an empty band below. */
#kp-stage{--dy:max(0px, calc((var(--stage-h) - 540px) / 2))}
#kp-stage{position:fixed;left:var(--stage-x);top:var(--stage-y);width:var(--stage-w);height:var(--stage-h);transform:scale(var(--s));transform-origin:0 0;overflow:hidden;container:kp-stage/size;background:linear-gradient(180deg,var(--kp-sky-1),var(--kp-sky-2));color:var(--kp-ink);font-family:var(--kp-font)}
#app{position:absolute;inset:0;overflow:hidden}
#app>.screen{min-height:0;height:100%;width:100%}
.kp-v3 button,.kp-v3 select,.kp-v3 input{font-family:inherit}
.kp-v3 :focus-visible{outline:4px solid #FFC21A;outline-offset:4px}

/* Drag ghosts and flights live outside the stage (viewport space): scale their art to match. */
.planting-drag,.insect-drag-ghost,.railway-drag-ghost{scale:var(--s)}

/* Top-layer dialogs are not inside the stage's transform; scale them on their own. They are as wide as
   the stage (wider than the viewport before scaling), so `margin:auto` would pin them to the left edge:
   centre them on the viewport explicitly instead. */
.kp-v3 dialog,.kp-v3 dialog:is(#parent-dialog,#parent-gate-dialog){inset:auto;left:50%;top:50%;margin:0;transform:translate(-50%,-50%) scale(var(--s));transform-origin:center}

/* ---------- Shared building blocks ---------- */
.kp-clay,.kp-v3 .quiet-button,.kp-v3 .ui-icon{
  border:0;cursor:pointer;color:#5A4A30;
  background:linear-gradient(#FFFDF6,#FFEFD2);
  box-shadow:0 6px 0 var(--kp-clay-edge),0 12px 18px rgba(90,55,10,.22),inset 0 3px 0 #fff;
  transition:transform .12s,box-shadow .12s}
.kp-clay:not(:disabled):active,.kp-v3 .quiet-button:not(:disabled):active,.kp-v3 .ui-icon:not(:disabled):active{transform:translateY(5px);box-shadow:0 1px 0 var(--kp-clay-edge),0 4px 8px rgba(90,55,10,.2),inset 0 3px 0 #fff}
.kp-gl{background-image:var(--kp-gloss)!important}
.kp-tile{display:inline-flex;align-items:center;justify-content:center;border-radius:20px;color:#fff;font-weight:700;background-image:var(--kp-gloss);text-shadow:0 3px 0 rgba(0,0,0,.18);box-shadow:0 6px 0 rgba(0,0,0,.14),var(--kp-shadow)}

/* Big round go button (green, pulsing) */
.kp-go{border:0;border-radius:50%;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;color:#fff;
  background:radial-gradient(circle at 35% 30%,#8BF19B,#22A447 70%);box-shadow:0 7px 0 var(--kp-green-d),0 14px 22px rgba(20,80,30,.3);animation:kp-pulse 1.4s infinite}
.kp-go:active{transform:translateY(5px);box-shadow:0 2px 0 var(--kp-green-d)}
@keyframes kp-pulse{0%{box-shadow:0 0 0 0 rgba(255,255,255,.9),0 7px 0 var(--kp-green-d),0 14px 22px rgba(20,80,30,.3)}100%{box-shadow:0 0 0 22px rgba(255,255,255,0),0 7px 0 var(--kp-green-d),0 14px 22px rgba(20,80,30,.3)}}
@keyframes kp-bob{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}
@keyframes kp-pop{0%{transform:scale(.4);opacity:0}70%{transform:scale(1.08);opacity:1}100%{transform:scale(1)}}
@keyframes kp-drift{from{transform:translateX(-180px)}to{transform:translateX(calc(var(--stage-w) + 40px))}}
@keyframes kp-sway{0%,100%{transform:rotate(-3deg)}50%{transform:rotate(3deg)}}
@keyframes kp-twinkle{0%,100%{opacity:.25;transform:scale(.6) rotate(0)}50%{opacity:1;transform:scale(1) rotate(45deg)}}
@keyframes kp-badge{0%,100%{scale:1;box-shadow:0 0 0 0 rgba(255,194,26,.75),0 5px 0 #C98A00}60%{scale:1.05;box-shadow:0 0 0 14px rgba(255,194,26,0),0 5px 0 #C98A00}}

/* Scenery pieces used on many screens */
.kp-cloud{position:absolute;left:0;background:#fff;border-radius:60px;box-shadow:inset 0 -8px 0 #E3F3FF;animation:kp-drift 60s linear infinite;pointer-events:none}
.kp-cloud::before{content:"";position:absolute;width:56%;height:150%;left:14%;bottom:30%;background:#fff;border-radius:50%}
.kp-land{position:absolute;left:0;bottom:0;width:100%;height:100%;pointer-events:none}

/* ========================= Splash (fast parade) ========================= */
.kp-splash{position:absolute;inset:0;z-index:1000;overflow:hidden;cursor:pointer;
  background:radial-gradient(circle at 50% 18%,#FFF6CF 0%,#BFEAFF 38%,#8FD3FF 100%);transition:opacity .6s ease,transform .6s cubic-bezier(.4,0,.2,1)}
.kp-splash.fade-out{opacity:0;transform:scale(1.03);pointer-events:none}
.kp-splash .ks-sky,.kp-splash .ks-garden{position:absolute;inset:0;pointer-events:none}
.kp-splash .ks-land{position:absolute;left:0;top:0;width:100%;height:100%}
.ks-track{position:absolute;left:0;right:0;top:432px;height:28px}
.ks-track::before{content:"";position:absolute;left:0;right:0;top:6px;height:14px;background:linear-gradient(#C9A27A,#8F663D);opacity:.6}
.ks-track i{position:absolute;left:0;right:0;top:0;height:26px;background:repeating-linear-gradient(90deg,transparent 0 10px,#8E5A2B 10px 24px,transparent 24px 60px);border-radius:4px}
.ks-track::after{content:"";position:absolute;left:0;right:0;top:4px;height:16px;border-top:6px solid #6E7280;border-bottom:6px solid #6E7280}
/* Beranda's windmill on the far hill, beside the logo, and flower beds on the hill and along the front. The hills
   stretch with the stage height, so the windmill and hill beds sit at a share of it (same spot on a 540 px phone). */
.kp-splash .ks-mill{position:absolute;left:calc(50% + 190px);bottom:49%;width:124px;height:158px}
.kp-splash .ks-mill svg{display:block;width:100%;height:100%}
.ks-fl-hill-l{left:4%;bottom:34%;width:130px;height:56px}
.ks-fl-hill-r{right:4%;bottom:35%;width:150px;height:62px}
.ks-fl-1{left:0;bottom:0;width:210px;height:86px}
.ks-fl-2{left:22%;bottom:4px;width:160px;height:70px}
.ks-fl-3{right:22%;bottom:4px;width:160px;height:70px}
.ks-fl-4{right:0;bottom:0;width:210px;height:86px}
/* Taller stages (tablets): like Beranda, the logo, track and parade move down by half the extra height (0 on phones). */
.kp-splash>:is(.ks-logo,.ks-spark,.ks-track,.ks-parade){translate:0 var(--dy)}
.ks-logo{position:absolute;left:50%;top:22px;width:220px;height:220px;margin-left:-110px;animation:ks-logo 1.2s cubic-bezier(.22,1.25,.4,1) .25s both}
/* The logo is cut out of its cream tile (scripts/icon-cutout.py) so it sits straight on the sky; the shadow follows its outline. */
.ks-logo img{width:100%;height:100%;filter:drop-shadow(0 8px 6px rgba(20,60,110,.22));animation:ks-logobob 2.6s ease-in-out 1.1s infinite}
.ks-spark{position:absolute;width:24px;height:24px;animation:kp-twinkle 1.4s ease-in-out infinite}
.ks-parade{position:absolute;left:0;top:262px;width:760px;height:200px;animation:ks-parade 6.6s linear .3s both}
.ks-train{position:absolute;left:190px;top:32px;width:520px;height:170px;animation:ks-chug .62s ease-in-out infinite}
.ks-train svg{display:block;width:100%;height:100%;overflow:visible}
.ks-train .railway-wheel{animation-duration:.95s}
.ks-walker{position:absolute;animation:ks-walk .55s ease-in-out infinite}
.ks-flyer{position:absolute;animation:ks-flutter 1.2s ease-in-out infinite}
.ks-wing{transform-box:fill-box;transform-origin:center;animation:ks-wing .16s linear infinite}
/* Publisher badge, centred at the bottom; its thin underline doubles as the loading bar. */
.ks-by{position:absolute;left:50%;bottom:14px;transform:translateX(-50%);display:flex;align-items:center;gap:10px;padding:9px 22px 15px 16px;border-radius:20px;background:rgba(255,255,255,.95);box-shadow:0 5px 0 rgba(30,90,20,.14),0 10px 22px rgba(0,40,80,.14);overflow:hidden;animation:ks-by-in .7s cubic-bezier(.22,1.2,.4,1) .5s both}
.ks-by-mark{width:30px;height:30px;object-fit:contain}
.ks-by-name{font:700 19px/1 var(--kp-font);letter-spacing:.12em;color:#1E1E1E}
.ks-load{position:absolute;left:14px;right:14px;bottom:6px;height:4px;border-radius:2px;background:rgba(30,60,30,.1);overflow:hidden}
.ks-load span{display:block;height:100%;border-radius:2px;background:linear-gradient(90deg,#FFC21A,#22A447);animation:ks-load 6.6s cubic-bezier(.4,0,.2,1) both}
@keyframes ks-by-in{from{opacity:0;transform:translate(-50%,16px)}to{opacity:1;transform:translate(-50%,0)}}
@keyframes ks-logo{0%{transform:translateY(-30px) scale(.6);opacity:0}55%{transform:translateY(4px) scale(1.04);opacity:1}100%{transform:none;opacity:1}}
@keyframes ks-logobob{0%,100%{transform:translateY(0) rotate(-2deg)}50%{transform:translateY(-8px) rotate(2deg)}}
/* The train rolls in, slows to a gentle cruise past the logo, then picks up speed and leaves. */
@keyframes ks-parade{0%{transform:translateX(-760px);animation-timing-function:cubic-bezier(.3,.5,.6,.85)}38%{transform:translateX(calc(var(--stage-w) / 2 - 600px));animation-timing-function:linear}66%{transform:translateX(calc(var(--stage-w) / 2 - 300px));animation-timing-function:cubic-bezier(.4,.15,.8,.6)}100%{transform:translateX(calc(var(--stage-w) + 40px))}}
@keyframes ks-chug{0%,100%{transform:translateY(0)}50%{transform:translateY(-3px)}}
@keyframes ks-spin{to{transform:rotate(360deg)}}
@keyframes ks-walk{0%,100%{transform:translateY(0) rotate(-4deg)}50%{transform:translateY(-6px) rotate(4deg)}}
@keyframes ks-flutter{0%,100%{transform:translateY(0)}50%{transform:translateY(-22px)}}
@keyframes ks-wing{0%,100%{transform:scaleX(1)}50%{transform:scaleX(.3)}}
@keyframes ks-load{from{width:0}to{width:100%}}

@media(prefers-reduced-motion:reduce){
  .kp-splash *,.kp-go,.kp-cloud{animation:none!important}
  .ks-parade{transform:translateX(calc(var(--stage-w) / 2 - 450px))}
}
