:root {
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #bfe9ff;
  font-family: var(--font);
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* Scene */
#scene {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: linear-gradient(#a8e4ff 0%, #d9f5ff 55%, #fff4cf 100%);
}

#sun {
  position: absolute;
  top: 6%;
  right: 9%;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #fff7b0, #ffd23f 60%, #ffb820);
  box-shadow: 0 0 40px 10px rgba(255, 220, 80, .5);
  cursor: pointer;
}
#sun.wiggle { animation: wiggle .6s ease-in-out; }

.cloud {
  position: absolute;
  width: 110px;
  height: 36px;
  background: #fff;
  border-radius: 40px;
  opacity: .92;
  animation: drift 40s ease-in-out infinite alternate;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.cloud::before { width: 50px; height: 50px; top: -22px; left: 18px; }
.cloud::after  { width: 60px; height: 60px; top: -30px; left: 50px; }
.c1 { top: 12%; left: -6%; }
.c2 { top: 28%; left: 38%; width: 84px; animation-duration: 55s; }
.c3 { top: 5%;  left: 60%; animation-duration: 70s; }

.tree {
  position: absolute;
  bottom: 44%;
  width: 14px;
  height: 90px;
  background: #b07a4f;
  border-radius: 6px;
}
.tree::before {
  content: "";
  position: absolute;
  left: -36px;
  bottom: 40px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: #7fcf7a;
  box-shadow: inset -8px -10px 0 rgba(0, 0, 0, .06);
}
.t1 { left: 3%; }
.t2 { right: 3%; height: 110px; }

.grass {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 45%;
  background: linear-gradient(#b8e986, #8fd16a);
  border-radius: 50% 50% 0 0 / 14% 14% 0 0;
}

.flower {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe36e 30%, #ff8fb1 34%);
}

.lake {
  position: absolute;
  top: 52%;
  right: 4%;
  width: 38%;
  height: 13%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 40% 40%, #c9f0ff, #6cc8f2 70%);
  overflow: hidden;
}
.lake::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shine 4s linear infinite;
}

#family {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#family * { pointer-events: auto; }

/* Actions */
#actions {
  flex: 0 0 22%;
  min-height: 110px;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  padding: 0 6px env(safe-area-inset-bottom);
  background: linear-gradient(#fff6e0, #ffe9c7);
}

.btn {
  width: min(64px, 14.5vw);
  height: min(64px, 14.5vw);
  min-width: 0;
  border: none;
  border-radius: 50%;
  padding: 0;
  font-family: var(--emoji);
  font-size: 32px;
  line-height: 1;
  color: inherit;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .12), 0 10px 18px rgba(0, 0, 0, .15);
  transition: transform .12s, box-shadow .12s;
}
.btn:active { transform: scale(.9) translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .12); }
.btn.active { transform: scale(1.08); outline: 4px solid #fff; outline-offset: 3px; }

.feed { background: #ffb36b; }
.bath { background: #8fd3ff; }
.pet  { background: #ffa5c8; }
.play { background: #a8e6a1; }

/* Start overlay */
#start {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity .4s;
}
#start.hidden { opacity: 0; pointer-events: none; }

#startBtn {
  width: min(56vw, 200px);
  height: min(56vw, 200px);
  padding-left: 12px;
  border: none;
  border-radius: 50%;
  color: #fff;
  font-family: var(--emoji);
  font-size: min(20vw, 96px);
  background: radial-gradient(circle at 40% 35%, #ffd27a, #ff9e6b);
  box-shadow: 0 10px 0 rgba(0, 0, 0, .12), 0 16px 30px rgba(0, 0, 0, .2);
  cursor: pointer;
  animation: pulse 1.2s ease-in-out infinite;
}

/* Animations */
@keyframes drift {
  from { transform: translateX(-30px); }
  to   { transform: translateX(30px); }
}
@keyframes shine {
  from { background-position: 150% 0; }
  to   { background-position: -50% 0; }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-12deg) scale(1.08); }
  75%      { transform: rotate(12deg) scale(1.08); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

/* Bath tub */
#tubBack, #tubFront { position: absolute; left: 6%; width: 88%; pointer-events: none; opacity: 0; transform: scale(.3); transform-origin: 50% 100%; }
#tubBack.show, #tubFront.show { opacity: 1; animation: tubIn .6s cubic-bezier(.3, 1.6, .5, 1) forwards; }
@keyframes tubIn { from { transform: scale(.3); } to { transform: scale(1); } }
#tubBack { top: 62%; height: 14%; z-index: 0; border-radius: 50% 50% 0 0 / 100% 100% 0 0; background: linear-gradient(#cfeeff, #8fd3f5); border: 4px solid #fff; border-bottom: 0; box-shadow: inset 0 8px 0 #7cc8ee; }
#tubFront { top: 75%; height: 14%; z-index: 3; }
#tubFront::before { content: ""; position: absolute; inset: 0 0 10% 0; background: linear-gradient(#fff 0%, #e6f6ff 40%, #9fd8f5 100%); border-radius: 8px 8px 45% 45% / 8px 8px 100% 100%; border: 3px solid #fff; box-shadow: 0 4px 0 rgba(0,0,0,.12); }
#tubFront .feet i { position: absolute; bottom: 0; width: 7%; height: 12%; background: #f5c542; border-radius: 40% 40% 50% 50%; border: 2px solid #c99a1c; }
#tubFront .feet i:first-child { left: 8%; } #tubFront .feet i:last-child { right: 8%; }
#tubFront .foam { position: absolute; left: 2%; right: 2%; top: -14%; height: 26%; z-index: 1;
  background: radial-gradient(circle at 6% 60%, #fff 0 9%, transparent 10%), radial-gradient(circle at 16% 40%, #fff 0 11%, transparent 12%), radial-gradient(circle at 28% 62%, #fff 0 9%, transparent 10%), radial-gradient(circle at 40% 38%, #fff 0 12%, transparent 13%), radial-gradient(circle at 52% 60%, #fff 0 10%, transparent 11%), radial-gradient(circle at 64% 40%, #fff 0 12%, transparent 13%), radial-gradient(circle at 76% 62%, #fff 0 9%, transparent 10%), radial-gradient(circle at 86% 40%, #fff 0 11%, transparent 12%), radial-gradient(circle at 95% 60%, #fff 0 9%, transparent 10%);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.2)); animation: foamW 2.4s ease-in-out infinite alternate; }
@keyframes foamW { to { transform: translateY(-3px) scaleX(1.01); } }

/* Shower */
#shower { position: absolute; left: 6%; width: 88%; top: 0; height: 36%; z-index: 4; display: none; pointer-events: none; }
#shower.show { display: block; }
#shower .rail { position: absolute; left: 0; right: 14px; top: 9%; height: 8px; border-radius: 4px; background: linear-gradient(#f4f7fa, #9aa7b3 60%, #d5dde4); box-shadow: 0 2px 0 rgba(0,0,0,.15); }
#shower .elbow { position: absolute; right: 0; top: -2px; width: 22px; height: calc(9% + 12px); border-radius: 0 14px 0 0; border: 8px solid #b9c4cd; border-left: 0; border-bottom: 0; box-sizing: border-box; }
#showerHead { position: absolute; top: 9%; left: 0; width: 56px; margin-left: -28px; height: 70px; pointer-events: auto; touch-action: none; cursor: grab; }
#showerHead .neck { position: absolute; left: 22px; top: 0; width: 12px; height: 22px; background: linear-gradient(90deg, #d5dde4, #f4f7fa, #9aa7b3); border-radius: 3px; }
#showerHead .dome { position: absolute; left: 0; top: 18px; width: 56px; height: 34px; border-radius: 50% 50% 40% 40% / 70% 70% 30% 30%; border: 3px solid #fff;
  background: radial-gradient(circle, #5fb4de 2px, transparent 2.5px) 4px 14px/9px 8px, linear-gradient(#bfe9ff, #7fcdf0); box-shadow: 0 3px 0 rgba(0,0,0,.18); }
#showerHead .stream { position: absolute; left: 8px; top: 48px; width: 40px; height: 0; opacity: 0; pointer-events: none; border-radius: 0 0 20px 20px;
  background: repeating-linear-gradient(180deg, rgba(120,200,245,.55) 0 10px, rgba(190,235,255,.3) 10px 22px); background-size: 100% 22px; transition: opacity .15s; }
#showerHead.on .stream { opacity: 1; animation: streamFall .35s linear infinite; }
@keyframes streamFall { to { background-position: 0 22px; } }
.fx-hint.shower-hint { animation: hintBob .7s ease-in-out infinite alternate; }
@keyframes hintBob { to { margin-top: 10px; } }

.sleep { background: linear-gradient(#a99cff, #7f7be0); }

/* Mud puddle */
#mud { position: absolute; left: 68%; top: 67.5%; width: 22%; height: 8%; z-index: 0; transition: opacity .4s, transform .4s;
  border-radius: 46% 54% 50% 50% / 58% 52% 48% 42%;
  background: radial-gradient(ellipse at 40% 35%, #8a5c36, #6b4423 65%, #5a371a);
  box-shadow: inset 0 0 0 4px #4a2d15, inset 0 5px 8px rgba(0,0,0,.25), 0 3px 0 rgba(0,0,0,.12); pointer-events: none; }
#mud .h { position: absolute; background: rgba(255,255,255,.45); border-radius: 50%; }
#mud .h1 { left: 22%; top: 24%; width: 18%; height: 11%; transform: rotate(-12deg); }
#mud .h2 { left: 62%; top: 52%; width: 11%; height: 8%; }
#mud .b { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #c79a70, #8a5c36); border: 1px solid #4a2d15; animation: mudPop 4s ease-in-out infinite; }
#mud .b1 { left: 45%; top: 40%; } #mud .b2 { left: 72%; top: 30%; width: 6px; height: 6px; animation-delay: -1.3s; } #mud .b3 { left: 30%; top: 62%; width: 7px; height: 7px; animation-delay: -2.6s; }
@keyframes mudPop { 0%, 60% { transform: scale(0); } 75% { transform: scale(1.1); } 90% { transform: scale(1.3); opacity: .6; } 100% { transform: scale(0); opacity: 0; } }
#scene.bathing #mud, #scene.night #mud { opacity: 0; transform: scale(.6); }

/* Night */
#night { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity 1.2s; background: linear-gradient(#10124a 0%, #2b2275 45%, #5a3f8f 75%, #6a4a8c 100%); }
#night i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #fff8c9; box-shadow: 0 0 6px 2px rgba(255,248,201,.7); animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: .25; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.3); } }
#scene.night #night { opacity: 1; }
#scene .tree, #scene .lake, #scene .grass, #scene .flower, #scene .cloud { transition: filter 1.2s, opacity 1.2s; }
#scene.night .grass, #scene.night .tree, #scene.night .lake, #scene.night .flower { filter: brightness(.6) saturate(.9); }
#scene.night .cloud { opacity: .12; }
#sun { z-index: 1; transition: background 1.2s, box-shadow 1.2s, transform 1.2s; }
#scene.night #sun { width: 64px; height: 64px; background: transparent; box-shadow: inset -18px -6px 0 0 #fff3b0, 0 0 30px 6px rgba(255,243,176,.25); transform: rotate(-20deg); }

/* Beds */
#beds, #bedsF { position: absolute; inset: 0; pointer-events: none; }
#bedsF { z-index: 3; }
.bed { position: absolute; transform: translate(-50%, -100%); transform-origin: 50% 100%; animation: tubIn .6s cubic-bezier(.3, 1.6, .5, 1) backwards; }
.bed.out { animation: bedOut .4s ease-in forwards; }
@keyframes bedOut { to { transform: translate(-50%, -100%) scale(.2); opacity: 0; } }
.bed .head { position: absolute; right: -4%; bottom: 0; width: 15%; height: 100%; background: linear-gradient(90deg, #c68a52, #a86f3d); border: 3px solid #7a4a22; border-radius: 14px 14px 6px 6px; }
.bed .mat { position: absolute; left: 0; right: 8%; bottom: 8%; height: 42%; background: #fff; border: 3px solid #e8e0f0; border-radius: 14px; }
.bed .pillow { position: absolute; right: 12%; bottom: 40%; width: 26%; height: 24%; background: #fff; border: 2px solid #e5e5f2; border-radius: 40%; box-shadow: 0 2px 0 rgba(0,0,0,.1); }
.bed .foot { position: absolute; left: -2%; bottom: 0; width: 6%; height: 28%; background: #a86f3d; border: 3px solid #7a4a22; border-radius: 6px; }
.bed .blanket { position: absolute; left: 4%; bottom: 8%; width: 58%; height: 36%; border-radius: 16px 24px 12px 12px; border: 3px solid rgba(0,0,0,.12);
  background: var(--bl); box-shadow: inset 0 6px 0 rgba(255,255,255,.35); }
.bed .blanket::after { content: ""; position: absolute; inset: 22% 8% auto 8%; height: 18%; border-radius: 50%; background: rgba(255,255,255,.35); }

.zz { position: fixed; z-index: 45; pointer-events: none; font: 800 20px var(--font); color: #fff; text-shadow: 0 0 6px #7f7be0, 0 1px 2px rgba(0,0,0,.4); }

/* School */
.btn.school { background: linear-gradient(#ffe08a, #ffc94a); }
#classroom { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .8s;
  background: linear-gradient(#fff1c9 0%, #ffe7a8 58%, #e0a96b 58%, #e0a96b 59.5%, #c98d55 59.5%) ; }
#classroom::after { content: ""; position: absolute; left: 0; right: 0; top: 59.5%; bottom: 0;
  background: repeating-linear-gradient(90deg, transparent 0 58px, rgba(110,62,25,.25) 58px 61px); }
#classroom .win { position: absolute; left: 4%; top: 10%; width: 18%; height: 22%; border: 6px solid #fff; border-radius: 8px;
  background: linear-gradient(#a8e4ff, #d9f5ff); box-shadow: inset 0 0 0 3px #e8d4a8, 0 3px 0 rgba(0,0,0,.1); }
#classroom .win::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 5px; margin-left: -2.5px; background: #fff; }
#scene.school #classroom { opacity: 1; }
#scene.school #sun, #scene.school .cloud, #scene.school .tree, #scene.school .lake, #scene.school .grass,
#scene.school .flower, #scene.school #mud { opacity: 0; transform: scale(.6); pointer-events: none; }
#scene .grass, #scene .lake, #scene .flower { transition: filter 1.2s, opacity .8s; }

#board { position: absolute; left: 30%; top: 7%; width: 62%; height: 34%; z-index: 1; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: radial-gradient(ellipse at 30% 30%, #3d7559, #2f5d46 70%); border: 9px solid #a86f3d; border-radius: 12px;
  box-shadow: inset 0 0 0 2px #7a4a22, 0 5px 0 rgba(0,0,0,.15); }
#scene.school #board { display: flex; animation: tubIn .6s cubic-bezier(.3, 1.6, .5, 1); }
#board .chalk { position: absolute; right: 10%; bottom: -9px; width: 26px; height: 6px; border-radius: 3px; background: #fff; }
#board .fruits { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px; min-height: 48px; padding: 0 6px; }
#board .fruit { position: relative; font-family: var(--emoji); font-size: min(38px, 9vw); line-height: 1.2; cursor: pointer; pointer-events: auto;
  animation: tubIn .4s cubic-bezier(.3, 1.6, .5, 1); }
#board .fruit[data-n]::after { content: attr(data-n); position: absolute; left: 50%; top: -12px; transform: translateX(-50%);
  font: 800 18px var(--font); color: #fff; text-shadow: 0 0 4px rgba(255,255,255,.6); }
#board .answer { font: 800 min(56px, 13vw) var(--font); color: #fff; line-height: 1; min-height: 1em; opacity: .95;
  text-shadow: 0 0 6px rgba(255,255,255,.5); }
#board .answer.show { animation: tubIn .5s cubic-bezier(.3, 1.6, .5, 1); }

#desksF { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.desk { position: absolute; width: 96px; height: 40px; transform: translate(-50%, -100%); transform-origin: 50% 100%;
  animation: tubIn .5s cubic-bezier(.3, 1.6, .5, 1) backwards; }
.desk.out { animation: bedOut .4s ease-in forwards; }
.desk .top { position: absolute; left: 0; right: 0; top: 0; height: 11px; border-radius: 5px; background: #d9945a; border: 3px solid #7a4a22; }
.desk .panel { position: absolute; left: 8%; right: 8%; top: 11px; height: 20px; background: #b8763f; border: 3px solid #7a4a22; border-top: 0; border-radius: 0 0 4px 4px; }
.desk .panel::before, .desk .panel::after { content: ""; position: absolute; bottom: -12px; width: 7px; height: 12px; background: #7a4a22; border-radius: 0 0 3px 3px; }
.desk .panel::before { left: 6%; } .desk .panel::after { right: 6%; }
#scene.school .capy-baby { width: 80px; }
.capy-teacher { width: 124px; }
