:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #18181d;
  --muted: #6c6a72;
  --line: #e3e0d8;
  --accent: #1d1d24;
  --right: #17834a;
  --right-bg: #e7f5ed;
  --wrong: #c93a3a;
  --wrong-bg: #fcebeb;
  --radius: 18px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px max(16px, env(safe-area-inset-left)) 14px max(16px, env(safe-area-inset-right));
  padding-top: max(14px, env(safe-area-inset-top));
  background: rgba(245, 243, 238, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-topic {
  overflow: hidden;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nav { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.nav-link,
.nav-button {
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.nav-link { color: var(--muted); }
.nav-link:hover { color: var(--ink); }
.nav-button { border-color: var(--line); background: var(--card); }
.nav-button:hover { border-color: var(--ink); }

/* Layout */
.wrap {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* Progress */
.stats { margin-bottom: 14px; }

.stats-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stats-row { align-items: center; }
.stats-right { display: flex; align-items: center; gap: 10px; }
.points { padding: 2px 9px; border-radius: 999px; background: var(--accent); color: #fff; }

.bar { height: 6px; overflow: hidden; border-radius: 999px; background: var(--line); }
.bar-fill { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.3s ease; }

/* Card */
.card {
  padding: 24px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(24, 24, 29, 0.04), 0 8px 24px rgba(24, 24, 29, 0.06);
}

.card-cat {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-q {
  margin: 0 0 20px;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

/* Answers */
.options { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.option:hover:not(:disabled) { border-color: var(--ink); }
.option:active:not(:disabled) { transform: scale(0.99); }
.option:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.option:disabled { cursor: default; }

.option-letter {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.option-text { flex: 1; font-weight: 500; }

.option-mark { flex-shrink: 0; width: 22px; font-size: 1.15rem; font-weight: 800; text-align: center; }

.option.is-wrong { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); }
.option.is-wrong .option-letter { background: var(--wrong); color: #fff; }

.option.is-right { border-color: var(--right); background: var(--right-bg); color: var(--right); }
.option.is-right .option-letter { background: var(--right); color: #fff; }

.option.is-wrong { animation: shake 0.3s; }

/* Once solved, fade the answers that weren't tried */
.options.is-solved .option:not(.is-right):not(.is-wrong) { opacity: 0.45; }

@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Feedback */
.feedback { min-height: 1.5em; margin: 16px 0 0; font-weight: 600; }
.feedback.is-right { color: var(--right); }
.feedback.is-wrong { color: var(--wrong); }

.note {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.925rem;
}

.primary {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 15px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.primary:hover { opacity: 0.9; }

/* End screen */
.done-score { margin: 0; font-size: 2.5rem; font-weight: 800; letter-spacing: -0.03em; }
.done-points { margin: 2px 0 0; font-size: 1.1rem; font-weight: 700; }
.done-msg { margin: 4px 0 0; color: var(--muted); }

/* Instructions page */
.how p { margin: 0 0 12px; }
.how-h { margin: 24px 0 8px; font-size: 1rem; }

.points-table { margin: 0 0 12px; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.points-table li { display: flex; justify-content: space-between; padding: 9px 14px; font-variant-numeric: tabular-nums; }
.points-table li + li { border-top: 1px solid var(--line); }

.steps { margin: 0; padding-left: 1.25em; }
.steps li { margin-bottom: 10px; padding-left: 4px; }

kbd {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg);
  font-family: inherit;
  font-size: 0.85em;
}

@media (min-width: 560px) {
  .wrap { padding-top: 32px; }
  .card { padding: 32px; }
  .card-q { font-size: 1.5rem; }
}

/* Short nav label on phones so the topic chip fits */
.label-short { display: none; }

@media (max-width: 430px) {
  .label-long { display: none; }
  .label-short { display: inline; }
  .brand { gap: 8px; }
  .nav { gap: 2px; }
  .nav-link { padding: 8px 8px; }
}

@media (max-width: 340px) {
  .brand-title { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
