:root {
  --bg: #fff7e8;
  --ink: #3b2f2a;
  --card: #ffffff;
  --line: #f0dfc4;
  --good: #3fb36b;
  --sky: #4aa3df;
  --sun: #ffc93c;
  --soft: #8a7a70;
  --emoji: "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: Nunito, ui-rounded, system-ui, sans-serif; font-weight: 900;
  user-select: none; -webkit-user-select: none; overscroll-behavior: none; overflow: hidden;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
#app { height: 100dvh; display: flex; flex-direction: column; padding: max(14px, env(safe-area-inset-top)) 18px max(14px, env(safe-area-inset-bottom)); }

/* Start overlay: the first tap unlocks sound */
.start { flex: 1; display: grid; place-items: center; text-align: center; }
.start .owl { font-size: min(34vh, 40vw); font-family: var(--emoji); animation: bob 2.4s ease-in-out infinite; }
.bigbtn {
  background: var(--good); color: #fff; border-radius: 999px; padding: 22px 56px; font-size: 40px;
  box-shadow: 0 8px 0 #2a8a50; transition: transform .1s;
}
.bigbtn:active { transform: translateY(6px); box-shadow: 0 2px 0 #2a8a50; }

/* Home */
.home { flex: 1; display: grid; grid-template-rows: auto 1fr auto; gap: 12px; }
.hello { display: flex; align-items: center; gap: 14px; font-size: clamp(26px, 4.4vw, 44px); }
.hello .owl { font-family: var(--emoji); font-size: 1.8em; animation: bob 2.4s ease-in-out infinite; }
.hello .grow { flex: 1; }
.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; align-content: center; }
.game {
  background: var(--card); border-radius: 28px; padding: 16px 10px 14px; border: 4px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: clamp(20px, 3vw, 30px);
  box-shadow: 0 6px 0 var(--line); transition: transform .1s;
}
.game:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--line); }
.game .pic { font-family: var(--emoji); font-size: clamp(54px, 10vh, 96px); line-height: 1.1; }
.stickerbtn {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 4px solid var(--line);
  border-radius: 999px; padding: 8px 20px 8px 14px; font-size: 26px;
}
.stickerbtn .pic { font-family: var(--emoji); font-size: 34px; }

/* Play */
.play { flex: 1; display: grid; grid-template-rows: auto auto 1fr; gap: 10px; min-height: 0; }
.bar { display: flex; align-items: center; gap: 14px; }
.round {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-family: var(--emoji);
  font-size: 32px; background: var(--card); border: 4px solid var(--line); flex: none;
}
.speak { width: 96px; height: 96px; font-size: 50px; background: var(--sun); border-color: #f2b21a; }
.speak.on { animation: pulse 0.9s ease-in-out infinite; }
.dots { flex: 1; display: flex; justify-content: center; gap: 10px; }
.dots i { width: 22px; height: 22px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-style: normal; font-size: 16px; font-family: var(--emoji); }
.dots i.now { background: var(--sun); transform: scale(1.25); }
.dots i.ok { background: var(--good); }
.scene {
  justify-self: center; display: grid; grid-template-columns: repeat(5, auto); gap: 4px 10px;
  background: var(--card); border-radius: 24px; padding: 10px 22px; border: 4px dashed var(--line);
  font-family: var(--emoji); font-size: clamp(40px, 8vh, 72px); line-height: 1.15;
}
.scene:empty { display: none; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; align-content: center; min-height: 0; }
.card {
  position: relative; background: var(--card); border: 5px solid var(--line); border-radius: 30px;
  aspect-ratio: 1 / 1; max-height: 52vh; width: 100%; justify-self: center;
  display: grid; place-items: center; font-family: var(--emoji); font-size: clamp(64px, 13vw, 150px);
  box-shadow: 0 7px 0 var(--line); transition: transform .12s, opacity .4s, border-color .2s;
}
.cards.short .card { max-height: 30vh; font-size: clamp(54px, 10vw, 110px); }
.card.txt { font-family: Nunito, ui-rounded, sans-serif; font-size: clamp(70px, 14vw, 160px); }
.cards.short .card.txt { font-size: clamp(60px, 10vw, 120px); }
.card:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--line); }
.card.named { border-color: var(--sun); transform: scale(1.05); }
.card.right { border-color: var(--good); background: #e9f9ef; animation: hop .5s ease; }
.card.wrong { animation: shake .4s ease; }
.card.gone { opacity: .18; pointer-events: none; filter: grayscale(1); }
.card.hint { animation: hop 1s ease-in-out infinite; border-color: var(--sun); }
.card .ear {
  position: absolute; right: 8px; top: 8px; width: 46px; height: 46px; border-radius: 50%;
  background: var(--bg); font-size: 24px; display: grid; place-items: center;
}

/* Done */
.done { flex: 1; display: grid; place-items: center; text-align: center; gap: 12px; align-content: center; }
.done .sticker { font-family: var(--emoji); font-size: min(30vh, 36vw); animation: pop .7s cubic-bezier(.2,1.6,.4,1); }
.done h1 { margin: 0; font-size: clamp(30px, 5vw, 52px); }
.done .stars { font-family: var(--emoji); font-size: 40px; letter-spacing: 4px; }
.row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.bigbtn.sky { background: var(--sky); box-shadow: 0 8px 0 #2f7fb5; }

/* Sticker book */
.book { flex: 1; display: grid; grid-template-rows: auto 1fr; gap: 12px; min-height: 0; }
.book h1 { margin: 0; font-size: clamp(26px, 4vw, 40px); flex: 1; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; overflow: auto; align-content: start; }
.slot {
  aspect-ratio: 1; border-radius: 22px; background: var(--card); border: 4px dashed var(--line);
  display: grid; place-items: center; font-family: var(--emoji); font-size: 56px;
}
.slot.got { border-style: solid; }
.slot:not(.got) { color: var(--line); font-family: Nunito, sans-serif; font-size: 34px; }

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#confetti i { position: absolute; top: -40px; font-style: normal; font-family: var(--emoji); font-size: 34px; animation: fall linear forwards; }

@keyframes bob { 50% { transform: translateY(-10px) rotate(-3deg); } }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes hop { 40% { transform: translateY(-16px) scale(1.06); } }
@keyframes shake { 20%, 60% { transform: translateX(-12px); } 40%, 80% { transform: translateX(12px); } }
@keyframes pop { from { transform: scale(0); } }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

@media (orientation: portrait) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .card { max-height: 30vh; }
  .speak { width: 80px; height: 80px; font-size: 42px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
