/* Стили для волшебной азбуки для девочки 4 лет */
@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@700&family=Nunito:wght@700;800;900&display=swap');

:root {
  --primary-pink: #FF6B8B;
  --soft-pink: #FFF0F5;
  --lavender: #E0BBE4;
  --mint: #B5EAD7;
  --sun-yellow: #FFDFBA;
  --dark-text: #4A4A68;
  --shadow-color: rgba(140, 110, 160, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  font-family: 'Nunito', 'Comfortaa', sans-serif;
  background: linear-gradient(135deg, #FFDEE9 0%, #B5FFFC 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Фоновые декоративные пузырьки и облачка */
.bg-decor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 50px;
  filter: blur(1px);
  animation: floatCloud 25s linear infinite;
}

.cloud-1 { width: 140px; height: 50px; top: 12%; left: -150px; }
.cloud-2 { width: 220px; height: 75px; top: 35%; left: -250px; animation-delay: 9s; animation-duration: 32s; }
.cloud-3 { width: 170px; height: 60px; top: 75%; left: -200px; animation-delay: 18s; animation-duration: 28s; }

@keyframes floatCloud {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 300px)); }
}

/* Верхняя панель */
.top-nav {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 15px var(--shadow-color);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Детские большие круглые кнопки */
.kid-btn {
  border: none;
  border-radius: 50px;
  background: #FFFFFF;
  color: #4A4A68;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.25rem;
  padding: 10px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 6px 0 #D4C3E2, 0 10px 15px var(--shadow-color);
  transition: all 0.12s ease;
  outline: none;
  position: relative;
}

.kid-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #D4C3E2, 0 4px 8px var(--shadow-color);
}

.kid-btn-icon {
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.6rem;
}

.kid-btn-pink {
  background: linear-gradient(135deg, #FF758C, #FF7EB3);
  color: #FFFFFF;
  box-shadow: 0 6px 0 #D84A6A, 0 10px 15px rgba(255, 117, 140, 0.35);
}
.kid-btn-pink:active {
  box-shadow: 0 2px 0 #D84A6A, 0 4px 8px rgba(255, 117, 140, 0.35);
}

.kid-btn-yellow {
  background: linear-gradient(135deg, #FFE259, #FFA751);
  color: #5D3E00;
  box-shadow: 0 6px 0 #D6892F, 0 10px 15px rgba(255, 167, 81, 0.35);
}
.kid-btn-yellow:active {
  box-shadow: 0 2px 0 #D6892F, 0 4px 8px rgba(255, 167, 81, 0.35);
}

.kid-btn-green {
  background: linear-gradient(135deg, #84fab0, #8fd3f4);
  color: #1A535C;
  box-shadow: 0 6px 0 #57B5A8, 0 10px 15px rgba(132, 250, 176, 0.35);
}
.kid-btn-green:active {
  box-shadow: 0 2px 0 #57B5A8, 0 4px 8px rgba(132, 250, 176, 0.35);
}

/* Звёздный счётчик */
.star-counter {
  background: #FFFBE6;
  border: 3px solid #FFD166;
  border-radius: 30px;
  padding: 8px 18px;
  font-size: 1.25rem;
  font-weight: 900;
  color: #D48806;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 10px rgba(255, 209, 102, 0.4);
}

.star-counter .star-icon {
  animation: gentlePulse 2s infinite ease-in-out;
}

.gentle-pulse {
  animation: gentlePulse 1.2s infinite ease-in-out;
}

@keyframes gentlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Главная игровая сцена */
.main-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 5;
  padding: 10px;
}

/* Панель выбора цвета буквы */
.color-palette-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.8);
  padding: 8px 16px;
  border-radius: 40px;
  box-shadow: 0 6px 16px rgba(120, 80, 150, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  max-width: 95vw;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.color-bubble {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #FFFFFF;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  outline: none;
}

.color-bubble:active {
  transform: scale(0.92);
}

.color-bubble.active {
  transform: translateY(-5px) scale(1.22);
  border-color: #FFFFFF;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25), 0 0 0 4px #FFD166;
}

.rainbow-bubble {
  background: linear-gradient(135deg, #FF0055, #FF9900, #FFE600, #00CC66, #0099FF, #9900FF);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
}

/* Контейнер холста для буквы */
.letter-board-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 800px;
}

.nav-arrow-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  font-size: 2rem;
  flex-shrink: 0;
  background: #FFFFFF;
  box-shadow: 0 7px 0 #D4C3E2, 0 12px 20px var(--shadow-color);
}

.board-container {
  position: relative;
  width: min(82vw, 480px);
  height: min(82vw, 480px);
  background: #FFFFFF;
  border-radius: 42px;
  box-shadow: 0 18px 40px rgba(120, 80, 150, 0.22), 0 0 0 10px rgba(255, 255, 255, 0.85);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

/* Холсты буквы и раскраски */
#tracerCanvas, #coloringCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 42px;
}

#coloringCanvas {
  pointer-events: none;
}

/* Нижняя панель инструментов для 4-летнего ребёнка */
.bottom-panel {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 18px 16px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 -6px 20px var(--shadow-color);
  width: 100%;
}

/* Переключатель режимов: Обводим / Раскрашиваем */
.mode-switch-wrap {
  display: flex;
  background: #F1F0FA;
  padding: 6px;
  border-radius: 35px;
  gap: 6px;
}

.mode-tab {
  border: none;
  background: transparent;
  padding: 10px 22px;
  border-radius: 30px;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  color: #6C6C8A;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.mode-tab.active {
  background: #FFFFFF;
  color: #FF5A88;
  box-shadow: 0 4px 12px rgba(255, 90, 136, 0.25);
  transform: scale(1.03);
}

/* Панель раскраски (палитра и штампики) */
.coloring-tools-bar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 680px;
}

.coloring-tools-bar.visible {
  display: flex;
}

.color-dot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid #FFFFFF;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.color-dot:active, .color-dot.active {
  transform: scale(1.22);
  border-color: #2D3748;
}

.rainbow-brush-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid #FFFFFF;
  background: linear-gradient(135deg, #FF6B6B, #FFE66D, #4ECDC4, #A855F7);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
}
.rainbow-brush-btn.active {
  transform: scale(1.22);
  border-color: #2D3748;
}

.stamp-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 3px solid #E2E8F0;
  background: #FFFFFF;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px rgba(0,0,0,0.06);
  transition: all 0.12s ease;
}

.stamp-btn.active {
  background: #FFF0F5;
  border-color: #FF6B8B;
  transform: scale(1.15);
}

/* Окно выбора всех 33 букв (Алфавит) */
.alphabet-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(45, 30, 60, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.alphabet-modal.open {
  display: flex;
}

.alphabet-card-sheet {
  background: linear-gradient(135deg, #FFFFFF, #FFF9FA);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  border-radius: 36px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 6px solid #FFFFFF;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: #FFE5EC;
  border-bottom: 3px solid #FFD1DC;
}

.modal-title {
  font-size: 1.6rem;
  color: #D81E5B;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 10px;
}

.letters-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.letter-grid-item {
  aspect-ratio: 1;
  border-radius: 20px;
  background: #FFFFFF;
  border: 3px solid #E2E8F0;
  box-shadow: 0 6px 0 #CBD5E1, 0 8px 12px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 900;
  color: #334155;
  cursor: pointer;
  position: relative;
  transition: all 0.12s ease;
}

.letter-grid-item:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #CBD5E1;
}

.letter-grid-item.completed {
  border-color: #FFD166;
  background: #FFFDF0;
  box-shadow: 0 6px 0 #ECC94B, 0 8px 14px rgba(255, 209, 102, 0.3);
}

.letter-grid-item .star-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 1.1rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.letter-grid-item.current {
  border-color: #FF6B8B;
  outline: 4px solid #FFCCD5;
}

/* Всплывающий праздничный экран при победе */
.celebration-toast {
  position: absolute;
  top: 15%;
  background: linear-gradient(135deg, #FFE259, #FFA751);
  color: #5D3E00;
  padding: 14px 28px;
  border-radius: 40px;
  font-size: 1.5rem;
  font-weight: 900;
  box-shadow: 0 10px 25px rgba(255, 167, 81, 0.4), 0 0 0 6px #FFFFFF;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 50;
  pointer-events: none;
}

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Адаптивность для небольших телефонов */
@media (max-width: 480px) {
  .top-nav { padding: 8px 12px; }
  .kid-btn-icon { width: 44px; height: 44px; font-size: 1.3rem; }
  .star-counter { font-size: 1rem; padding: 6px 12px; }
  .nav-arrow-btn { width: 50px; height: 50px; font-size: 1.5rem; }
  .color-dot, .rainbow-brush-btn { width: 36px; height: 36px; }
  .stamp-btn { width: 38px; height: 38px; font-size: 1.2rem; }
  .mode-tab { padding: 8px 14px; font-size: 1rem; }
}
