/* ===== 全体 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f5edd0;
  --card: #fdf9ee;
  --card-border: #e8dfc0;
  --accent: #e2683c;
  --accent-soft: #f0a382;
  --text: #2b2620;
  --text-sub: #7a715e;
  --correct-bg: #e2683c;
  --wrong-bg: #8a8378;
  --highlight: #faf3c0;
}

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

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* ===== ホーム ===== */
.home-header { text-align: center; padding: 24px 0 8px; }
.home-header h1 { font-size: 1.35rem; }
.home-header .subtitle { color: var(--text-sub); font-size: 0.9rem; }

.home-stats {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 0.9rem;
}
.home-stats .stats-total { display: flex; justify-content: space-around; text-align: center; margin-bottom: 4px; }
.home-stats .stats-total .num { font-size: 1.4rem; font-weight: bold; color: var(--accent); }
.home-stats .stats-total .label { font-size: 0.75rem; color: var(--text-sub); }

.mode-section { display: flex; gap: 10px; margin-bottom: 20px; }
.mode-btn {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  transition: transform 0.1s;
}
.mode-btn:active { transform: scale(0.97); }
.mode-icon { font-size: 1.6rem; display: block; }
.mode-label { font-weight: bold; display: block; margin-top: 2px; }
.mode-desc { font-size: 0.72rem; color: var(--text-sub); display: block; margin-top: 2px; }
.mode-review .mode-desc.has-items { color: var(--accent); font-weight: bold; }

.category-section h2 { font-size: 1rem; margin-bottom: 10px; }
.category-list { display: flex; flex-direction: column; gap: 8px; }

.category-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  display: block;
  width: 100%;
}
.category-btn:active { transform: scale(0.99); }
.category-btn .cat-row { display: flex; justify-content: space-between; align-items: center; }
.category-btn .cat-name { font-weight: bold; }
.category-btn .cat-rate { font-size: 0.8rem; color: var(--text-sub); }
.category-btn .cat-bar {
  height: 6px; border-radius: 3px; background: #ece4c8; margin-top: 8px; overflow: hidden;
}
.category-btn .cat-bar-fill {
  height: 100%; background: var(--accent-soft); border-radius: 3px;
  transition: width 0.3s;
}

.disclaimer {
  margin-top: 28px;
  font-size: 0.75rem;
  color: var(--text-sub);
  background: var(--card);
  border: 1px dashed var(--card-border);
  border-radius: 10px;
  padding: 10px 12px;
}

/* ===== クイズ画面 ===== */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 12px;
}
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 1.1rem;
  flex-shrink: 0;
}
.quiz-title { flex: 1; text-align: center; }
.quiz-tag { font-weight: bold; font-size: 0.95rem; }
.quiz-progress { font-size: 0.82rem; color: var(--text-sub); }
.quiz-timer {
  min-width: 44px;
  text-align: right;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-size: 0.95rem;
}

.question-card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
#question-text { font-size: 1.02rem; font-weight: 500; }
.question-source { text-align: right; font-size: 0.72rem; color: var(--text-sub); margin-top: 8px; }

.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choice-btn {
  background: var(--card);
  border: 2px solid transparent;
  border-top: 4px solid #e0d8ba;
  border-radius: 10px;
  padding: 12px;
  font-size: 0.88rem;
  text-align: left;
  line-height: 1.6;
  transition: transform 0.08s;
}
.choice-btn:not(:disabled):active { transform: scale(0.98); }
.choice-btn.selected { border: 2px solid var(--accent); border-top-width: 4px; border-top-color: var(--accent); }
.choice-btn.correct-answer { background: var(--highlight); border: 2px solid var(--accent); }
.choice-btn:disabled { cursor: default; }

.result-bar {
  margin: 14px -16px 0;
  padding: 10px 16px;
  color: #fff;
  font-weight: bold;
  font-size: 1.05rem;
  text-align: center;
  letter-spacing: 0.3em;
}
.result-bar.correct { background: var(--correct-bg); }
.result-bar.wrong { background: var(--wrong-bg); }

.explanation { margin-top: 16px; }
.explanation-answer {
  background: #e9e4d4;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.92rem;
  margin-bottom: 10px;
}
.explanation-text {
  background: var(--highlight);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.92rem;
  white-space: pre-wrap;
}

.quiz-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 24px;
}
.round-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--card-border);
  font-size: 0.82rem;
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.round-btn:active { transform: scale(0.95); }

.next-btn {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 88px; height: 88px;
  border-radius: 50%;
  background: #4a453c;
  color: #fff;
  font-weight: bold;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 10;
}
.next-btn:active { transform: scale(0.95); }

/* ===== 結果画面 ===== */
.result-header { text-align: center; padding: 24px 0 8px; }
.result-header h1 { font-size: 1.3rem; }

.score-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  margin: 16px 0 20px;
}
.score-card .score-main { font-size: 2.2rem; font-weight: bold; color: var(--accent); }
.score-card .score-sub { color: var(--text-sub); font-size: 0.9rem; }
.score-card .pass-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 18px;
  border-radius: 999px;
  font-weight: bold;
  font-size: 0.95rem;
}
.score-card .pass-badge.pass { background: var(--accent); color: #fff; }
.score-card .pass-badge.fail { background: var(--wrong-bg); color: #fff; }

.result-list-wrap h2 { font-size: 1rem; margin-bottom: 10px; }
.result-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 0.88rem;
}
.result-item summary { cursor: pointer; font-weight: 500; list-style: none; display: flex; gap: 8px; }
.result-item summary::-webkit-details-marker { display: none; }
.result-item .mark { flex-shrink: 0; font-weight: bold; }
.result-item .mark.ok { color: var(--accent); }
.result-item .mark.ng { color: var(--wrong-bg); }
.result-item .detail { margin-top: 10px; border-top: 1px dashed var(--card-border); padding-top: 10px; }
.result-item .detail .ans { background: var(--highlight); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }

.primary-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-weight: bold;
  font-size: 1rem;
  border-radius: 999px;
  padding: 14px;
  margin-top: 20px;
}
.primary-btn:active { transform: scale(0.98); }

.empty-msg { color: var(--text-sub); text-align: center; padding: 20px 0; }
