:root {
  --header-h: 52px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  background: #fef6e9;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.screen.hidden { display: none; }

/* ---------- 共通トップバー ---------- */
.top-bar {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  background: #ffffff;
  border-bottom: 1px solid #eee1c9;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: #fbf0da;
  border-radius: 12px;
  font-size: 20px;
  cursor: pointer;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.icon-btn:active { background: #f3e2ba; }
.icon-btn-spacer { width: 44px; flex: 0 0 auto; }
.region-title {
  font-size: 17px;
  font-weight: bold;
  color: #4a3a20;
}
.timer-display {
  font-size: 12px;
  color: #a3906a;
  font-variant-numeric: tabular-nums;
  width: 44px;
  text-align: right;
  flex: 0 0 auto;
}

/* ---------- ホーム画面 ---------- */
#screen-home {
  background: linear-gradient(180deg, #fef6e9 0%, #ffffff 100%);
}
.home-title-wrap { flex: 1 1 auto; text-align: center; }
.home-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 20px 24px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}
.mode-btn {
  border: none;
  border-radius: 20px;
  padding: 20px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #4a3a20;
}
.mode-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.15); }
.mode-btn-icon { font-size: 28px; }
.mode-btn-title { font-size: 20px; font-weight: bold; }
.mode-btn-sub { font-size: 13px; color: #8a7350; }
.mode-btn-1 { background: linear-gradient(135deg, #ffe1a8, #ffc978); }
.mode-btn-2 { background: linear-gradient(135deg, #bde0f0, #8fc7e0); }

/* ---------- クイズ画面 ---------- */
.quiz-progress-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}
.quiz-progress { font-size: 16px; font-weight: bold; color: #4a3a20; }
.quiz-score { font-size: 12px; color: #8a7350; }

.quiz-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  padding: 24px 16px;
  overflow-y: auto;
}
.quiz-question {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 120px;
}
.quiz-question-name {
  font-size: 24px;
  font-weight: bold;
  color: #4a3a20;
  text-align: center;
}
.quiz-question-sub {
  font-size: 15px;
  color: #8a7350;
  text-align: center;
}
.quiz-answer-area {
  width: 100%;
  max-width: 440px;
}

/* ---------- 大きな再生ボタン（モード1） ---------- */
.big-play-btn {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ffc978, #ff9f5a);
  box-shadow: 0 6px 0 rgba(180, 100, 30, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: #fff;
}
.big-play-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(180, 100, 30, 0.35); }
.big-play-icon { font-size: 56px; line-height: 1; }
.big-play-label { font-size: 16px; font-weight: bold; }
.big-play-btn.playing {
  animation: play-pulse 0.6s ease-in-out infinite;
}
@keyframes play-pulse {
  0%, 100% { box-shadow: 0 6px 0 rgba(180, 100, 30, 0.35), 0 0 0 0 rgba(255, 159, 90, 0.5); }
  50% { box-shadow: 0 6px 0 rgba(180, 100, 30, 0.35), 0 0 0 14px rgba(255, 159, 90, 0); }
}

/* ---------- 4つの再生ボタンから選ぶ（モード2） ---------- */
.sound-choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sound-choice-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  background: #ffffff;
  border: 2px solid #eee1c9;
  border-radius: 16px;
  padding: 8px;
}
.sound-choice-row.played { border-color: #f3c98a; }
.sound-choice-row.is-playing { border-color: #ff9f5a; background: #fff6e9; }
.sound-choice-play {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  background: #fbf0da;
  border-radius: 12px;
  min-height: 56px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  color: #4a3a20;
}
.sound-choice-row.is-playing .sound-choice-play { background: #ffe1a8; }
.sound-choice-num { font-size: 20px; }
.sound-choice-icon { font-size: 22px; }
.sound-choice-row.played .sound-choice-icon::after { content: " ✓"; color: #4caf7d; }
.sound-choice-pick {
  flex: 0 0 84px;
  border: none;
  background: #4caf7d;
  color: #fff;
  border-radius: 12px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}
.sound-choice-pick:active { background: #3f9268; }

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.choice-btn {
  border: 2px solid #eee1c9;
  background: #ffffff;
  border-radius: 16px;
  cursor: pointer;
  min-height: 56px;
  font-size: 16px;
  font-weight: bold;
  color: #4a3a20;
}
.choice-btn:active { background: #fbf0da; }
.choice-btn-item {
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.choice-btn-item img { width: 56px; height: 56px; object-fit: contain; }
.choice-btn-item span { font-size: 14px; }

/* ---------- 正解画面（答えあわせカード） ---------- */
.answer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 10, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}
.answer-overlay.hidden { display: none; }
.answer-card {
  background: #ffffff;
  border-radius: 22px;
  padding: 24px;
  width: min(360px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  animation: pop-in 0.25s ease-out;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@keyframes pop-in {
  0%   { transform: scale(0.92); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}
.answer-badge {
  font-size: 20px;
  font-weight: bold;
  border-radius: 999px;
  padding: 6px 0;
}
.answer-badge-correct { color: #227a4e; background: #eafaf1; }
.answer-badge-wrong { color: #b3541e; background: #fff2ea; }
.answer-illust {
  width: min(45%, 140px);
  height: min(45vw, 140px);
  object-fit: contain;
  margin: 4px auto 0;
}
.answer-main { font-size: 22px; font-weight: bold; color: #4a3a20; }
.answer-onomatopoeia {
  font-size: 14px;
  color: #6a5730;
}
.answer-habitat {
  font-size: 13.5px;
  text-align: left;
  background: #f6f2e7;
  border-radius: 12px;
  padding: 10px 12px;
  color: #4a3a20;
}
.answer-taxon {
  font-size: 13px;
  color: #8a7350;
}
.answer-trivia {
  text-align: left;
  font-size: 13.5px;
  line-height: 1.5;
  color: #6b5116;
  background: #fff6df;
  border: 1px solid #f2dfa0;
  border-radius: 12px;
  padding: 10px 12px;
}

/* ---------- 完成/結果画面 ---------- */
.completion-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 10, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}
.completion-overlay.hidden { display: none; }
.completion-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 28px;
  text-align: center;
  width: min(360px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  animation: pop-in 0.3s ease-out;
}
.completion-title { font-size: 24px; font-weight: bold; color: #4a3a20; margin-bottom: 8px; }
.completion-sub { font-size: 16px; color: #8a7350; margin-bottom: 16px; }
.result-wrong-heading { font-size: 13px; color: #a3906a; margin-bottom: 8px; text-align: left; }
.result-wrong-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.result-wrong-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #4a3a20;
}
.result-wrong-item img { width: 44px; height: 44px; object-fit: contain; }
.completion-buttons { display: flex; flex-direction: column; gap: 10px; }
.completion-btn {
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  font-weight: bold;
  color: #ffffff;
  background: #4caf7d;
  cursor: pointer;
}
.completion-btn-secondary { background: #fbf0da; color: #4a3a20; }
.completion-btn-wrong { background: #ff9f5a; }

/* ---------- せってい画面 ---------- */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 10, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2100;
}
.settings-overlay.hidden { display: none; }
.settings-card {
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.25);
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eee1c9;
  flex: 0 0 auto;
}
.settings-title { font-size: 18px; font-weight: bold; color: #4a3a20; }
.settings-body { overflow-y: auto; padding: 8px 16px 24px; }
.settings-group { padding: 14px 0; border-bottom: 1px solid #f6f2e7; }
.settings-group-label { font-size: 14px; color: #8a7350; margin-bottom: 8px; }
.settings-row { display: flex; flex-wrap: wrap; gap: 8px; }
.settings-option {
  border: 2px solid #eee1c9;
  background: #ffffff;
  color: #4a3a20;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
}
.settings-option.active {
  border-color: #4caf7d;
  background: #eafaf1;
  color: #227a4e;
  font-weight: bold;
}
.settings-credit-link {
  display: block;
  text-align: center;
  padding: 16px 0 4px;
  font-size: 13px;
  color: #8a7350;
  text-decoration: none;
}
