/* Quiz engine — styles. Цвета темы меняются в :root (или в <style> внутри index.html). */
:root {
  --bg1: #6d5dfc;
  --bg2: #b06ab3;
  --card: #ffffff;
  --text: #1d1b2f;
  --muted: #6b6880;
  --accent: #6d5dfc;
  --accent-text: #ffffff;
  --answer: #f4f3fb;
  --answer-active: #e6e3ff;
  --ok: #22b07d;
  --bad: #e5484d;
  --radius: 20px;
}

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

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

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

.screen { display: none; flex: 1; flex-direction: column; animation: fadeIn .35s ease; }
.screen.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: 0 18px 40px rgba(20, 10, 60, .25);
}

.screen.no-anim { animation: none; }

/* ---------- Language switch ---------- */
.lang {
  display: flex; flex: none;
  background: rgba(255,255,255,.2);
  border-radius: 12px;
  padding: 3px;
}
.lang button {
  border: 0; background: transparent; color: #fff;
  font: 700 13px/1 inherit; font-family: inherit;
  padding: 9px 10px; border-radius: 9px; cursor: pointer; min-width: 38px;
}
.lang button.on { background: #fff; color: var(--accent); }
.start-top { justify-content: flex-end; }

/* ---------- Start screen ---------- */
.start { justify-content: center; text-align: center; }
.start .hero {
  font-size: 96px;
  line-height: 1;
  margin: 8px 0 18px;
  animation: float 3s ease-in-out infinite;
}
.start .hero img { width: 180px; height: 180px; object-fit: cover; border-radius: 28px; }
.badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--answer-active);
  color: var(--accent);
  margin-bottom: 12px;
}
h1 { font-size: 27px; line-height: 1.2; margin: 0 0 10px; font-weight: 800; }
.sub { font-size: 16px; line-height: 1.45; color: var(--muted); margin: 0 0 22px; }
.meta { display: flex; justify-content: center; gap: 16px; font-size: 14px; color: var(--muted); margin-top: 14px; }

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 18px 20px;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 8px 20px rgba(109, 93, 252, .35);
  text-decoration: none;
  text-align: center;
  transition: transform .12s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: none; border: 2px solid var(--answer-active); margin-top: 10px; }
.btn.pulse { animation: pulseBtn 1.8s ease-in-out infinite; }
@keyframes pulseBtn { 0%, 100% { box-shadow: 0 8px 20px rgba(109, 93, 252, .35); } 50% { box-shadow: 0 8px 34px rgba(109, 93, 252, .7); } }

/* ---------- Question screen ---------- */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; color: #fff; }
.back {
  border: 0; background: rgba(255,255,255,.2); color: #fff;
  width: 38px; height: 38px; border-radius: 12px; font-size: 20px; cursor: pointer; flex: none;
}
.back[hidden] { visibility: hidden; display: block; }
.progress { flex: 1; height: 8px; background: rgba(255,255,255,.25); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: #fff; border-radius: 99px; transition: width .4s ease; }
.counter { font-size: 14px; font-weight: 700; min-width: 38px; text-align: right; }

.q-media {
  height: 170px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 84px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--answer-active), var(--answer));
  overflow: hidden;
}
.q-media img { width: 100%; height: 100%; object-fit: cover; }
.q-media span { animation: pop .45s ease; display: inline-block; }
.q-title { font-size: 21px; line-height: 1.3; font-weight: 800; margin: 0 0 16px; }

.answers { display: grid; gap: 10px; }
.answers.grid { grid-template-columns: 1fr 1fr; }
.answer {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--answer);
  padding: 15px 14px;
  font-size: 16px; font-weight: 600; font-family: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform .12s ease, background .2s, border-color .2s;
}
.answer:active { transform: scale(.97); }
.answer .ico { font-size: 26px; flex: none; }
.answers.grid .answer { flex-direction: column; text-align: center; padding: 16px 10px; gap: 8px; }
.answers.grid .answer .ico { font-size: 40px; }
.answers.grid .answer img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.answer.chosen { background: var(--answer-active); border-color: var(--accent); }
.answer.correct { background: #e3f7ef; border-color: var(--ok); }
.answer.wrong { background: #fdeaea; border-color: var(--bad); }
.answers.locked .answer { pointer-events: none; }

.feedback { min-height: 22px; margin-top: 12px; font-size: 15px; font-weight: 600; text-align: center; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }

/* ---------- Loading screen ---------- */
.loading { justify-content: center; text-align: center; color: #fff; }
.spinner {
  width: 72px; height: 72px; margin: 0 auto 22px;
  border: 6px solid rgba(255,255,255,.25); border-top-color: #fff;
  border-radius: 50%; animation: spin 1s linear infinite;
}
.loading h2 { font-size: 22px; margin: 0 0 18px; }
.steps { list-style: none; padding: 0; margin: 0 auto; max-width: 300px; text-align: left; }
.steps li { padding: 8px 0; font-size: 16px; opacity: .45; transition: opacity .3s; }
.steps li.done { opacity: 1; }
.steps li.done::before { content: "✓ "; font-weight: 800; }

/* ---------- Result screen ---------- */
.result { justify-content: center; }
.result .card { text-align: center; }
.result .r-media { font-size: 100px; line-height: 1; margin: 4px 0 12px; animation: pop .6s ease; }
.result .r-media img { width: 100%; max-height: 240px; object-fit: cover; border-radius: 16px; }
.result .r-label { font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.result h2 { font-size: 28px; margin: 6px 0 12px; line-height: 1.2; }
.result .r-text { font-size: 16px; line-height: 1.55; color: var(--text); margin: 0 0 16px; text-align: left; }
.score {
  display: inline-block; font-size: 15px; font-weight: 700;
  background: var(--answer-active); color: var(--accent);
  padding: 8px 14px; border-radius: 999px; margin-bottom: 14px;
}
.traits { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0 0 18px; }
.traits span { background: var(--answer); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 600; }
.r-section { text-align: left; border-top: 1px solid var(--answer-active); padding-top: 14px; margin-top: 4px; margin-bottom: 14px; }
.r-section h3 { font-size: 17px; margin: 0 0 6px; }
.r-section p { font-size: 15px; line-height: 1.55; margin: 0 0 6px; color: var(--text); }

/* ---------- Fact / cheer ---------- */
.cheer {
  font-size: 14px; font-weight: 700; text-align: center;
  background: var(--answer-active); color: var(--accent);
  border-radius: 12px; padding: 9px 12px; margin-bottom: 14px;
  animation: pop .45s ease;
}
.fact {
  margin-top: 14px; padding: 14px; border-radius: 14px;
  background: #fff8e6; border: 1px solid #ffe2a0;
  animation: fadeIn .35s ease;
}
.fact b { font-size: 15px; }
.fact p { font-size: 15px; line-height: 1.5; margin: 6px 0 12px; }
.fact .btn { padding: 15px; font-size: 17px; }

/* ---------- More quizzes ---------- */
.more { margin-top: 14px; }
.more h3 { font-size: 17px; margin: 0 0 10px; }
.more-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: 14px; background: var(--answer);
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 16px;
  margin-top: 8px;
}
.more-item .ico { font-size: 26px; }
.more-item .go { margin-left: auto; font-size: 22px; color: var(--accent); }

.foot { text-align: center; color: rgba(255,255,255,.75); font-size: 12px; margin-top: 16px; line-height: 1.5; }
.foot a { color: inherit; }

@media (max-height: 680px) {
  .q-media { height: 120px; font-size: 64px; }
  .start .hero { font-size: 76px; }
  .answer { padding: 12px; }
}
