:root {
  --bg1: #fff4d6;
  --bg2: #ffe0ec;
  --ink: #3d2c5e;
  --soft: #8a7aa8;
  --card: #ffffff;
  --line: #f0e4ff;
  --good: #3ccf7a;
  --bad: #ff6b6b;
  --gold: #ffb800;
  --shadow: 0 6px 0 rgba(61, 44, 94, .12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
  font-weight: 800;
  color: var(--ink);
  background: linear-gradient(170deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; background: none; }

#app {
  position: relative;
  max-width: 560px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
}
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
  gap: 12px;
}
.screen.on { display: flex; animation: fadeIn .25s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }

/* ─── Сова с репликой ─── */
.owl-row { display: flex; align-items: center; gap: 10px; }
.owl { font-size: 64px; line-height: 1; flex: none; animation: bob 2.6s ease-in-out infinite; }
.owl-row.small .owl { font-size: 46px; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-4deg); } }
.owl.happy { animation: hop .5s ease-out; }
@keyframes hop { 40% { transform: translateY(-14px) scale(1.12); } }
.bubble {
  position: relative; flex: 1;
  background: var(--card); border-radius: 20px;
  padding: 12px 16px; font-size: 20px; line-height: 1.25;
  box-shadow: var(--shadow);
}
.owl-row.small .bubble { font-size: 19px; padding: 10px 14px; }
.bubble::before {
  content: ""; position: absolute; left: -9px; top: 50%; margin-top: -9px;
  border: 9px solid transparent; border-right-color: var(--card); border-left: 0;
}

/* ─── Главная ─── */
.logo .age { font-size: 14px; vertical-align: middle; color: #fff; background: var(--soft); border-radius: 8px; padding: 2px 6px; text-shadow: none; letter-spacing: 0; }
.logo {
  margin: 4px 0 0; text-align: center; font-size: 40px; font-weight: 900; letter-spacing: 1px;
  color: #ff6fa8; text-shadow: 0 3px 0 #fff, 0 6px 0 rgba(61,44,94,.12);
}
.tiles { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: center; }
.tile {
  border-radius: 24px; padding: 14px 8px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: #fff; font-size: 19px; text-shadow: 0 2px 0 rgba(0,0,0,.15);
  box-shadow: 0 6px 0 rgba(0,0,0,.14);
  transition: transform .1s;
  min-height: 118px; justify-content: center;
}
.tile:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.14); }
.tile .ic { font-size: 48px; line-height: 1.1; text-shadow: none; }
.tile .ic.abc { font-size: 26px; font-weight: 900; background: #fff; color: #2b7fd1; border-radius: 12px; padding: 8px 10px; margin: 6px 0 4px; letter-spacing: 1px; }
.tile .st { font-size: 14px; opacity: .95; letter-spacing: 1px; }

.home-bottom { display: flex; gap: 10px; align-items: center; }
.pill {
  flex: 1; background: var(--card); border-radius: 999px;
  padding: 14px 18px; font-size: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .1s;
}
.pill:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(61,44,94,.12); }
.pill { white-space: nowrap; }
.pill b { background: var(--gold); color: #fff; border-radius: 999px; padding: 0 10px; font-size: 17px; }
.pill.go { background: var(--good); color: #fff; }
.round-btn {
  width: 52px; height: 52px; flex: none; border-radius: 50%;
  background: var(--card); font-size: 24px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.round-btn:active { transform: translateY(3px); }

/* ─── Верхняя полоса ─── */
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar h1 { flex: 1; margin: 0; text-align: center; font-size: 24px; font-weight: 900; }
.topbar .spacer { width: 52px; flex: none; }
.dots { flex: 1; display: flex; justify-content: center; gap: 8px; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: rgba(61,44,94,.15); transition: background .3s, transform .3s; }
.dot.now { background: var(--gold); transform: scale(1.25); }
.dot.done { background: var(--good); }

/* ─── Уровни ─── */
.level-list { flex: 1; display: flex; flex-direction: column; gap: 12px; justify-content: center; }
.level {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: 22px; padding: 12px 16px;
  box-shadow: var(--shadow); font-size: 22px; text-align: left;
}
.level:active { transform: translateY(3px); }
.level .num {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 26px; font-weight: 900;
}
.level .lbl { flex: 1; }
.level .stars { font-size: 22px; letter-spacing: 2px; }
.level.locked { opacity: .5; }
.level.locked .num { background: #c9bfd9 !important; }

/* ─── Сцена задания ─── */
.scene { display: flex; align-items: center; justify-content: center; flex: 1; min-height: 0; }
.scene:empty { display: none; }
.pile {
  display: flex; flex-wrap: wrap; justify-content: center; align-content: center;
  gap: 6px; background: var(--card); border-radius: 26px; padding: 14px;
  box-shadow: var(--shadow); max-width: 100%;
}
.pile span { line-height: 1.1; animation: popIn .3s backwards; }
.sum { display: flex; align-items: center; gap: 10px; }
.sum .plus { font-size: 44px; color: var(--soft); }
.sum .pile { max-width: 42vw; }
.big-pic { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.big-pic .pic { font-size: 120px; line-height: 1.1; background: var(--card); border-radius: 36px; padding: 10px 26px; box-shadow: var(--shadow); animation: popIn .35s; }
.big-pic .cap { font-size: 40px; letter-spacing: 6px; font-weight: 900; }
.seq { display: flex; flex-wrap: nowrap; justify-content: center; gap: 6px; background: var(--card); border-radius: 26px; padding: 14px; box-shadow: var(--shadow); }
.seq span { line-height: 1.15; text-align: center; flex: none; animation: popIn .3s backwards; }
.seq span.q { color: var(--gold); font-weight: 900; border: 3px dashed var(--gold); border-radius: 14px; }
.seq.text span { font-weight: 900; }
@keyframes popIn { from { transform: scale(.3); opacity: 0; } }

/* ─── Варианты ─── */
.options { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; padding-bottom: 6px; }
.opt {
  min-width: 84px; height: 92px; padding: 0 16px; flex: 1 1 0; max-width: 140px;
  background: var(--card); border-radius: 24px; box-shadow: 0 6px 0 rgba(61,44,94,.14);
  font-size: 46px; font-weight: 900; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, opacity .3s, background .2s;
}
.opt:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(61,44,94,.14); }
.opt.emoji { font-size: 54px; }
.opt.right { background: var(--good); color: #fff; animation: pop .45s; }
.opt.wrong { animation: shake .4s; background: #ffe1e1; }
.opt.gone { opacity: .35; pointer-events: none; }
@keyframes pop { 40% { transform: scale(1.15); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.options.four .opt { flex: 0 0 calc(50% - 6px); max-width: 180px; }
.options.panels { flex: 1; align-items: center; flex-wrap: nowrap; }
.options.panels .opt { flex: 1; max-width: none; height: min(48vh, 360px); padding: 10px; }
.panel-items { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 4px; font-size: min(44px, 9.5vw); }
.options.panels .opt { overflow: hidden; }
/* Сцены нет — варианты сами становятся сценой: крупно и по центру. */
.solo .options { flex: 1; align-content: center; }
.solo .opt { height: 118px; max-width: 150px; }
.solo .opt.emoji { font-size: 66px; }
.solo .opt:not(.emoji) { font-size: 60px; }
.with-panels .scene { display: none; }

/* ─── Найди пару ─── */
.board { display: grid; gap: 10px; width: 100%; max-width: 480px; margin: 0 auto; }
.card { aspect-ratio: 3 / 4; perspective: 600px; }
.card .in { position: relative; width: 100%; height: 100%; transition: transform .35s; transform-style: preserve-3d; }
.card.open .in { transform: rotateY(180deg); }
.card .f, .card .b {
  position: absolute; inset: 0; border-radius: 18px; backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.card .b { background: repeating-linear-gradient(45deg, #b07cff, #b07cff 10px, #c39bff 10px, #c39bff 20px); font-size: 34px; }
.card .f { background: var(--card); transform: rotateY(180deg); font-size: min(12vw, 56px); }
.card.done .f { background: #dbffe9; }
.card.done { animation: pop .45s; }

/* ─── Итог ─── */
.result-box { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; }
.big-stars { font-size: 64px; letter-spacing: 6px; }
.big-stars span { display: inline-block; animation: starIn .5s backwards; }
.big-stars span.off { filter: grayscale(1); opacity: .3; }
@keyframes starIn { from { transform: scale(0) rotate(-180deg); } }
.result-text { font-size: 26px; }
.sticker-reveal { display: flex; gap: 16px; justify-content: center; min-height: 10px; }
.sticker-new { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 18px; animation: spinIn .8s backwards; }
.sticker-new .s { font-size: 72px; width: 120px; height: 120px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 6px var(--gold), var(--shadow); }
@keyframes spinIn { from { transform: scale(0) rotate(-360deg); opacity: 0; } }
.result-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; }

/* ─── Альбом ─── */
.album-note { text-align: center; font-size: 18px; color: var(--soft); }
.album-grid {
  flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px; align-content: start; padding: 4px 2px 10px;
}
.slot {
  aspect-ratio: 1; border-radius: 50%; background: rgba(255,255,255,.55);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; border: 3px dashed rgba(61,44,94,.15);
}
.slot.have { background: #fff; border: 3px solid var(--gold); box-shadow: var(--shadow); }
.slot.locked { color: rgba(61,44,94,.2); font-size: 28px; }
.slot.have:active { transform: scale(1.1); }

@media (max-height: 640px) {
  .logo { font-size: 28px; margin: 0; }
  .pill { font-size: 18px; padding: 12px 14px; }
  .owl { font-size: 48px; }
  .owl-row.small .owl { font-size: 36px; }
  .bubble, .owl-row.small .bubble { font-size: 17px; padding: 8px 12px; }
  .tile { min-height: 96px; }
  .tile .ic { font-size: 40px; }
  .opt { height: 76px; font-size: 38px; }
  .opt.emoji { font-size: 44px; }
  .big-pic .pic { font-size: 90px; }
}

/* ─── Золотой альбом ─── */
.gold-head { grid-column: 1 / -1; text-align: center; font-size: 22px; font-weight: 900; color: #c98a00; margin-top: 14px; }
.gold-buy { grid-column: 1 / -1; background: linear-gradient(180deg, #ffd34d, #ffb800); color: #5a3b00;
  border-radius: 999px; padding: 12px 16px; font-size: 18px; box-shadow: var(--shadow); white-space: nowrap; }
.slot.gold.have { border-color: #ffb800; background: radial-gradient(circle, #fff 55%, #fff1c2); }
.slot.gold.locked { color: #e6b800; border-color: rgba(230,184,0,.35); }

/* ─── Замок для взрослых ─── */
.gate { position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(61,44,94,.45); padding: 16px; z-index: 10; }
.gate.on { display: flex; }
.gate-box { background: #fff; border-radius: 24px; padding: 20px 18px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 10px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.gate-title { font-size: 22px; font-weight: 900; }
.gate-text { font-size: 16px; color: var(--soft); line-height: 1.35; }
.gate-q { font-size: 34px; font-weight: 900; }
.gate-in { font: inherit; font-size: 28px; text-align: center; border: 3px solid var(--line); border-radius: 16px;
  padding: 8px; width: 120px; margin: 0 auto; color: var(--ink); }
.gate-err { min-height: 20px; color: var(--bad); font-size: 15px; }
.gate-btns { display: flex; gap: 10px; }
