/* Zvířátková dílna — redesign v2
   Source of truth: /docs/STYLE_GUIDE.md */

:root{
  --v2-pink:#FF9FD1;
  --v2-lavender:#C9A7FF;
  --v2-aqua:#89E4D9;
  --v2-sky:#A8D8FF;
  --v2-vanilla:#FFF2B8;
  --v2-peach:#FFD6B0;
  --v2-cream:#FFF9F2;
  --v2-ink:#4A4358;
  --v2-gold:#FFD86B;
  --v2-success:#7FD6A3;
  --v2-radius:28px;
  --v2-shadow:0 14px 34px rgba(74,67,88,.16),0 3px 0 rgba(255,255,255,.75) inset;
  --v2-tap:160ms;
  --v2-ui:300ms;
}

body{
  color:var(--v2-ink);
  background:
    radial-gradient(circle at 12% 4%,rgba(255,255,255,.9),transparent 30%),
    linear-gradient(165deg,#FFF0F8 0%,#F0E9FF 48%,#E3F5FF 100%);
}

.btn{
  min-width:54px;
  height:54px;
  border-radius:19px;
  background:rgba(255,255,255,.9);
  box-shadow:0 7px 18px rgba(74,67,88,.14),0 2px 0 rgba(255,255,255,.85) inset;
  transition:transform var(--v2-tap) cubic-bezier(.2,.8,.2,1),box-shadow var(--v2-tap) ease;
}
.btn:active,.btn.v2-pressed{
  transform:scale(.96);
  box-shadow:0 4px 12px rgba(74,67,88,.13),0 1px 0 rgba(255,255,255,.85) inset;
}
.btn.primary{background:linear-gradient(145deg,#FF78BE,#FF59A9);box-shadow:0 8px 18px rgba(211,61,139,.28)}
.btn.green{background:linear-gradient(145deg,#8EE2AF,#63CA91);box-shadow:0 8px 18px rgba(73,160,111,.25)}

.stars{
  min-height:48px;
  padding:8px 15px;
  background:rgba(255,255,255,.84);
  border:1px solid rgba(255,255,255,.92);
  box-shadow:0 10px 24px rgba(74,67,88,.12);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
}

/* ---------- WORLD HOME ---------- */
#home{
  background:
    radial-gradient(circle at 76% 10%,rgba(255,244,183,.75) 0 7%,transparent 22%),
    linear-gradient(180deg,#92D9FF 0%,#CDEEFF 38%,#EAF8FF 63%,#F8FCFF 100%);
}
#home .home-scene{opacity:.92}
#home .home-top{
  z-index:6;
  padding:12px max(14px,env(safe-area-inset-right)) 8px max(14px,env(safe-area-inset-left));
}
#home .home-body{
  justify-content:flex-start;
  gap:10px;
  padding:2px 14px 24px;
  overflow-y:auto;
  scroll-padding-bottom:24px;
}
#home .hero-row{
  align-items:center;
  min-height:116px;
  padding:0 4px;
  gap:10px;
}
#home .home-body h1{
  font-size:clamp(36px,10vw,62px);
  line-height:.9;
  letter-spacing:-.025em;
  text-shadow:
    2px 0 #fff,-2px 0 #fff,0 2px #fff,0 -2px #fff,
    0 8px 20px rgba(79,57,112,.16);
}
#home .home-body h1 span{
  background:linear-gradient(95deg,#F95BA5,#9A77E8,#4DAADB);
  -webkit-background-clip:text;background-clip:text;
  filter:none;
  animation:none;
}
#home .mascot{
  width:clamp(94px,27vw,148px);
  animation:v2Float 5.8s ease-in-out infinite;
  filter:drop-shadow(0 14px 12px rgba(80,58,120,.18));
}
@keyframes v2Float{
  0%,100%{transform:translateY(0) rotate(-1deg)}
  50%{transform:translateY(-7px) rotate(1.5deg)}
}
#home .lead{
  margin:-10px 4px 4px;
  max-width:none;
  width:max-content;
  padding:7px 12px;
  border-radius:999px;
  background:rgba(255,255,255,.68);
  color:#66577C;
  box-shadow:0 6px 16px rgba(74,67,88,.08);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
}

/* The activity selector is a map, not a dashboard grid. */
#home .modes{
  position:relative;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px 12px;
  padding:14px 2px 22px;
  isolation:isolate;
}
#home .modes::before{
  content:"";
  position:absolute;
  z-index:-2;
  left:50%;
  top:0;
  bottom:0;
  width:50%;
  transform:translateX(-50%) rotate(-2deg);
  border-radius:48% 52% 48% 52%;
  background:
    radial-gradient(circle at 48% 9%,rgba(255,255,255,.9) 0 5px,transparent 6px),
    radial-gradient(circle at 52% 27%,rgba(255,255,255,.8) 0 4px,transparent 5px),
    radial-gradient(circle at 47% 45%,rgba(255,255,255,.82) 0 5px,transparent 6px),
    radial-gradient(circle at 52% 65%,rgba(255,255,255,.78) 0 4px,transparent 5px),
    radial-gradient(circle at 48% 84%,rgba(255,255,255,.78) 0 5px,transparent 6px);
  opacity:.58;
  pointer-events:none;
}
#home .mode{
  position:relative;
  min-height:112px;
  padding:11px;
  border-radius:30px;
  border:1px solid rgba(255,255,255,.72);
  background:var(--g);
  box-shadow:
    0 13px 24px rgba(68,54,94,.16),
    0 3px 0 rgba(255,255,255,.35) inset,
    0 -3px 0 rgba(75,50,110,.12) inset;
  transform:translateZ(0);
  transition:transform 180ms cubic-bezier(.2,.85,.2,1),box-shadow 180ms ease;
  animation:v2LocationIn 480ms cubic-bezier(.2,.85,.2,1);
}
#home .mode:nth-child(2){animation-delay:40ms}
#home .mode:nth-child(3){animation-delay:80ms}
#home .mode:nth-child(4){animation-delay:120ms}
#home .mode:nth-child(5){animation-delay:160ms}
#home .mode:nth-child(6){animation-delay:200ms}
#home .mode:nth-child(7){animation-delay:240ms}
@keyframes v2LocationIn{
  from{opacity:0;transform:translateY(10px) scale(.98)}
  to{opacity:1;transform:translateY(0) scale(1)}
}
#home .mode::before{
  background:
    radial-gradient(circle at 15% 3%,rgba(255,255,255,.48),transparent 40%),
    radial-gradient(circle at 95% 100%,rgba(255,255,255,.15) 0 23%,transparent 24%);
}
#home .mode::after{display:none}
#home .mode:active,#home .mode.v2-pressed{
  transform:scale(.965);
  box-shadow:0 7px 14px rgba(68,54,94,.14),0 2px 0 rgba(255,255,255,.32) inset;
}
#home .mode:nth-child(even):not(.wide){transform:translateY(10px) rotate(1deg)}
#home .mode:nth-child(odd):not(.wide){transform:translateY(-2px) rotate(-1deg)}
#home .mode:nth-child(even):not(.wide):active,
#home .mode:nth-child(even):not(.wide).v2-pressed{transform:translateY(10px) rotate(1deg) scale(.965)}
#home .mode:nth-child(odd):not(.wide):active,
#home .mode:nth-child(odd):not(.wide).v2-pressed{transform:translateY(-2px) rotate(-1deg) scale(.965)}

#home .mode.wide{
  grid-column:1/-1;
  min-height:124px;
  border-radius:34px;
  padding:11px 16px 11px 10px;
}
#home .mode-art{
  width:68px;height:68px;
  border-radius:22px;
  box-shadow:0 7px 16px rgba(55,42,83,.18),0 2px 0 rgba(255,255,255,.72) inset;
}
#home .mode.wide .mode-art{
  width:106px;
  border-radius:26px;
  filter:drop-shadow(0 9px 8px rgba(55,42,83,.15));
}
#home .mode-name{
  font-size:clamp(17px,4.7vw,22px);
  letter-spacing:-.01em;
  text-shadow:0 2px 5px rgba(46,28,74,.18);
}
#home .mode.wide .mode-name{font-size:clamp(23px,6.8vw,31px)}
#home .mode-sub{
  margin-top:4px;
  opacity:.92;
  line-height:1.12;
}
#home .mode-new{
  right:13px;bottom:12px;
  padding:6px 10px;
  background:rgba(255,245,170,.96);
  color:#76540A;
  box-shadow:0 5px 12px rgba(125,91,15,.18);
  animation:v2Badge 3.2s ease-in-out infinite;
}
@keyframes v2Badge{0%,100%{transform:rotate(2deg)}50%{transform:rotate(-1deg) scale(1.035)}}

#home .parade{display:none}
#home .twinkles{opacity:.48}

/* ---------- SHARED GAME SURFACES ---------- */
.topbar{
  min-height:70px;
  padding:10px 14px;
  background:linear-gradient(180deg,rgba(255,255,255,.68),rgba(255,255,255,0));
}
.topbar h2{
  font-size:clamp(22px,6.2vw,29px);
  letter-spacing:-.015em;
}
.scroll{padding-left:14px;padding-right:14px}

.tile,.ctile,.num-tile,.abc-card,.trace-box{
  border:1px solid rgba(255,255,255,.84);
  box-shadow:var(--v2-shadow);
}
.tile,.ctile,.num-tile{
  transition:transform 170ms cubic-bezier(.2,.85,.2,1),box-shadow 170ms ease;
}
.tile:active,.ctile:active,.num-tile:active,
.tile.v2-pressed,.ctile.v2-pressed,.num-tile.v2-pressed{
  transform:scale(.965);
  box-shadow:0 8px 18px rgba(74,67,88,.14);
}

.chip,.tool,.seg button{
  border:1px solid rgba(255,255,255,.8);
  box-shadow:0 6px 15px rgba(74,67,88,.11);
}
.seg button[aria-pressed="true"]{
  background:linear-gradient(145deg,#7D70BA,#574A86);
  box-shadow:0 7px 16px rgba(65,50,104,.22);
}
.seg.icons button[aria-pressed="true"]{
  background:linear-gradient(145deg,#F47DB9,#9A78E8);
  box-shadow:0 8px 18px rgba(112,70,160,.22);
}

.pz-area{
  border:1px solid rgba(255,255,255,.88);
  box-shadow:0 16px 36px rgba(74,67,88,.14),0 3px 0 rgba(255,255,255,.8) inset;
}
.pz-piece.anim,.piece.anim{transition-duration:190ms}
.piece.lift{
  filter:drop-shadow(0 13px 13px rgba(30,30,60,.24));
}

.ans.bad{
  animation:none;
  opacity:.72;
  transform:scale(.96);
  background:rgba(255,255,255,.72);
}
.ans.ok{background:linear-gradient(145deg,#8BE0AD,#62C98F)}

/* ---------- V2 LOCAL SUCCESS BURST ---------- */
.v2-burst-layer{
  position:fixed;inset:0;z-index:99999;pointer-events:none;overflow:hidden;
}
.v2-burst-star{
  position:absolute;
  left:var(--x);top:var(--y);
  width:var(--s);height:var(--s);
  transform:translate(-50%,-50%) scale(.55) rotate(0deg);
  opacity:0;
  animation:v2Burst var(--d) cubic-bezier(.18,.72,.2,1) forwards;
  animation-delay:var(--delay);
  filter:drop-shadow(0 3px 4px rgba(76,54,108,.15));
}
.v2-burst-star::before{
  content:"";
  position:absolute;inset:0;
  background:var(--c);
  clip-path:polygon(50% 0%,61% 35%,100% 50%,61% 64%,50% 100%,39% 64%,0 50%,39% 35%);
}
@keyframes v2Burst{
  0%{opacity:0;transform:translate(-50%,-50%) scale(.45) rotate(0)}
  18%{opacity:1}
  70%{opacity:1}
  100%{
    opacity:0;
    transform:translate(calc(-50% + var(--dx)),calc(-50% + var(--dy))) scale(.9) rotate(var(--rot));
  }
}

.v2-lumi-bubble{
  position:absolute;
  z-index:20;
  max-width:min(230px,62vw);
  padding:9px 13px;
  border-radius:18px 18px 18px 5px;
  background:rgba(255,255,255,.94);
  color:var(--v2-ink);
  font-weight:800;
  font-size:15px;
  line-height:1.15;
  box-shadow:0 10px 24px rgba(74,67,88,.14);
  transform:translateY(6px) scale(.97);
  opacity:0;
  animation:v2BubbleIn 220ms ease forwards;
}
@keyframes v2BubbleIn{to{opacity:1;transform:translateY(0) scale(1)}}

/* Phone on its side: everything must fit without scrolling and the title must not touch the cards. */
@media (orientation:landscape) and (max-height:520px){
  #home .home-body{
    grid-template-columns:minmax(180px,30%) 1fr;
    column-gap:16px;
    padding-bottom:6px;
    overflow:hidden;
  }
  #home .hero-row{min-height:0}
  #home .home-body h1{font-size:clamp(28px,4.9vw,42px)}
  #home .mascot{width:clamp(80px,21vh,112px)}
  #home .modes{grid-template-columns:repeat(2,1fr);gap:8px 10px;padding:4px 2px 8px;overflow-y:auto}
  #home .modes::before{display:none}
  #home .mode{min-height:0;padding:6px 10px;border-radius:22px}
  #home .mode.wide{min-height:0;padding:6px 12px 6px 8px;border-radius:24px}
  #home .mode-art{width:44px;height:44px;border-radius:14px}
  #home .mode.wide .mode-art{width:66px;height:50px}
  #home .mode-name{font-size:clamp(15px,2.5vw,18px)}
  #home .mode.wide .mode-name{font-size:clamp(20px,3.2vw,23px)}
  #home .mode-sub{margin-top:1px;font-size:12px;line-height:1.1}
  #home .mode-new{right:10px;bottom:8px;padding:4px 8px}
  #home .mode:nth-child(even):not(.wide),
  #home .mode:nth-child(odd):not(.wide){transform:none}
  #home .mode:nth-child(even):not(.wide):active,
  #home .mode:nth-child(even):not(.wide).v2-pressed,
  #home .mode:nth-child(odd):not(.wide):active,
  #home .mode:nth-child(odd):not(.wide).v2-pressed{transform:scale(.965)}
}

/* Shorter phones upright (iPhone mini, SE): all seven places must fit without scrolling.
   Subtitles are for parents only, so they go first. */
@media (orientation:portrait) and (max-height:830px){
  #home .mode-sub{display:none}
  #home .mode{min-height:92px}
  #home .mode.wide{min-height:100px}
}
@media (orientation:portrait) and (max-height:700px){
  #home .hero-row{min-height:80px}
  #home .home-body h1{font-size:clamp(30px,9vw,38px)}
  #home .mascot{width:clamp(76px,22vw,92px)}
  #home .modes{gap:10px;padding:8px 2px 12px}
  #home .mode{min-height:80px;padding:9px}
  #home .mode.wide{min-height:88px}
  #home .mode-art{width:50px;height:50px;border-radius:16px}
  #home .mode.wide .mode-art{width:80px;height:58px}
  #home .mode-name{font-size:17px}
  #home .mode.wide .mode-name{font-size:24px}
}

@media (prefers-reduced-motion:reduce){
  #home .mascot,#home .mode,#home .mode-new,
  .v2-burst-star{animation:none!important}
  #home .mode:nth-child(even):not(.wide),
  #home .mode:nth-child(odd):not(.wide){transform:none}
}

/* Keep ambient sparkle subtle; it should never compete with the activities. */
.twinkles{opacity:.42}

/* Puzzle hint: glow, not shake. */
.pz-piece.wiggle{
  animation:v2HintGlow 820ms ease-in-out!important;
}
@keyframes v2HintGlow{
  0%,100%{filter:drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 5px 7px rgba(20,30,50,.26));}
  50%{filter:drop-shadow(0 0 10px rgba(255,255,255,.96)) drop-shadow(0 0 18px rgba(201,167,255,.85)) brightness(1.08);}
}
.pz-hint{
  opacity:0;
  animation:v2TargetHint 1100ms ease-in-out!important;
  filter:brightness(1.25) drop-shadow(0 0 8px rgba(255,255,255,.95)) drop-shadow(0 0 13px rgba(201,167,255,.7));
}
@keyframes v2TargetHint{
  0%,100%{opacity:0}
  25%,68%{opacity:.66}
}
