:root {
  --bg: #fdfdfc;
  --fg: #1a1a18;
  --muted: #8a8a80;
  --line: #e0e0d8;
  --accent: #1a1a18;
  --accent-fg: #fdfdfc;
  --ok: #2f7d4f;
  --ok-bg: #e8f4ec;
  --bad: #b4342c;
  --bad-bg: #fbecea;
}

/* Dark palette applies when the system asks for it and the user has not
   explicitly chosen light, or when the user has explicitly chosen dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161614;
    --fg: #ecece6;
    --muted: #7c7c74;
    --line: #2e2e2a;
    --accent: #ecece6;
    --accent-fg: #161614;
    --ok: #6fce96;
    --ok-bg: #1c2c22;
    --bad: #ef8079;
    --bad-bg: #2e1d1c;
  }
}

:root[data-theme="dark"] {
  --bg: #161614;
  --fg: #ecece6;
  --muted: #7c7c74;
  --line: #2e2e2a;
  --accent: #ecece6;
  --accent-fg: #161614;
  --ok: #6fce96;
  --ok-bg: #1c2c22;
  --bad: #ef8079;
  --bad-bg: #2e1d1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

/* header ------------------------------------------------------------------ */

header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.selectors { display: flex; flex-direction: column; gap: 0.4rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }

.chip {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip:hover:not(:disabled) { color: var(--fg); border-color: var(--muted); }

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.chip:disabled { opacity: 0.35; cursor: not-allowed; }

.parts .chip {
  padding: 0.2rem 0.5rem;
  border-radius: 0.35rem;
  font-size: 0.75rem;
}

.modes { margin-bottom: 0.15rem; }

.modes .chip {
  padding: 0.25rem 0.7rem;
  border-radius: 0.35rem;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.scoreline { display: flex; align-items: center; gap: 0.5rem; }

.score {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

.reset {
  border: none;
  background: none;
  padding: 0.15rem 0.3rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  text-decoration: underline;
  cursor: pointer;
  opacity: 0.7;
}

.reset:hover { opacity: 1; color: var(--fg); }

.theme {
  width: 1.9rem;
  height: 1.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.theme:hover { color: var(--fg); border-color: var(--muted); }

/* prompt ------------------------------------------------------------------ */

.prompt { text-align: center; padding: 3rem 0 0.5rem; }

#word {
  margin: 0;
  font-size: clamp(2.25rem, 8vw, 3.25rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

.pos {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.hint {
  margin: 2.5rem 0 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* options ----------------------------------------------------------------- */

.options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

@media (max-width: 34rem) {
  .options { grid-template-columns: repeat(2, 1fr); }
}

.option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: none;
  color: var(--fg);
  font: inherit;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.option:hover:not(:disabled) { border-color: var(--muted); }

.option .num {
  position: absolute;
  top: 0.35rem;
  left: 0.45rem;
  font-size: 0.65rem;
  color: var(--muted);
  opacity: 0.6;
}

.option .mark {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.option.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.option:disabled { cursor: default; opacity: 1; }

.option.correct {
  border-color: var(--ok);
  background: var(--ok-bg);
  color: var(--ok);
}

.option.missed {
  border-color: var(--ok);
  border-style: dashed;
  color: var(--ok);
}

.option.wrong {
  border-color: var(--bad);
  background: var(--bad-bg);
  color: var(--bad);
}

.option.correct .mark, .option.missed .mark { color: var(--ok); }
.option.wrong .mark { color: var(--bad); }

/* foot -------------------------------------------------------------------- */

.foot { text-align: center; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.submit {
  min-width: 9rem;
  padding: 0.7rem 1.5rem;
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  cursor: pointer;
}

.submit:disabled {
  border-color: var(--line);
  background: none;
  color: var(--muted);
  cursor: not-allowed;
}

.ghost {
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.ghost:hover { color: var(--fg); border-color: var(--line); }

.verdict { margin: 1.25rem 0 0; font-size: 0.95rem; min-height: 1.5rem; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }

.definition {
  max-width: 32rem;
  margin: 0.5rem auto 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}

.status { margin: 1rem 0 0; color: var(--bad); font-size: 0.85rem; }

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
