:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #182230;
  --muted: #64748b;
  --line: #d8e0ea;
  --accent: #126e82;
  --accent-dark: #0f4f61;
  --ok: #166534;
  --bad: #b42318;
  --warn: #b7791f;
  --soft: #edf7f7;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #e8f0f3 0, var(--bg) 340px);
}

button,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

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

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

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.danger {
  color: var(--bad);
  border-color: #f2b8b2;
}

.subtle {
  background: #fbfcfd;
}

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.18;
  letter-spacing: 0;
}

.total-badge {
  display: grid;
  place-items: center;
  min-width: 88px;
  min-height: 76px;
  border-radius: 8px;
  background: #102a43;
  color: #fff;
  box-shadow: 0 12px 24px rgba(16, 42, 67, 0.16);
}

.total-badge span {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
}

.total-badge small {
  color: #cde4ef;
}

.control-panel,
.question-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.control-panel {
  padding: 16px;
  margin-bottom: 16px;
}

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

.stats-grid div {
  min-height: 64px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfdff;
  padding: 10px;
}

.stats-grid span {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
}

.stats-grid small {
  color: var(--muted);
}

.filters {
  display: grid;
  grid-template-columns: 1.25fr 1fr 0.8fr;
  gap: 12px;
  margin-bottom: 14px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.toggle span {
  margin: 0;
  color: var(--ink);
}

.reset-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.reset-panel p {
  margin: 0;
  font-weight: 700;
}

.reset-panel div {
  display: flex;
  gap: 8px;
}

.question-card {
  min-height: 420px;
  padding: 22px;
}

.empty-state {
  display: grid;
  min-height: 350px;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin: 0 0 8px;
  color: var(--ink);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 800;
}

.progress-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 700;
}

.question-text {
  margin: 0 0 18px;
  font-size: 1.18rem;
  line-height: 1.75;
  letter-spacing: 0;
}

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

.choice {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  text-align: left;
  line-height: 1.45;
}

.choice .mark {
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #e6edf3;
  font-weight: 800;
}

.choice.selected {
  border-color: var(--accent);
  background: #eef9fa;
}

.choice.correct {
  border-color: #86efac;
  background: #ecfdf3;
}

.choice.wrong {
  border-color: #fecaca;
  background: #fff1f2;
}

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.result-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfdff;
}

.result-box.correct {
  border-color: #86efac;
  background: #f0fdf4;
}

.result-box.wrong {
  border-color: #fecaca;
  background: #fff7f7;
}

.result-box strong {
  display: block;
  margin-bottom: 8px;
}

.done-state {
  text-align: center;
  padding: 60px 12px;
}

.done-state h2 {
  margin: 0 0 10px;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1060px);
    padding-top: 16px;
  }

  .topbar {
    align-items: stretch;
  }

  .total-badge {
    min-width: 72px;
    min-height: 68px;
  }

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

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

  .mode-row,
  .reset-panel,
  .reset-panel div {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-row > button,
  .mode-row > .toggle,
  .reset-panel button {
    width: 100%;
  }

  .question-card {
    padding: 16px;
  }

  .question-text {
    font-size: 1.04rem;
  }
}
