:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #607168;
  --paper: #fbf8ef;
  --panel: #fffdf6;
  --line: #ddd0b9;
  --green: #2f6f5e;
  --green-dark: #1c4d41;
  --red: #b34b3f;
  --gold: #d69b3c;
  --shadow: 0 18px 50px rgba(35, 45, 39, .14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  background:
    linear-gradient(135deg, rgba(47, 111, 94, .10), transparent 34%),
    radial-gradient(circle at 90% 10%, rgba(214, 155, 60, .20), transparent 30%),
    var(--paper);
}

button {
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(780px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 18px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.school-mark {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin: 10px 0 0;
  padding: 5px 12px;
  border: 1px solid rgba(47, 111, 94, .28);
  border-radius: 999px;
  background: rgba(255, 253, 246, .62);
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 800;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 26px;
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stats-grid article {
  min-height: 72px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 246, .74);
  text-align: center;
}

.stats-grid span {
  display: block;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.stats-grid small {
  color: var(--muted);
  font-size: 12px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 246, .72);
}

.mode-tabs button {
  min-height: 42px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
}

.mode-tabs button.active {
  color: #fff;
  background: var(--green);
  font-weight: 800;
}

.question-panel {
  position: relative;
  overflow: hidden;
  min-height: 430px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.question-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .10;
  background-image:
    linear-gradient(45deg, var(--green) 12%, transparent 12% 88%, var(--green) 88%),
    linear-gradient(-45deg, var(--gold) 12%, transparent 12% 88%, var(--gold) 88%);
  background-size: 34px 34px;
}

.question-panel > * {
  position: relative;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.ghost-button {
  min-width: 74px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .58);
  color: var(--green-dark);
}

.ghost-button.on {
  border-color: var(--gold);
  background: rgba(214, 155, 60, .18);
  color: #8b5d16;
  font-weight: 800;
}

.progress-track {
  height: 8px;
  margin: 14px 0 18px;
  border-radius: 999px;
  background: #eadfcc;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width .25s ease;
}

h2 {
  min-height: 92px;
  margin: 0 0 18px;
  font-size: 22px;
  line-height: 1.52;
}

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

.option {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .70);
  text-align: left;
  line-height: 1.45;
}

.option strong {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #efe4cf;
  color: var(--green-dark);
}

.option.correct {
  border-color: rgba(47, 111, 94, .55);
  background: rgba(47, 111, 94, .14);
}

.option.wrong {
  border-color: rgba(179, 75, 63, .55);
  background: rgba(179, 75, 63, .12);
}

.feedback {
  margin-top: 16px;
  padding: 14px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: rgba(47, 111, 94, .10);
  line-height: 1.55;
}

.feedback.wrong {
  border-left-color: var(--red);
  background: rgba(179, 75, 63, .10);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
  margin: 14px 0 10px;
}

.controls button,
.tools button {
  min-height: 48px;
  border-radius: 8px;
  font-weight: 800;
}

.primary {
  background: var(--green);
  color: white;
}

.secondary,
.tools button {
  border: 1px solid var(--line);
  background: rgba(255, 253, 246, .78);
}

.tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tools button {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 20px;
}

@media (max-width: 520px) {
  .app-shell { padding-inline: 12px; }
  h1 { font-size: 26px; }
  h2 { font-size: 19px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .mode-tabs { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .mode-tabs button { min-height: 38px; font-size: 13px; }
  .question-panel { min-height: 410px; padding: 16px; }
  .option { grid-template-columns: 36px 1fr; }
  .tools { grid-template-columns: 1fr; }
}
