:root {
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --paper: #f5f5f7;
  --paper-strong: rgba(255, 255, 255, .92);
  --line: rgba(0, 0, 0, .09);
  --teal: #0071e3;
  --teal-deep: #0066cc;
  --teal-soft: #eaf3ff;
  --gold: #ffd60a;
  --orange: #ff9f0a;
  --orange-soft: #fff7e6;
  --green: #34c759;
  --green-soft: #e9f9ed;
  --red: #ff3b30;
  --red-soft: #fff0ef;
  --shadow: 0 24px 70px rgba(0, 0, 0, .10);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 16px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(0, 113, 227, .10), transparent 30rem),
    radial-gradient(circle at 100% 18%, rgba(255, 214, 10, .10), transparent 28rem),
    var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Yu Gothic", "YuGothic", Meiryo, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.site-header {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245, 245, 247, .76);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; background: var(--teal); font-weight: 800; font-size: 20px;
  box-shadow: 0 7px 16px rgba(0, 113, 227, .24);
}
.brand-copy { display: grid; line-height: 1.1; gap: 4px; }
.brand-kicker { color: var(--teal); letter-spacing: .12em; font-size: 10px; font-weight: 700; }
.brand-title { font-size: 14px; font-weight: 700; }

.connection-status {
  display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px;
}
.connection-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.connection-status.is-offline::before { background: var(--orange); }

main { width: min(1120px, calc(100% - 40px)); margin: 0 auto; flex: 1; padding: 24px 0 64px; }
main:focus { outline: none; }
.site-footer {
  width: min(1120px, calc(100% - 40px)); margin: auto; padding: 0 0 24px;
  display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 11px;
}

.eyebrow { margin: 0; color: var(--orange); font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.display-title { margin: 7px 0 12px; font-size: clamp(30px, 6vw, 60px); line-height: 1.2; letter-spacing: -.06em; font-weight: 750; }
.lead { max-width: 670px; margin: 0; color: var(--muted); font-size: 15px; }

.start-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(320px, .82fr); gap: 32px; align-items: center; min-height: 570px; }
.start-intro { padding: 24px 0; }
.start-intro::after { content: "Ⅰ Ⅱ Ⅲ Ⅳ Ⅴ Ⅹ Ⅺ Ⅻ"; display: block; margin-top: 46px; color: rgba(0, 113, 227, .22); font-size: clamp(24px, 5vw, 46px); letter-spacing: .08em; font-weight: 800; }
.start-card, .result-card, .question-card { background: var(--paper-strong); border: 1px solid rgba(255, 255, 255, .82); box-shadow: var(--shadow); border-radius: var(--radius-lg); }
.start-card { padding: 30px; }
.card-kicker { color: var(--teal); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.start-card h2 { margin: 6px 0 20px; font-size: 22px; }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 26px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.meta-item { display: grid; gap: 2px; padding: 0 12px; border-right: 1px solid var(--line); }
.meta-item:first-child { padding-left: 0; }
.meta-item:last-child { border-right: 0; }
.meta-label { color: var(--muted); font-size: 11px; }
.meta-value { font-size: 18px; font-weight: 700; }
.field { display: grid; gap: 7px; margin-bottom: 18px; }
.field label { font-size: 13px; font-weight: 700; }
.field input { width: 100%; padding: 13px 14px; color: var(--ink); background: rgba(245, 245, 247, .82); border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none; transition: .2s ease; }
.field input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(23, 76, 79, .12); }
.field-error { min-height: 1.2em; margin: -8px 0 10px; color: var(--red); font-size: 12px; }
.start-note { margin: 14px 0 0; color: var(--muted); font-size: 11px; }

.primary-button, .secondary-button, .ghost-button {
  min-height: 48px; border-radius: 999px; padding: 0 20px; font-weight: 700; transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.primary-button { width: 100%; border: 0; color: #fff; background: var(--teal); box-shadow: 0 8px 18px rgba(0, 113, 227, .20); }
.primary-button:hover { background: var(--teal-deep); transform: translateY(-1px); box-shadow: 0 11px 22px rgba(0, 113, 227, .25); }
.secondary-button { border: 1px solid var(--teal); color: var(--teal); background: transparent; }
.secondary-button:hover { background: var(--teal-soft); }
.ghost-button { border: 1px solid var(--line); color: var(--ink); background: var(--paper-strong); }
.ghost-button:hover { border-color: var(--teal); }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.button-row > button { flex: 1 1 180px; }

.resume-banner { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 22px; padding: 14px 16px; border: 1px solid #d4e4dd; border-radius: var(--radius-sm); color: var(--green); background: var(--green-soft); font-size: 13px; }
.resume-banner strong { display: block; }

.quiz-shell { max-width: 820px; margin: 0 auto; }
.quiz-topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.progress-copy { display: grid; gap: 2px; }
.progress-copy strong { font-size: 14px; }
.progress-copy span { color: var(--muted); font-size: 12px; }
.timer { min-width: 142px; padding: 9px 14px; border: 1px solid rgba(0, 113, 227, .18); border-radius: 999px; background: rgba(255, 255, 255, .78); display: flex; align-items: center; justify-content: center; gap: 9px; box-shadow: 0 6px 18px rgba(0, 0, 0, .05); }
.timer-icon { color: var(--orange); font-size: 15px; }
.timer strong { font-variant-numeric: tabular-nums; font-size: 17px; letter-spacing: .04em; }
.timer.is-urgent { color: var(--red); border-color: #efc3bd; background: var(--red-soft); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(180, 73, 61, .08); } }
.progress-track { height: 6px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: #e9e5dc; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--orange), var(--gold)); transition: width .3s ease; }

.question-card { overflow: hidden; border-color: rgba(0, 0, 0, .06); }
.question-header { padding: 24px 28px 17px; border-bottom: 1px solid var(--line); }
.section-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; color: var(--teal); background: var(--teal-soft); border-radius: 999px; font-size: 11px; font-weight: 700; }
.section-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }
.question-id { margin: 13px 0 0; color: var(--muted); font-size: 12px; }
.question-prompt { margin: 8px 0 0; font-size: clamp(20px, 3vw, 27px); line-height: 1.75; font-weight: 700; letter-spacing: -.02em; white-space: pre-wrap; }
.reading-passage { margin: 0 28px; padding: 18px 20px; border-left: 4px solid var(--gold); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: #385052; background: #fff8e7; font-size: 14px; line-height: 2; }
.reading-passage-label { margin: 21px 28px 0; color: var(--orange); font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.options { display: grid; gap: 14px; padding: 28px; }
.option-button { width: 100%; min-height: 72px; padding: 16px 18px; display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 14px; text-align: left; color: var(--ink); border: 1px solid rgba(0, 0, 0, .14); border-radius: var(--radius-sm); background: rgba(255, 255, 255, .96); transition: .16s ease; }
.option-button:hover:not(:disabled) { border-color: rgba(0, 113, 227, .42); background: var(--teal-soft); transform: translateY(-1px); }
.option-button:active:not(:disabled) { transform: scale(.99); }
.option-button:focus-visible { outline: 3px solid rgba(229, 122, 68, .45); outline-offset: 2px; }
.option-button:disabled { opacity: 1; }
.option-letter { width: 34px; height: 34px; display: grid; place-items: center; color: var(--teal); background: var(--teal-soft); border-radius: 50%; font-size: 14px; font-weight: 700; }
.option-label { color: #1d1d1f; font-size: 19px; line-height: 1.65; letter-spacing: .01em; font-weight: 500; }
.option-button.is-selected { border-color: var(--teal); background: #eef6ff; box-shadow: 0 0 0 3px rgba(0, 113, 227, .12); }
.option-button.is-selected .option-label { font-weight: 600; }
.option-button.is-correct { border-color: #71b894; background: var(--green-soft); }
.option-button.is-correct .option-letter { color: #fff; background: var(--green); }
.option-button.is-wrong { border-color: #e2a29b; background: var(--red-soft); }
.option-button.is-wrong .option-letter { color: #fff; background: var(--red); }
.feedback-card { margin: 0 28px 24px; padding: 17px 18px; border: 1px solid; border-radius: var(--radius-sm); }
.feedback-card.is-correct { color: var(--green); border-color: #b7d9c5; background: var(--green-soft); }
.feedback-card.is-wrong { color: var(--red); border-color: #efc3bd; background: var(--red-soft); }
.feedback-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; }
.feedback-answer { margin: 6px 0 0; color: var(--ink); font-size: 13px; font-weight: 700; }
.feedback-explanation { margin: 7px 0 0; color: #4e6263; font-size: 13px; line-height: 1.8; }
.question-footer { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 0 28px 28px; }
.question-footer-note { color: var(--muted); font-size: 12px; }
.next-button { min-width: 140px; }
.next-button:disabled { color: #a0aaa7; border-color: #e4e2db; background: #f1efe9; box-shadow: none; }

.result-shell { max-width: 920px; margin: 0 auto; }
.result-hero { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 24px; align-items: center; margin-bottom: 24px; }
.result-card { padding: 28px; }
.result-card h1 { margin: 5px 0 8px; font-size: clamp(28px, 5vw, 46px); line-height: 1.25; }
.result-card p { margin: 0; color: var(--muted); font-size: 13px; }
.score-circle { aspect-ratio: 1; display: grid; place-items: center; align-content: center; border-radius: 50%; color: #fff; background: linear-gradient(145deg, #0071e3, #005bb8); box-shadow: 0 16px 36px rgba(0, 113, 227, .24); }
.score-number { font-size: 56px; font-weight: 900; line-height: 1; }
.score-unit { margin-top: 5px; font-size: 12px; }
.result-section { margin-top: 22px; }
.result-section h2 { margin: 0 0 12px; font-size: 18px; }
.section-results { display: grid; gap: 11px; }
.section-result { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(255, 253, 249, .76); }
.section-result-name { font-size: 13px; font-weight: 700; }
.section-result-name small { display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
.bar-track { height: 9px; overflow: hidden; border-radius: 99px; background: #e8e6de; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #4ca184); }
.section-result-score { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.feedback-intro { margin: 0 0 18px !important; line-height: 1.8; }
.feedback-viewer { margin-top: 18px; }
.feedback-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 0 2px 16px; }
.feedback-heading h2 { margin: 5px 0 0; font-size: 20px; }
.feedback-counter { color: var(--teal); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.review-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255, 255, 255, .76); }
.review-question-header { padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.review-question-header .question-id { margin: 0; }
.review-question-prompt { margin: 8px 0 0; font-size: clamp(20px, 3vw, 25px); line-height: 1.7; letter-spacing: -.02em; }
.review-answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 22px 24px 0; }
.review-answer { min-height: 82px; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(255, 255, 255, .9); }
.review-answer span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.review-answer strong { display: block; margin-top: 5px; color: var(--ink); font-size: 15px; line-height: 1.6; }
.review-answer.is-correct { border-color: #a7d8b7; background: var(--green-soft); }
.review-answer.is-wrong { border-color: #efc3bd; background: var(--red-soft); }
.review-card > .feedback-card { margin: 18px 24px 24px; }
.feedback-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 24px 24px; }
.feedback-nav > span { color: var(--muted); font-size: 12px; text-align: center; }
.feedback-nav button { width: auto; min-width: 150px; }
.feedback-nav button:last-child { justify-self: end; }
.feedback-nav .ghost-button:disabled { color: #a0aaa7; border-color: #e4e2db; background: #f1efe9; }
.wrong-list { display: grid; gap: 14px; }
.wrong-item { padding: 18px; border-left: 4px solid var(--orange); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: rgba(255, 253, 249, .86); }
.wrong-item-title { margin: 0 0 8px; font-size: 15px; line-height: 1.65; font-weight: 700; }
.wrong-item p { margin: 4px 0; color: #526566; font-size: 12px; }
.wrong-item strong { color: var(--ink); }
.review-empty { padding: 24px; border: 1px dashed #9dc8b2; border-radius: var(--radius-sm); color: var(--green); background: var(--green-soft); }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.result-actions button { flex: 1 1 180px; }
.result-note { margin-top: 20px !important; font-size: 11px !important; }

.loading, .error-state { min-height: 55vh; display: grid; place-items: center; text-align: center; color: var(--muted); }
.error-state .start-card { max-width: 520px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .site-header, main, .site-footer { width: min(100% - 28px, 680px); }
  .site-header { padding-top: 18px; }
  .site-footer { flex-direction: column; gap: 3px; padding-bottom: 17px; }
  main { padding-top: 13px; padding-bottom: 38px; }
  .start-grid { display: block; min-height: auto; }
  .start-intro { padding: 24px 0 32px; }
  .start-intro::after { margin-top: 30px; font-size: 27px; }
  .start-card { padding: 22px; }
  .meta-grid { margin-bottom: 21px; }
  .meta-item { padding: 0 8px; }
  .meta-value { font-size: 16px; }
  .quiz-topbar { align-items: flex-start; }
  .timer { min-width: 124px; padding-inline: 10px; }
  .question-header { padding: 20px 19px 14px; }
  .options { padding: 20px 19px; }
  .option-button { min-height: 68px; padding: 14px; grid-template-columns: 36px 1fr; gap: 12px; }
  .option-letter { width: 32px; height: 32px; }
  .option-label { font-size: 17px; line-height: 1.6; }
  .feedback-card { margin-inline: 19px; }
  .question-footer { align-items: stretch; flex-direction: column; padding: 0 19px 20px; }
  .next-button { width: 100%; }
  .reading-passage { margin-inline: 19px; padding: 15px; font-size: 13px; }
  .reading-passage-label { margin-inline: 19px; }
  .feedback-heading { align-items: flex-start; }
  .feedback-heading h2 { font-size: 18px; }
  .feedback-counter { padding-top: 3px; }
  .review-question-header { padding: 20px 19px 14px; }
  .review-question-prompt { font-size: 20px; }
  .review-answer-grid { grid-template-columns: 1fr; padding: 20px 19px 0; }
  .review-card > .feedback-card { margin-inline: 19px; }
  .feedback-nav { grid-template-columns: 1fr 1fr; padding: 0 19px 20px; }
  .feedback-nav > span { grid-column: 1 / -1; grid-row: 1; }
  .feedback-nav button { min-width: 0; width: 100%; }
  .feedback-nav button:last-child { grid-column: 2; grid-row: 2; }
  .result-hero { grid-template-columns: 1fr; }
  .score-circle { width: 170px; margin: 0 auto; }
  .section-result { grid-template-columns: 98px 1fr auto; gap: 9px; }
}

@media print {
  body { background: #fff; }
  .site-header, .site-footer, .result-actions, .result-note { display: none !important; }
  main { width: 100%; padding: 0; }
  .result-card, .wrong-item, .section-result { box-shadow: none; break-inside: avoid; }
  .result-hero { grid-template-columns: 1fr 180px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
