:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --text: #1f1f1f;
  --muted: #726f68;
  --border: #e2ded4;
  --primary: #1f1f1f;
  --accent: #ff5a36;
  --correct: #1aae7a;
  --wrong: #e1483f;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 31, 31, 0.04), 0 8px 24px rgba(31, 31, 31, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.page { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 0.85rem;
}

.content {
  flex: 1; width: 100%; max-width: 760px; margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

.footer {
  text-align: center; padding: 1.25rem; color: var(--muted);
  font-size: 0.82rem; border-top: 1px solid var(--border);
}

/* ---------- Home / hero ---------- */
.hero { display: flex; flex-direction: column; gap: 2.25rem; }
.hero-copy h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 800; line-height: 1.15;
  margin: 0 0 0.75rem;
}
.lead { color: var(--muted); font-size: 1.02rem; line-height: 1.55; margin: 0 0 1.5rem; }

.topic-form { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.topic-input {
  flex: 1 1 260px; min-width: 0; padding: 0.85rem 1rem; border-radius: 12px;
  border: 1.5px solid var(--border); font-size: 1rem; font-family: inherit;
  background: var(--surface);
}
.topic-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 90, 54, 0.18);
}

.btn-quiz {
  display: inline-flex; align-items: center; gap: 0.5rem; justify-content: center;
  padding: 0.85rem 1.4rem; border-radius: 12px; border: none;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 0.98rem;
  cursor: pointer; text-decoration: none; transition: transform 0.12s ease, opacity 0.12s ease;
  white-space: nowrap;
}
.btn-quiz:hover { transform: translateY(-1px); opacity: 0.92; color: #fff; }
.btn-quiz:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-quiz.is-loading { opacity: 0.6; cursor: progress; }
.btn-quiz--ghost {
  background: transparent; color: var(--text); border: 1.5px solid var(--border);
  margin-top: 1.5rem;
}

.form-error { color: var(--wrong); font-weight: 600; margin-top: 0.6rem; }

.steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;
}
.step {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.step-num {
  display: block; font-family: 'JetBrains Mono', monospace; font-weight: 700;
  color: var(--accent); font-size: 0.85rem; margin-bottom: 0.35rem; letter-spacing: 0.04em;
}
.step-text { color: var(--text); font-size: 0.94rem; line-height: 1.4; }

/* ---------- Quiz / state cards ---------- */
.topic-chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: var(--surface); border: 1px solid var(--border);
  padding: 0.4rem 0.85rem; border-radius: 999px; font-weight: 700;
  font-size: 0.85rem; margin-bottom: 1.25rem; color: var(--muted);
}
.topic-chip i { color: var(--accent); }

.state-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem 1.75rem; box-shadow: var(--shadow); text-align: center;
}
.state-card h2 { font-size: 1.3rem; margin: 0.5rem 0 0.5rem; }
.state-card p { color: var(--muted); margin: 0; }
.state-error i { font-size: 1.8rem; color: var(--wrong); }
.state-pending i, .state-pending .spinner { color: var(--accent); }

.spinner {
  width: 2.4rem; height: 2.4rem; border-radius: 50%; margin: 0 auto 0.75rem;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.name-card { text-align: left; }
.name-card h2 { text-align: left; }
.name-form { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0 1.1rem; }
.name-form input {
  flex: 1 1 220px; padding: 0.8rem 1rem; border-radius: 12px;
  border: 1.5px solid var(--border); font-size: 1rem; font-family: inherit;
}
.name-form input:focus { outline: none; border-color: var(--accent); }
.link-muted { color: var(--muted); font-size: 0.9rem; text-decoration: none; }
.link-muted:hover { color: var(--accent); }

/* Signature element: the answer trail — a strip of 10 dots tracking progress
   through the quiz, filling in as the player answers each question. */
.trail {
  display: flex; gap: 0.4rem; justify-content: center; margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.trail-dot {
  width: 1.6rem; height: 0.45rem; border-radius: 999px; background: var(--border);
  transition: background 0.25s ease;
}
.trail-dot--answered { background: var(--primary); }
.trail-dot--correct { background: var(--correct); }
.trail-dot--wrong { background: var(--wrong); }

.quiz-card { text-align: left; }
.question-head { text-align: center; margin-bottom: 0.5rem; }
.question-count {
  font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--muted);
  letter-spacing: 0.05em; text-transform: uppercase;
}
.question-text {
  font-size: 1.35rem; font-weight: 700; text-align: center; line-height: 1.35;
  margin: 0.5rem 0 1.5rem;
}

.options { display: grid; gap: 0.65rem; }
.option-btn {
  display: flex; align-items: center; gap: 0.75rem; text-align: left;
  padding: 0.85rem 1rem; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); font-family: inherit; font-size: 0.98rem; color: var(--text);
  cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease;
}
.option-btn:hover:not(:disabled) { border-color: var(--accent); }
.option-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.option-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; border-radius: 8px; background: var(--bg);
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 0.82rem;
  flex-shrink: 0;
}
.option-btn--picked { border-color: var(--primary); background: #f6f4ef; }
.option-btn--dim { opacity: 0.5; }

.result-card { display: flex; flex-direction: column; align-items: center; }
.result-score { display: flex; align-items: baseline; gap: 0.35rem; }
.result-number {
  font-family: 'JetBrains Mono', monospace; font-size: 3.4rem; font-weight: 800;
  color: var(--accent); line-height: 1;
}
.result-total { font-family: 'JetBrains Mono', monospace; font-size: 1.3rem; color: var(--muted); }
.result-caption { color: var(--muted); margin-top: 0.4rem; }

.share-block { margin-top: 1.5rem; width: 100%; }
.share-label { font-weight: 700; font-size: 0.88rem; margin-bottom: 0.6rem; text-align: center; }
.share-buttons { display: flex; flex-wrap: wrap; gap: 0.7rem; justify-content: center; }
.share-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 3rem; height: 3rem; border-radius: 50%; border: none;
  background: var(--muted); color: #fff; text-decoration: none;
  font-family: inherit; cursor: pointer; box-shadow: var(--shadow);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.share-btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.share-btn i { font-size: 1.25rem; line-height: 1; }
.share-btn--vk { background: #0077ff; }
.share-btn--telegram { background: #29a9ea; }
.share-btn--whatsapp { background: #25d366; }
.share-btn--copy { background: var(--primary); }

/* ---------- Leaderboard ---------- */
.board-wrap { }
.board-title { font-size: 1.6rem; font-weight: 800; margin: 0.2rem 0 0.3rem; }
.board-list { list-style: none; margin: 1.5rem 0; padding: 0; display: grid; gap: 0.5rem; }
.board-row {
  display: flex; align-items: center; gap: 0.9rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.75rem 1.1rem;
}
.board-row--top { border-color: var(--accent); }
.board-rank {
  font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--muted);
  width: 1.6rem; text-align: center;
}
.board-row--top .board-rank { color: var(--accent); }
.board-name { flex: 1; font-weight: 600; }
.board-score { font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: 1.1rem; }
.board-score-total { font-weight: 500; color: var(--muted); font-size: 0.85rem; }
.board-actions { margin: 1.5rem 0; }

@media (max-width: 560px) {
  .steps { grid-template-columns: 1fr; }
  .content { padding: 1.75rem 1rem 2.5rem; }
  .result-number { font-size: 2.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--border); }
  .btn-quiz, .option-btn { transition: none; }
}
