:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #172033;
  --muted: #687386;
  --line: #dfe6ef;
  --primary: #245b9e;
  --primary-dark: #19477e;
  --primary-soft: #eaf2fc;
  --success: #147a55;
  --success-soft: #e7f7ef;
  --danger: #bd3b3b;
  --danger-soft: #fff0f0;
  --warning-soft: #fff8e6;
  --shadow: 0 14px 36px rgba(36, 65, 104, 0.08);
  font-family:
    "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, #e9f2fd 0, transparent 34rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

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

.app-header {
  padding: 16px 4px 22px;
}

.app-header h1,
.hero-card h2,
.complete-card h2 {
  margin: 0;
}

.app-header h1 {
  margin-top: 3px;
  color: #173f70;
  font-size: clamp(30px, 8vw, 42px);
  letter-spacing: -0.04em;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.app-subtitle,
.muted-text,
.home-footer,
.keyboard-hint {
  color: var(--muted);
}

.app-subtitle {
  margin: 8px 0 0;
  font-size: 15px;
}

.card {
  border: 1px solid rgba(223, 230, 239, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 22px;
}

.hero-card h2,
.complete-card h2 {
  margin-top: 6px;
  font-size: 24px;
}

.stats-grid,
.complete-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.stat-item,
.complete-stats div {
  padding: 12px 6px;
  border-radius: 14px;
  background: #f7f9fc;
  text-align: center;
}

.stat-item strong,
.complete-stats strong {
  display: block;
  color: #173f70;
  font-size: 22px;
}

.stat-item span,
.complete-stats span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.setup-card {
  margin-top: 16px;
  padding: 20px;
}

fieldset {
  min-width: 0;
  margin: 0 0 22px;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 800;
}

.choice-grid,
.pill-grid {
  display: grid;
  gap: 10px;
}

.choice-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.select-card,
.pill-option {
  position: relative;
}

.select-card input,
.pill-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.select-card span,
.pill-option span {
  display: flex;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.select-card span {
  flex-direction: column;
  justify-content: center;
  padding: 12px 13px;
}

.select-card small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.pill-option span {
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.pill-option small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 11px;
}

.select-card input:checked + span,
.pill-option input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(36, 91, 158, 0.08);
}

.select-card input:focus-visible + span,
.pill-option input:focus-visible + span,
.button:focus-visible,
.icon-button:focus-visible,
.option-button:focus-visible,
.text-button:focus-visible {
  outline: 3px solid rgba(36, 91, 158, 0.34);
  outline-offset: 3px;
}

.home-actions,
.quiz-actions {
  display: grid;
  gap: 10px;
}

.home-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 10px 16px;
  font-weight: 800;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.button:not(:disabled):active,
.option-button:not(:disabled):active {
  transform: translateY(1px);
}

.button-primary {
  color: #fff;
  background: var(--primary);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.button-secondary {
  border-color: var(--line);
  color: #2e4668;
  background: #fff;
}

.button-secondary:hover:not(:disabled) {
  border-color: #c4d3e7;
  background: #f8fbff;
}

.muted-text {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.55;
}

.home-footer {
  padding: 18px 4px 0;
  font-size: 12px;
  text-align: center;
}

.home-footer p {
  margin: 8px 0 0;
}

.text-button {
  border: 0;
  padding: 5px;
  background: transparent;
  font-size: 13px;
}

.danger-text {
  color: var(--danger);
}

.quiz-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 42px;
  border: 0;
  padding: 6px 4px;
  color: #31557e;
  background: transparent;
  font-weight: 800;
}

.icon-button span:first-child {
  font-size: 24px;
  line-height: 1;
}

.toolbar-tags,
.question-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.tag,
.question-meta span {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
}

.tag {
  color: #1f558f;
  background: var(--primary-soft);
  font-weight: 800;
}

.tag-muted,
.question-meta span {
  color: var(--muted);
  background: #f1f4f8;
}

.progress-card {
  padding: 14px 16px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  height: 7px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f6;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #377cc6, #245b9e);
  transition: width 240ms ease;
}

.question-card {
  margin-top: 14px;
  padding: 20px;
}

.question-type {
  color: #1f558f !important;
  background: var(--primary-soft) !important;
  font-weight: 800;
}

.question-text {
  margin: 17px 0 18px;
  font-size: clamp(19px, 4.8vw, 23px);
  line-height: 1.65;
}

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

.option-button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 13px;
  color: var(--ink);
  background: #fff;
  line-height: 1.55;
  text-align: left;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.option-button:hover:not(:disabled) {
  border-color: #b8cbe3;
  background: #fbfdff;
}

.option-key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #46617f;
  background: #f0f4f9;
  font-size: 14px;
  font-weight: 800;
}

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

.option-button.is-selected .option-key {
  color: #fff;
  background: var(--primary);
}

.option-button.is-correct {
  border-color: #6fc39f;
  background: var(--success-soft);
}

.option-button.is-correct .option-key {
  color: #fff;
  background: var(--success);
}

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

.option-button.is-wrong .option-key {
  color: #fff;
  background: var(--danger);
}

.answer-panel {
  margin-top: 17px;
  border-radius: 14px;
  padding: 14px 15px;
  background: var(--primary-soft);
}

.answer-panel.is-success {
  background: var(--success-soft);
}

.answer-panel.is-danger {
  background: var(--danger-soft);
}

.answer-result,
.correct-answer {
  margin: 0;
}

.answer-result {
  margin-bottom: 6px;
  font-weight: 800;
}

.quiz-actions {
  position: sticky;
  bottom: 0;
  grid-template-columns: 0.78fr 1.22fr;
  margin-top: 14px;
  padding: 12px 0 5px;
  background: linear-gradient(180deg, rgba(244, 247, 251, 0), var(--bg) 27%);
}

.keyboard-hint {
  margin: 9px 0 0;
  font-size: 12px;
  text-align: center;
}

.complete-card {
  margin-top: 58px;
  padding: 28px 22px;
  text-align: center;
}

.complete-summary {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.complete-card .home-actions {
  margin-top: 23px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 18px;
  left: 16px;
  z-index: 10;
  width: fit-content;
  max-width: min(520px, calc(100vw - 32px));
  margin: auto;
  border-radius: 999px;
  padding: 11px 16px;
  color: #fff;
  background: rgba(25, 47, 76, 0.94);
  box-shadow: 0 12px 28px rgba(21, 41, 67, 0.22);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 560px) {
  .app-shell {
    padding: 16px 12px 34px;
  }

  .app-header {
    padding: 11px 4px 17px;
  }

  .hero-card,
  .setup-card,
  .question-card {
    border-radius: 18px;
  }

  .hero-card,
  .setup-card {
    padding: 17px;
  }

  .question-card {
    padding: 17px 15px;
  }

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

  .compact-grid {
    grid-template-columns: 1fr;
  }

  .option-button {
    grid-template-columns: 35px minmax(0, 1fr);
    min-height: 56px;
    padding: 9px 10px;
  }

  .keyboard-hint {
    display: none;
  }
}

@media (max-width: 390px) {
  .choice-grid-two {
    grid-template-columns: 1fr;
  }

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