:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #1f2a44;
  --ink-soft: #5b6b88;
  --brand: #2f80ed;
  --brand-dark: #1f5fc4;
  --accent: #27c498;
  --warn: #ff7a59;
  --warn-bg: #fff1ec;
  --good: #27c498;
  --line: #e6ecf4;
  --shadow: 0 8px 24px rgba(31, 42, 68, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  background: linear-gradient(160deg, #eef3fb 0%, #f6f8fc 100%);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.7;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

.hidden { display: none !important; }
.center { text-align: center; }

/* ===== カード共通 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 16px 32px; font-size: 17px; width: 100%; max-width: 340px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(47,128,237,.32); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #eef3fb; color: var(--brand-dark); }
.btn-secondary:hover { background: #e2ebf8; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { color: var(--ink); }

.note { font-size: 12px; color: var(--ink-soft); margin: 12px 0 0; }

/* ===== スタート画面 ===== */
.hero { text-align: center; padding: 36px 24px; }
.hero-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.hero h1 { font-size: 30px; margin: 6px 0 14px; letter-spacing: .02em; }
.lead { color: var(--ink-soft); margin: 0 0 22px; }
.hero-points {
  list-style: none;
  padding: 0;
  margin: 0 auto 26px;
  max-width: 320px;
  text-align: left;
}
.hero-points li {
  background: #f4f8fe;
  border-radius: 12px;
  padding: 11px 16px;
  margin-bottom: 9px;
  font-size: 14px;
  font-weight: 600;
}

/* スタートボタン（簡易版 / 本格版） */
.start-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.start-buttons .btn-lg {
  flex-direction: column;
  gap: 2px;
  padding: 14px 24px;
}
.start-main { font-size: 17px; font-weight: 800; }
.start-sub { font-size: 12px; font-weight: 600; opacity: .82; }

/* ===== 進捗バー ===== */
.progress-wrap { display: flex; align-items: center; gap: 12px; margin: 6px 4px 16px; }
.progress-bar { flex: 1; height: 10px; background: #e3eaf5; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 10%; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 999px; transition: width .3s ease; }
.progress-text { font-size: 13px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }

/* ===== 質問 ===== */
.question-card { padding: 28px 24px; }
.q-category { display: inline-block; font-size: 12px; font-weight: 700; color: var(--brand); background: #eaf2fe; padding: 4px 12px; border-radius: 999px; margin-bottom: 14px; }
.q-text { font-size: 21px; margin: 0 0 8px; }
.q-help { font-size: 13px; color: var(--ink-soft); margin: 0 0 20px; }
.q-options { display: flex; flex-direction: column; gap: 10px; }

.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: #f7faff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .06s;
  font-family: inherit;
}
.opt:hover { border-color: var(--brand); background: #eef5ff; }
.opt:active { transform: scale(.99); }
.opt .opt-emoji { font-size: 20px; }

/* 数値入力タイプ */
.num-input-wrap { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.num-input {
  flex: 1;
  font-size: 22px;
  font-weight: 700;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  text-align: right;
  color: var(--ink);
  font-family: inherit;
  width: 100%;
}
.num-input:focus { outline: none; border-color: var(--brand); }
.num-unit { font-size: 16px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.num-submit { margin-top: 16px; width: 100%; }

.quiz-nav { display: flex; justify-content: flex-start; margin-top: 4px; }

/* ===== 結果画面 ===== */
.capture-area { background: linear-gradient(160deg, #eef3fb, #f6f8fc); padding: 4px; }
.result-header { display: flex; align-items: baseline; justify-content: space-between; padding: 8px 6px 14px; }
.result-title { font-size: 19px; font-weight: 800; }
.result-date { font-size: 12px; color: var(--ink-soft); }

.score-card { display: flex; align-items: center; gap: 20px; }
.score-left { text-align: center; min-width: 110px; }
.score-grade {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  width: 96px; height: 96px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
}
.score-label { font-size: 13px; color: var(--ink-soft); margin-top: 8px; font-weight: 600; }
.score-right { flex: 1; }
.type-name {
  display: inline-block;
  font-size: 18px; font-weight: 800; color: var(--brand-dark);
  background: #eaf2fe; padding: 4px 14px; border-radius: 999px; margin-bottom: 8px;
}
.score-number { font-size: 16px; color: var(--ink-soft); }
.score-number #score-value { font-size: 44px; font-weight: 800; color: var(--ink); }
.score-unit { margin-left: 2px; }
.score-comment { font-size: 14px; color: var(--ink-soft); margin-top: 6px; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card { padding: 20px; }
.card-title { font-size: 15px; margin: 0 0 14px; font-weight: 800; }
.chart-note { font-size: 12px; color: var(--ink-soft); margin: 10px 0 0; }

.problems-list { display: flex; flex-direction: column; gap: 10px; }
.problem {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--warn-bg);
  border-left: 4px solid var(--warn);
  border-radius: 10px;
  padding: 12px 14px;
}
.problem .p-emoji { font-size: 18px; }
.problem .p-body { font-size: 14px; }
.problem .p-title { font-weight: 800; }
.problem .p-desc { color: var(--ink-soft); font-size: 13px; }
.no-problem { background: #ecfaf4; border-left-color: var(--good); }

.actions-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; }
.actions-list li { font-size: 14.5px; }
.actions-list .a-title { font-weight: 800; }
.actions-list .a-desc { color: var(--ink-soft); font-size: 13px; }

.capture-footer { text-align: center; font-size: 12px; color: var(--ink-soft); padding: 14px 0 6px; font-weight: 700; }

.result-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.result-buttons .btn { flex: 1 1 auto; min-width: 140px; }
#btn-restart { flex-basis: 100%; }

/* ===== ローディング ===== */
.loading {
  position: fixed; inset: 0;
  background: rgba(31,42,68,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: #fff; font-weight: 700; z-index: 50;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== はい/いいえ ボタン ===== */
.yesno { display: flex; gap: 14px; margin-top: 24px; }
.btn-yesno {
  flex: 1;
  font-size: 19px; font-weight: 800;
  padding: 22px 0;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #f7faff;
  color: var(--ink);
  cursor: pointer;
  transition: transform .06s, border-color .12s, background .12s, color .12s;
  font-family: inherit;
}
.btn-yesno:active { transform: scale(.98); }
.btn-yesno.yes:hover, .btn-yesno.yes.selected { border-color: var(--accent); background: #e8faf3; color: #1a8f6c; }
.btn-yesno.no:hover, .btn-yesno.no.selected { border-color: var(--warn); background: var(--warn-bg); color: #d65a3a; }

/* ===== 設定画面 ===== */
.settings-title { font-size: 20px; margin: 0 0 6px; }
.settings-lead { font-size: 13px; color: var(--ink-soft); margin: 0 0 20px; }
.set-row { margin-bottom: 22px; }
.set-label { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.set-options { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid var(--line);
  background: #f7faff;
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
  font-family: inherit;
}
.chip:hover { border-color: var(--brand); }
.chip.selected { border-color: var(--brand); background: var(--brand); color: #fff; }
.chip-unknown.selected { border-color: var(--ink-soft); background: var(--ink-soft); }
.precise-wrap { display: flex; align-items: center; gap: 8px; margin-top: 10px; max-width: 220px; }
.precise-input {
  flex: 1; font-size: 16px; font-weight: 700;
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px;
  text-align: right; color: var(--ink); font-family: inherit; width: 100%;
}
.precise-input:focus { outline: none; border-color: var(--brand); }
.precise-unit { font-size: 14px; font-weight: 700; color: var(--ink-soft); }

/* ===== スマホ調整 ===== */
@media (max-width: 560px) {
  .result-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 25px; }
  .q-text { font-size: 19px; }
  .score-card { flex-direction: column; text-align: center; }
}
