/* Стили Развивашки №3 «Alfabeto português». Палитра — синий Gelimo +
   цветные акценты, большие тапающиеся элементы для пальцев 2–5 лет. */

: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;
}
.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;
}
/* На финале 5 кнопок (сертификат + повтор + 3 мостика) — при низком экране
   они не помещаются и обрезаются. Делаем сам экран прокручиваемым. */
#screen-reward { justify-content: flex-start; overflow-y: auto; padding-top: 24px; padding-bottom: 32px; }
#screen-reward .mascot { width: 200px; height: 140px; margin-bottom: 4px; }
#screen-reward .mascot-emoji { font-size: 100px; }
#screen-reward h2 { font-size: 32px; margin: 8px 0 0; }
#screen-reward .subtitle { font-size: 16px; margin: 4px 0 12px; }

/* === Маскоты ====================================================== */
.mascot { width: 280px; height: 200px; 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: 140px; 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;
}
.brand-slot .brand-logo { background: transparent; box-shadow: none; padding: 0; font-size: 18px; }

h1 { font-size: 44px; margin: 16px 0 0; color: var(--g-blue); letter-spacing: -0.5px; }
h2 { font-size: 36px; margin: 16px 0 4px; color: var(--g-blue); }
.subtitle { font-size: 20px; margin: 4px 0 12px; opacity: 0.7; }
.hint-line { font-size: 18px; color: var(--g-blue); font-weight: 700; margin: 6px 0 12px; opacity: 0.85; }

/* === Возрастные кнопки и большие кнопки =========================== */
.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;
  padding: 14px 20px; 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: 22px; font-weight: 800; padding: 16px 28px; 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.ghost { background: white; color: var(--g-blue); box-shadow: 0 4px 0 #c3d8e6, 0 8px 16px rgba(0,0,0,0.12); }
.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; }
.reward-hint { font-size: 14px; color: var(--g-blue); opacity: 0.7; margin: 8px 0 4px; }
.reward-bridges { display: flex; flex-direction: column; gap: 10px; align-items: stretch; width: 100%; }
.reward-bridges .big-btn { width: 100%; padding: 12px 18px; font-size: 17px; }

/* === Плашка задания =============================================== */
.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: 38px; height: 38px;
  border-radius: 50%; font-size: 16px; 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; }

/* === Подсказки ==================================================== */
.pulse-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.25); filter: drop-shadow(0 0 24px gold) drop-shadow(0 0 8px #ffaa00); }
}

/* === Игровая область ============================================== */
.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: 320px;
}
.letter-field { background: linear-gradient(180deg, #e6f5ff 0%, #fff5e6 100%); }

.obj {
  position: absolute; width: 88px; height: 88px;
  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, .letter-tile svg, .seq-cell svg, .digit-tile svg { width: 100%; height: 100%; display: block; }
.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); }
}

/* === Плитка буквы ================================================= */
.letter-tile { width: 96px; height: 96px; cursor: pointer; }
.letter-tile.option {
  position: relative; width: 110px; height: 110px;
  display: inline-flex; align-items: center; justify-content: center;
  margin: 8px; transition: transform 0.15s;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}
.letter-tile.option:active { transform: scale(0.92); }
.letter-tile.found { animation: pop 0.5s ease forwards; pointer-events: none; }
.letter-tile.shake { animation: shake 0.4s; }
.digit-tile { width: 96px; height: 96px; }
.digit-tile.option { position: relative; width: 110px; height: 110px; display: inline-flex; align-items: center; justify-content: center; margin: 8px; }
.digit-tile.found { animation: pop 0.5s ease forwards; pointer-events: none; }
.digit-tile.shake { animation: shake 0.4s; }

/* === Карточка слова (emoji + label) =============================== */
.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: 110px;
}
.word-card:active { transform: scale(0.96); }
.word-card.found { animation: pop 0.5s ease forwards; pointer-events: none; }
.word-card.shake { animation: shake 0.4s; }
.word-card.tapped { background: var(--g-blue-soft); }
.word-card.bounce { animation: card-bounce 0.6s ease; }
@keyframes card-bounce {
  0%,100% { transform: scale(1); }
  40% { transform: scale(1.15) rotate(-3deg); }
  70% { transform: scale(1.08) rotate(3deg); }
}
.word-emoji { font-size: 56px; line-height: 1; }
.word-label { font-size: 17px; font-weight: 800; color: var(--g-blue); }

/* === Игра 2 «Word starts» ========================================= */
.word-starts-area, .first-letter-area {
  flex: 1; display: flex; flex-direction: column; gap: 16px;
  background: white; border-radius: 24px; padding: 20px;
  box-shadow: inset 0 0 0 4px rgba(2,82,138,0.15);
  align-items: center; justify-content: space-around; min-height: 0;
}
.big-letter { width: 160px; height: 160px; }
.big-letter svg { width: 100%; height: 100%; display: block; }
.word-options, .letter-options {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
}

/* === Игра 8 «Ache a letra inicial» ================================ */
.word-big { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.word-big-emoji { font-size: 100px; line-height: 1; animation: bounce-in 0.5s ease both; }
.word-big-emoji.big { font-size: 150px; }
.word-big-label { font-size: 30px; font-weight: 900; color: var(--g-blue); }
@keyframes bounce-in {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); }
}

/* === Игра 4 «Muitas palavras» ===================================== */
.multi-words-area {
  flex: 1; display: grid; grid-template-columns: 160px 1fr; gap: 16px;
  background: white; border-radius: 24px; padding: 16px;
  box-shadow: inset 0 0 0 4px rgba(2,82,138,0.15);
  min-height: 0; overflow: auto;
}
.big-letter-side { align-self: center; }
.multi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px; align-content: center;
}

/* === Игра 10 «Conte as letras» ==================================== */
.count-letters-area { flex: 1; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.count-letters-items {
  flex: 1; background: white; border-radius: 24px;
  box-shadow: inset 0 0 0 4px rgba(2,82,138,0.15);
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: center; padding: 18px; overflow: hidden;
}
.cl-letter { width: 88px; height: 88px; animation: bounce-in 0.4s ease both; }
.cl-letter svg { width: 100%; height: 100%; display: block; }
.count-letters-options { display: flex; justify-content: center; gap: 14px; flex-shrink: 0; }

/* === Игра 3 «Link» — буквы сверху в ряд, картинки-слова снизу ====== */
.link-area {
  flex: 1; display: grid; grid-template-rows: 132px 1fr; gap: 14px;
  background: white; border-radius: 24px; padding: 16px;
  box-shadow: inset 0 0 0 4px rgba(2,82,138,0.15); min-height: 0; overflow: hidden;
}
/* Буквы всегда на переднем плане и с запасом сверху, чтобы ни на каком
   экране/встраивании их верх не подрезался (правка по тесту Карины). */
.link-row { position: relative; z-index: 2; }
.link-col { position: relative; height: 100%; }
/* Позиционирование БЕЗ transform: анимации (hint-pulse, dragging) задают
   свой transform и сдвигали бы букву с места. */
.link-row .obj.letter-tile { position: absolute; top: calc(50% - 48px); width: 96px; height: 96px; }
.link-row .obj.letter-tile:nth-child(1) { left: calc(16.5% - 48px); }
.link-row .obj.letter-tile:nth-child(2) { left: calc(50% - 48px); }
.link-row .obj.letter-tile:nth-child(3) { left: calc(83.5% - 48px); }
.link-groups { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.link-group {
  background: var(--g-blue-soft); border: 3px dashed var(--g-blue);
  border-radius: 20px; padding: 12px; min-height: 80px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: background 0.2s, transform 0.15s;
}
.link-group .word-emoji { font-size: 42px; }
.link-group .word-label { font-size: 16px; }
.link-group.over { background: var(--g-yellow); transform: scale(1.04); }
.link-group.matched { background: #d4f5d4; border-style: solid; border-color: var(--g-green); }
.link-group.shake { animation: shake 0.4s; }
/* В Link-игре буква уезжает к правильному слову (kid-test Карины),
   а на её месте остаётся полупрозрачный контур-призрак — чтобы
   ребёнок видел, что эту букву уже разобрал. */
.link-row .obj.letter-tile.found {
  filter: drop-shadow(0 0 14px var(--g-green));
  pointer-events: none;
}
.link-row .ghost-letter {
  position: absolute; top: calc(50% - 48px);
  width: 96px; height: 96px;
  opacity: 0.28; pointer-events: none;
  filter: grayscale(0.6) drop-shadow(0 0 6px var(--g-green));
}

/* === Игра 5 «Sequence» ============================================ */
.seq-area { flex: 1; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.seq-row {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 16px;
  background: white; border-radius: 24px; padding: 16px;
  box-shadow: inset 0 0 0 4px rgba(2,82,138,0.15);
}
.seq-cell { width: 96px; height: 96px; display: flex; align-items: center; justify-content: center; }
.seq-cell.blank {
  border: 4px dashed var(--g-red); border-radius: 16px;
  font-size: 56px; font-weight: 900; color: var(--g-red);
}
.seq-options { display: flex; justify-content: center; gap: 14px; flex-shrink: 0; }

/* === Игра 6 «Colorindo as letras» ================================= */
.coloring-single { flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.cn-canvas {
  flex: 1; background: white; border-radius: 24px;
  display: flex; align-items: center; justify-content: center; padding: 14px;
  box-shadow: inset 0 0 0 4px rgba(2,82,138,0.15);
}
.cn-hint { text-align: center; font-weight: 700; color: var(--g-blue); font-size: 18px; padding: 4px; opacity: 0.85; }
.cn-digit.big { width: 200px; height: 200px; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15)); }
.cn-digit.big svg { width: 100%; height: 100%; }
.cn-digit .region { cursor: pointer; transition: fill 0.25s; }
.palette { display: flex; gap: 12px; justify-content: center; padding: 12px; background: white; border-radius: 20px; flex-shrink: 0; }
.palette-color {
  width: 56px; height: 56px; border-radius: 50%; cursor: pointer;
  border: 4px solid white; box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  transition: transform 0.2s; padding: 0;
}
.palette-color:active { transform: scale(0.92); }
.palette-color.expected {
  animation: palette-pulse 0.9s ease-in-out infinite;
  border-color: gold; box-shadow: 0 0 18px gold, 0 3px 8px rgba(0,0,0,0.2);
}
.palette-color.dim { opacity: 0.45; }
@keyframes palette-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* === Игра 9 «Monte a palavra» ===================================== */
.build-word-area {
  flex: 1; display: flex; flex-direction: column; gap: 18px;
  background: white; border-radius: 24px; padding: 18px;
  box-shadow: inset 0 0 0 4px rgba(2,82,138,0.15);
  align-items: center; min-height: 0; overflow: auto;
}
.bw-target { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bw-slots { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.bw-slot {
  width: 80px; height: 80px;
  border: 4px dashed var(--g-red); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(237,28,37,0.04);
  transition: background 0.2s;
}
.bw-slot.shake { animation: shake 0.4s; }
.bw-slot:has(.bw-tile) { border-style: solid; border-color: var(--g-green); background: #e8fce8; }
.bw-tiles { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.bw-tile {
  width: 72px; height: 72px; cursor: grab; touch-action: none;
  transition: transform 0.15s;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.18));
}
.bw-tile svg { width: 100%; height: 100%; display: block; }
.bw-tile.placed { width: 70px; height: 70px; cursor: default; }
.bw-tile.dragging {
  z-index: 1000; transform: scale(1.15);
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.35));
  cursor: grabbing;
}

/* === 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;
}

/* === Теоретическое интро ========================================== */
.theory-area {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: white; border-radius: 24px; padding: 20px; gap: 18px;
  box-shadow: inset 0 0 0 4px rgba(2,82,138,0.15);
}
.theory-mascot { font-size: 80px; }
.theory-stage { display: flex; align-items: center; justify-content: center; min-height: 180px; }
.theory-slot {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  animation: bounce-in 0.5s ease both;
}
.theory-letter { width: 140px; height: 140px; }
.theory-letter svg { width: 100%; height: 100%; }
.theory-plus { font-size: 32px; color: var(--g-blue); opacity: 0.5; display: none; }
.theory-emoji { font-size: 86px; line-height: 1; }
.theory-word { font-size: 26px; font-weight: 900; color: var(--g-blue); }
.theory-skip {
  align-self: center;
  background: var(--g-cream); color: var(--g-blue);
  border: 2px solid var(--g-blue-soft);
  border-radius: 999px; padding: 8px 18px;
  font-family: inherit; font-weight: 700; font-size: 14px;
  cursor: pointer; opacity: 0.8;
  transition: opacity 0.15s, transform 0.1s;
}
.theory-skip:hover { opacity: 1; }
.theory-skip:active { transform: translateY(1px); }

/* === Celebrate (мини-салют конца игры) ============================ */
.celebrate {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
}
.celebrate-mascot { font-size: 140px; animation: bob 1.4s ease-in-out infinite; }
.celebrate-text { font-size: 56px; font-weight: 900; color: var(--g-green); }

/* === Салют =========================================================*/
.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; }
}

/* === Кувырок обезьянки ============================================ */
.monkey-flip-overlay {
  position: fixed; top: 50%; left: 50%; font-size: 110px; z-index: 1500;
  pointer-events: none; animation: monkey-flip 0.85s ease-out forwards;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.25));
}
@keyframes monkey-flip {
  0%   { transform: translate(-50%,-50%) scale(0.4) rotate(0); opacity: 0; }
  25%  { transform: translate(-50%,-50%) scale(1.2) rotate(180deg); opacity: 1; }
  50%  { transform: translate(-50%,-75%) scale(1.3) rotate(360deg); opacity: 1; }
  75%  { transform: translate(-50%,-50%) scale(1.2) rotate(540deg); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(0.6) rotate(720deg); 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: 64px; font-weight: 900; color: var(--g-red);
  background: white; border-radius: 50%; width: 96px; height: 96px;
  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); } }
