/* ============================================================
   CSS ПЕРЕМЕННЫЕ — меняй цвета и шрифты здесь в одном месте
   ============================================================ */
:root {
  /* Цвета */
  --color-bg-from:      #667eea;
  --color-bg-to:        #764ba2;
  --color-primary:      #ff6b6b;
  --color-primary-dark: #e55a5a;
  --color-secondary:    #4ecdc4;
  --color-success:      #51cf66;
  --color-danger:       #ff6b6b;
  --color-text:         #2d3748;
  --color-text-light:   #718096;
  --color-white:        #ffffff;
  --color-card:         rgba(255, 255, 255, 0.97);

  /* Типографика */
  --font:            'Nunito', 'Comic Sans MS', cursive;
  --text-sm:         14px;
  --text-base:       18px;
  --text-lg:         22px;
  --text-xl:         30px;
  --text-hero:       44px;

  /* Прочее */
  --radius:      18px;
  --radius-sm:   10px;
  --shadow:      0 6px 24px rgba(0, 0, 0, 0.18);
  --shadow-sm:   0 2px 10px rgba(0, 0, 0, 0.10);
  --transition:  0.25s ease;
}

/* ============================================================
   СБРОС И БАЗОВЫЕ СТИЛИ
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  background: linear-gradient(135deg, var(--color-bg-from), var(--color-bg-to));
  min-height: 100vh;
  color: var(--color-text);
  overflow-x: hidden;
}

/* ============================================================
   ЭКРАНЫ — показываем/скрываем через JS (класс .active)
   ============================================================ */
.screen {
  display: none;
  min-height: 100vh;
  padding: 20px 16px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* ============================================================
   КНОПКИ
   ============================================================ */
.btn {
  display: inline-block;
  padding: 14px 30px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: var(--text-lg);
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  line-height: 1.2;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-white);
}

.btn--primary:hover {
  background: var(--color-primary-dark);
}

.btn--secondary {
  background: var(--color-secondary);
  color: var(--color-white);
}

.btn--next {
  background: var(--color-secondary);
  color: var(--color-white);
  margin-top: 14px;
  width: 100%;
}


/* ============================================================
   ЭКРАН 1: ГЛАВНЫЙ
   ============================================================ */
.home__deco {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

/* Плавающие звёздочки на фоне */
.deco-star {
  position: absolute;
  font-size: 28px;
  animation: floatUp 8s ease-in-out infinite;
  opacity: 0.5;
}

.deco-star:nth-child(1) { left: 8%;  top: 15%; animation-delay: 0s;   font-size: 22px; }
.deco-star:nth-child(2) { left: 80%; top: 10%; animation-delay: 1.5s; font-size: 32px; }
.deco-star:nth-child(3) { left: 50%; top: 75%; animation-delay: 3s;   font-size: 18px; }
.deco-star:nth-child(4) { left: 20%; top: 80%; animation-delay: 4s;   font-size: 28px; }
.deco-star:nth-child(5) { left: 90%; top: 60%; animation-delay: 2s;   font-size: 24px; }

.home__content {
  text-align: center;
  color: var(--color-white);
  position: relative;
  z-index: 1;
}

.home__icon {
  font-size: 80px;
  margin-bottom: 16px;
  animation: sway 4s ease-in-out infinite;
  display: inline-block;
}

.home__title {
  font-size: var(--text-hero);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 16px;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}

.home__subtitle {
  font-size: var(--text-lg);
  margin-bottom: 40px;
  opacity: 0.9;
}

/* ============================================================
   ЭКРАН 2: ВЫБОР ВОЗРАСТА
   ============================================================ */
.age__content {
  text-align: center;
  width: 100%;
  max-width: 520px;
}

.age__title {
  color: var(--color-white);
  font-size: var(--text-xl);
  font-weight: 800;
  margin-bottom: 8px;
}

.age__hint {
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--text-sm);
  margin-bottom: 32px;
}

.age__cards {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.age__card {
  background: var(--color-card);
  border: 3px solid transparent;
  border-radius: var(--radius);
  padding: 32px 36px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  min-width: 170px;
}

.age__card:hover {
  transform: translateY(-5px);
  border-color: var(--color-primary);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
}

.age__emoji {
  font-size: 56px;
}

.age__label {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
}

.age__desc {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  line-height: 1.5;
}

/* ============================================================
   ЭКРАН 3: ВЫБОР ПЕРСОНАЖА
   ============================================================ */
.character__content {
  text-align: center;
  width: 100%;
  max-width: 720px;
}

.character__title {
  color: var(--color-white);
  font-size: var(--text-xl);
  font-weight: 800;
  margin-bottom: 6px;
}

.character__hint {
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--text-sm);
  margin-bottom: 28px;
}

.character__cards {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.character__card {
  background: var(--color-card);
  border: 3px solid transparent;
  border-radius: var(--radius);
  padding: 24px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
  width: 210px;
  text-align: center;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.character__card:hover {
  transform: translateY(-5px);
  border-color: var(--color-primary);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
}

.character__avatar {
  font-size: 68px;
  animation: sway 3s ease-in-out infinite;
  display: inline-block;
}

.character__name {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
}

.character__desc {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  line-height: 1.5;
}

/* Бейджи уровней */
.character__level {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  margin-top: 2px;
}

.level--easy   { background: #d4f7d4; color: #2a7a2a; }
.level--medium { background: #fff4b0; color: #7a6000; }
.level--hard   { background: #ffd6d6; color: #c0392b; }

/* Плейсхолдеры для личной информации */
.placeholder {
  display: inline-block;
  background: linear-gradient(135deg, #ffebee 0%, #fce4ec 100%);
  border: 2px dashed #f44336;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  color: #c62828;
  font-size: 0.95em;
  white-space: nowrap;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

/* ============================================================
   ЭКРАН 4: ИГРА
   ============================================================ */
#screen-game {
  gap: 14px;
  padding-top: 16px;
  padding-bottom: 24px;
}

/* Верхняя панель */
.game__header {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.game__progress {
  flex: 1;
}

.progress__bar {
  height: 12px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress__fill {
  height: 100%;
  background: var(--color-success);
  border-radius: 6px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress__text {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.9);
}

.game__score {
  color: var(--color-white);
  font-size: var(--text-lg);
  font-weight: 800;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 14px;
  border-radius: 20px;
}

/* Персонаж */
.game__character {
  font-size: 72px;
  line-height: 1;
}

.character__bubble {
  display: inline-block;
  animation: sway 3s ease-in-out infinite;
}

/* Облачко с вопросом */
.game__question-box {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 20px 52px 20px 22px;
  width: 100%;
  max-width: 600px;
  position: relative;
  box-shadow: var(--shadow);
  animation: fadeSlideIn 0.35s ease;
}

.question__text {
  font-size: var(--text-lg);
  line-height: 1.5;
  color: var(--color-text);
  font-weight: 700;
}

/* Варианты ответа */
.game__options {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  background: var(--color-card);
  border: 3px solid transparent;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
  animation: fadeSlideIn 0.3s ease;
}

.option-btn:hover {
  transform: translateX(5px);
  border-color: var(--color-secondary);
}

/* Состояния кнопок после ответа */
.option-btn.correct {
  background: #d4f7d4;
  border-color: var(--color-success);
  pointer-events: none;
}

.option-btn.wrong {
  background: #ffd6d6;
  border-color: var(--color-danger);
  pointer-events: none;
}

.option-btn.neutral-disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Поле свободного ввода */
.game__input-box {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.game__input {
  width: 100%;
  padding: 14px 18px;
  border: 3px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--text-lg);
  background: var(--color-card);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition);
}

.game__input:focus {
  border-color: var(--color-secondary);
}

/* Мгновенная обратная связь */
.game__feedback {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 20px 22px;
  width: 100%;
  max-width: 600px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: fadeSlideIn 0.35s ease;
}

.feedback__icon {
  font-size: 52px;
  margin-bottom: 8px;
  animation: popIn 0.4s ease;
  display: block;
}

.feedback__text {
  font-size: var(--text-base);
  color: var(--color-text);
  line-height: 1.55;
  font-weight: 600;
}

/* Кнопка для показа сказки */
.btn--story {
  background: linear-gradient(135deg, #fff9e6 0%, #ffe8cc 100%);
  color: #e65100;
  border: 2px solid #ff9800;
  font-weight: 700;
  margin-top: 12px;
  margin-bottom: 12px;
  transition: all 0.25s ease;
}

.btn--story:hover {
  background: linear-gradient(135deg, #ffe8cc 0%, #ffd699 100%);
  border-color: #f57c00;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 152, 0, 0.3);
}

/* Блок со сказкой */
.story-box {
  background: linear-gradient(135deg, #fff9e6 0%, #ffe8cc 100%);
  border: 2px dashed #ff9800;
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
  margin-bottom: 16px;
  text-align: left;
  animation: slideDown 0.4s ease;
}

.story__title {
  font-weight: 700;
  color: #e65100;
  margin-bottom: 10px;
  font-size: 16px;
  text-align: center;
}

.story__text {
  font-size: 15px;
  line-height: 1.6;
  color: #4a4a4a;
  margin: 0;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
  }
  to {
    opacity: 1;
    max-height: 500px;
    padding-top: 16px;
    padding-bottom: 16px;
    margin-top: 12px;
    margin-bottom: 16px;
  }
}

/* Мобильная адаптация для сказки */
@media (max-width: 480px) {
  .story__title {
    font-size: 15px;
  }
  
  .story__text {
    font-size: 14px;
    line-height: 1.55;
  }
  
  .story-box {
    padding: 14px;
  }
}

/* ============================================================
   ЭКРАН 5: РЕЗУЛЬТАТЫ
   ============================================================ */
#screen-result {
  padding-top: 24px;
  padding-bottom: 32px;
}

.result__content {
  width: 100%;
  max-width: 600px;
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.result__character {
  font-size: 80px;
  margin-bottom: 10px;
  animation: sway 3s ease-in-out infinite;
  display: inline-block;
}

.result__title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 10px;
}

.result__score {
  font-size: 28px;
  margin-bottom: 6px;
  letter-spacing: 2px;
  max-width: 100%;
  word-wrap: break-word;
  line-height: 1.4;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
}

.result__phrase {
  font-size: var(--text-base);
  color: var(--color-text-light);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Разбор ошибок */
.result__mistakes {
  text-align: left;
  margin-bottom: 24px;
}

.mistakes__title {
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--color-danger);
  font-size: var(--text-base);
}

.mistake__item {
  background: #fff3f3;
  border-left: 4px solid var(--color-danger);
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  line-height: 1.55;
}

/* Правила безопасности */
.result__rules {
  text-align: left;
  background: #f0fff4;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 24px;
}

.rules__title {
  font-size: var(--text-base);
  font-weight: 800;
  margin-bottom: 12px;
}

.rules__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rules__list li {
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* Кнопки финала */
.result__buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================================
   АНИМАЦИИ
   ============================================================ */

/* Покачивание персонажей */
@keyframes sway {
  0%, 100% { transform: rotate(-4deg); }
  50%       { transform: rotate(4deg); }
}

/* Плавное появление блоков */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Появление иконки реакции */
@keyframes popIn {
  0%   { transform: scale(0.3); opacity: 0; }
  70%  { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1);   opacity: 1; }
}

/* Плавающие звёзды на главном экране */
@keyframes floatUp {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.5; }
  50%       { transform: translateY(-20px) rotate(15deg); opacity: 0.8; }
}

/* ============================================================
   АДАПТИВНОСТЬ — телефоны (до 480px)
   ============================================================ */
@media (max-width: 480px) {
  :root {
    --text-base: 16px;
    --text-lg:   19px;
    --text-xl:   24px;
    --text-hero: 34px;
  }

  .character__cards {
    flex-direction: column;
    align-items: center;
  }

  .character__card {
    width: 100%;
    max-width: 320px;
  }

  .age__cards {
    flex-direction: column;
    align-items: center;
  }

  .age__card {
    width: 100%;
    max-width: 280px;
    padding: 24px 20px;
  }

  .result__buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  .game__question-box {
    padding: 16px 48px 16px 16px;
  }

  .result__score {
    font-size: 22px;
    letter-spacing: 1px;
    gap: 1px;
  }
}
