/* いじんずかんクイズ - 偉人となかよくなろう */

:root {
  --bg: #fdf6ec;
  --card: #ffffff;
  --ink: #46392c;
  --ink-light: #8a7a64;
  --main: #c96a4a;
  --main-dark: #a34c30;
  --cream: #fbeede;
  --accent: #e0a13c;
  --line: #ecdfc9;
  --radius: 20px;
  --shadow: 0 4px 14px rgba(120, 90, 50, 0.13);
  --frame: #f3e9d8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", sans-serif;
  font-size: 16px;
  font-variant-numeric: lining-nums;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; }

ruby rt {
  font-size: 0.45em;
  color: var(--ink-light);
}

body.no-furigana ruby rt { display: none; }

/* ---------------- ヘッダー ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 250, 241, 0.95);
  border-bottom: 3px solid var(--main);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--main-dark);
}

.logo-img { width: 44px; height: 44px; object-fit: contain; }

.logo-text {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.header-buttons { display: flex; gap: 8px; }

.header-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  white-space: nowrap;
  border: 2px solid var(--main);
  border-radius: 999px;
  background: #fff;
  color: var(--main-dark);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}

.header-btn:hover { background: var(--cream); transform: translateY(-2px); }
.header-btn .material-symbols-rounded { font-size: 20px; }
.header-btn.furigana-off { border-color: #ccc; color: #999; }

/* ---------------- レイアウト ---------------- */
.app {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* 画面の切りかえを、ふわっとフェードイン */
@keyframes app-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.app.app-in {
  animation: app-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  .app.app-in { animation: none; }
}

.site-footer {
  text-align: center;
  padding: 22px 16px;
  background: #f1e6d2;
  color: var(--ink-light);
  font-size: 0.9rem;
  line-height: 1.7;
}

.site-footer .footer-note { max-width: 620px; margin: 0 auto 4px; }
.site-footer .footer-copy { margin-top: 8px; font-weight: 700; }
.site-footer .footer-credit { margin-top: 8px; }
.site-footer .footer-credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.25s;
}
.site-footer .footer-credit a:hover { opacity: 0.7; }
.site-footer .footer-credit a::after {
  content: "open_in_new";
  font-family: "Material Symbols Rounded";
  font-size: 0.9em;
  vertical-align: -2px;
  margin-left: 2px;
}

/* ---------------- 共通パーツ ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 32px;
  border: none;
  border-radius: 999px;
  background: var(--main-dark);
  color: #fff;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #7d3922;
  transition: transform 0.12s, box-shadow 0.12s;
}

.btn:hover { transform: translateY(2px); box-shadow: 0 2px 0 #7d3922; }

/* ボタン内のふりがな: 本文は1列にそろえ、ふりがなは上に浮かせる */
.btn ruby { position: relative; }
.btn ruby rt {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  margin-bottom: -5px;
  font-size: 0.5em;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  color: inherit;
  opacity: 0.8;
}

.btn.btn-sub {
  background: #fff;
  color: var(--main-dark);
  border: 2px solid var(--main);
  box-shadow: 0 4px 0 #e6cdbf;
}

.btn.btn-accent {
  background: var(--accent);
  box-shadow: 0 4px 0 #b67d22;
}

.center { text-align: center; }
.back-row { margin-bottom: 16px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-light);
  cursor: pointer;
}

.back-link:hover { color: var(--main-dark); }

/* 吹き出し＋キャラ */
.piyo-block {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 24px;
}

.piyo-block img { width: 110px; flex-shrink: 0; }

.speech {
  position: relative;
  flex: 1;
  background: var(--card);
  border: 3px solid var(--main);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-weight: 500;
}

/* ---------------- トップページ ---------------- */
.hero { text-align: center; padding: 12px 0 8px; }
.hero-img { width: 200px; }

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--main-dark);
  margin: 8px 0 4px;
}

.hero-sub { color: var(--ink-light); font-weight: 700; margin-bottom: 20px; }

.hero-lead {
  max-width: 520px;
  margin: 0 auto 28px;
  text-align: left;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
}

.furigana-hint {
  display: inline-block;
  max-width: 480px;
  margin-top: 16px;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink-light);
  background: var(--cream);
  border-radius: 18px;
  padding: 8px 16px;
}

.furigana-hint .material-symbols-rounded {
  font-size: 18px;
  color: var(--accent);
  vertical-align: -3px;
  margin-right: 4px;
}

/* ---------------- テーマ一覧 ---------------- */
.page-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--main-dark);
  margin-bottom: 20px;
  text-align: center;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}

.theme-card:hover { transform: translateY(-3px); border-color: var(--main); }

.theme-card .theme-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 800;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.theme-card .theme-head .material-symbols-rounded {
  font-size: 26px;
  color: var(--theme-color, var(--main-dark));
}

.theme-card .theme-catch {
  font-size: 1rem;
  color: var(--ink-light);
  line-height: 1.6;
}

.theme-card .theme-count {
  align-self: flex-start;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--theme-color, var(--main-dark));
  background: var(--cream);
  border-radius: 999px;
  padding: 2px 12px;
}

.theme-card .cleared-badge {
  position: absolute;
  top: -10px;
  right: -6px;
  width: 52px;
  transform: rotate(12deg);
}

.theme-card.locked-final { opacity: 0.55; }

.final-note {
  margin-top: 14px;
  text-align: center;
  font-size: 1rem;
  color: var(--ink-light);
}

/* ---------------- 肖像画・写真のわく ---------------- */
.portrait {
  margin: 0 auto;
  background: var(--frame);
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
}

.portrait-img {
  display: block;
  width: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.portrait-cap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--ink-light);
}

.portrait-type {
  align-self: center;
  font-weight: 700;
  color: var(--main-dark);
  background: #fff;
  border-radius: 999px;
  padding: 1px 10px;
}

.portrait-imagined {
  align-self: center;
  color: #b06a2c;
  background: #fbeecd;
  border-radius: 8px;
  padding: 2px 10px;
  font-weight: 700;
}

.portrait-credit { word-break: break-word; }

/* サイズちがい */
.portrait-q { max-width: 320px; }
.portrait-q .portrait-img { height: 340px; }

.portrait-answer { max-width: 260px; margin-bottom: 10px; }
.portrait-answer .portrait-img { height: 280px; }

.portrait-card {
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
}
.portrait-card .portrait-img { height: 210px; background: none; }

/* ---------------- 図鑑ページ ---------------- */
.zukan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.zukan-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.zukan-card .portrait { width: 100%; }

.zukan-body { padding: 10px 4px 2px; }

.zukan-name {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.5;
}

.zukan-era {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--main-dark);
  margin: 2px 0 8px;
}

.zukan-desc {
  font-size: 0.98rem;
  line-height: 1.75;
  background: var(--cream);
  border-radius: 12px;
  padding: 10px 12px;
}

.zukan-cap {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  align-items: flex-start;
  text-align: left;
}

.zukan-cap .portrait-type { align-self: flex-start; }
.zukan-cap .portrait-imagined { align-self: flex-start; }

/* ---------------- クイズ ---------------- */
.quiz-progress {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}

.quiz-progress .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e7dcc4;
}

.quiz-progress .dot.now { background: var(--accent); }
.quiz-progress .dot.done-ok { background: var(--main-dark); }
.quiz-progress .dot.done-ng { background: #e0a49d; }

.quiz-q {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
}

.portrait-q { margin-bottom: 18px; }

/* 文字の選択肢（肖像→名前） */
.choice-list { display: flex; flex-direction: column; gap: 10px; }

.choice-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}

.choice-btn:hover { border-color: var(--main); transform: translateX(4px); }

.choice-mark {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--cream);
  color: var(--main-dark);
  font-weight: 800;
  font-size: 0.9rem;
}

/* 肖像の選択肢（名前→肖像） */
.choice-portraits {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.choice-portrait-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--frame);
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}

.choice-portrait-btn:hover { border-color: var(--main); transform: translateY(-3px); }

.choice-portrait-btn .choice-mark {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
}

.choice-portrait-img {
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}

.choice-note {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--ink-light);
  text-align: center;
}

/* 判定パネル */
.judge {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: 18px;
  animation: pop-in 0.3s ease;
}

.judge > img { width: 100px; flex-shrink: 0; align-self: flex-start; }

.judge-body {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 3px solid var(--main);
}

.judge-body.ng { border-color: #eebcb4; }

.judge-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.judge-title.ok { color: var(--main-dark); }
.judge-title.ng { color: #c15a48; }
.judge-title .material-symbols-rounded { font-size: 26px; }

.answer-name { font-size: 1.15rem; font-weight: 800; text-align: center; }
.answer-era {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--main-dark);
  text-align: center;
  margin-bottom: 8px;
}

.judge-explain {
  font-size: 1rem;
  line-height: 1.75;
  margin-bottom: 12px;
  background: var(--cream);
  border-radius: 12px;
  padding: 10px 12px;
}

.judge .btn { white-space: nowrap; padding: 12px 22px; font-size: 1rem; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* ---------------- 結果・クリア画面 ---------------- */
.result-hero { text-align: center; padding: 8px 0; }
.result-hero img { width: 190px; }

.result-title {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--main-dark);
  margin: 10px 0 4px;
}

.result-title.ng { color: #c15a48; }

.result-score {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink-light);
  margin-bottom: 18px;
}

.result-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.stamp-get {
  width: 150px;
  margin: 8px auto;
  animation: stamp-press 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes stamp-press {
  0% { opacity: 0; transform: scale(2.2) rotate(-14deg); }
  60% { opacity: 1; transform: scale(0.92) rotate(-8deg); }
  100% { transform: scale(1) rotate(-8deg); }
}

/* ---------------- スタンプ台紙 ---------------- */
.stamp-board {
  background: var(--card);
  border: 3px dashed var(--main);
  border-radius: var(--radius);
  padding: 24px 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.stamp-slot { text-align: center; }

.stamp-slot .stamp-img-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  border-radius: 50%;
}

.stamp-slot img { width: 84px; height: 84px; object-fit: contain; }

.stamp-slot .stamp-num {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--main-dark);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  z-index: 1;
}

.stamp-slot .stamp-label { font-size: 1rem; font-weight: 700; line-height: 1.5; }
.stamp-slot.locked img { filter: grayscale(1) opacity(0.3); }
.stamp-slot.locked .stamp-num { background: #c9bfa8; }

.stamp-c1 img { filter: none; }
.stamp-c2 img { filter: hue-rotate(215deg); }
.stamp-c3 img { filter: hue-rotate(28deg) saturate(1.1); }
.stamp-c4 img { filter: hue-rotate(140deg) brightness(0.92); }
.stamp-c5 img { filter: hue-rotate(180deg); }
.stamp-c6 img { filter: hue-rotate(48deg) saturate(1.2) brightness(1.1); }
.stamp-c7 img { filter: hue-rotate(255deg) saturate(0.85); }
.stamp-c8 img { filter: hue-rotate(300deg) saturate(0.7) brightness(0.95); }

.stamp-slot.locked img { filter: grayscale(1) opacity(0.3) !important; }

.master-banner {
  margin-top: 24px;
  text-align: center;
  background: linear-gradient(135deg, #fff2d8, #ffe6b8);
  border-radius: var(--radius);
  padding: 24px 18px;
  box-shadow: var(--shadow);
}

.master-banner img { width: 170px; }

.master-banner .master-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: #b8860b;
  margin-top: 8px;
}

/* ---------------- スマホ調整 ---------------- */
@media (max-width: 520px) {
  /* ヘッダーを2段構成に：上段=ロゴ、下段=ふりがな/スタンプボタン */
  .site-header { flex-wrap: wrap; justify-content: center; padding: 10px 12px; gap: 8px; }
  .logo { gap: 6px; }
  .header-buttons { width: 100%; justify-content: center; }
  .header-btn { padding: 6px 10px; gap: 3px; }
  .header-btn .material-symbols-rounded { font-size: 17px; }
  .header-btn .btn-label { font-size: 0.85rem; }
  .piyo-block img { width: 84px; }
  .judge { flex-direction: column; align-items: center; text-align: center; }
  .judge > img { width: 80px; align-self: center; }
  .judge .btn { white-space: normal; }
  .stamp-board { grid-template-columns: repeat(2, 1fr); }
  .hero-img { width: 160px; }
  .portrait-q .portrait-img { height: 300px; }
  .choice-portrait-img { height: 140px; }
}

@media (max-width: 359px) {
  .choice-portraits { grid-template-columns: 1fr; }
}
