/*
 * Web 版の共通のスタイル。デジタル庁デザインシステム(DADS)の作りにそろえ、色(メインの色)だけ独自にする。
 * - 色・角丸・影・フォントの値は DADS の公式トークン(@digital-go-jp/design-tokens 2.1.0、MIT License © デジタル庁)と、
 *   公式の HTML 見本(digital-go-jp/design-system-example-components-html)のボタン・チェックボックスの CSS による。
 * - メインの色(--primary 系)だけ独自の青(fp3-exam と同じ)。ほかの色(文字・背景・線・成功・エラー・フォーカス)は DADS の値。
 * - クラス名は fp3-exam と同じ(画面の作りは共通の app.js・テンプレートのまま)。
 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* 独自のメインの色(白い文字と 4.5:1 以上) */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-active: #1e3a8a;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;

  /* DADS のニュートラル */
  --white: #ffffff;
  --black: #000000;
  --gray-50: #f2f2f2;
  --gray-100: #e6e6e6;
  --gray-200: #cccccc;
  --gray-420: #949494;   /* 白に対して 3:1(操作できる部品の境界) */
  --gray-536: #767676;   /* 白に対して 4.5:1(文字に使える最も薄い灰色) */
  --gray-600: #666666;
  --gray-700: #4d4d4d;
  --gray-800: #333333;
  --gray-900: #1a1a1a;   /* 本文 */

  /* DADS の意味の色 */
  --success-1: #259d63;
  --success-2: #197a4b;
  --success-bg: #e6f5ec;
  --error-1: #ec0000;
  --error-2: #ce0000;
  --error-bg: #fdeeee;
  --warning-2: #927200;
  --warning-bg: #fbf5e0;
  --focus-yellow: #ffd43d;

  /* DADS の角丸 */
  --radius-4: 4px;
  --radius-8: 8px;
  --radius-12: 12px;
  --radius-full: 9999px;
}

html { font-size: 100%; }
body {
  font-family: 'Noto Sans JP', 'Noto Sans TC', 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  font-size: 1rem;              /* Std-16N-170 */
  line-height: 1.7;
  letter-spacing: 0.02em;
  color: var(--gray-900);
  background: var(--white);
}
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); text-decoration-thickness: 3px; }

/* DADS のフォーカス: 黒 4px の外枠+黄色 2px のリング(変えてはいけない) */
:focus-visible {
  outline: 4px solid var(--black);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--focus-yellow);
}

.hidden { display: none !important; }
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ── 見出し(DADS の Std スタイル) ── */
h1 { font-size: 1.75rem; line-height: 1.5; letter-spacing: 0.01em; font-weight: 700; }   /* Std-28B-150 */
h2 { font-size: 1.25rem; line-height: 1.5; font-weight: 700; }                           /* Std-20B-150 */
h3 { font-size: 1.125rem; line-height: 1.6; font-weight: 700; }                          /* Std-18B-160 */
@media (min-width: 768px) { h1 { font-size: 2rem; } }                                    /* Std-32B-150 */

/* ── ホーム ── */
.home-container { max-width: 720px; margin: 0 auto; padding: 40px 16px 64px; display: flex; flex-direction: column; gap: 24px; }
.subtitle { color: var(--gray-700); margin-top: -16px; }
.intro { color: var(--gray-700); }

/* 主役のボタン(DADS の塗りのボタン・大: 高さ 56・角丸 8) */
.quick-start-btn {
  display: flex; align-items: center; gap: 16px; width: 100%; min-height: 56px; padding: 12px 16px;
  border: 4px double transparent; border-radius: var(--radius-8);
  background: var(--primary); color: var(--white); font: inherit; font-weight: 700; cursor: pointer;
}
.quick-start-btn:hover { background: var(--primary-hover); text-decoration: underline; }
.quick-start-btn:active { background: var(--primary-active); }
.quick-start-icon { font-size: 1.5rem; line-height: 1; }
.quick-start-title { flex: 1; text-align: left; font-size: 1.125rem; }
.quick-start-arrow { font-size: 1.25rem; }

/* 本番模擬試験・モードの選択(白・1px の枠・角丸 12。押せる部品の枠は白に対して 3:1) */
.exam-section-title { font-size: 1.25rem; font-weight: 700; line-height: 1.5; margin-bottom: -8px; }
.exam-cards { display: flex; flex-direction: column; gap: 16px; }
.exam-card, .mode-card {
  display: flex; align-items: center; gap: 16px; width: 100%; padding: 16px 24px;
  background: var(--white); border: 1px solid var(--gray-420); border-radius: var(--radius-12);
  color: var(--gray-900); font: inherit; text-align: left; cursor: pointer;
}
.exam-card:hover, .mode-card:hover { background: var(--primary-50); border-color: var(--primary); }
.exam-card:hover h2, .mode-card:hover h2 { text-decoration: underline; }
.exam-card h2, .mode-card h2 { font-size: 1.125rem; line-height: 1.6; color: var(--primary); }
.exam-card p, .mode-card p { color: var(--gray-700); }
.mode-icon { font-size: 1.75rem; line-height: 1; flex: none; }
.mode-cards { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .mode-cards { grid-template-columns: 1fr 1fr; } }

/* 設定(DADS のチェックボックス・ラジオ: 24px・2px の枠。チェックボックスは四角、ラジオは丸) */
.settings-panel { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-12); padding: 24px; display: flex; flex-direction: column; gap: 24px; }
.setting-row { display: flex; flex-direction: column; gap: 8px; }
.setting-row > label { font-weight: 700; }
.checkbox-group, .radio-group { display: flex; flex-wrap: wrap; gap: 0 24px; }
.checkbox-group { flex-direction: column; }
.cb-label, .rb-label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.cb-label input, .rb-label input {
  appearance: none; flex: none; width: 24px; height: 24px; margin: 0;
  border: 2px solid var(--gray-600); background: var(--white); cursor: pointer;
}
.cb-label input { border-radius: 3px; }
.rb-label input { border-radius: 50%; }
.cb-label:hover input, .rb-label:hover input { border-color: var(--black); }
.cb-label input:checked {
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.5 16.2 5.3 12l-1.4 1.4 5.6 5.6 12-12-1.4-1.4z' fill='%23fff'/%3E%3C/svg%3E") center / 20px no-repeat;
  border-color: var(--primary);
}
.rb-label input:checked { border-color: var(--primary); background: radial-gradient(var(--primary) 0 42%, var(--white) 46%); }
.count-info { color: var(--gray-700); font-weight: 700; }

/* ── 出題 ── */
.quiz-body { max-width: 720px; margin: 0 auto; padding: 24px 16px 120px; }
.question-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.exam-tag, .q-num { font-size: 0.875rem; line-height: 1.5; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-4); }
.exam-tag { background: var(--gray-50); color: var(--gray-800); border: 1px solid var(--gray-200); }
.q-num { background: var(--primary-50); color: var(--primary); border: 1px solid var(--primary-200); }
.question-text { font-size: 1.125rem; line-height: 1.6; font-weight: 700; white-space: pre-wrap; margin-bottom: 24px; }   /* Std-18B-160 */
.q-image { display: block; max-width: 100%; border: 1px solid var(--gray-200); border-radius: var(--radius-8); margin: 0 0 24px; }
.answer-area { display: flex; flex-direction: column; gap: 8px; }
#tf-buttons { flex-direction: row; }

/* 選択肢(DADS のアウトラインのボタンの作り。高さ 56 以上・角丸 8) */
.choice-btn, .tf-btn {
  display: flex; align-items: flex-start; gap: 16px; width: 100%; min-height: 56px; padding: 12px 16px;
  background: var(--white); border: 1px solid var(--gray-420); border-radius: var(--radius-8);
  color: var(--gray-900); font: inherit; text-align: left; cursor: pointer;
}
.tf-btn { justify-content: center; align-items: center; font-size: 1.75rem; font-weight: 700; }
.choice-btn:hover:not(:disabled), .tf-btn:hover:not(:disabled) { background: var(--primary-50); border-color: var(--primary); }
.choice-num {
  flex: none; min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full); border: 1px solid var(--gray-420); font-weight: 700; line-height: 1;
}
.choice-text { white-space: pre-wrap; padding-top: 2px; }
.choice-btn.picked, .tf-btn.selected { background: var(--primary-50); border: 2px solid var(--primary); }
.choice-btn.picked .choice-num { background: var(--primary); border-color: var(--primary); color: var(--white); }
.choice-btn.correct, .tf-btn.correct { background: var(--success-bg); border: 2px solid var(--success-1); }
.choice-btn.correct .choice-num { background: var(--success-1); border-color: var(--success-1); color: var(--white); }
.choice-btn.wrong, .tf-btn.wrong { background: var(--error-bg); border: 2px solid var(--error-1); }
.choice-btn.wrong .choice-num { background: var(--error-1); border-color: var(--error-1); color: var(--white); }
.choice-btn:disabled, .tf-btn:disabled { cursor: default; }

/* 正誤と解説(DADS の通知バナーの作り: 枠 2px・角丸 12) */
.feedback { margin-top: 24px; padding: 16px 24px 24px; border: 2px solid var(--gray-420); border-radius: var(--radius-12); background: var(--white); }
.feedback.correct-fb { border-color: var(--success-1); background: var(--success-bg); }
.feedback.wrong-fb { border-color: var(--error-1); background: var(--error-bg); }
.feedback-result { font-size: 1.25rem; font-weight: 700; line-height: 1.5; }
.feedback.correct-fb .feedback-result { color: var(--success-2); }
.feedback.wrong-fb .feedback-result { color: var(--error-2); }
.feedback-answer { font-weight: 700; margin-top: 8px; }
.feedback-explanation { margin-top: 16px; padding: 16px; background: var(--white); border-radius: var(--radius-8); border: 1px solid var(--gray-200); }
.explanation-label { font-size: 0.875rem; font-weight: 700; color: var(--gray-700); margin-bottom: 4px; }
.explanation-text { white-space: pre-wrap; }
.feedback-actions { display: flex; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.feedback-actions > * { flex: 1; }

/* ボタン(DADS の塗り・アウトライン、大: 高さ 56・角丸 8・太字 16・ホバーで下線) */
.btn-primary, .btn-secondary, .btn-next {
  display: inline-flex; align-items: center; justify-content: center; min-height: 56px; padding: 12px 16px;
  border-radius: var(--radius-8); font: inherit; font-weight: 700; line-height: 1; letter-spacing: 0.02em;
  text-decoration: none; cursor: pointer;
}
.btn-primary, .btn-next { background: var(--primary); color: var(--white); border: 4px double transparent; }
.btn-primary:hover, .btn-next:hover { background: var(--primary-hover); color: var(--white); text-decoration: underline; text-decoration-thickness: 1px; }
.btn-primary:active, .btn-next:active { background: var(--primary-active); }
.btn-secondary { background: var(--white); color: var(--primary); border: 1px solid currentColor; }
.btn-secondary:hover { background: var(--primary-50); color: var(--primary-hover); text-decoration: underline; text-decoration-thickness: 1px; }
.btn-secondary:active { background: var(--primary-100); }
.btn-next.standalone { width: 100%; margin-top: 24px; }
a.btn-primary, a.btn-secondary { display: flex; width: 100%; }

/* 下のバー */
.quiz-footer { position: fixed; bottom: 0; left: 0; right: 0; background: var(--white); border-top: 1px solid var(--gray-200); z-index: 100; }
.progress-bar-track { height: 8px; background: var(--gray-100); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width 0.3s ease; }
.quiz-footer-row { display: flex; align-items: center; gap: 16px; max-width: 720px; margin: 0 auto; padding: 8px 16px; }
.btn-icon { min-width: 44px; min-height: 44px; background: none; border: 0; border-radius: var(--radius-8); font-size: 1.25rem; color: var(--gray-800); cursor: pointer; }
.btn-icon:hover { background: var(--gray-50); }
.progress-text { flex: 1; text-align: center; font-weight: 700; color: var(--gray-800); }
.score-badge { font-weight: 700; color: var(--primary); background: var(--primary-50); border: 1px solid var(--primary-200); padding: 2px 12px; border-radius: var(--radius-full); }
.timer { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
.timer.low { color: var(--error-2); }

/* ── 結果 ── */
.result-container { max-width: 720px; margin: 0 auto; padding: 40px 16px 64px; display: flex; flex-direction: column; gap: 24px; }
.result-header { text-align: center; }
.result-reasons { text-align: center; color: var(--gray-700); }
.score-circle {
  width: 200px; height: 200px; margin: 0 auto; border-radius: 50%; border: 8px solid var(--primary);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-number { font-size: 3rem; font-weight: 700; line-height: 1.4; color: var(--primary); }
.score-total { color: var(--gray-700); }
.score-pct { font-size: 1.25rem; font-weight: 700; }
.result-bar-wrap { height: 8px; background: var(--gray-100); border-radius: var(--radius-full); overflow: hidden; }
.result-bar { height: 100%; width: 0; background: var(--primary); transition: width 0.6s ease; }
.result-grade { align-self: center; font-size: 1.25rem; font-weight: 700; padding: 8px 24px; border-radius: var(--radius-8); border: 2px solid; }
.grade-pass { color: var(--success-2); background: var(--success-bg); border-color: var(--success-1); }
.grade-close { color: var(--warning-2); background: var(--warning-bg); border-color: var(--warning-2); }
.grade-fail { color: var(--error-2); background: var(--error-bg); border-color: var(--error-1); }
.result-breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.breakdown-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px; border: 1px solid var(--gray-200); border-radius: var(--radius-12); }
.breakdown-label { color: var(--gray-700); font-size: 0.875rem; font-weight: 700; }
.breakdown-val { font-size: 1.25rem; font-weight: 700; }
.result-actions { display: flex; flex-direction: column; gap: 16px; }
.wrong-list h3 { margin-bottom: 8px; }
.wrong-item { padding: 16px 0; border-bottom: 1px solid var(--gray-200); display: flex; flex-direction: column; gap: 8px; }
.wrong-item-meta { font-size: 0.875rem; color: var(--gray-700); font-weight: 700; }
.wrong-item-q { font-weight: 700; white-space: pre-wrap; }
.wrong-item-ans { color: var(--success-2); font-weight: 700; }
.wrong-item-expl { white-space: pre-wrap; color: var(--gray-800); background: var(--gray-50); padding: 12px 16px; border-radius: var(--radius-8); }

/* アプリの案内 */
.app-promo { padding: 24px; border: 1px solid var(--gray-200); border-radius: var(--radius-12); background: var(--gray-50); text-align: center; display: flex; flex-direction: column; gap: 8px; }
.app-promo-title { font-size: 1.125rem; font-weight: 700; }
.app-promo-sub { color: var(--gray-700); }
.app-promo-links { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.app-promo-badge img { display: block; height: 48px; width: auto; }

/* 広告の枠 */
.ad-unit { min-height: 100px; }
.ad-preview .ad-unit { outline: 2px dashed var(--error-1); position: relative; }
.ad-preview .ad-unit::before { content: '広告枠(プレビュー表示)'; position: absolute; top: 40px; left: 0; right: 0; text-align: center; color: var(--error-2); font-size: 0.875rem; }

/* フッター */
.home-nav { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.site-footer { text-align: center; color: var(--gray-700); font-size: 0.875rem; display: flex; flex-direction: column; gap: 8px; }

/* プライバシーポリシーのページ */
.container { max-width: 720px; margin: 0 auto; padding: 40px 16px 64px; display: flex; flex-direction: column; gap: 16px; }

/* モードのカード: 絵・見出し・説明が並列の子なので、絵を左、見出しと説明を縦に積む */
.mode-card { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; row-gap: 0; align-items: center; }
.mode-card .mode-icon { grid-row: span 2; }
