/* Стили Развивашки №4 «Atividades para crianças» (6-9 лет). Палитра и общие
   узоры унаследованы от разв.3 (синий Gelimo + тёплые акценты), но добавлена
   сетка меню-хаба и убрано всё, что было специфично для алфавита/букв. */

:root {
  --g-blue: #02528a; --g-blue-soft: #a8dbff;
  --g-red: #ed1c25; --g-cream: #fff8ee;
  --g-yellow: #ffd23f; --g-pink: #ff5e8a;
  --g-green: #6dd47e; --g-text: #02528a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: "Satoshi", "Nunito", "Comic Sans MS", system-ui, sans-serif;
  color: var(--g-text);
  background: linear-gradient(180deg, #d6f0ff 0%, #fff8ee 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;
  overflow-y: auto;
}
.screen.active { display: flex; }
@keyframes fadein { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

#screen-start, #screen-reward, #screen-rest, #screen-loading {
  align-items: center; justify-content: center; text-align: center; position: relative;
}

/* === Прогресс-бар предзагрузки звуков ============================= */
.loadbar {
  width: 280px; max-width: 80%; height: 22px; background: #fff;
  border-radius: 999px; overflow: hidden; margin: 14px 0 6px;
  box-shadow: inset 0 0 0 3px rgba(2,82,138,0.15);
}
.loadbar-fill { height: 100%; width: 0%; background: var(--g-red); border-radius: 999px; transition: width 0.2s ease; }

/* === Маскоты ======================================================= */
.mascot { width: 220px; height: 160px; filter: drop-shadow(0 12px 24px rgba(2,82,138,0.2)); margin-bottom: 8px; }
.mascot.bob { animation: bob 2.4s ease-in-out infinite; transform-origin: center bottom; }
.mascot-emoji { display: flex; align-items: center; justify-content: center; gap: 16px; font-size: 110px; line-height: 1; }
.mascot-emoji .m-left  { transform: rotate(-6deg); }
.mascot-emoji .m-right { transform: rotate(6deg); }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* === Бренд-плашка =================================================== */
.brand-bar { position: absolute; top: 16px; left: 16px; }
.brand-logo {
  display: inline-flex; align-items: center; background: white;
  padding: 8px 16px; border-radius: 999px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  font-weight: 900; color: var(--g-blue); font-size: 20px; letter-spacing: 0.3px;
}

h1 { font-size: 40px; margin: 16px 0 0; color: var(--g-blue); letter-spacing: -0.5px; }
h2 { font-size: 32px; margin: 16px 0 4px; color: var(--g-blue); }
.subtitle { font-size: 18px; margin: 4px 0 12px; opacity: 0.75; }

/* === Кнопки возраста и общие крупные кнопки ======================== */
.age-picker { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; justify-content: center; }
.age-btn {
  background: white; border: 3px solid transparent; cursor: pointer;
  min-width: 96px; min-height: 56px; padding: 14px 22px; border-radius: 16px;
  font-family: inherit; font-weight: 700; font-size: 18px; color: var(--g-blue);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08); transition: transform 0.1s, border-color 0.2s;
}
.age-btn:active { transform: translateY(1px); border-color: var(--g-red); background: var(--g-blue-soft); }

.big-btn {
  background: var(--g-red); color: white; border: none; font-family: inherit;
  font-size: 20px; font-weight: 800; padding: 16px 26px; min-height: 52px;
  border-radius: 999px; box-shadow: 0 6px 0 #b8141c, 0 12px 24px rgba(237,28,37,0.35);
  cursor: pointer; transition: transform 0.1s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8141c, 0 4px 8px rgba(237,28,37,0.35); }
.big-btn.alt { background: var(--g-blue); box-shadow: 0 6px 0 #013a63, 0 12px 24px rgba(2,82,138,0.35); }
.big-btn.alt:active { box-shadow: 0 2px 0 #013a63, 0 4px 8px rgba(2,82,138,0.35); }
.big-btn:disabled { background: #cfd8dd; box-shadow: none; cursor: not-allowed; opacity: 0.7; }
.reward-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; max-width: 380px; margin: 0 auto 16px; width: 100%; }
.reward-actions .big-btn { width: 100%; padding: 14px 22px; font-size: 18px; }

/* === Плашка задания (экран игры) =================================== */
.task-bar {
  display: flex; align-items: center; gap: 12px;
  background: white; padding: 10px 16px; border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08); margin-bottom: 12px; flex-shrink: 0;
}
.task-text { font-weight: 800; font-size: 17px; flex: 1; color: var(--g-blue); }
.counter { background: var(--g-yellow); color: var(--g-blue); padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 18px; white-space: nowrap; }
.bar-btn {
  background: var(--g-cream); border: none; width: 44px; height: 44px;
  border-radius: 50%; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1); flex-shrink: 0;
  transition: transform 0.1s; font-family: inherit;
}
.bar-btn:active { transform: translateY(1px) scale(0.95); }
.bar-btn.muted { opacity: 0.5; }

/* === Подсказки и общие анимации реакции ============================ */
/* --hint-pulse-total is set per age by audio-core.js (scheduleHint) - the
   3 pulses below split it evenly, so harder levels glow longer overall. */
.pulse-hint { animation: hint-pulse calc(var(--hint-pulse-total, 2.4s) / 3) 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.2); filter: drop-shadow(0 0 20px gold) drop-shadow(0 0 6px #ffaa00); }
}
.shake { animation: shake 0.4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-5deg); }
  75% { transform: translateX(8px) rotate(5deg); }
}
@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); }
}

/* === Меню-хаб: сетка из 8 плиток ==================================== */
/* Компактный переключатель уровня - тот же стиль, что и .age-btn на старте,
   только меньше по размеру, чтобы не спорить с плитками игр за место. */
.level-switch { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 0 auto 10px; }
.level-switch-label { font-weight: 800; font-size: 14px; color: var(--g-blue); opacity: 0.75; }
.level-switch-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.level-btn {
  background: white; border: 3px solid transparent; cursor: pointer;
  min-width: 64px; min-height: 40px; padding: 6px 14px; border-radius: 14px;
  font-family: inherit; font-weight: 700; font-size: 14px; color: var(--g-blue);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08); transition: transform 0.1s, border-color 0.2s;
}
.level-btn:active { transform: translateY(1px); }
.level-btn.active { border-color: var(--g-red); background: var(--g-blue-soft); }
.menu-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; max-width: 640px; margin: 0 auto; }
.menu-stars { font-weight: 800; font-size: 18px; background: white; padding: 8px 16px; border-radius: 999px; box-shadow: 0 3px 8px rgba(0,0,0,0.08); }
.cert-btn { font-size: 16px; padding: 10px 18px; }
.cert-hint { font-size: 13px; opacity: 0.7; margin: 6px auto 4px; max-width: 480px; text-align: center; }

.menu-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px;
  width: 100%; max-width: 640px; margin: 12px auto 0; flex: 1; align-content: start;
}
@media (min-width: 720px) {
  .menu-grid { grid-template-columns: repeat(4, 1fr); max-width: 920px; }
}
.menu-tile {
  position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; min-height: 120px;
  background: white; border: none; border-radius: 22px; padding: 16px 10px;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 6px 0 rgba(2,82,138,0.15), 0 10px 20px rgba(0,0,0,0.08);
  transition: transform 0.1s;
}
.menu-tile:active { transform: translateY(3px); }
.menu-tile.done { background: #eafcea; }
.tile-icon { font-size: 46px; line-height: 1; }
.tile-title { font-size: 15px; font-weight: 800; color: var(--g-blue); text-align: center; }
.tile-star { position: absolute; top: 12px; right: 16px; font-size: 20px; }

/* === Игровая область (общая для всех восьми игр) =================== */
.play-area { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; }
.play-field {
  flex: 1; position: relative; background: white; border-radius: 24px;
  box-shadow: inset 0 0 0 4px rgba(2,82,138,0.15); overflow: hidden;
  min-height: 280px;
}

/* Тайл-объект на поле (морской бой, найди предмет, отличия и т.п.) */
.obj {
  position: absolute; width: 72px; height: 72px; min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; cursor: pointer; transition: transform 0.15s;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.2));
}
.obj:active { transform: scale(0.92); }
.obj.found { animation: pop 0.5s ease forwards; pointer-events: none; }
.obj.draggable { cursor: grab; touch-action: none; }
.obj.draggable:active { cursor: grabbing; }
.obj.dragging { z-index: 1000; transform: scale(1.2); filter: drop-shadow(0 8px 24px rgba(0,0,0,0.35)); cursor: grabbing; }

/* Карточка с эмодзи и подписью (память, домино, викторина) */
.word-card {
  background: white; border-radius: 18px; padding: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; transition: transform 0.15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); min-width: 96px; min-height: 44px;
}
.word-card:active { transform: scale(0.96); }
.word-card.found { animation: pop 0.5s ease forwards; pointer-events: none; }
.word-emoji { font-size: 48px; line-height: 1; }
.word-label { font-size: 16px; font-weight: 800; color: var(--g-blue); }

/* Ряд вариантов ответа (логика, последовательность, викторина) */
.options-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

/* === Celebrate (конец одной игры, перед возвратом в меню) =========== */
.celebrate {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
}
.celebrate-mascot { font-size: 120px; animation: bob 1.4s ease-in-out infinite; }

/* === Салют ============================================================ */
.salute-burst {
  position: fixed; width: 18px; height: 18px; pointer-events: none;
  background: gold; border-radius: 50%; z-index: 2000;
  animation: salute-burst-anim 0.8s ease-out forwards;
  box-shadow: 0 0 12px gold, 0 0 4px #ffaa00;
}
@keyframes salute-burst-anim {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx,0px), var(--dy,-180px)) scale(0.4); opacity: 0; }
}

/* === Экран «Отдых для глазок» ======================================= */
.eye-rest {
  flex: 1; background: linear-gradient(180deg, #d6f0ff 0%, #fff8ee 100%);
  border-radius: 24px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center;
}
.countdown-pulse {
  font-size: 60px; font-weight: 900; color: var(--g-red);
  background: white; border-radius: 50%; width: 90px; height: 90px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(237,28,37,0.25);
  animation: countdown-pulse 1s ease-in-out infinite;
}
@keyframes countdown-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* === Конфетти ========================================================= */
.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); } }

/* Все интерактивные элементы - минимум 44x44px под палец ребёнка */
button { min-width: 44px; min-height: 44px; }

/* Пустой счётчик в шапке не показываем (экран выбора режима и т.п.). */
.counter:empty { display: none; }
/* Меню: заголовок не залезает под плашку «Gelimo» в левом верхнем углу. */
#screen-menu h2 { margin-top: 52px; text-align: center; }
/* Телефон: длинная инструкция в шапке - максимум 2 строки, мельче. */
@media (max-width: 560px) {
  .task-text { font-size: 14px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .task-bar { padding: 8px 10px; gap: 8px; }
}
