* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg1: #12103a;
  --bg2: #2b1a5e;
  --accent: #ffd166;
  --accent2: #06d6a0;
  --danger: #ef476f;
  --card: #1c1946;
  --text: #f4f2ff;
  --muted: #a9a3d6;
}

body {
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, var(--bg1), var(--bg2) 60%, #43117a);
  color: var(--text);
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(400px 400px at 15% 20%, rgba(255, 209, 102, .18), transparent 70%),
    radial-gradient(500px 500px at 85% 80%, rgba(6, 214, 160, .16), transparent 70%);
}

.app {
  width: min(720px, 100%);
  padding: 16px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.logo { font-size: 1.25rem; font-weight: 800; letter-spacing: .5px; }

.badge {
  background: rgba(255, 209, 102, .15);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
}

.screen { display: none; animation: pop .35s ease; }
.screen.active { display: block; }

.card {
  background: rgba(28, 25, 70, .9);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 22px;
  padding: 26px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  position: relative;
  overflow: hidden;
}

.start-card { text-align: center; padding: 42px 26px; }
.start-card h1 { font-size: 2rem; margin: 10px 0 14px; }
.start-card p { color: var(--muted); margin-bottom: 10px; line-height: 1.5; }
.start-card b { color: var(--accent); }

.big-emoji { font-size: 4rem; }
.float { animation: float 2.4s ease-in-out infinite; }

.start-hint { margin-top: 14px; font-size: .85rem; color: var(--muted); }

.btn {
  border: none;
  border-radius: 16px;
  padding: 15px 30px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active { transform: translateY(1px) scale(.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ff9f1c);
  color: #2b1a00;
  box-shadow: 0 8px 24px rgba(255, 159, 28, .35);
  margin-top: 12px;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 700;
}

.score-pill {
  background: rgba(6, 214, 160, .15);
  border: 1px solid var(--accent2);
  color: var(--accent2);
  padding: 5px 14px;
  border-radius: 999px;
}

.progress {
  height: 10px;
  background: rgba(255, 255, 255, .12);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-bar {
  height: 100%;
  width: 4%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width .45s cubic-bezier(.3, 1.2, .5, 1);
}

.q-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 8px;
}

.question-card h2 { font-size: 1.35rem; line-height: 1.4; margin-bottom: 20px; }

.answers { display: grid; gap: 12px; }

.answer {
  text-align: left;
  background: rgba(255, 255, 255, .06);
  border: 2px solid rgba(255, 255, 255, .14);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform .12s, background .2s, border-color .2s;
  animation: slideUp .3s ease backwards;
}
.answer:nth-child(1) { animation-delay: .02s; }
.answer:nth-child(2) { animation-delay: .09s; }
.answer:nth-child(3) { animation-delay: .16s; }
.answer:nth-child(4) { animation-delay: .23s; }

.answer:hover:not(:disabled) {
  background: rgba(255, 209, 102, .14);
  border-color: var(--accent);
  transform: translateX(5px);
}
.answer:disabled { cursor: default; }

.answer .key {
  flex: 0 0 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .12);
  border-radius: 9px;
  font-weight: 800;
  font-size: .9rem;
}

.answer.correct {
  background: rgba(6, 214, 160, .22);
  border-color: var(--accent2);
  animation: shake .35s;
}
.answer.correct .key { background: var(--accent2); color: #04352a; }

.answer.wrong {
  background: rgba(239, 71, 111, .22);
  border-color: var(--danger);
  animation: shake .35s;
}
.answer.wrong .key { background: var(--danger); color: #fff; }

.answer.dim { opacity: .45; }

.feedback {
  min-height: 26px;
  margin-top: 14px;
  font-weight: 800;
  font-size: 1.05rem;
}
.feedback.ok { color: var(--accent2); }
.feedback.bad { color: var(--danger); }

.hidden { display: none; }

#nextBtn { width: 100%; }

/* --- Результат --- */
.result-card { text-align: center; padding: 36px 26px; }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.result-emoji { font-size: 4rem; animation: float 2.2s ease-in-out infinite; }

.result-score {
  font-size: 6rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: zoomIn .5s cubic-bezier(.3, 1.4, .5, 1);
}

.result-label { color: var(--muted); margin-top: 6px; font-weight: 600; }

.result-text {
  margin: 18px auto 8px;
  max-width: 420px;
  line-height: 1.55;
  color: var(--text);
}

@keyframes pop { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
@keyframes zoomIn { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- Правила на старте --- */
.rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0 8px;
}
.rule {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 16px;
  padding: 14px 12px;
  transition: transform .2s, border-color .2s;
}
.rule:hover { transform: translateY(-4px); border-color: var(--accent); }
.rule span { font-size: 1.5rem; }
.rule p { margin-top: 8px; font-size: .85rem; color: var(--muted); line-height: 1.4; }
.rule b { color: var(--accent); }

/* --- Шапка вопроса и фазы --- */
.question-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), #4cc9f0);
}
.q-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.q-label { margin-bottom: 0; }
.phase-chip {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 800;
  white-space: nowrap;
}
.phase-chip.think {
  background: rgba(255, 209, 102, .16);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.phase-chip.fast {
  background: rgba(6, 214, 160, .16);
  color: var(--accent2);
  border: 1px solid var(--accent2);
  animation: blink .5s infinite alternate;
}

/* --- Фаза раздумий --- */
.think-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 209, 102, .1);
  border: 2px dashed rgba(255, 209, 102, .55);
  border-radius: 16px;
  padding: 16px;
  font-weight: 700;
  animation: pulseThink 1s infinite alternate;
}
.think-emoji { font-size: 1.8rem; }
.think-box b { font-size: 1.5rem; color: var(--accent); margin-left: 6px; }

/* --- Таймер ответа --- */
.timer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.timer-track {
  flex: 1;
  height: 12px;
  background: rgba(255, 255, 255, .1);
  border-radius: 999px;
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #06d6a0, #4cc9f0);
  transition: width .06s linear;
}
.timer-bar[data-level="warn"] { background: linear-gradient(90deg, #ffd166, #ff9f1c); }
.timer-bar[data-level="danger"] {
  background: linear-gradient(90deg, #ef476f, #ff6b6b);
  animation: blink .3s infinite alternate;
}
.timer-num {
  min-width: 48px;
  text-align: right;
  font-weight: 900;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent2);
}
.timer-num[data-level="warn"] { color: var(--accent); }
.timer-num[data-level="danger"] { color: var(--danger); }

/* --- Пульс счёта и статистика --- */
.score-pill.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.25); } }

.stats-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 18px 0 4px;
}
.stat-pill {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 16px;
  padding: 12px 20px;
  min-width: 140px;
}
.stat-pill span {
  display: block;
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1.1;
}
.stat-pill small {
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

@keyframes blink { from { opacity: .7; } to { opacity: 1; } }
@keyframes pulseThink { from { opacity: .8; } to { opacity: 1; } }

/* --- Анализ ответов --- */
.analysis {
  text-align: left;
  margin-top: 16px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
  border-left: 4px solid var(--accent2);
  border-radius: 16px;
  padding: 16px 18px;
}
.analysis-title {
  font-weight: 900;
  font-size: .78rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 8px;
}
.analysis-arch {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 12px;
}
.analysis-list { list-style: none; display: grid; gap: 8px; }
.analysis-list li {
  background: rgba(255, 255, 255, .05);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: .95rem;
  line-height: 1.45;
  animation: slideUp .35s ease backwards;
}
.analysis-list li:nth-child(1) { animation-delay: .05s; }
.analysis-list li:nth-child(2) { animation-delay: .13s; }
.analysis-list li:nth-child(3) { animation-delay: .21s; }
.analysis-list li:nth-child(4) { animation-delay: .29s; }
.analysis-list li:nth-child(5) { animation-delay: .37s; }
.analysis-list b { color: var(--accent2); }

.hidden { display: none !important; }

@media (max-width: 480px) {
  .question-card h2 { font-size: 1.15rem; }
  .result-score { font-size: 4.6rem; }
  .card { padding: 20px; }
  .rules { grid-template-columns: 1fr; }
  .stats-row { flex-wrap: wrap; }
}
