:root {
  color-scheme: light;
  --cream: #F8F3E7;
  --card: #FFFCF5;
  --ink: #2D2D2B;
  --ink2: #4A473F;
  --blue: #B6CAEB;
  --blue-l: #EAF0F9;
  --blue-d: #9FB6E0;
  --olive: #9AAB65;
  --olive-l: #E1E6D1;
  --yellow: #F7D66E;
  --yellow-l: #FEEFBF;
  --pink: #FFB2DD;
  --pink-l: #FAE1E5;
  --r-lg: 28px;
  --r-md: 20px;
  --font: -apple-system, 'SF Pro Text', 'SF Pro Display', 'Inter', system-ui, sans-serif;
  --head: 'Unbounded', var(--font);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--cream); color: var(--ink); font-family: var(--font); font-weight: 500; }
body { overflow-x: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
button, a, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { -webkit-user-drag: none; }

#app {
  min-height: 100dvh;
  max-width: 1194px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 14px;
}

h1, h2, .head { font-family: var(--head); font-weight: 700; margin: 0; line-height: 1.2; }
h1 { font-size: 28px; }
h2 { font-size: 20px; font-weight: 600; }
.muted { color: var(--ink2); font-weight: 500; }
.small { font-size: 14px; }

/* buttons */
.btn { min-height: 64px; border: 0; border-radius: 999px; background: var(--blue); font-weight: 600; font-size: 22px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 28px; text-decoration: none; }
.btn:active { background: var(--blue-d); transform: scale(.98); }
.btn.secondary { background: var(--card); }
.btn.mic { background: var(--pink); }
.icon-btn { width: 52px; height: 52px; flex: none; border: 0; border-radius: 999px; background: var(--card); display: flex; align-items: center; justify-content: center; }
.icon-btn.accent { background: var(--blue); }
.icon-btn:active { transform: scale(.95); }
.bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 480px; align-self: center; }

.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.card { background: var(--card); border-radius: var(--r-lg); padding: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* progress */
.bar { height: 10px; min-height: 10px; border-radius: 5px; background: var(--olive-l); overflow: hidden; flex: 1 1 auto; }
.bar > span { display: block; height: 100%; border-radius: 5px; background: var(--olive); transition: width .4s; }

/* hero + speech bubble */
.hero { object-fit: contain; }
.bounce { animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }
.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: .3 } to { transform: scale(1); opacity: 1 } }
.shake { animation: shake .4s; }
@keyframes shake { 0%,100% { transform: translateX(0) } 25% { transform: translateX(-8px) } 75% { transform: translateX(8px) } }
.peek-l { animation: peekl .8s ease-out both; }
.peek-r { animation: peekr .8s ease-out .2s both; }
.peek-b { animation: peekb .8s ease-out .4s both; }
@keyframes peekl { from { transform: translateX(-120%) rotate(12deg) } to { transform: translateX(0) rotate(12deg) } }
@keyframes peekr { from { transform: translateX(120%) rotate(-14deg) } to { transform: translateX(0) rotate(-14deg) } }
@keyframes peekb { from { transform: translateY(120%) } to { transform: translateY(0) } }

.say { display: flex; align-items: center; gap: 4px; }
.bubble { background: var(--card); border-radius: 22px; padding: 10px 14px; font-weight: 600; font-size: 17px; line-height: 1.3; }
.bubble .en { font-weight: 600; font-size: 19px; }

/* tiles & images */
.tile { border: 0; border-radius: 26px; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px; position: relative; }
.tile:active { transform: scale(.97); }
.tile.locked { opacity: .55; }
.tile.right { box-shadow: 0 0 0 5px var(--olive); }
.tile.wrong { box-shadow: 0 0 0 5px var(--pink); }
.pic { width: 100%; height: 100%; object-fit: contain; }
.ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 26px; color: var(--ink2); text-align: center; }
.badge { position: absolute; top: 8px; left: 8px; background: var(--blue); border-radius: 999px; padding: 2px 10px; font-weight: 600; font-size: 12px; }
.check { position: absolute; top: 8px; right: 8px; }

.word { font-weight: 700; font-size: 52px; line-height: 1; }

/* steps strip */
.steps { display: flex; gap: 6px; }
.steps > * { flex: 1; text-align: center; padding: 6px 0; border: 0; border-radius: 14px; background: var(--card); font: inherit; font-weight: 500; font-size: 13px; color: var(--ink2); cursor: pointer; }
.steps > .done { background: var(--olive-l); color: var(--ink); }
.steps > .on { background: var(--blue); color: var(--ink); font-weight: 600; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .d { position: relative; aspect-ratio: 1; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; overflow: hidden; background: var(--cream); color: var(--ink2); }
.cal .d.past { background: #EDE8DA; color: #6E6A60; }
.cal .d.today { background: var(--card); box-shadow: inset 0 0 0 3px var(--blue); color: var(--ink); }
.cal .d.waiting { box-shadow: 0 0 0 3px var(--blue); }
.cal .d.waiting img { opacity: .45; filter: grayscale(.6); }
/* on a wide screen the month stays phone-sized instead of huge tiles */
.cal-card { width: 100%; max-width: 520px; align-self: center; }
/* a day with English: the hero's face close up fills the tile */
.cal .d.face img { width: 100%; height: 100%; object-fit: cover; transform: scale(2.1); transform-origin: 54% 54%; }
.cal .d.face .face-date { position: absolute; top: 3px; left: 5px; font-size: 10px; font-weight: 700; color: rgba(255,255,255,.9); text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.cal .wd { text-align: center; font-weight: 600; font-size: 12px; color: var(--ink2); }

/* seg control */
.seg { display: flex; background: var(--cream); border-radius: 999px; padding: 4px; }
.seg button { min-height: 48px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; font-weight: 600; font-size: 14px; }
.seg button[aria-checked="true"] { background: var(--blue); }
.choice { border: 0; border-radius: 20px; background: var(--cream); padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; }
.choice[aria-checked="true"] { background: var(--blue-l); box-shadow: 0 0 0 3px var(--blue); }

input.text { min-height: 52px; border: 2px solid var(--olive-l); border-radius: 18px; background: var(--card); padding: 0 16px; font-weight: 600; font-size: 20px; width: 100%; -webkit-user-select: text; user-select: text; }

/* feed game */
.stage { position: relative; flex: 1; min-height: 300px; overflow: hidden; margin: 0 -20px; }
.drop { border: 4px dashed rgba(45,45,43,.35); border-radius: 999px; }
.food { touch-action: none; }
.dragging { position: fixed; z-index: 10; pointer-events: none; transform: scale(1.1); }
/* while dragging, only the picture moves — no tile background or border */
.dragging.tile { background: transparent !important; box-shadow: none !important; border: 0 !important; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 8px; border-radius: 3px; animation: fall 1.8s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg) } }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: var(--card); border-radius: 999px; padding: 10px 18px; font-weight: 600; font-size: 14px; z-index: 20; }

/* iPad / wide: two columns where screens opt in */
@media (min-width: 820px) {
  #app { padding-left: 40px; padding-right: 40px; }
  .wide-2 { display: grid; grid-template-columns: 5fr 6fr; gap: 36px; align-items: center; flex: 1; }
  .grid-themes { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .word { font-size: 64px; }
}

/* Reduce Motion (HIG Motion: make motion optional) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .confetti { display: none; }
}
/* M3 medium window (600–819): keep content readable instead of stretching */
@media (min-width: 600px) and (max-width: 819px) {
  #app { max-width: 640px; padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
  .grid-themes { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

/* counting: digit + items */
.count-row { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; height: 100%; }
.count-grid { display: grid; gap: 4px; justify-content: center; align-content: center; }
.count-dot { border-radius: 50%; background: var(--yellow); }
.count-empty { border: 3px dashed var(--ink2); border-radius: 50%; opacity: .35; }
.count-grid img { animation-fill-mode: both; }
.ord-row { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; }
.ord-row .ord-off { opacity: .35; }
.ord-row .ord-on { transform: scale(1.6); transform-origin: bottom center; margin: 0 6px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.15)); }
.week-strip { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.week-day { border-radius: 12px; background: var(--blue); opacity: .35; }
.week-day.weekend { background: var(--pink); }
.week-day.on { opacity: 1; transform: scale(1.45); margin: 0 8px; box-shadow: 0 4px 10px rgba(0,0,0,.12); }

/* «Подскажи» in the hero's bubble: a tap shows the Russian translation */
.bubble.hint { border: 0; cursor: pointer; font: inherit; font-weight: 600; font-size: 19px; color: var(--ink); box-shadow: 0 0 0 3px var(--blue); }
.bubble.hint.shown { box-shadow: none; cursor: default; }

/* Russian translation button in the hero's bubble */
.icon-btn.ru { width: 42px; height: 42px; background: var(--pink); }
.bubble.row .en { flex: 1; }

/* mini-games: the target hops when it gets the right item */
.goal { display: flex; align-items: center; justify-content: center; }
.goal.hop { animation: hop .45s ease-out; }
@keyframes hop { 0% { transform: translateY(0) scale(1) } 35% { transform: translateY(-22px) scale(1.06) } 70% { transform: translateY(0) scale(.97) } 100% { transform: translateY(0) scale(1) } }

/* game cards on the topic screen: tall coloured cards, three in a row */
.game-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.game-card { position: relative; display: flex; flex-direction: column; aspect-ratio: .76; padding: 0 12px 12px; border-radius: 20px; overflow: hidden; text-decoration: none; color: var(--ink); transition: transform .12s; }
.game-card:active { transform: scale(.97); }
.game-cover { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; margin: 0 -12px 6px; }
.game-cover img { width: 84%; height: 84%; object-fit: contain; }
.game-name { font-weight: 600; font-size: 15px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.game-hint { font-size: 13px; font-weight: 500; color: rgba(45,45,43,.6); margin-top: 2px; }
.game-lock { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 999px; background: var(--card); display: flex; align-items: center; justify-content: center; }
.game-card.soon { filter: grayscale(1); opacity: .55; }
@media (min-width: 600px) { .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 820px) { .game-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; } }

/* «Pop the balloon!»: balloons with pictures float up the stage */
.pop-stage { position: relative; flex: 1; min-height: 420px; overflow: hidden; border-radius: 32px; background: linear-gradient(var(--blue-l), var(--card)); }
.balloon { position: absolute; border: 0; padding: 0; background: none; display: flex; flex-direction: column; align-items: center; touch-action: manipulation; cursor: pointer; }
.balloon-body { width: 100%; aspect-ratio: 1 / 1.1; border-radius: 50% 50% 48% 48%; background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.7), var(--c) 42%); display: flex; align-items: center; justify-content: center; box-shadow: inset -6px -8px 0 rgba(0,0,0,.08), 0 0 0 1.5px rgba(45,45,43,.15); animation: sway 3s ease-in-out infinite; }
.balloon-body img { width: 66%; height: 66%; object-fit: contain; pointer-events: none; }
.balloon-string { width: 2px; flex: 1; min-height: 18px; background: rgba(45,45,43,.35); }
.balloon.popped .balloon-body { animation: burst .35s ease-out forwards; }
.balloon.popped .balloon-string { opacity: 0; }
.balloon.wobble .balloon-body { animation: shake .4s; }
@keyframes sway { 0%,100% { transform: rotate(-4deg) } 50% { transform: rotate(4deg) } }
@keyframes burst { 0% { transform: scale(1) } 30% { transform: scale(1.25) } 100% { transform: scale(1.6); opacity: 0 } }
.burst-ring { position: absolute; transform: translate(-50%, -50%); border: 6px solid; border-radius: 50%; pointer-events: none; animation: ring .45s ease-out forwards; }
@keyframes ring { from { transform: translate(-50%, -50%) scale(.6); opacity: .9 } to { transform: translate(-50%, -50%) scale(1.8); opacity: 0; border-width: 1px } }
.burst-bit { position: absolute; width: 10px; height: 14px; pointer-events: none; }

/* «Найди пару»: cards flip to show the picture */
.memory-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .memory-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.memory-card { position: relative; aspect-ratio: 1; border: 0; padding: 0; background: none; perspective: 600px; cursor: pointer; }
.memory-back, .memory-face { position: absolute; inset: 0; border-radius: 20px; display: flex; align-items: center; justify-content: center; backface-visibility: hidden; transition: transform .35s; }
.memory-back { background: var(--blue); box-shadow: inset 0 0 0 6px var(--blue-l); }
.memory-face { background: var(--card); padding: 8px; transform: rotateY(180deg); }
.memory-card.open .memory-back { transform: rotateY(180deg); }
.memory-card.open .memory-face { transform: rotateY(360deg); }
.memory-card.matched .memory-face { box-shadow: 0 0 0 4px var(--olive); }

/* «Что пропало?»: a row of pictures under a curtain */
.missing-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; border-radius: 32px; background: var(--blue-l); }
.missing-item { aspect-ratio: 1; border-radius: 16px; background: var(--card); padding: 6px; display: flex; align-items: center; justify-content: center; }
.missing-item.empty { background: var(--cream); box-shadow: inset 0 0 0 3px var(--blue); }
.missing-curtain { position: absolute; inset: 0; border-radius: 32px; background: var(--yellow-l); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; opacity: 0; pointer-events: none; transition: opacity .3s; }
.missing-curtain.on { opacity: 1; }
