:root {
  --ink: #16202a;
  --muted: #68717c;
  --line: #d8d4c7;
  --paper: #f6f3ea;
  --surface: #ffffff;
  --navy: #17324d;
  --red: #b6463a;
  --green: #26735b;
  --gold: #b58a2a;
  --blue: #2e6f9e;
  --shadow: 0 16px 38px rgba(22, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "Microsoft JhengHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  min-height: 100vh;
  padding: max(16px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 980px;
  margin: 0 auto 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: white;
  background: var(--navy);
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand p,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.timer {
  min-width: 76px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.page {
  max-width: 980px;
  margin: 0 auto;
}

.hero {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero h2 {
  margin: 0;
  font-size: clamp(24px, 6vw, 42px);
  line-height: 1.05;
}

.hero-copy {
  max-width: 720px;
  color: #43505d;
  line-height: 1.65;
}

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

.stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.stat strong {
  display: block;
  font-size: 22px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.card {
  padding: 14px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.card:hover,
.card:focus-visible {
  border-color: var(--blue);
  outline: none;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.btn {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  border-color: var(--navy);
  color: white;
  background: var(--navy);
}

.btn.danger {
  border-color: var(--red);
  color: var(--red);
}

.btn.ghost {
  background: transparent;
}

.quiz {
  display: grid;
  gap: 12px;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #ded9ca;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--green);
  width: 0;
}

.question {
  padding: 16px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef1f4;
  color: #3a4651;
  font-size: 12px;
  font-weight: 700;
}

.tag.warn {
  color: #6b4c09;
  background: #f3e8c4;
}

.question h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.45;
}

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

.option {
  width: 100%;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  line-height: 1.45;
  cursor: pointer;
}

.option strong {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  border-radius: 999px;
  color: white;
  background: var(--navy);
}

.option.correct {
  border-color: var(--green);
  background: #eef8f3;
}

.option.wrong {
  border-color: var(--red);
  background: #fff0ee;
}

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

.explain-item {
  padding: 12px;
  border-left: 4px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  line-height: 1.55;
}

.explain-item.correct {
  border-left-color: var(--green);
}

.explain-item.wrong {
  border-left-color: var(--red);
}

.result {
  padding: 14px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result.good {
  border: 1px solid var(--green);
}

.result.bad {
  border: 1px solid var(--red);
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.small {
  font-size: 13px;
}

@media (min-width: 760px) {
  .app-shell {
    padding-left: 22px;
    padding-right: 22px;
  }

  .hero {
    grid-template-columns: 1.3fr 0.7fr;
    align-items: end;
  }

  .toolbar {
    display: flex;
    justify-content: space-between;
  }

  .quiz {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }

  .question {
    grid-column: 1 / -1;
  }
}
