:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-soft: #f1ede3;
  --text: #22211f;
  --muted: #68635b;
  --line: #ded7c9;
  --accent: #2f7d63;
  --accent-strong: #23644f;
  --accent-soft: #e4f2eb;
  --warn: #9a5a12;
  --danger: #b73a35;
  --danger-soft: #fbe7e5;
  --success: #24765c;
  --shadow: 0 18px 50px rgb(45 39 28 / 10%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #fcfbf7 0%, var(--bg) 42%, #f0f4ef 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
}

button,
select {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.hidden {
  display: none !important;
}

.app-header {
  padding: 18px 2px 20px;
}

.eyebrow,
.meta-text,
.topic-line,
.question-topline,
.field label {
  color: var(--muted);
  font-size: 0.92rem;
}

.eyebrow {
  margin: 0 0 8px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin: 4px 0 0;
  font-size: 1.25rem;
  line-height: 1.25;
}

h3 {
  margin: 12px 0 18px;
  font-size: 1.2rem;
  line-height: 1.6;
}

.panel,
.question-card,
.empty-state,
.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.notice {
  margin-bottom: 16px;
  padding: 16px;
  border-color: #e0b36e;
  background: #fff7e8;
  color: #5f3a05;
}

.notice p {
  margin: 6px 0 0;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.actions,
.quiz-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.primary-button,
.secondary-button {
  width: 100%;
  padding: 12px 16px;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 22px rgb(47 125 99 / 22%);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary-button:hover {
  background: #e9e2d4;
}

.text-button {
  min-height: 42px;
  padding: 8px 12px;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.stats-grid article {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 72%);
}

.stats-grid span {
  display: block;
  font-size: 1.65rem;
  font-weight: 900;
}

.stats-grid p {
  margin: 4px 0 0;
  color: var(--muted);
}

.quiz-header {
  display: grid;
  gap: 12px;
  padding: 8px 0 16px;
}

.meta-text {
  margin: 0;
  font-weight: 700;
}

.question-card {
  padding: 18px;
}

.question-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.topic-line {
  margin: 12px 0 0;
}

.options-list {
  display: grid;
  gap: 10px;
}

.option-button {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.option-key {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-soft);
  font-weight: 900;
}

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

.option-button.selected.correct {
  border-color: var(--success);
  background: var(--accent-soft);
}

.option-button.selected.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.option-button.reveal-correct {
  border-color: var(--success);
}

.answer-panel {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.answer-panel p {
  margin: 8px 0 0;
}

.answer-panel p:first-child {
  margin-top: 0;
}

.answer-result {
  font-weight: 900;
}

.answer-result.correct {
  color: var(--success);
}

.answer-result.wrong {
  color: var(--danger);
}

.quiz-nav {
  margin-top: 14px;
  grid-template-columns: 1fr 1fr;
}

.empty-state {
  margin-top: 60px;
  padding: 24px;
  text-align: center;
}

.empty-state p {
  color: var(--muted);
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 42px;
  }

  .panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }

  .actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .quiz-header {
    grid-template-columns: auto 1fr;
    align-items: start;
  }
}
