/* =================================================
   ЮНИВЕРИЯ — Стили мини-аппа квиза
   Адаптивно под мобильный webview, крупные кнопки.
   Цвета — только из бренд-токенов, без tg-theme override.
   ================================================= */

:root {
  /* Мини-апп использует только бренд-токены ЮНИВЕРИЯ.
     Тёмная тема Telegram намеренно игнорируется — бренд всегда светлый. */
  --bg:           var(--yun-bg-warm);
  --text:         var(--yun-navy-ink);
  --hint:         var(--yun-slate);
  --primary:      var(--yun-ginger);
  --primary-ink:  var(--yun-ginger-ink);
  --primary-soft: var(--yun-ginger-soft);
  --primary-text: #FFFFFF;
  --secondary-bg: var(--yun-paper);
  --link:         var(--yun-sky-ink);

  --success: var(--yun-success);
  --error:   var(--yun-error);
  --soft:    var(--yun-peach);     /* мягкая подложка вместо лавандовой */
  --mist:    var(--yun-mist);

  --grad-warm: var(--yun-grad-warm);

  --radius: var(--yun-radius-md);
  --shadow: var(--yun-shadow-md);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--yun-font-body, 'Inter'), -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 16px;
  line-height: var(--yun-lh-body, 1.55);
  color: var(--text) !important;
  background: var(--yun-grad-hero) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: var(--yun-font-display, 'Unbounded'), 'Inter', system-ui, sans-serif;
  letter-spacing: var(--yun-ls-tight, -0.02em);
  color: var(--yun-navy-ink, var(--text));
}

/* ============ ЭКРАНЫ (по одному на экран) ============ */

/* ============ ВЕРХНЯЯ ШАПКА БРЕНДА ============ */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--mist);
}
.app-logo {
  font-family: var(--yun-font-display, 'Unbounded'), system-ui;
  font-weight: 800;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: baseline;
}
.app-logo .logo-uni {
  color: var(--yun-navy-ink);
}
.app-logo .logo-veria {
  background: linear-gradient(90deg,
    var(--yun-gold) 0%,
    var(--yun-ginger) 55%,
    var(--yun-ginger-ink) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  /* Сверху отступ под фиксированную шапку (42px + 6px воздуха) */
  padding: 50px 16px 16px;
  min-height: 100vh;
  min-height: 100dvh; /* учитывает адресную строку на мобильных */
  max-width: 560px;
  margin: 0 auto;
  animation: screenIn 0.35s ease;
}
.screen.active { display: flex; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }
.center { text-align: center; }

/* ============ КАРТОЧКА (контент-блок) ============ */

.card {
  width: 100%;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-top: 12px;
  text-align: center;
}

h1 { font-size: 22px; margin: 0 0 12px; text-align: center; }
h2 { font-size: 18px; margin: 0 0 12px; line-height: 1.35; text-align: center; }
h3 { font-size: 15px; margin: 16px 0 8px; color: var(--hint); text-align: center; }
p  { margin: 0 0 12px; }
.muted { color: var(--hint); font-size: 14px; }

/* ============ КНОПКИ ============ */

.btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  margin-top: 12px;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--grad-warm);
  color: #fff;
  box-shadow: 0 10px 24px rgba(240, 138, 60, 0.30);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-secondary {
  background: var(--yun-paper, #fff);
  color: var(--primary-ink);
  border: 1.5px solid var(--mist);
}
.btn-secondary:hover { border-color: var(--primary); }

/* Outline-кнопка — для второй CTA */
.btn-outline {
  background: var(--yun-paper, #fff);
  color: var(--primary-ink);
  border: 2px solid var(--primary-soft);
  box-shadow: 0 4px 14px rgba(240, 138, 60, 0.10);
}
.btn-outline:hover { border-color: var(--primary); }

/* Текстовая «тихая» кнопка — для второстепенных действий */
.btn-link {
  background: transparent;
  color: var(--primary-ink);
  border: 0;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 12px;
  box-shadow: none;
  margin-top: 4px;
}
.btn-link:hover { color: var(--primary); }
.btn-mute { color: var(--yun-slate); font-weight: 500; }
.btn-mute:hover { color: var(--yun-navy); }

/* ============ CTA-блок на финале (Stage 5) ============ */

.cta-block {
  margin-top: 14px;
  border-top: 1px solid var(--mist);
  padding-top: 12px;
}
.cta-title {
  font-size: 13px;
  color: var(--yun-slate);
  margin: 0 0 8px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}
.cta-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 12px 14px;
  width: 100%;
  margin-top: 8px;
}
.cta-btn .cta-emoji {
  font-size: 24px;
  flex: 0 0 32px;
  text-align: center;
  line-height: 1;
}
.cta-btn .cta-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
}
.cta-btn .cta-text b { font-size: 15px; }
.cta-btn .cta-sub {
  font-size: 12px;
  opacity: 0.85;
  font-weight: 500;
}
.btn-outline.cta-btn .cta-sub { color: var(--yun-slate); }

/* ============ КОТ-РОБОТ ============ */

.cat-stage {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Мобильный отступ для облака-реплики над котом (под шапкой 42+padding 8) */
  margin: 56px auto 0;
}
.cat-stage.small { width: 100px; height: 100px; margin: 48px auto 0; }

/* Сцена-герой (экран приветствия) — крупнее, чтобы маскот смотрелся естественно */
.cat-stage.cat-stage-hero {
  width: 220px;
  height: 220px;
  margin: 60px auto 4px;
}

/* Десктоп: облако сбоку — большой верхний отступ не нужен */
@media (min-width: 720px) {
  .cat-stage,
  .cat-stage.small,
  .cat-stage.cat-stage-hero {
    margin-top: 12px;
  }
}

/* ============ ОБЛАКО-РЕПЛИКА КОТА ============ */

.cat-bubble {
  position: absolute;
  z-index: 3;
  /* Мобильная позиция по умолчанию — НАД котом, хвостик смотрит вниз */
  bottom: calc(100% + 14px);
  left: 50%;
  max-width: 260px;
  min-width: 140px;
  background: #FFFFFF;
  color: var(--yun-navy-ink);
  border: 2px solid var(--yun-mist);
  border-radius: 18px;
  padding: 10px 14px;
  font-family: var(--yun-font-body, 'Inter'), system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  box-shadow: 0 8px 22px rgba(30, 52, 100, 0.10);
  opacity: 0;
  transform: translate(-50%, 8px) scale(0.95);
  transform-origin: 50% 100%;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  white-space: pre-wrap;
}
.cat-bubble.visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
/* Хвостик облака — указывает вниз на кота (мобильная позиция) */
.cat-bubble::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-right: 2px solid var(--yun-mist);
  border-bottom: 2px solid var(--yun-mist);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 0 0 4px 0;
}
/* Курсор-каретка во время «печати» */
.cat-bubble.typing::after {
  content: '▍';
  display: inline-block;
  margin-left: 1px;
  color: var(--yun-ginger);
  animation: caretBlink 0.8s steps(1) infinite;
}
@keyframes caretBlink {
  50% { opacity: 0; }
}

/* Десктоп: облако СБОКУ от кота, в свободной зоне справа от карточки */
@media (min-width: 720px) {
  .cat-bubble {
    bottom: auto;
    left: calc(100% + 18px);
    top: 24px;
    max-width: 240px;
    transform: translateX(8px) scale(0.96);
    transform-origin: 0% 50%;
  }
  .cat-bubble.visible {
    transform: translateX(0) scale(1);
  }
  .cat-bubble::before {
    bottom: auto;
    left: -9px;
    top: 22px;
    transform: rotate(45deg);
    border-right: none;
    border-bottom: none;
    border-left: 2px solid var(--yun-mist);
    border-top: 2px solid var(--yun-mist);
    border-radius: 4px 0 0 0;
  }
}

/* Очень узкий экран — облако чуть уже */
@media (max-width: 380px) {
  .cat-bubble {
    max-width: 220px;
    font-size: 13px;
    padding: 8px 12px;
  }
}

/* Кнопка-динамик для голосового приветствия */
.audio-toggle {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--grad-warm);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(240, 138, 60, 0.40);
  transition: transform 0.15s ease, opacity 0.2s ease;
  z-index: 2;
}
.audio-toggle:active { transform: scale(0.94); }
.audio-toggle.playing {
  animation: audioPulse 1.4s ease-in-out infinite;
}
@keyframes audioPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 138, 60, 0.4); }
  50%      { box-shadow: 0 0 0 12px rgba(240, 138, 60, 0); }
}
.audio-toggle svg { width: 22px; height: 22px; fill: currentColor; }

.cat {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  filter: drop-shadow(0 8px 12px rgba(30, 52, 100, 0.14));
}

.cat-shadow {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 70%;
  height: 12px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.18), transparent 70%);
  border-radius: 50%;
  animation: catShadow 2.6s ease-in-out infinite;
}

/* ===== Состояния персонажа через CSS-анимации ===== */

/* IDLE — лёгкое покачивание + моргание */
.cat-idle {
  animation: catIdle 2.6s ease-in-out infinite;
}
@keyframes catIdle {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-6px) rotate(1deg); }
}
@keyframes catShadow {
  0%, 100% { transform: translateX(-50%) scaleX(1);   opacity: 0.7; }
  50%      { transform: translateX(-50%) scaleX(0.85); opacity: 0.4; }
}

/* HAPPY — прыжок (правильный ответ) */
.cat-happy {
  animation: catHappy 0.7s ease-out;
}
@keyframes catHappy {
  0%   { transform: translateY(0) scale(1); }
  30%  { transform: translateY(-26px) scale(1.06); }
  60%  { transform: translateY(0) scale(1); }
  80%  { transform: translateY(-10px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}

/* SUPPORTIVE — мягкое покачивание (поддержка после ошибки, не наказание) */
.cat-supportive {
  animation: catSupportive 0.9s ease-in-out;
}
@keyframes catSupportive {
  0%, 100% { transform: rotate(0) translateY(0); }
  25%      { transform: rotate(-3deg) translateY(-2px); }
  50%      { transform: rotate(0) translateY(0); }
  75%      { transform: rotate(3deg) translateY(-2px); }
}

/* THINKING — медленное вращение «думаю» (во время загрузки ИИ-отчёта) */
.cat-thinking {
  animation: catThink 2s ease-in-out infinite;
}
@keyframes catThink {
  0%, 100% { transform: rotate(-6deg); }
  50%      { transform: rotate(6deg); }
}

/* WAVING — приветствие, лёгкое размашистое движение */
.cat-waving {
  animation: catWave 1.2s ease-in-out;
}
@keyframes catWave {
  0%, 100% { transform: rotate(0) translateY(0); }
  25%      { transform: rotate(-8deg) translateY(-4px); }
  75%      { transform: rotate(8deg) translateY(-4px); }
}

/* WELCOME — приветствие на стартовом экране: взмах один раз, затем вечное лёгкое покачивание */
.cat-welcome {
  transform-origin: 60% 90%;
  animation: catWave 1.2s ease-in-out, catIdle 2.8s ease-in-out 1.2s infinite;
}

/* TALKING — слабая «дышащая» анимация (для экранов с текстом) */
.cat-talking {
  animation: catTalking 1.8s ease-in-out infinite;
}
@keyframes catTalking {
  0%, 100% { transform: scale(1) translateY(0); }
  50%      { transform: scale(1.03) translateY(-2px); }
}

/* POINTING — лёгкий подъём (подсказка) */
.cat-pointing {
  animation: catPoint 1s ease-in-out;
}
@keyframes catPoint {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px) rotate(-3deg); }
}

/* IDEA — пульсация (озарение на финале с высоким баллом) */
.cat-idea {
  animation: catIdea 0.9s ease-in-out;
}
@keyframes catIdea {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 8px 12px rgba(240, 138, 60, 0.18)); }
  50%      { transform: scale(1.08); filter: drop-shadow(0 8px 16px rgba(245, 158, 11, 0.5)); }
}

/* ============ ПРОГРЕСС-БАР ============ */

.quiz-header {
  width: 100%;
  margin-bottom: 8px;
}
.progress {
  width: 100%;
  height: 8px;
  background: var(--soft);
  border-radius: 8px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--grad-warm);
  border-radius: 8px;
  transition: width 0.35s ease;
}
.progress-text {
  display: flex;
  justify-content: flex-end;
  font-size: 12px;
  color: var(--hint);
  margin-top: 6px;
}

/* ============ ВОПРОСЫ ============ */

.topic-chip {
  display: inline-block;
  background: rgba(240, 138, 60, 0.14);
  color: var(--primary-ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 12px;
  border-radius: 999px;
  margin: 0 auto 10px;
}

.answer-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  align-items: stretch;
  text-align: left;
}

.option-btn {
  background: var(--soft);
  color: var(--text);
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid transparent;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.option-btn:active { transform: scale(0.98); }
.option-btn.selected {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(240, 138, 60, 0.18);
}
.option-btn.correct {
  background: rgba(31, 181, 106, 0.12);
  border-color: var(--success);
  color: #0F6A3F;
}
.option-btn.wrong {
  background: rgba(229, 72, 77, 0.10);
  border-color: var(--error);
  color: #8A1E22;
}

.numeric-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  border-radius: 12px;
  border: 2px solid var(--soft);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  text-align: center;
}
.numeric-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(240, 138, 60, 0.18);
}

/* ============ ВЫБОР КЛАССА ============ */

.grade-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0 12px;
}
.grade-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 18px 10px;
  background: var(--soft);
  color: var(--primary);
  border: 2px solid transparent;
  border-radius: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}
.grade-btn:active { transform: scale(0.97); }
.grade-btn:hover { border-color: rgba(240, 138, 60, 0.32); }
.grade-btn.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 6px 14px rgba(240, 138, 60, 0.32);
}
.grade-num {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}
.grade-label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
}

/* ============ ИНТЕРАКТИВ: ФИГУРА ПО ТОЧКАМ ============ */

.shape-canvas-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.shape-hint {
  font-size: 13px;
  color: var(--hint);
}
.shape-canvas {
  width: 100%;
  max-width: 175px;
  aspect-ratio: 1 / 1;
  background: #fff;
  border: 2px solid var(--soft);
  border-radius: 12px;
  touch-action: none;
  user-select: none;
}
.shape-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}
.shape-actions .btn-mini {
  flex: 1;
  background: var(--soft);
  color: var(--primary);
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  font-size: 14px;
}
.shape-actions .btn-mini:active { transform: scale(0.97); }

/* ============ ФИДБЕК (правильно/неправильно) ============ */

.feedback {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  animation: feedbackIn 0.25s ease;
}
.feedback.correct {
  background: rgba(31, 181, 106, 0.12);
  color: #0F6A3F;
}
.feedback.wrong {
  background: rgba(229, 72, 77, 0.10);
  color: #8A1E22;
}
@keyframes feedbackIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ РЕЗУЛЬТАТ ============ */

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 12px 0;
}
.score-circle {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: var(--grad-warm);
  color: #fff;
  font-family: var(--yun-font-display, 'Unbounded'), 'Inter', system-ui, sans-serif;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(240, 138, 60, 0.32);
  animation: scorePop 0.6s ease;
}
.score-pct {
  font-size: 18px;
  opacity: 0.9;
  align-self: center;
}

/* ============ КОМПАКТ ДЛЯ ФИНАЛА (без скролла) ============ */
#screen-result .cat-stage { width: 120px; height: 120px; margin-top: 44px; }
@media (min-width: 720px) {
  #screen-result .cat-stage { margin-top: 12px; }
}
#screen-result .card { padding: 14px 16px 16px; margin-top: 8px; }
#screen-result h1 { font-size: 20px; margin-bottom: 6px; }
#screen-result h3 { font-size: 13px; margin: 10px 0 6px; }
#screen-result .score-block { margin: 6px 0 4px; }
#screen-result .ai-report { margin-top: 10px; padding: 8px 12px; }
#screen-result .ai-report summary { font-size: 13px; }
#screen-result .btn { padding: 11px 16px; margin-top: 8px; font-size: 15px; }
#screen-result #result-summary { font-size: 13px; margin: 4px 0 0; }
#screen-result .topics-map { gap: 6px; }
#screen-result .topic-row { gap: 8px; }
#screen-result .topic-row .name { font-size: 13px; flex-basis: 40%; }
#screen-result .topic-row .pct { font-size: 12px; }
#screen-result .topic-row .bar { height: 6px; }

/* То же для вопроса — экран должен помещаться */
#screen-question .quiz-header { margin-bottom: 4px; }
#screen-question .card { padding: 12px 16px 14px; margin-top: 6px; }
#screen-question .answer-area { gap: 6px; margin: 8px 0; }
#screen-question .option-btn { padding: 11px 14px; font-size: 14px; }
#screen-question .btn { padding: 11px 16px; font-size: 15px; margin-top: 8px; }
#screen-question h2 { font-size: 15px; margin: 0 0 4px; line-height: 1.25; }
#screen-question .feedback { padding: 9px 12px; font-size: 13px; margin-top: 8px; }
#screen-question .cat-stage.small { width: 72px; height: 72px; margin-top: 20px; }
#screen-question .topic-chip { padding: 3px 10px; font-size: 11px; margin-bottom: 4px; }
#screen-question .shape-canvas-wrap { gap: 4px; }
#screen-question .shape-hint { font-size: 12px; margin: 0; }
#screen-question .shape-actions { gap: 6px; }
#screen-question .shape-actions .btn-mini { padding: 7px 10px; font-size: 12px; }

/* ===== Shape-вопрос: кот маленький слева, пузырь справа от него ===== */
#screen-question.has-shape .cat-stage.small {
  width: 100%;
  height: 56px;
  margin: 6px auto 2px;
  justify-content: flex-start;
  padding-left: 8px;
  overflow: visible;
}
#screen-question.has-shape .cat-stage.small .cat {
  width: 52px;
  height: 52px;
}
#screen-question.has-shape .cat-bubble {
  bottom: auto;
  top: 2px;
  left: 64px;
  max-width: calc(100% - 76px);
  min-width: 80px;
  font-size: 12px;
  padding: 7px 10px;
  transform: translateX(0) scale(0.96);
  transform-origin: 0% 50%;
}
#screen-question.has-shape .cat-bubble.visible {
  transform: translateX(0) scale(1);
}
#screen-question.has-shape .cat-bubble::before {
  bottom: auto;
  left: -9px;
  top: 10px;
  transform: rotate(45deg);
  border-right: none;
  border-bottom: none;
  border-left: 2px solid var(--yun-mist);
  border-top: 2px solid var(--yun-mist);
  border-radius: 4px 0 0 0;
}
@media (min-width: 720px) {
  #screen-question .cat-stage.small { margin-top: 8px; }
}
@keyframes scorePop {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

.topics-map {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.topic-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topic-row .name {
  flex: 0 0 45%;
  font-size: 14px;
}
.topic-row .bar {
  flex: 1;
  height: 8px;
  background: var(--soft);
  border-radius: 8px;
  overflow: hidden;
}
.topic-row .bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.6s ease;
}
.bar-good { background: var(--success); }
.bar-mid  { background: var(--yun-warning, #E8A43A); }
.bar-low  { background: var(--error); }

.topic-row .pct {
  flex: 0 0 40px;
  text-align: right;
  font-size: 13px;
  color: var(--hint);
}

.ai-report {
  margin-top: 16px;
  background: var(--soft);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
}
.ai-report[hidden] { display: none; }
.ai-report summary {
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.ai-report #ai-report-text {
  padding: 8px 0;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* ============ КОНФЕТТИ (победная сцена) ============ */

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti span {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: confettiFall 1.4s linear forwards;
  opacity: 0;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg);    opacity: 1; }
  100% { transform: translateY(220px) rotate(540deg); opacity: 0; }
}

/* ============ КОМПАКТ ДЛЯ МАЛЕНЬКИХ ЭКРАНОВ ============ */

@media (max-height: 640px) {
  .cat-stage { width: 130px; height: 130px; margin-top: 80px; }
  .cat-stage.cat-stage-hero { width: 200px; height: 200px; margin-top: 84px; }
  .score-circle { width: 100px; height: 100px; font-size: 32px; }
  .card { padding: 16px; }
  h1 { font-size: 20px; }
  h2 { font-size: 16px; }
}

/* Совсем узкие экраны (iPhone SE, старые Android) */
@media (max-width: 380px) {
  .cat-stage.cat-stage-hero { width: 200px; height: 200px; }
  .cat-stage { width: 150px; height: 150px; }
  .card { padding: 16px; }
  h1 { font-size: 20px; }
  .btn { padding: 12px 16px; font-size: 15px; }
}
