:root {
  color-scheme: light;
  --ink: #162c28;
  --ink-soft: #52635f;
  --paper: #f4f0e7;
  --card: #fffdf8;
  --line: #d9d3c7;
  --orange: #e9662c;
  --orange-dark: #c74b18;
  --mint: #dce9df;
  --green: #1f715b;
  --red: #b93e36;
  --shadow: 0 22px 60px rgba(22, 44, 40, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(233, 102, 44, 0.13), transparent 24rem),
    linear-gradient(rgba(22, 44, 40, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 44, 40, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 32px 32px, 32px 32px, auto;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.page-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 32px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  border-bottom: 1px solid rgba(22, 44, 40, 0.18);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--ink);
  font-family: Georgia, serif;
  font-size: 22px;
  font-style: italic;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: 0.06em;
}

.brand small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.18em;
}

.text-button,
.back-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.text-button {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
}

.hero {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: clamp(40px, 8vw, 100px);
  align-items: center;
  min-height: calc(100vh - 150px);
  padding: 64px 0;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--orange-dark);
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.hero h1 {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(42px, 5.5vw, 72px);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.04em;
}

.hero h1 em {
  color: var(--orange);
  font-style: normal;
  white-space: nowrap;
}

.lead {
  max-width: 34em;
  margin: 28px 0 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.9;
}

.start-card,
.question-card,
.result-screen {
  border: 1px solid rgba(22, 44, 40, 0.1);
  border-radius: 4px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.start-card {
  padding: clamp(24px, 4vw, 44px);
}

.card-heading {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 28px;
}

.step-number {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-style: italic;
}

.card-heading p,
.card-heading h2 {
  margin: 0;
}

.card-heading p {
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.card-heading h2 {
  margin-top: 3px;
  font-family: "Yu Mincho", serif;
  font-size: 24px;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-option {
  position: relative;
  cursor: pointer;
}

.mode-option.wide {
  grid-column: 1 / -1;
}

.mode-option input {
  position: absolute;
  opacity: 0;
}

.mode-option span {
  display: flex;
  min-height: 72px;
  padding: 14px 16px;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  background: white;
  transition: 160ms ease;
}

.mode-option span::after {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 8px;
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 50%;
  content: "";
}

.mode-option b {
  font-size: 15px;
}

.mode-option small {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 11px;
}

.mode-option input:checked + span {
  border-color: var(--ink);
  background: var(--mint);
  box-shadow: inset 3px 0 var(--ink);
}

.mode-option input:checked + span::after {
  border-color: var(--orange);
  background: var(--orange);
  box-shadow: 0 0 0 3px white;
}

.mode-option input:focus-visible + span {
  outline: 3px solid rgba(233, 102, 44, 0.35);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.feedback button {
  min-height: 56px;
  border: 0;
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, background 120ms ease;
}

.primary-button {
  display: flex;
  width: 100%;
  margin-top: 24px;
  padding: 0 20px;
  align-items: center;
  justify-content: space-between;
  color: white;
  background: var(--orange);
}

.primary-button:hover {
  background: var(--orange-dark);
  transform: translateY(-1px);
}

.condition-note {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  text-align: center;
}

.quiz-screen {
  width: min(760px, 100%);
  min-height: calc(100vh - 145px);
  margin: 0 auto;
  padding: 40px 0 72px;
}

.quiz-topbar,
.progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-button {
  padding: 8px 0;
  color: var(--ink-soft);
}

.score-cluster {
  display: flex;
  gap: 20px;
  color: var(--ink-soft);
  font-size: 13px;
}

.score-cluster strong {
  color: var(--ink);
  font-size: 18px;
}

.progress-area {
  margin: 28px 0;
}

.progress-label {
  margin-bottom: 9px;
  color: var(--ink-soft);
  font-family: Arial, sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.progress-track {
  height: 3px;
  overflow: hidden;
  background: var(--line);
}

.progress-track span {
  display: block;
  width: 10%;
  height: 100%;
  background: var(--orange);
  transition: width 260ms ease;
}

.question-card {
  position: relative;
  padding: clamp(28px, 5vw, 48px);
  overflow: hidden;
  text-align: center;
}

.question-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--orange);
  content: "";
}

.question-type {
  display: inline-block;
  padding: 6px 12px;
  color: var(--green);
  background: var(--mint);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.question-kicker {
  margin: 28px 0 12px;
  color: var(--ink-soft);
}

.question-card h2 {
  margin: 0;
  font-family: "Yu Mincho", serif;
  font-size: clamp(30px, 6vw, 48px);
  font-weight: 500;
}

.question-card h2 strong {
  color: var(--orange-dark);
  font-weight: 700;
}

.question-condition {
  margin: 24px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.answer-button {
  position: relative;
  min-height: 78px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: 25px;
  font-weight: 700;
  transition: 140ms ease;
}

.answer-button::before {
  position: absolute;
  top: 10px;
  left: 12px;
  color: #9b968d;
  content: attr(data-label);
  font-family: Arial, sans-serif;
  font-size: 10px;
}

.answer-button:hover:not(:disabled) {
  border-color: var(--ink);
  transform: translateY(-2px);
}

.answer-button:disabled {
  cursor: default;
}

.answer-button.correct {
  border-color: var(--green);
  color: var(--green);
  background: #e3f0e8;
  box-shadow: inset 4px 0 var(--green);
}

.answer-button.wrong {
  border-color: var(--red);
  color: var(--red);
  background: #f8e7e4;
  box-shadow: inset 4px 0 var(--red);
}

.feedback {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding: 20px 24px;
  border-left: 4px solid var(--green);
  background: var(--mint);
}

.feedback.is-wrong {
  border-color: var(--red);
  background: #f4e5e2;
}

.feedback strong,
.feedback p {
  margin: 0;
}

.feedback p {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 13px;
}

.feedback button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 18px;
  color: white;
  background: var(--ink);
}

.result-screen {
  width: min(620px, 100%);
  margin: 64px auto;
  padding: clamp(32px, 6vw, 64px);
  text-align: center;
}

.result-score {
  color: var(--orange);
  font-family: Georgia, serif;
}

.result-score span {
  font-size: clamp(76px, 15vw, 128px);
  line-height: 1;
}

.result-score small {
  font-size: 28px;
}

.result-screen h2 {
  margin: 14px 0 8px;
  font-family: "Yu Mincho", serif;
  font-size: 30px;
}

.result-screen > p:not(.eyebrow) {
  color: var(--ink-soft);
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 32px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-stats div {
  padding: 20px 8px;
}

.result-stats div + div {
  border-left: 1px solid var(--line);
}

.result-stats span,
.result-stats strong {
  display: block;
}

.result-stats span {
  color: var(--ink-soft);
  font-size: 12px;
}

.result-stats strong {
  margin-top: 4px;
  font-size: 22px;
}

.result-actions {
  display: grid;
  gap: 10px;
}

.result-actions .primary-button {
  justify-content: center;
  margin: 0;
}

.secondary-button {
  border: 1px solid var(--ink);
  background: transparent;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 24px 0;
  border-top: 1px solid rgba(22, 44, 40, 0.18);
  color: var(--ink-soft);
  font-size: 10px;
}

dialog {
  width: min(760px, calc(100% - 32px));
  max-height: min(820px, calc(100vh - 32px));
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--card);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(16, 31, 28, 0.65);
  backdrop-filter: blur(3px);
}

.dialog-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  padding: 24px 28px 18px;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.dialog-header h2,
.dialog-header p {
  margin-top: 0;
  margin-bottom: 0;
}

.dialog-header button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  font-size: 24px;
}

.reference-content {
  padding: 8px 28px 32px;
}

.reference-content section {
  margin-top: 28px;
}

.reference-content h3,
.reference-content p {
  margin: 0;
}

.reference-content section > p {
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 11px;
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--ink-soft);
  background: var(--paper);
  font-size: 11px;
}

td:last-child,
th:last-child {
  font-weight: 800;
  text-align: right;
}

.formula {
  padding: 14px;
  background: var(--mint);
  font-size: 12px !important;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 780px) {
  .page-shell {
    padding: 0 18px;
  }

  .site-header {
    min-height: 72px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand strong {
    font-size: 14px;
  }

  .hero {
    display: block;
    min-height: auto;
    padding: 42px 0 56px;
  }

  .hero-copy {
    margin-bottom: 36px;
  }

  .hero h1 {
    font-size: clamp(40px, 12vw, 60px);
  }

  .lead {
    margin-top: 20px;
  }

  .quiz-screen {
    padding-top: 26px;
  }

  footer {
    display: block;
    text-align: center;
  }

  footer p {
    margin: 4px;
  }
}

@media (max-width: 520px) {
  .mode-grid,
  .answers {
    grid-template-columns: 1fr;
  }

  .mode-option.wide {
    grid-column: auto;
  }

  .answer-button {
    min-height: 64px;
  }

  .feedback {
    display: block;
  }

  .feedback button {
    width: 100%;
    margin-top: 16px;
  }

  .question-card {
    padding: 30px 20px;
  }

  .result-screen {
    margin: 32px auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
