/* ─── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ★ 全要素共通の非表示クラス (バグ修正: これがないと .hidden が効かない) */
.hidden { display: none !important; }

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: #fff7ed;
  color: #1c1917;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─────────────────────────────────────── */
header {
  background: #ea580c;
  color: #fff;
  padding: 0 1rem;
  height: 52px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(234,88,12,.35);
}
.header-inner { max-width: 900px; width: 100%; margin: 0 auto; }
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }

/* ─── Main ───────────────────────────────────────── */
main { max-width: 900px; width: 100%; margin: 0 auto; padding: 1.5rem 1rem 3rem; flex: 1; }

/* ─── Hero ───────────────────────────────────────── */
.hero { text-align: center; margin-bottom: 1.5rem; }
.hero-icon { font-size: 3rem; margin-bottom: .5rem; }
.hero h1 { font-size: 1.75rem; font-weight: 800; color: #ea580c; margin-bottom: .5rem; }
.description { color: #57534e; font-size: .95rem; line-height: 1.7; }

/* ─── Mode Tabs ──────────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1.25rem;
}
.mode-tab {
  padding: .55rem 1.1rem;
  border: 2px solid #e7e5e4;
  border-radius: 999px;
  background: #fff;
  color: #57534e;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
}
.mode-tab:hover  { border-color: #ea580c; color: #ea580c; }
.mode-tab.active { background: #ea580c; border-color: #ea580c; color: #fff; }

/* モードタブ → 凡例 → 地図 の間を詰める */
.mode-tabs { margin-bottom: .5rem; }

/* ─── 地図 × パネル 2カラムレイアウト ────────────── */
.map-quiz-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1.5rem;
}
.map-column {
  min-width: 0; /* grid overflow 防止 */
}
.panel-column {
  position: sticky;
  top: 64px; /* header(52px) + 余白 */
  padding-top: .9rem; /* 凡例とパネルの間隔を確保 */
}
/* 240px の右列では学習詳細を縦並びに（横2列では狭すぎる） */
.panel-column .learn-detail { grid-template-columns: 1fr; }

/* ─── Japan Map (SVG container) ──────────────────── */
.map-wrap {
  /* margin-bottom は grid gap で代替 */
}
.japan-map {
  width: 100%;
}

/* Loading / Error states */
.map-loading {
  text-align: center;
  padding: 3rem 1rem;
  color: #78716c;
  font-size: .95rem;
}
.map-error {
  text-align: center;
  padding: 2rem 1rem;
  color: #b91c1c;
}

/* ─── SVG Prefecture Paths ───────────────────────── */
.pref-path {
  cursor: pointer;
  transition: filter .12s, stroke-width .12s;
}
.pref-path:hover {
  filter: brightness(1.18) drop-shadow(0 0 3px rgba(0,0,0,.4));
  stroke-width: 1.2 !important;
  z-index: 1;
}
.pref-path.highlighted {
  stroke: #fbbf24 !important;
  stroke-width: 3 !important;
  filter: brightness(1.15) drop-shadow(0 0 5px rgba(251,191,36,.7));
  animation: pulse-path 1.1s ease-in-out infinite;
}
.pref-path.correct {
  stroke: #22c55e !important;
  stroke-width: 3 !important;
  filter: brightness(1.1) drop-shadow(0 0 5px rgba(34,197,94,.6));
}
.pref-path.wrong {
  stroke: #ef4444 !important;
  stroke-width: 3 !important;
  filter: brightness(.8) drop-shadow(0 0 5px rgba(239,68,68,.5));
}
.pref-path.dim {
  opacity: .22;
  pointer-events: none;
}
.pref-path.answered { cursor: default; }

@keyframes pulse-path {
  0%, 100% { filter: brightness(1.15) drop-shadow(0 0 4px rgba(251,191,36,.7)); }
  50%       { filter: brightness(1.25) drop-shadow(0 0 9px rgba(251,191,36,.9)); }
}

/* ─── Region Legend ──────────────────────────────── */
.region-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .6rem;
  justify-content: center;
  font-size: .74rem;
  margin-bottom: .4rem;   /* 地図との間隔を最小化 */
}
.legend-item { display: flex; align-items: center; gap: .25rem; color: #57534e; }
.legend-dot  { width: 11px; height: 11px; border-radius: 2px; flex-shrink: 0; }

/* ─── Panels ─────────────────────────────────────── */
.panel { display: none; }
.panel.active { display: block; }
/* .hidden 単体ルール（上部の .hidden { display:none !important } が適用される） */

/* ─── Learn Panel ────────────────────────────────── */
.learn-header { text-align: center; margin-bottom: 1rem; }
.learn-header h2 { font-size: 1.25rem; color: #ea580c; font-weight: 700; }
.learn-sub { color: #78716c; font-size: .88rem; margin-top: .25rem; }

.learn-info {
  background: #fff;
  border-radius: 12px;
  border: 1.5px solid #fed7aa;
  padding: 1.5rem;
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(234,88,12,.08);
}
.learn-placeholder { text-align: center; color: #a8a29e; }
.learn-placeholder .learn-icon { font-size: 2rem; display: block; margin-bottom: .5rem; }

.learn-detail { display: grid; grid-template-columns: 1fr; gap: 1rem; width: 100%; }
.learn-detail-left { text-align: center; }
.learn-pref-name { font-size: 2rem; font-weight: 800; color: #ea580c; margin-bottom: .25rem; }
.learn-pref-kana { font-size: 1rem; color: #78716c; margin-bottom: .5rem; }
.learn-region-badge {
  display: inline-block; padding: .2rem .7rem;
  border-radius: 999px; font-size: .8rem; font-weight: 600; color: #fff;
}
.learn-detail-right { display: flex; flex-direction: column; gap: .6rem; justify-content: center; }
.learn-row { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.learn-row-label { color: #78716c; font-size: .8rem; min-width: 80px; }
.learn-row-val { font-weight: 600; color: #1c1917; }

.learn-all-btn-wrap { text-align: center; margin-bottom: 1.25rem; }

.learn-list { margin-top: 1rem; }
.learn-list-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.learn-list-table th {
  background: #ea580c; color: #fff; padding: .5rem .75rem; text-align: left; font-weight: 600;
}
.learn-list-table td { padding: .45rem .75rem; border-bottom: 1px solid #fed7aa; }
.learn-list-table tr:nth-child(even) td { background: #fff7ed; }
.learn-list-table tr:hover td { background: #ffedd5; }
.learn-list-table .region-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 2px; margin-right: .4rem; vertical-align: middle;
}

/* ─── Quiz Panels ────────────────────────────────── */
.quiz-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; }
.quiz-progress { flex: 1; }
.quiz-progress > span { font-size: .82rem; color: #78716c; display: block; margin-bottom: .3rem; }
.progress-bar { height: 6px; background: #e7e5e4; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: #ea580c; border-radius: 999px; transition: width .4s ease; width: 0%; }
.quiz-score-wrap { text-align: right; }
.score-label { font-size: .75rem; color: #78716c; display: block; }
.quiz-score  { font-size: 1.75rem; font-weight: 800; color: #ea580c; }

.quiz-question {
  background: #fff; border-radius: 12px; border: 1.5px solid #fed7aa;
  padding: 1.25rem; text-align: center; margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(234,88,12,.08);
}
.q-label { font-size: .85rem; color: #78716c; margin-bottom: .5rem; }
.q-pref  { font-size: 2rem; font-weight: 800; color: #ea580c; }
.q-hint  { font-size: .85rem; color: #a8a29e; margin-top: .25rem; }

/* Choices */
.choices-grid { display: grid; grid-template-columns: 1fr; gap: .6rem; margin-bottom: 1rem; }
.choice-btn {
  padding: .8rem .6rem; border: 2px solid #e7e5e4; border-radius: 10px;
  background: #fff; font-size: .95rem; font-weight: 600; color: #1c1917;
  cursor: pointer; transition: all .15s; text-align: center;
}
.choice-btn:hover:not(:disabled) { border-color: #ea580c; color: #ea580c; background: #fff7ed; }
.choice-btn.correct { background: #dcfce7; border-color: #22c55e; color: #15803d; }
.choice-btn.wrong   { background: #fee2e2; border-color: #ef4444; color: #b91c1c; }
.choice-btn:disabled { cursor: default; opacity: .85; }

/* Feedback */
.quiz-feedback {
  border-radius: 10px; padding: .75rem 1rem; font-size: .9rem;
  font-weight: 600; margin-bottom: 1rem; text-align: center;
}
.quiz-feedback.correct { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; cursor: pointer; }
.quiz-feedback.wrong   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; cursor: pointer; }
/* 「タップして次へ」ヒント文字 */
.fb-next-hint {
  display: block; font-size: .73rem; font-weight: 400;
  opacity: .62; margin-top: .3rem; letter-spacing: .02em;
}

/* Buttons */
.btn-start {
  display: block; width: 100%; padding: .85rem;
  background: #ea580c; color: #fff; border: none; border-radius: 10px;
  font-size: 1rem; font-weight: 700; cursor: pointer; transition: background .18s, transform .1s;
}
.btn-start:hover  { background: #c2410c; }
.btn-start:active { transform: scale(.98); }

.btn-secondary {
  display: inline-block; padding: .7rem 1.5rem;
  background: #fff; color: #ea580c; border: 2px solid #ea580c;
  border-radius: 10px; font-size: .95rem; font-weight: 700;
  cursor: pointer; transition: all .18s;
}
.btn-secondary:hover { background: #fff7ed; }

/* ─── Result Panel ───────────────────────────────── */
.panel-result {
  text-align: center; padding: 1.25rem .75rem;
  background: #fff; border-radius: 16px; border: 1.5px solid #fed7aa;
  box-shadow: 0 4px 20px rgba(234,88,12,.1);
}
.result-icon { font-size: 4rem; margin-bottom: .75rem; }
.panel-result h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 1rem; }
.result-score-big { font-size: 3.5rem; font-weight: 800; color: #ea580c; line-height: 1; margin-bottom: .75rem; }
.result-total { font-size: 1.5rem; color: #78716c; }
.result-msg  { color: #57534e; margin-bottom: 1.5rem; font-size: .95rem; }
.result-wrong-wrap { text-align: left; margin-bottom: 1.5rem; }
.result-wrong-title { font-size: .9rem; font-weight: 700; color: #b91c1c; margin-bottom: .5rem; }
.result-wrong-list  { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; }
.result-wrong-item  { background: #fee2e2; border-radius: 6px; padding: .3rem .6rem; font-size: .82rem; color: #b91c1c; }
.result-btns { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* ─── Info Card ──────────────────────────────────── */
.card {
  background: #fff; border-radius: 14px; border: 1.5px solid #fed7aa;
  padding: 1.5rem; margin-top: 1.5rem; box-shadow: 0 2px 8px rgba(234,88,12,.07);
}
.card h2 { font-size: 1.1rem; font-weight: 700; color: #ea580c; margin-bottom: .75rem; }
.tips-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.tip-item  { display: flex; gap: .75rem; }
.tip-icon  { font-size: 1.5rem; flex-shrink: 0; }
.tip-text strong { display: block; font-weight: 700; margin-bottom: .2rem; font-size: .9rem; }
.tip-text p { font-size: .82rem; color: #78716c; line-height: 1.5; }

/* ─── Footer ─────────────────────────────────────── */
footer {
  text-align: center; padding: 1.5rem 1rem; font-size: .82rem;
  color: #a8a29e; border-top: 1px solid #e7e5e4; margin-top: auto;
}
footer a { color: #ea580c; text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer p + p { margin-top: .3rem; }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 720px) {
  /* 2カラム → 1カラムに戻す */
  .map-quiz-layout {
    grid-template-columns: 1fr;
    gap: .5rem;
  }
  /* モバイルではパネルを地図の上に表示 → 学習モードがすぐ見える */
  .panel-column {
    order: -1;      /* 地図より先に表示 */
    position: static;
    padding-top: 0;
  }
  .map-column { order: 0; }
  /* 狭い画面でも学習詳細を縦並びに */
  .panel-column .learn-detail { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .tips-grid        { grid-template-columns: 1fr; }
  .learn-detail     { grid-template-columns: 1fr; }
  .choices-grid     { grid-template-columns: 1fr; }
  .mode-tab         { font-size: .82rem; padding: .45rem .8rem; }
}

/* ━━━ Amazonおすすめ ━━━ */
.amazon-card h2 { margin-bottom: 0.25rem; }
.amazon-note { font-size: 0.82rem; color: #999; margin-bottom: 1rem; }
.amazon-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.amazon-item {
  display: block;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 0.9rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}
.amazon-item:hover {
  border-color: #FF9900;
  box-shadow: 0 2px 8px rgba(255,153,0,0.15);
  transform: translateY(-1px);
}
.amazon-item-icon { font-size: 1.7rem; margin-bottom: 0.35rem; }
.amazon-item-name { font-size: 0.88rem; font-weight: bold; margin-bottom: 0.2rem; }
.amazon-item-desc { font-size: 0.76rem; color: #888; line-height: 1.5; margin-bottom: 0.45rem; }
.amazon-item-link { font-size: 0.78rem; color: #FF9900; font-weight: bold; }

.amazon-notice {
  font-size: 0.72rem;
  color: #bbb;
  margin-top: 0.2rem;
}

/* ━━━ FAQ ━━━ */
.faq-list { display: flex; flex-direction: column; }
.faq-item { padding: .9rem 0; border-bottom: 1px solid #f0f0f0; }
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.faq-q { font-size: .9rem; font-weight: 700; color: #1a73e8; margin-bottom: .35rem; }
.faq-a { font-size: .85rem; color: #555; line-height: 1.75; }
