/* ---------- Тема: дефолт (тёмный), переопределяется Telegram themeParams ---------- */
:root {
  --bg: #17212b;
  --text: #ffffff;
  --hint: #8a9bae;
  --accent: #5eb5f7;
  --accent-text: #ffffff;
  --card: #232e3c;
  --card-2: #2b3848;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 16px;
  --max-w: 560px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Экраны ---------- */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: fade-in 0.25s ease;
}
.screen.is-active { display: flex; }

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

/* ---------- Кнопки ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn--ghost {
  background: transparent;
  color: var(--hint);
  border: 1px solid var(--border);
}

/* ---------- Интро ---------- */
.intro {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  padding: 24px 0;
}
.intro__emoji { font-size: 72px; line-height: 1; }
.intro__title { font-size: 28px; font-weight: 800; margin: 0; letter-spacing: -0.5px; }
.intro__lead { font-size: 17px; color: var(--hint); margin: 0; max-width: 420px; }
.intro #btn-start { max-width: 360px; margin-top: 8px; }
.intro__hint { font-size: 14px; color: var(--hint); margin: 0; opacity: 0.8; }

/* ---------- Квиз ---------- */
.quiz { flex: 1; display: flex; flex-direction: column; padding-top: 8px; }
.quiz__progress { margin-bottom: 22px; }
.quiz__progress-text { font-size: 14px; color: var(--hint); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.quiz__progress-bar {
  height: 6px;
  background: var(--card);
  border-radius: 99px;
  overflow: hidden;
}
.quiz__progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.quiz__question {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 22px;
  line-height: 1.3;
}
.quiz__options { display: flex; flex-direction: column; gap: 12px; }
.option {
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1.4;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.option:active { transform: scale(0.985); background: var(--card-2); }
.option.is-picked { border-color: var(--accent); background: var(--card-2); }

/* ---------- Результат ---------- */
.result { flex: 1; display: flex; flex-direction: column; gap: 22px; padding-top: 8px; }
.result__head { text-align: center; }
.result__emoji { font-size: 72px; line-height: 1; margin-bottom: 8px; }
.result__name { font-size: 30px; font-weight: 800; margin: 0; letter-spacing: -0.5px; }
.result__psychotype { font-size: 16px; color: var(--accent); font-weight: 600; margin-top: 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.result__desc { margin: 0; font-size: 16px; line-height: 1.5; }
.result__tagline {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--card-2);
  border-radius: 12px;
  font-style: italic;
  font-size: 16px;
}
.result__team { margin-top: 16px; font-size: 15px; }
.result__team-label { color: var(--hint); display: block; margin-bottom: 2px; }
.result__team-text { font-weight: 600; }

.block { display: flex; flex-direction: column; gap: 12px; }
.block__title { font-size: 18px; font-weight: 700; margin: 0; }

/* ---------- Полоски процентов ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar { display: flex; flex-direction: column; gap: 5px; }
.bar__head { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; }
.bar__name { font-weight: 600; }
.bar__name .bar__emoji { margin-right: 6px; }
.bar__pct { color: var(--hint); font-variant-numeric: tabular-nums; }
.bar__track { height: 8px; background: var(--card); border-radius: 99px; overflow: hidden; }
.bar__fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.bar.is-me .bar__fill { background: var(--accent); }
.bar.is-me .bar__name { color: var(--accent); }
.bar:not(.is-me) .bar__fill { opacity: 0.55; }

.stats-summary {
  font-size: 15px;
  color: var(--hint);
  margin-bottom: 4px;
}
.stats-summary b { color: var(--text); }

.result__actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

/* ---------- Тост ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 12px 20px;
  border-radius: 99px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 380px) {
  body { font-size: 16px; }
  .intro__title { font-size: 24px; }
  .quiz__question { font-size: 20px; }
  .result__name { font-size: 26px; }
}
