/* 最後まで清潔なデモページのまま。赤い文字・ノイズ加工・目立つアニメーションは使わない。 */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-weak: #eff6ff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
    'Noto Sans JP', 'Yu Gothic UI', Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  word-break: auto-phrase;
  -webkit-font-smoothing: antialiased;
  /* 中身が短い画面でも、注意書きを画面の下端に置く */
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---- ページの枠 ---- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
}

.brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.progress-label {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 2px;
  background: var(--line);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

#stage {
  flex: 1 0 auto;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 56px 20px 96px;
  transition: opacity 0.22s ease;
}

/* フィクションである旨の注意書き。スクロールしても常に画面の下に見えている */
.site-footer {
  position: sticky;
  bottom: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  color: var(--faint);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

/* 幅が足りないときは、文の途中ではなく文と文の間で折り返す */
.site-footer span {
  display: inline-block;
}

#stage.is-leaving {
  opacity: 0;
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

p {
  margin: 0;
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 28px;
}

.primary {
  appearance: none;
  border: 0;
  border-radius: 8px;
  padding: 12px 28px;
  background: var(--text);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.primary:hover {
  background: #1f2937;
}

.primary:disabled {
  background: var(--line);
  color: var(--faint);
  cursor: default;
}

.primary:focus-visible,
.play:focus-visible,
.choice:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- 導入 ---- */

.intro h1 {
  font-size: 30px;
}

.intro .lead {
  margin-top: 20px;
}

.notes {
  margin: 28px 0 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  list-style: none;
  font-size: 15px;
}

.notes li:first-child {
  font-weight: 600;
}

.fine-print {
  margin-top: 14px;
  color: var(--faint);
  font-size: 11px;
}

.intro .actions {
  justify-content: flex-start;
}

.entry {
  margin-top: 28px;
}

.entry-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.entry-input {
  display: block;
  width: 100%;
  max-width: 320px;
  height: 44px;
  margin-top: 6px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.entry-input:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent-weak);
}

.entry-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

/* 入力の誤りも赤くしない。文字を濃くするだけ */
.entry-hint.is-error {
  color: var(--text);
  font-weight: 600;
}

/* ---- 設問 ---- */

.q-no {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.q-prompt {
  margin-top: 4px;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 28px;
}

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

/* 再生ボタン */
.play {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.play:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.play:disabled {
  border-color: var(--line);
  color: var(--faint);
  cursor: default;
}

.play-icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent currentColor;
}

.play-now,
.bars {
  display: none;
}

.voice.is-playing .play {
  border-color: var(--accent);
  color: var(--accent);
}

.voice.is-playing .play-icon,
.voice.is-playing .play-idle {
  display: none;
}

.voice.is-playing .play-now {
  display: inline;
}

.voice.is-playing .bars {
  display: flex;
}

.bars {
  align-items: flex-end;
  gap: 3px;
  height: 14px;
}

.bars span {
  width: 3px;
  height: 100%;
  border-radius: 1px;
  background: var(--accent);
  transform-origin: bottom;
  animation: bar 0.9s ease-in-out infinite;
}

.bars span:nth-child(2) {
  animation-delay: -0.6s;
}

.bars span:nth-child(3) {
  animation-delay: -0.3s;
}

.bars span:nth-child(4) {
  animation-delay: -0.75s;
}

@keyframes bar {
  0%,
  100% {
    transform: scaleY(0.3);
  }
  50% {
    transform: scaleY(1);
  }
}

/* 回答ボタン。表記は全問「A」「B」で固定 */
.choice {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 128px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.choice-label {
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
}

.choice-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  color: var(--muted);
  font-size: 12px;
}

.choice:disabled {
  color: var(--faint);
  cursor: default;
}

.choice:not(:disabled) {
  border-color: #cbd5e1;
}

.choice:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.choice.is-chosen,
.choice.is-correct {
  color: var(--text);
}

.choice.is-chosen {
  border-color: var(--text);
}

.choice.is-correct {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.choice.is-correct .choice-foot {
  color: var(--accent);
}

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 28px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- 正解表示 ---- */

.result {
  margin-top: 8px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.result-head {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
}

.badge {
  padding: 1px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}

.badge.is-miss {
  background: #e5e7eb;
  color: #374151;
}

.explanation {
  margin-top: 10px;
  font-size: 15px;
}

.rate {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---- 第9問（複数選択） ---- */

.options {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
}

.option input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.option-label {
  flex: 1;
}

.option-tag {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.option.is-locked {
  cursor: default;
}

.option.is-correct {
  border-color: var(--accent);
  background: var(--accent-weak);
}

/* ---- 第10問（無音） ---- */

.countdown {
  margin-top: 96px;
  font-size: 96px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---- 答え合わせ ---- */

.respondent {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.review table {
  width: 100%;
  margin-top: 24px;
  border-collapse: collapse;
  font-size: 14px;
}

.review th {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.review td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.review td:first-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 正誤 */
.mark {
  color: var(--faint);
  font-size: 13px;
  white-space: nowrap;
}

.mark.is-correct {
  color: var(--accent);
  font-weight: 600;
}

.mark.is-miss {
  color: var(--text);
}

/* 設問文の下の、開閉できる解説 */
.note {
  margin-top: 6px;
  font-size: 13px;
}

.note summary {
  width: fit-content;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.note summary:hover {
  color: var(--text);
}

.note p {
  margin-top: 6px;
  line-height: 1.7;
}

.note-answer {
  font-weight: 600;
}

.fade-in {
  opacity: 0;
  transition: opacity 2.4s ease;
}

/* 見えていない間は押せないようにする */
.fade-in:not(.is-visible) {
  visibility: hidden;
}

.fade-in.is-visible {
  opacity: 1;
}

.last-line {
  margin-top: 56px;
  font-size: 18px;
}

.share {
  appearance: none;
  margin-top: 36px;
  padding: 9px 22px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.share:hover {
  border-color: var(--text);
}

.share:focus-visible,
.credits-link:focus-visible,
.ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.share-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 28px 24px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

/* 文面の改行（空行）をそのまま見せる */
.share-dialog p {
  white-space: pre-line;
}

.share-dialog::backdrop {
  background: rgb(17 24 39 / 0.4);
}

.share-dialog .actions {
  align-items: center;
  gap: 8px;
  margin-top: 24px;
}

a.primary {
  display: inline-block;
  text-decoration: none;
}

.ghost {
  appearance: none;
  border: 0;
  padding: 12px 14px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

/* ---- クレジット ---- */

.review-footer {
  margin-top: 72px;
}

.credits-link {
  appearance: none;
  border: 0;
  padding: 4px 0;
  background: none;
  color: var(--faint);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.credits-link:hover {
  color: var(--muted);
  text-decoration: underline;
}

.credits-dialog h2 {
  margin: 0 0 18px;
  font-size: 16px;
  font-weight: 700;
}

.credits-dialog section + section {
  margin-top: 18px;
}

.credits-dialog h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.credits-dialog a {
  color: inherit;
}

.credits-dialog dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  margin: 6px 0 0;
  font-size: 14px;
}

.credits-dialog dt {
  color: var(--muted);
}

.credits-dialog dd {
  margin: 0;
}

.credits-dialog .disclaimer {
  margin-top: 22px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 480px) {
  #stage {
    padding: 36px 16px 72px;
  }

  .site-header {
    padding: 0 16px;
  }

  .intro h1 {
    font-size: 26px;
  }

  h1 {
    font-size: 21px;
  }

  .choices {
    gap: 12px;
  }

  .choice {
    height: 112px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bars span,
  .spinner {
    animation: none;
  }
}
