/* CKQuiz — single stylesheet. Theme follows prefers-color-scheme via variables on :root. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #4f5361;
  --border: #868a98;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --on-accent: #ffffff;
  --focus: #1d4ed8;
  --correct: #166534;
  --correct-bg: #e7f6ec;
  --wrong: #b91c1c;
  --wrong-bg: #fdecec;
  --radius: 0.75rem;
  --space: 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121317;
    --surface: #1d1f25;
    --text: #eceef3;
    --muted: #b0b4c0;
    --border: #7d8191;
    --accent: #8ab4ff;
    --accent-hover: #b3ceff;
    --on-accent: #0b1220;
    --focus: #8ab4ff;
    --correct: #7ee2a0;
    --correct-bg: #15301f;
    --wrong: #ff9b9b;
    --wrong-bg: #3a1a1c;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
p,
ul,
ol {
  margin: 0;
}

.container {
  max-width: 40rem;
  margin: 0 auto;
  padding: calc(var(--space) * 1.5) var(--space) calc(var(--space) * 3);
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

h1 {
  font-size: 2rem;
  line-height: 1.2;
}

h3 {
  font-size: 1.125rem;
  margin-top: var(--space);
}

a {
  color: var(--accent);
}

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

[tabindex="-1"]:focus {
  outline: none;
}

.tagline,
.status {
  color: var(--muted);
}

/* Buttons and button-like links */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.625rem 1.25rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button.secondary {
  background: transparent;
  color: var(--accent);
}

.button.secondary:hover {
  background: var(--surface);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.actions:empty {
  display: none;
}

/* Home */

.quiz-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 44px;
  padding: var(--space);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.card:hover {
  border-color: var(--accent);
}

.card-title {
  font-size: 1.25rem;
  color: var(--accent);
}

.card-meta {
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Game */

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
}

.game-title {
  font-weight: 600;
}

.quit {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.5rem;
}

.progress {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.progress-label {
  color: var(--muted);
  font-size: 0.9375rem;
}

progress {
  appearance: none;
  width: 100%;
  height: 0.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: transparent;
}

progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.question {
  font-size: 1.375rem;
  line-height: 1.3;
}

.choices {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  width: 100%;
  min-height: 44px;
  padding: 0.75rem var(--space);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.choice:hover:enabled {
  border-color: var(--accent);
}

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

.choice.is-correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}

.choice.is-wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}

.mark {
  font-weight: 700;
  white-space: nowrap;
}

.is-correct .mark,
.indicator.is-correct {
  color: var(--correct);
}

.is-wrong .mark,
.indicator.is-wrong {
  color: var(--wrong);
}

/* Kept rendered when empty so screen readers track the live region before it is filled. */
.feedback:empty {
  padding: 0;
  border: 0;
  margin-top: calc(var(--space) * -1);
}

.feedback {
  padding: var(--space);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.feedback.is-correct {
  border-left-color: var(--correct);
}

.feedback.is-wrong {
  border-left-color: var(--wrong);
}

.feedback-title {
  font-weight: 700;
}

/* Result */

.result {
  padding: var(--space);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.result-score {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.result-message {
  font-size: 1.125rem;
}

.record {
  margin-top: 0.5rem;
  font-weight: 700;
  color: var(--accent);
}

.recap {
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recap-question {
  font-weight: 600;
}

.indicator {
  font-weight: 700;
  white-space: nowrap;
}
