/* Стили развивашки №1. Мобильный приоритет, крупные тапающиеся элементы. */

:root {
  --gelimo-pink: #ff5e8a;
  --gelimo-cream: #fff8ee;
  --gelimo-blue: #4ec1f5;
  --gelimo-yellow: #ffd23f;
  --gelimo-green: #6dd47e;
  --gelimo-text: #2b2640;
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: "Nunito", "Comic Sans MS", system-ui, sans-serif;
  color: var(--gelimo-text);
  background: linear-gradient(180deg, #ffe6f0 0%, #ffe9c8 100%);
  overflow: hidden; user-select: none; -webkit-user-select: none;
}

#app { position: fixed; inset: 0; }

.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column; padding: 16px;
  animation: fadein 0.4s ease;
}
.screen.active { display: flex; }
@keyframes fadein { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* Стартовый и финальный экраны */
#screen-intro, #screen-reward { align-items: center; justify-content: center; text-align: center; position: relative; }

/* Маскот — Pixar-style PNG-иллюстрация. Сохраняем bob-анимацию.
   width:auto + max-height — пропорциональное вписывание под высоту экрана. */
.mascot {
  width: auto;
  height: auto;
  max-width: 60vw;
  max-height: 42vh;
  display: block;
  filter: drop-shadow(0 12px 24px rgba(255, 94, 138, 0.35));
  margin-bottom: 8px;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}
.mascot.bob { animation: bob 2.4s ease-in-out infinite; transform-origin: center bottom; }
.mascot svg { width: 100%; height: 100%; display: block; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-14px) rotate(3deg); }
}

h1 { font-size: 56px; margin: 16px 0 0; color: var(--gelimo-pink); letter-spacing: 1px; }
h2 { font-size: 40px; margin: 16px 0 4px; color: var(--gelimo-pink); }
.subtitle { font-size: 22px; margin: 4px 0 32px; opacity: 0.7; }

.big-btn {
  background: var(--gelimo-pink); color: white; border: none;
  font-size: 28px; font-weight: 800; padding: 18px 48px; border-radius: 999px;
  box-shadow: 0 6px 0 #d44671, 0 12px 24px rgba(255, 94, 138, 0.35);
  cursor: pointer; transition: transform 0.1s; font-family: inherit;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #d44671, 0 4px 8px rgba(255, 94, 138, 0.35); }

/* Плашка задания и кнопок управления */
.task-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: white;
  padding: 10px 12px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  margin-bottom: 12px;
  flex-shrink: 0;
}
.task-bar-side {
  display: flex; align-items: center; gap: 8px;
}
.task-bar-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; min-width: 0;
}
.task-text {
  font-weight: 800; font-size: 16px; line-height: 1.2;
  text-align: center;
  color: var(--gelimo-text);
  overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
@media (min-width: 480px) {
  .task-text { font-size: 18px; }
}

/* Прогресс-бар из звёздочек — заполняется по мере правильных тапов */
.progress-stars {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 18px;
}
.star {
  width: 16px; height: 16px;
  background-color: rgba(43, 38, 64, 0.18);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2.5l2.9 6.6 7.1.7-5.4 4.8 1.6 7-6.2-3.7L5.8 21.6l1.6-7L2 9.8l7.1-.7z'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2.5l2.9 6.6 7.1.7-5.4 4.8 1.6 7-6.2-3.7L5.8 21.6l1.6-7L2 9.8l7.1-.7z'/></svg>") center/contain no-repeat;
  transition: background-color 0.3s ease, transform 0.3s ease;
}
.star.lit {
  background-color: var(--gelimo-yellow);
  filter: drop-shadow(0 0 6px rgba(255, 210, 63, 0.7));
  animation: star-pop 0.4s ease;
}
@keyframes star-pop {
  0%   { transform: scale(0.6); }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Универсальная круглая кнопка управления игрой */
.ctrl-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; cursor: pointer;
  background: var(--gelimo-pink);
  color: white;
  box-shadow: 0 3px 0 #d44671, 0 4px 10px rgba(255, 94, 138, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.ctrl-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 #d44671, 0 6px 14px rgba(255, 94, 138, 0.32); }
.ctrl-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #d44671, 0 2px 6px rgba(255, 94, 138, 0.25); }
.ctrl-btn svg { width: 20px; height: 20px; display: block; }
.ctrl-btn.muted { opacity: 0.5; }
.ctrl-btn-primary {
  width: 48px; height: 48px;
  box-shadow: 0 4px 0 #d44671, 0 6px 14px rgba(255, 94, 138, 0.35);
}
.ctrl-btn-primary svg { width: 22px; height: 22px; }
.ctrl-btn-primary:active { box-shadow: 0 1px 0 #d44671, 0 3px 8px rgba(255, 94, 138, 0.3); }

/* Подсказка — золотое свечение через 10 сек простоя */
.obj.hint { animation: hint-pulse 0.8s ease-in-out 3; z-index: 5; }
@keyframes hint-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 3px 4px rgba(0,0,0,0.2)); }
  50% { transform: scale(1.3); filter: drop-shadow(0 0 24px #ffd700) drop-shadow(0 0 8px #ffaa00); }
}
[data-diff].hint, [data-item].hint {
  fill: rgba(255, 215, 0, 0.5) !important;
  stroke: #ffd700; stroke-width: 6;
  animation: hint-svg 0.8s ease-in-out 3;
}
@keyframes hint-svg {
  0%, 100% { stroke-opacity: 0.5; fill-opacity: 0.3; }
  50% { stroke-opacity: 1; fill-opacity: 0.6; }
}

/* Универсальная игровая область */
.play-area { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }

/* Поле для разбросанных объектов (игры с шариками и неправильными цветами) */
.play-field {
  flex: 1; position: relative;
  background: white; border-radius: 24px;
  box-shadow: inset 0 0 0 4px rgba(255,94,138,0.15);
  overflow: hidden;
}

/* Объект на поле (мороженое-шарик в SVG или эмодзи) */
.obj {
  position: absolute; width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; cursor: pointer; transition: transform 0.15s;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.2));
}
.obj svg { width: 100%; height: 100%; }
.ice-img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;       /* клики и pointerdown идут на родительский .obj */
  -webkit-user-drag: none;     /* запрет drag-картинки (Safari/Chrome) */
  user-select: none;
}
.obj:active { transform: scale(0.92); }
.obj.found { animation: pop 0.5s ease forwards; pointer-events: none; }
.obj.shake { animation: shake 0.4s; }
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.5) rotate(15deg); filter: drop-shadow(0 0 24px gold); }
  100% { transform: scale(1.15); filter: drop-shadow(0 0 12px gold); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-5deg); }
  75% { transform: translateX(8px) rotate(5deg); }
}

/* Игра «Найди отличия»: две сцены друг над другом */
.diff-stack { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.diff-scene {
  flex: 1; background: linear-gradient(180deg, #b8e3ff 0%, #d6f5d3 100%);
  border-radius: 20px; position: relative; overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.diff-scene svg { width: 100%; height: 100%; display: block; }

/* Сцена «Найди отличия / Найди предмет»: <image> и rect-hit-зоны внутри
   одного SVG с общим viewBox 1024×1024 — координаты hit-зон гарантированно
   совпадают с положением объектов на картинке при любом масштабировании. */
.scene-svg {
  width: 100%; height: 100%;
  display: block;
}
[data-diff], [data-item] { transition: fill 0.2s; }
[data-diff].found, [data-item].found {
  fill: rgba(255, 94, 138, 0.35) !important;
  stroke: var(--gelimo-pink); stroke-width: 4;
  pointer-events: none; animation: pulse-svg 0.5s ease;
}
[data-item].shake { animation: shake-svg 0.4s; }
@keyframes pulse-svg { 0% { stroke-opacity: 0; } 100% { stroke-opacity: 1; } }
@keyframes shake-svg {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Одна сцена для игры «Найди предмет» */
.single-scene {
  flex: 1; background: linear-gradient(180deg, #b8e3ff 0%, #d6f5d3 100%);
  border-radius: 20px; position: relative; overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.single-scene svg { width: 100%; height: 100%; display: block; }

/* Игра «Сгруппируй по цвету»: поле сверху, ведра снизу */
.sort-area { flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.sort-items {
  flex: 1; background: white; border-radius: 24px;
  box-shadow: inset 0 0 0 4px rgba(255,94,138,0.15);
  position: relative; overflow: hidden;
}
.sort-bins {
  display: flex; gap: 12px; height: 110px; flex-shrink: 0;
}
.bin {
  flex: 1; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: transform 0.15s;
  border: 4px solid rgba(255,255,255,0.6);
  font-size: 32px; color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.bin.target { transform: scale(1.08); border-color: white; }
.obj.selected { transform: scale(1.2); filter: drop-shadow(0 0 16px var(--gelimo-pink)); }

/* Цветная плашка в задании (для «лопай шарики» — показывает целевой цвет) */
.color-chip {
  display: inline-block; width: 22px; height: 22px;
  border-radius: 50%; vertical-align: middle;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  margin: 0 4px;
}

/* Игра «Лопай шарики»: всплывающие снизу шарики */
.bubble-field { background: linear-gradient(180deg, #d6f5ff 0%, #fff5e6 100%); }
.bubble {
  position: absolute; bottom: -80px;
  width: 64px; height: 80px;
  cursor: pointer;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
  transition: transform 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.bubble svg { width: 100%; height: 100%; }
.bubble:active { transform: scale(0.85); }
.bubble.popped { animation: bubble-pop 0.35s forwards; pointer-events: none; }
@keyframes bubble-rise {
  0%   { bottom: -80px; }
  100% { bottom: 105%; }
}
@keyframes bubble-pop {
  0%   { transform: scale(1); opacity: 1; filter: drop-shadow(0 0 0 gold); }
  100% { transform: scale(2); opacity: 0; filter: drop-shadow(0 0 24px gold); }
}

/* Перетаскивание (drag-and-drop в игре «сортировка») */
.obj.draggable { cursor: grab; touch-action: none; }
.obj.draggable:active { cursor: grabbing; }
.obj.dragging {
  z-index: 1000; transform: scale(1.25);
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.35));
  cursor: grabbing; transition: transform 0.1s;
}
.bin.over {
  transform: scale(1.18) !important;
  border-color: #ffd700 !important;
  box-shadow: 0 0 32px rgba(255,215,0,0.6), 0 4px 12px rgba(0,0,0,0.15);
}
.bin.shake { animation: shake 0.4s; }

/* Салют — разлетается в конце каждой мини-игры */
.salute {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 100;
  overflow: hidden;
}
.salute span {
  position: absolute;
  font-size: 36px;
  animation: salute-burst 1.6s ease-out forwards;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
  transform-origin: center;
}
@keyframes salute-burst {
  0%   { transform: translate(0,0) scale(0) rotate(0); opacity: 1; }
  20%  { transform: translate(0,0) scale(1.4) rotate(0); opacity: 1; }
  100% {
    transform: translate(var(--tx,0px), var(--ty,-280px)) scale(0.4) rotate(var(--rot,360deg));
    opacity: 0;
  }
}

/* === Игра «Whack-a-mole»: 6 норок, мороженые выскакивают === */
.mole-field {
  flex: 1; display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 14px; padding: 16px;
  background: linear-gradient(180deg, #6dd47e 0%, #ffd87f 100%);
  border-radius: 24px;
}
.hole {
  position: relative;
  background: radial-gradient(ellipse at center, #5a4030 0%, #3a2820 70%);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: inset 0 8px 16px rgba(0,0,0,0.5);
  display: flex; align-items: end; justify-content: center;
  border: 4px solid #8a5b3a;
}
.mole-item {
  position: absolute; bottom: -110%;
  width: 70%; height: 110%;
  cursor: pointer;
  transition: bottom 0.3s ease-out;
  display: flex; align-items: end; justify-content: center;
}
.mole-item svg { width: 100%; height: auto; }
.mole-item.up { bottom: -10%; }
.mole-item:active { transform: scale(0.92); }
.mole-item.hit { animation: pop 0.3s forwards; }

/* === Игра «Color trail»: показываем «дотронулся, но не тот» === */
.trail-field { background: linear-gradient(180deg, #e6f5ff 0%, #fff5e6 100%); }
.obj.touched { opacity: 0.5; }

/* === Игра «Memory pairs»: переворачивающиеся карточки === */
.memory-field { background: linear-gradient(180deg, #fff5e6 0%, #ffe6f0 100%); }
.memory-card {
  position: absolute;
  width: 88px; height: 112px;
  perspective: 800px;
  cursor: pointer;
}
.card-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s;
}
.memory-card.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  font-size: 44px;
}
.card-back {
  background: linear-gradient(135deg, #ff5e8a 0%, #d44671 100%);
  color: white;
  border: 4px solid white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  padding: 6px;
}
.card-back .card-mascot {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
.card-front {
  background: white;
  border: 4px solid var(--gelimo-pink);
  transform: rotateY(180deg);
  padding: 6px;
}
.card-front svg { width: 100%; height: 100%; }
.memory-card.matched .card-front {
  background: #fffbe0;
  box-shadow: 0 0 20px gold;
  border-color: gold;
}

/* === Игра «Animal feeding»: зверушка + мысленный пузырь === */
.feeding-area {
  flex: 1; display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(180deg, #d6f5ff 0%, #d6f5d3 100%);
  border-radius: 24px; padding: 16px; position: relative;
  overflow: hidden;
}
.feeding-top {
  display: flex; align-items: center; justify-content: center;
  gap: 24px; padding: 16px 8px;
}
.thought-bubble {
  background: white; border-radius: 50%;
  width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  border: 4px solid var(--gelimo-pink);
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.thought-bubble::after {
  content: ""; position: absolute; right: -16px; bottom: 12px;
  width: 18px; height: 18px; background: white;
  border: 4px solid var(--gelimo-pink); border-radius: 50%;
}
.thought-bubble svg { width: 64px; height: 64px; }
.feeding-animal {
  font-size: 110px; line-height: 1;
  transition: transform 0.3s;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.2));
}
.feeding-animal.happy { animation: feed-bounce 0.6s; }
@keyframes feed-bounce {
  0%, 100% { transform: scale(1) rotate(0); }
  30%      { transform: scale(1.3) rotate(-8deg); }
  60%      { transform: scale(1.2) rotate(8deg); }
}
.feeding-items {
  flex: 1; position: relative;
  background: white; border-radius: 16px;
  box-shadow: inset 0 0 0 3px rgba(255,94,138,0.15);
}

/* === Игра «Coloring page»: палитра цветов + области === */
.coloring-area { flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.coloring-canvas {
  flex: 1; min-height: 0;        /* без min-height:0 flexbox не сжимает блок,
                                    SVG разрастается и палитра уезжает за фрейм */
  overflow: hidden;
  background: white; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  box-shadow: inset 0 0 0 3px rgba(255,94,138,0.15);
}
.coloring-canvas svg {
  width: 100%; height: 100%;
  max-width: 100%; max-height: 100%;
  /* SVG c viewBox сохраняет aspect-ratio через preserveAspectRatio xMidYMid meet */
}
.region { cursor: pointer; transition: fill 0.25s; }
.color-palette {
  display: flex; gap: 12px; justify-content: center;
  padding: 14px; background: white; border-radius: 20px;
  flex-shrink: 0;
}
.palette-color {
  width: 52px; height: 52px; border-radius: 50%;
  cursor: pointer; border: 4px solid white;
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  transition: transform 0.2s, box-shadow 0.2s;
}
.palette-color:active { transform: scale(0.92); }
.palette-color.selected {
  transform: scale(1.2);
  border-color: gold;
  box-shadow: 0 0 16px gold, 0 3px 8px rgba(0,0,0,0.2);
}

/* Конфетти финального экрана */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span { position: absolute; font-size: 32px; animation: fall 3s linear infinite; }
@keyframes fall {
  0% { transform: translateY(-50px) rotate(0); }
  100% { transform: translateY(110vh) rotate(720deg); }
}

/* Видео-перебивка между мини-играми (glazki.mp4) */
.interstitial {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.interstitial-video {
  max-width: 92vw; max-height: 88vh;
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  background: #000;
  display: block;
}
.interstitial-skip {
  position: absolute; top: 16px; right: 16px;
  width: 44px; height: 44px;
  border: none; border-radius: 50%;
  background: var(--gelimo-pink); color: white;
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 #d44671, 0 4px 12px rgba(255, 94, 138, 0.4);
}
.interstitial-skip:active { transform: translateY(1px); }
