:root {
  --sky-top: #8fd3ff;
  --sky-bottom: #dff4ff;
  --grass: #7ccf6b;
  --grass-dark: #4fa64a;
  --soil: #a0704a;
  --soil-dark: #7a5233;
  --ink: #23324a;
  --card: #ffffffee;
  --accent: #ff8a3d;
  --accent-dark: #d96a20;
  --good: #3bb273;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --tap: 80px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(var(--sky-top), var(--sky-bottom) 60%, var(--grass) 60%, var(--grass-dark));
  background-attachment: fixed;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app { min-height: 100dvh; display: flex; }

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}
.screen.active { display: flex; }

button { font-family: inherit; color: inherit; cursor: pointer; border: 0; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }
svg { display: block; }

.title {
  font-size: clamp(32px, 8vw, 56px);
  margin: 8px 0 0;
  color: #fff;
  text-shadow: 0 3px 0 #3d8fc4, 0 6px 12px #0003;
  letter-spacing: 1px;
}

.garden {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 64px;
  max-width: 100%;
}
.garden .friend { width: 56px; height: 56px; animation: float 3s ease-in-out infinite; }
.garden .friend:nth-child(2n) { animation-delay: -1.2s; }
.garden .empty { opacity: .25; animation: none; }

.stages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 640px;
}
.stage-btn {
  position: relative;
  min-height: 112px;
  border-radius: 28px;
  background: var(--card);
  box-shadow: 0 6px 0 #0002;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 36px;
  font-weight: 800;
  transition: transform .1s;
}
.stage-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #0002; }
.stage-btn svg { width: 48px; height: 48px; }
.stage-btn[disabled] { opacity: .55; cursor: default; }
.stage-btn .lock { position: absolute; top: 8px; right: 10px; width: 24px; height: 24px; }
.stage-btn.done::after {
  content: "";
  position: absolute; top: 8px; right: 10px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--good) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12l5 5 9-10' stroke='white' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center/16px no-repeat;
}

.grownups {
  margin-top: auto;
  background: #ffffffaa;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  min-height: 44px;
}

.bar { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 8px; }
.icon-btn, .big-btn {
  width: var(--tap); height: var(--tap);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 5px 0 #0002;
  display: grid; place-items: center;
}
.icon-btn svg { width: 40px; height: 40px; }
.big-btn { width: 112px; height: 112px; background: var(--accent); color: #fff; box-shadow: 0 6px 0 var(--accent-dark); }
.big-btn svg { width: 56px; height: 56px; }

.dots { display: flex; gap: 8px; }
.dot { width: 22px; height: 22px; border-radius: 50%; background: #ffffff88; border: 3px solid #fff; }
.dot.on { background: var(--good); }

.prompt {
  margin: 0;
  font-size: clamp(22px, 5vw, 34px);
  font-weight: 800;
  text-align: center;
  background: var(--card);
  padding: 10px 20px;
  border-radius: 20px;
  min-height: 1.6em;
}

.scene {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.bed {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 6px;
  padding: 16px;
  border-radius: 28px;
  background: var(--soil);
  box-shadow: inset 0 -8px 0 var(--soil-dark);
  max-width: 100%;
}
.bed .flower { width: 64px; height: 64px; }
.bed.small .flower { width: 40px; height: 40px; }

.patches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--tap), 1fr));
  gap: 8px;
  width: 100%;
  max-width: 560px;
}
.patch {
  aspect-ratio: 1;
  min-height: var(--tap);
  border-radius: 24px;
  background: var(--soil);
  box-shadow: inset 0 -8px 0 var(--soil-dark);
  display: grid; place-items: center;
}
.patch .flower { width: 80%; height: 80%; }
.patch .hole { width: 40%; height: 18%; border-radius: 50%; background: var(--soil-dark); }

.compare { display: flex; gap: 12px; width: 100%; justify-content: center; flex-wrap: wrap; }
.compare .bed { flex: 1 1 240px; min-height: 160px; max-width: 420px; }
.compare button.bed { cursor: pointer; }

.answers { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; min-height: var(--tap); }
.num-btn {
  min-width: 96px; height: 96px;
  border-radius: 28px;
  background: var(--card);
  box-shadow: 0 6px 0 #0002;
  font-size: 52px;
  font-weight: 900;
}
.can-btn { background: #6cc4ff; color: #fff; box-shadow: 0 6px 0 #3d8fc4; width: 112px; height: 96px; border-radius: 28px; display: grid; place-items: center; }
.can-btn svg { width: 64px; height: 64px; }

.flower { transform-origin: 50% 100%; }
.flower.grow { animation: grow .45s cubic-bezier(.3, 1.6, .5, 1); }
.flower.new { animation: grow .45s cubic-bezier(.3, 1.6, .5, 1), glow 1.2s ease-in-out 2; }
.flower.lit { animation: bounce .4s; filter: drop-shadow(0 0 8px #fff); }
.counter-badge { font-size: 64px; font-weight: 900; color: #fff; text-shadow: 0 4px 0 #0003; width: 100%; text-align: center; }

.wiggle { animation: wiggle .5s; }
.yay { animation: bounce .5s; }

.reward-art { width: min(60vw, 260px); aspect-ratio: 1; margin-top: 10vh; animation: float 3s ease-in-out infinite; }
.reward-art svg { width: 100%; height: 100%; }

.panel {
  background: #fff;
  border-radius: 24px;
  padding: 20px;
  max-width: 520px;
  width: 100%;
  margin-top: 8vh;
  font-size: 17px;
  line-height: 1.5;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 10px 30px #0002;
}
.panel h2 { margin: 0; }
.panel ul, .panel p { margin: 0; }
.text-btn { background: var(--accent); color: #fff; font-weight: 800; font-size: 17px; padding: 12px 18px; border-radius: 14px; min-height: 48px; }
.text-btn.ghost { background: #eef3f8; color: var(--ink); }
.link { color: #1d6fb8; font-weight: 700; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.toggle input { width: 24px; height: 24px; }

.hold-btn { position: relative; overflow: hidden; height: 64px; border-radius: 16px; background: #eef3f8; font-weight: 800; font-size: 18px; }
.hold-fill { position: absolute; inset: 0; width: 0; background: #ffd2b0; }
.hold-btn.holding .hold-fill { width: 100%; transition: width var(--hold, 3s) linear; }
.hold-label { position: relative; }
.gate-form { display: flex; flex-direction: column; gap: 8px; }
.gate-form[hidden] { display: none; }
.gate-form input { font-size: 24px; padding: 10px; border-radius: 12px; border: 2px solid #c9d6e3; }

@keyframes grow { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes bounce { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.25); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes glow { 50% { filter: drop-shadow(0 0 10px #fff6a0); } }
@keyframes float { 50% { transform: translateY(-8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .title { font-size: 28px; margin: 0; }
  .reward-art { margin-top: 0; width: 160px; }
  .stage-btn { min-height: 96px; }
  .bed .flower { width: 48px; height: 48px; }
  .num-btn, .can-btn { height: 84px; }
}
a.text-btn { text-decoration: none; text-align: center; }
