:root {
  --bg: #f6f3ff;
  --surface: #ffffff;
  --text: #1d1530;
  --muted: #6b6280;
  --brand: #6c3bff;
  --brand-ink: #ffffff;
  --accent: #ff4d8d;
  --line: #e6e0f5;
  --good: #14915f;
  --good-bg: #e3f6ec;
  --bad: #c2334d;
  --bad-bg: #fdebef;
  --you-bg: #efe8ff;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(60, 30, 140, 0.10);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #130f1f;
    --surface: #1e1830;
    --text: #f3efff;
    --muted: #a99fc4;
    --brand: #8f6bff;
    --accent: #ff6fa3;
    --line: #2f2747;
    --good: #4fd39a;
    --good-bg: #133326;
    --bad: #ff7f95;
    --bad-bg: #3a1822;
    --you-bg: #2c2150;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
  min-height: 100dvh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--brand);
  margin-bottom: 20px;
  text-decoration: none;
}
.brand img { width: 28px; height: 28px; border-radius: 8px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
  margin-bottom: 16px;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
h2 { font-size: 20px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 18px; }

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
input[type="text"]:focus { border-color: var(--brand); }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  padding: 15px 18px;
  border-radius: 14px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  margin-top: 12px;
  background: var(--brand);
  color: var(--brand-ink);
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.secondary { background: transparent; color: var(--brand); border: 2px solid var(--brand); }
.btn.accent { background: var(--accent); color: #fff; }

.error { color: var(--bad); font-weight: 600; margin: 10px 0 0; min-height: 1.2em; }

.progress { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width 0.25s; }

.question { font-size: 23px; font-weight: 750; line-height: 1.25; margin: 4px 0 18px; }

.options { display: grid; gap: 10px; }
.option {
  font: inherit;
  font-size: 17px;
  text-align: left;
  padding: 16px 16px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
.option:active { transform: scale(0.98); }
.option.picked { border-color: var(--brand); background: var(--you-bg); }

.link {
  background: none;
  border: 0;
  font: inherit;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 0;
}

.score {
  font-size: 64px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 6px 0 4px;
}
.center { text-align: center; }

.answers { list-style: none; margin: 0; padding: 0; }
.answers li { border-top: 1px solid var(--line); padding: 12px 0; }
.answers li:first-child { border-top: 0; }
.answers .q { font-weight: 650; margin-bottom: 6px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 14px; margin: 2px 6px 2px 0; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.key { background: var(--you-bg); color: var(--text); }

.board { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.board li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 12px; }
.board li.you { background: var(--you-bg); font-weight: 700; }
.board .rank { width: 28px; text-align: center; font-weight: 800; color: var(--muted); }
.board .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-weight: 800; }

.fine { color: var(--muted); font-size: 13px; text-align: center; margin: 18px 0 0; }
.fine a, .fine button { color: var(--muted); }

.loading, .noscript { text-align: center; color: var(--muted); margin-top: 40vh; }

.spinner {
  width: 40px; height: 40px; margin: 30vh auto 16px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 20px;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgba(10, 5, 25, 0.5); }
.reasons label { display: flex; gap: 10px; align-items: center; font-weight: 500; padding: 8px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 15px;
  max-width: calc(100vw - 32px);
}

/* Static pages */
.page h1 { font-size: 28px; }
.page h2 { font-size: 19px; margin-top: 26px; }
.page p, .page li { color: var(--text); }
.page a { color: var(--brand); }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { position: relative; padding: 0 0 14px 44px; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -2px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 800; display: grid; place-items: center;
}
