:root {
  --ink: #16324f;
  --paper: #f8fbff;
  --grid: #d7e7f3;
  --mark: #e84a3c;
  --highlight: #ffe38a;
  --leaf: #197a66;
  --white: #ffffff;
  --muted: #52697f;
  --shadow: 0 18px 50px rgba(22, 50, 79, 0.10);
  --touch: 44px;

  font-family: "BIZ UDPGothic", "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.85;
}

html {
  box-sizing: border-box;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
  box-sizing: inherit;
}

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
  min-height: 100vh;
}

a {
  color: var(--ink);
  text-underline-offset: 4px;
}

a:hover,
a:focus-visible {
  color: var(--mark);
}

img {
  max-width: 100%;
  height: auto;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  background: var(--white);
  padding: 0.75rem 1rem;
  border: 2px solid var(--ink);
  border-radius: 4px;
}

.wrap {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}

/* ヘッダー */
.site-head {
  background: rgba(248, 251, 255, 0.96);
  border-bottom: 2px solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.nav {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--touch);
}

.brand__icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: var(--highlight);
  border: 2px solid var(--ink);
  border-radius: 50%;
  font-family: "Roboto Mono", monospace;
  font-weight: 700;
  font-size: 0.95rem;
}

.nav-links {
  display: flex;
  gap: 8px;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 10px;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  border-bottom-color: var(--highlight);
}

/* フッター */
.site-foot {
  border-top: 2px solid var(--ink);
  margin-top: 64px;
  padding: 28px 0 40px;
  background: rgba(248, 251, 255, 0.8);
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}

.foot a {
  color: var(--muted);
}

/* ホーム */
.hero {
  padding: 64px 0 80px;
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 48px;
  align-items: center;
}

.eyebrow {
  display: inline-block;
  font-family: "Roboto Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  border-bottom: 4px solid var(--highlight);
  margin-bottom: 20px;
  padding-bottom: 2px;
}

.hero h1 {
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", sans-serif;
  font-size: clamp(2rem, 5.5vw, 3.6rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 22px;
}

.hero h1 em {
  font-style: normal;
  color: var(--mark);
  background: linear-gradient(transparent 60%, var(--highlight) 60%);
}

.lead {
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  max-width: 46rem;
  margin: 0 0 26px;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}

.fine {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

/* ボタン */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 24px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--white);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 5px 5px 0 var(--highlight);
  cursor: pointer;
  font: inherit;
  line-height: 1.4;
}

.button:hover,
.button:focus-visible {
  background: var(--mark);
  border-color: var(--mark);
  color: var(--white);
}

.button.secondary {
  background: var(--white);
  color: var(--ink);
}

.button.secondary:hover,
.button.secondary:focus-visible {
  background: var(--highlight);
  color: var(--ink);
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

/* 診断票カード */
.score-sheet {
  background: var(--white);
  border: 2px solid var(--ink);
  padding: 22px 24px 24px;
  box-shadow: var(--shadow);
  transform: rotate(1deg);
}

.score-sheet h2 {
  font-family: "M PLUS Rounded 1c", sans-serif;
  font-size: 1.05rem;
  margin: 0 0 16px;
}

.pencil-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--grid);
  font-size: 0.9rem;
}

.pencil-line:last-child {
  border-bottom: 0;
}

.line {
  flex: 1;
  height: 2px;
  background: var(--grid);
  position: relative;
}

.line::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: var(--score, 0%);
  background: var(--ink);
  transition: width 0.25s ease-out;
}

/* カード群 */
.section-head {
  border-top: 2px solid var(--ink);
  padding-top: 48px;
  margin-top: 48px;
}

.section-head h2 {
  font-family: "M PLUS Rounded 1c", sans-serif;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  margin: 0 0 8px;
}

.section-head p {
  color: var(--muted);
  margin: 0 0 24px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border: 2px solid var(--ink);
  background: var(--white);
}

.card {
  padding: 24px;
  border-right: 2px solid var(--ink);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card:last-child {
  border-right: 0;
}

.card h3 {
  font-family: "M PLUS Rounded 1c", sans-serif;
  font-size: 1.1rem;
  margin: 0;
}

.card p {
  margin: 0;
  font-size: 0.95rem;
}

/* コンテンツページ */
.content {
  padding: 48px 0 64px;
}

.prose {
  max-width: 680px;
  margin-inline: auto;
  background: var(--white);
  border: 2px solid var(--ink);
  padding: clamp(24px, 5vw, 48px);
  box-shadow: var(--shadow);
}

.page-title {
  font-family: "M PLUS Rounded 1c", sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.25;
  margin: 12px 0 24px;
}

.prose h2 {
  font-family: "M PLUS Rounded 1c", sans-serif;
  font-size: 1.25rem;
  margin: 36px 0 14px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--highlight);
}

.prose h3 {
  font-family: "M PLUS Rounded 1c", sans-serif;
  font-size: 1.1rem;
  margin: 26px 0 10px;
}

.prose p,
.prose li {
  font-size: 0.98rem;
}

.prose ul,
.prose ol {
  padding-left: 1.5rem;
}

.prose li + li {
  margin-top: 6px;
}

.source {
  margin-top: 18px;
  padding: 16px;
  border-left: 4px solid var(--highlight);
  background: var(--paper);
}

.source h2 {
  margin: 0 0 10px;
  border-bottom: 0;
  font-size: 1.1rem;
}

.source p {
  margin: 0 0 8px;
}

.source p:last-child {
  margin-bottom: 0;
}

/* 診断画面 */
.assessment {
  max-width: 800px;
  margin: 32px auto 80px;
  background: var(--white);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}

.assessment-head {
  padding: 24px 28px;
  border-bottom: 2px solid var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.assessment-head h1 {
  font-family: "M PLUS Rounded 1c", sans-serif;
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  margin: 0;
}

.progress-label {
  font-family: "Roboto Mono", monospace;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
}

.progress {
  height: 10px;
  background: var(--grid);
  border: 1px solid var(--ink);
  margin-top: 8px;
  width: 170px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--leaf);
  width: 0;
  transition: width 0.2s ease-out;
}

.panel {
  padding: clamp(24px, 5vw, 40px);
}

/* 学年選択 */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 24px 0;
}

.grade {
  min-height: 72px;
  border: 2px solid var(--ink);
  background: var(--white);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.grade:hover,
.grade:focus-visible,
.grade[aria-pressed="true"] {
  background: var(--highlight);
}

.grade__note {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.grade-choice {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 8px;
}

/* 設問 */
.question-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-family: "Roboto Mono", monospace;
  font-size: 0.8rem;
  margin-bottom: 16px;
  color: var(--muted);
}

.domain {
  padding: 3px 9px;
  background: var(--highlight);
  border: 1px solid var(--ink);
  color: var(--ink);
}

.question {
  font-family: "M PLUS Rounded 1c", sans-serif;
  font-size: clamp(1.25rem, 2.8vw, 1.75rem);
  line-height: 1.55;
  margin: 0 0 26px;
}

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

.choice {
  border: 2px solid var(--ink);
  padding: 14px 16px;
  background: var(--white);
  text-align: left;
  font: inherit;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: var(--touch);
  width: 100%;
}

.choice:hover,
.choice:focus-visible {
  background: #edf7fb;
}

.choice.selected {
  background: var(--highlight);
}

.choice__key {
  font-family: "Roboto Mono", monospace;
  font-weight: 700;
  flex: 0 0 28px;
  text-align: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  font-size: 0.85rem;
  margin-top: 1px;
}

.choice__text {
  flex: 1;
  line-height: 1.6;
}

.choice__hint {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ヒントパネル */
.hint {
  margin: 22px 0 0;
  border: 2px solid var(--ink);
  background: var(--paper);
}

.hint__toggle {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 14px;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.hint__toggle:hover,
.hint__toggle:focus-visible {
  background: var(--highlight);
}

.hint__icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  font-family: "Roboto Mono", monospace;
  font-size: 0.85rem;
}

.hint__body {
  padding: 0 14px 14px;
  font-size: 0.95rem;
}

.hint__body p {
  margin: 0 0 8px;
}

.hint__body p:last-child {
  margin-bottom: 0;
}

/* 診断アクション */
.assessment-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 32px;
  flex-wrap: wrap;
}

/* 結果 */
.result-summary {
  display: flex;
  gap: 22px;
  align-items: center;
  padding-bottom: 28px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 28px;
}

.big-score {
  font: 700 1.8rem "Roboto Mono", monospace;
  min-width: 110px;
  height: 110px;
  border: 3px solid var(--mark);
  display: grid;
  place-items: center;
  transform: rotate(-3deg);
  background: var(--white);
  flex-shrink: 0;
}

.domain-result {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed var(--grid);
}

.domain-result:last-child {
  border-bottom: 0;
}

.domain-result strong {
  font-family: "M PLUS Rounded 1c", sans-serif;
  font-size: 1rem;
}

.domain-result .mono {
  font-family: "Roboto Mono", monospace;
  font-size: 0.9rem;
  color: var(--muted);
}

.bar {
  height: 10px;
  background: var(--grid);
  border: 1px solid var(--ink);
  position: relative;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--leaf);
  width: 0;
  transition: width 0.3s ease-out;
}

.next-card {
  border: 2px solid var(--ink);
  padding: 18px;
  margin-top: 14px;
  background: var(--paper);
}

.next-card h3 {
  font-family: "M PLUS Rounded 1c", sans-serif;
  font-size: 1.05rem;
  margin: 0 0 8px;
}

.next-card p {
  margin: 0;
  font-size: 0.95rem;
}

.note-card {
  border-left: 4px solid var(--mark);
  padding: 16px 18px;
  background: #fff6f5;
  margin-top: 22px;
}

.note-card p {
  margin: 0;
  font-size: 0.95rem;
}

/* メッセージ */
.error {
  padding: 14px 16px;
  border-left: 5px solid var(--mark);
  background: #fff2ef;
  margin: 16px 0;
}

.error p {
  margin: 0;
}

.no-js {
  padding: 16px;
  border: 2px solid var(--mark);
  background: #fff2ef;
  margin-bottom: 16px;
}

.busy {
  padding: 24px 0;
  color: var(--muted);
}

/* 表示制御 */
.hidden {
  display: none !important;
}

/* 印刷 */
@media print {
  html {
    scroll-behavior: auto;
  }

  body {
    background: #fff !important;
    background-image: none !important;
  }

  .site-head,
  .site-foot,
  .actions,
  .assessment-actions,
  .hint__toggle,
  .nav-links,
  .no-print {
    display: none !important;
  }

  .wrap {
    width: 100% !important;
    margin: 0 !important;
  }

  .assessment,
  .prose,
  .score-sheet,
  .card,
  .next-card {
    box-shadow: none !important;
    border: 1px solid #999 !important;
    break-inside: avoid;
  }

  .big-score {
    transform: none !important;
  }

  a {
    text-decoration: none !important;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8rem;
    color: #333;
    word-break: break-all;
  }
}

/* モバイル */
@media (max-width: 760px) {
  .nav-links {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 44px 0 56px;
  }

  .hero h1 {
    font-size: 2.1rem;
  }

  .score-sheet {
    transform: none;
  }

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

  .card {
    border-right: 0;
    border-bottom: 2px solid var(--ink);
  }

  .card:last-child {
    border-bottom: 0;
  }

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

  .assessment-head {
    display: block;
  }

  .progress {
    width: 100%;
    margin-top: 14px;
  }

  .domain-result {
    grid-template-columns: 1fr auto;
  }

  .domain-result .bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .result-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .big-score {
    width: 95px;
    height: 95px;
    font-size: 1.5rem;
  }

  .assessment-actions {
    flex-direction: column-reverse;
  }

  .assessment-actions .button {
    width: 100%;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
