/* 和の学習帳：生成りの紙、墨の文字、朱の印 */
:root {
  --paper: #f4efe4;
  --paper-2: #ebe4d3;
  --ink: #23201b;
  --ink-2: #6a6356;
  --rule: #d5cbb6;
  --shu: #b8412c;
  --shu-soft: rgba(184, 65, 44, .08);
  --ai: #2c4a6e;
  --ai-soft: rgba(44, 74, 110, .08);
  --on-ink: #f4efe4;
  --mincho: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  --gothic: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1c1a17;
    --paper-2: #26231f;
    --ink: #ebe5d7;
    --ink-2: #a39b8b;
    --rule: #3b372f;
    --shu: #e27a62;
    --shu-soft: rgba(226, 122, 98, .1);
    --ai: #94b3d8;
    --ai-soft: rgba(148, 179, 216, .1);
    --on-ink: #1c1a17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1c1a17;
  --paper-2: #26231f;
  --ink: #ebe5d7;
  --ink-2: #a39b8b;
  --rule: #3b372f;
  --shu: #e27a62;
  --shu-soft: rgba(226, 122, 98, .1);
  --ai: #94b3d8;
  --ai-soft: rgba(148, 179, 216, .1);
  --on-ink: #1c1a17;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--gothic);
  line-height: 1.7;
}
button { font: inherit; color: inherit; }
button:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--shu); outline-offset: 2px; }
body::before {
  content: ''; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10;
  background: var(--paper);
}
.muted { color: var(--ink-2); }
.small { font-size: .82rem; }

/* ---------- 見出し ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; align-items: center; gap: 10px;
  max-width: 640px; margin: 0 auto;
  padding-block: 14px 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}
.seal {
  display: grid; place-items: center;
  width: 28px; height: 28px; flex: none;
  background: var(--shu); color: var(--paper);
  font-family: var(--mincho); font-weight: 700; font-size: 1rem;
  border-radius: 3px;
}
.brand { font-family: var(--mincho); font-weight: 700; font-size: 1.2rem; margin: 0; letter-spacing: .08em; }
/* 「博識になろう！」の右にある実績のボタン（上に小さく「実績」、下に本のマーク） */
.ach-btn {
  display: grid; justify-items: center; gap: 1px; border: 0; background: none; cursor: pointer;
  padding: 0 4px; color: var(--shu); line-height: 1;
}
.ach-btn { margin-block: -11px; } /* 本のマークを大きくしても、上の帯の高さは変えない */
.ach-btn .lbl { font-size: .62rem; font-weight: 700; letter-spacing: .1em; }
.ach-btn[hidden] { display: none; }
#ideaBtn, #rankBtn { margin-left: -6px; }

/* ---------- ランキング ---------- */
.rank-me { padding: 14px 0 16px; text-align: center; font-family: var(--mincho); font-size: 1.05rem; border-bottom: 1px solid var(--ink); display: grid; gap: 6px; }
.rank-me .my-no { font-size: .9rem; color: var(--ink-2); }
.rank-me .my-no b { color: var(--ink); font-size: 1.1rem; }
.rank-me .big { font-size: 2.2rem; color: var(--shu); margin: 0 2px; }
.rank-me small { font-size: .85rem; color: var(--ink-2); margin-left: 4px; }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li {
  display: grid; grid-template-columns: 4.2em 1fr auto; align-items: baseline; gap: 10px;
  padding: 10px 6px; border-bottom: 1px solid var(--rule);
}
.rank-list .pos { font-family: var(--mincho); font-weight: 700; font-size: 1.1rem; }
.rank-list .pos small { font-size: .7rem; margin-left: 1px; color: var(--ink-2); }
.rank-list .who .no { font-family: var(--mincho); font-weight: 700; }
.rank-list .who small { margin-left: 8px; font-size: .78rem; color: var(--ink-2); }
.rank-list .who b { margin-left: 8px; font-size: .72rem; color: var(--paper); background: var(--shu); padding: 2px 6px; border-radius: 3px; letter-spacing: .08em; }
.rank-list .pts { font-family: var(--mincho); font-weight: 700; font-size: 1.05rem; }
.rank-list li.top .pos { color: var(--shu); } /* 3位まで（同じ順位が並んでも、順位の数字で決める） */
.rank-list li.me { background: var(--shu-soft); }
.rank-gap { text-align: center; color: var(--ink-2); padding: 4px 0; }
.rank-note { color: var(--ink-2); text-align: center; padding: 24px 0; margin: 0; }
.rank-note.small { font-size: .78rem; padding: 18px 0 8px; }
/* 新しい実績があるときは、実績のボタンを点滅させる */
.ach-btn.blink { animation: ach-btn-blink 1s ease-in-out infinite; }
@keyframes ach-btn-blink { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(1.12); } }
.back {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  font-size: .85rem; color: var(--ink-2); padding: 4px 0;
}
.back:hover { color: var(--ink); }

main {
  max-width: 640px; margin: 0 auto;
  padding-block: 0 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.section-title {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--mincho); font-weight: 700; font-size: 1.05rem; letter-spacing: .1em;
  margin: 32px 0 4px; padding-bottom: 6px; border-bottom: 1px solid var(--ink);
}
.section-title .note { font-family: var(--gothic); font-weight: 400; font-size: .78rem; letter-spacing: 0; color: var(--ink-2); }

/* ---------- 目次（ホーム） ---------- */
.standing {
  display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 4px 20px;
  padding: 24px 0 0;
}
/* 次の称号までのバー（前の二重線と同じ位置に置く：4px の行間 + 11px + 6px = 前の余白18px + 線3px） */
.title-meter {
  position: relative; grid-column: 1 / -1; grid-row: 3; height: 6px; margin-top: 11px;
  background: var(--rule); border-radius: 3px; overflow: visible;
}
.title-meter span { display: block; height: 100%; background: var(--shu); border-radius: 3px; transition: width .3s; }
.title-meter.counting span { transition: none; } /* 数え上げ中は毎フレーム幅を変えるので、なめらかさは数え上げ側でつける */
/* 称号が上がる直前、画面がバーの右端に寄る（拡大の中心は JS で決める） */
.topbar, #app { transition: transform .55s cubic-bezier(.5, 0, .2, 1); }
html.zooming { overflow: hidden; } /* 拡大中にスクロールバーが出ないように */
/* 拡大中、周りを暗くして真ん中に目が行くようにする（明るく残す大きさ --w / --h は JS で決める） */
.zoom-dim {
  position: fixed; inset: 0; z-index: 40; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse var(--w) var(--h) at 50% 50%, transparent 55%, rgba(0, 0, 0, .78) 100%);
  transition: opacity .55s ease;
}
.zoom-dim.on { opacity: 1; }

/* 称号が上がったときの画面全体の演出 */
.title-fx { position: fixed; inset: 0; z-index: 50; pointer-events: none; display: grid; place-items: center; overflow: hidden; }
.title-fx .glow {
  position: absolute; inset: -20%;
  background: radial-gradient(circle at 50% 45%, var(--shu) 0, transparent 60%);
  animation: fx-glow 2.2s ease-out forwards;
}
.title-fx .word {
  position: relative; text-align: center; color: var(--ink);
  font-family: var(--mincho); font-weight: 700; font-size: clamp(3rem, 16vw, 6rem); letter-spacing: .12em; line-height: 1.1;
  text-shadow: 0 0 24px var(--shu);
  animation: fx-word 2.2s cubic-bezier(.2, .9, .3, 1) forwards;
}
/* 満点（知恵の神）のときは演出を少し長くし、称号の下に「完」のハンコを押す */
.title-fx.with-hanko .glow, .title-fx.with-hanko .word { animation-duration: 3s; }
.title-fx .word .hanko { position: relative; top: auto; right: auto; margin: 22px auto 0; text-shadow: none; letter-spacing: 0; background: var(--paper); animation-delay: .15s; }
.title-fx .word small { display: block; font-size: .9rem; letter-spacing: .3em; font-weight: 400; color: var(--ink-2); text-shadow: none; margin-bottom: 6px; }
@keyframes fx-glow {
  0% { opacity: 0; transform: scale(.3); }
  20% { opacity: .55; }
  100% { opacity: 0; transform: scale(1.4); }
}
@keyframes fx-word {
  0% { opacity: 0; transform: scale(.6); }
  18% { opacity: 1; transform: scale(1.05); }
  30% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.08) translateY(-12px); }
}
/* バーの右端の上：「次の称号まであと〜問」、最高の称号なら「MAX」 */
.title-meter b {
  position: absolute; right: 0; bottom: 100%; margin-bottom: 3px;
  font-family: var(--gothic); font-weight: 400; font-size: .8rem; color: var(--ink-2); line-height: 1; white-space: nowrap;
}
.title-meter.max b { font-family: var(--mincho); font-weight: 700; font-size: .7rem; letter-spacing: .1em; color: var(--shu); }
.standing .label { grid-column: 1 / -1; font-size: .8rem; color: var(--ink-2); letter-spacing: .1em; }
.standing .num { font-family: var(--mincho); font-weight: 700; font-size: 3.4rem; line-height: 1; }
.standing .num small { font-family: var(--gothic); font-weight: 400; font-size: .85rem; color: var(--ink-2); margin-left: 4px; }
.standing .rank { padding-bottom: 4px; }
/* 称号は博識度の数字と同じくらい大きく。「あなたの博識度」の行の高さも使って、下の線の位置は前と同じにする
   （狭い画面では横にはみ出さないよう縮める） */
.standing { grid-template-rows: auto minmax(3.58rem, auto); } /* 前の称号表示のときと同じ高さにして、下の線の位置を変えない */
.standing .label { grid-column: 1; grid-row: 1; }
.standing .num { grid-column: 1; grid-row: 2; }
/* 博識度の欄は「完 満点／満点」の幅をいつもとっておく（見えない .ghost を重ねる）。桁が増えても称号の位置が動かない */
.standing .num { display: grid; }
.standing .num > span { grid-area: 1 / 1; white-space: nowrap; }
.standing .num .ghost { visibility: hidden; }
/* 称号は、博識度の欄の右端から線の右端までの真ん中に置く */
.standing .rank { grid-column: 2; grid-row: 1 / 3; margin-left: -20px; padding-bottom: 14px; white-space: nowrap; text-align: center; line-height: 1; } /* -20px は列の間の gap を打ち消す */
.standing .rank b { position: relative; display: inline-block; font-family: var(--mincho); font-size: clamp(1.4rem, 6.2vw, 3rem); letter-spacing: .1em; line-height: 1; }
/* 小さな「称号」は称号の上に浮かせて、称号の文字そのものが真ん中にくるようにする（高さも増やさない） */
.standing .rank .tag {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px;
  font-family: var(--gothic); font-weight: 400; font-size: .8rem; letter-spacing: 0; color: var(--ink-2);
}

/* ---------- 実績 ---------- */
/* 実績のマーク：8角形のメダル。外側の枠の色で格を表す（金・銀・銅。分野ごとの実績は銅）。内側は白
   重ね方：濃い縁（::before）→ 光沢のある金属の枠（::after）→ 白い面（中の span）。全体に影をつけて浮かせる */
:root {
  --gold: #c9a227; --gold-hi: #fff0a3; --gold-lo: #7a5a08; --gold-rim: #4a3604;
  --silver: #a9aeb6; --silver-hi: #f7f9fb; --silver-lo: #686d76; --silver-rim: #393c42;
  --bronze: #b0703a; --bronze-hi: #f0b987; --bronze-lo: #6b3c15; --bronze-rim: #43250b;
}
.ach-big {
  --mid: var(--bronze); --hi: var(--bronze-hi); --lo: var(--bronze-lo); --rim: var(--bronze-rim);
  position: relative; display: grid; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5));
  font-family: var(--mincho); font-weight: 700; letter-spacing: 0; line-height: 1; color: #3a2614;
}
.ach-big::before, .ach-big::after, .ach-big > i, .ach-big > span { position: absolute; clip-path: polygon(29.3% 0, 70.7% 0, 100% 29.3%, 100% 70.7%, 70.7% 100%, 29.3% 100%, 0 70.7%, 0 29.3%); }
.ach-big::before { content: ""; inset: 0; background: var(--rim); }
.ach-big::after {
  content: ""; inset: 1.5px;
  background: linear-gradient(150deg, var(--hi) 0%, var(--mid) 42%, var(--lo) 78%, var(--mid) 100%);
}
.ach-big > i { z-index: 1; inset: calc(var(--bw) - 1px); background: var(--rim); } /* 白い面のふちの細い線 */
.ach-big > span {
  z-index: 2; inset: var(--bw); display: grid; place-items: center;
  background: radial-gradient(circle at 35% 28%, #ffffff 0%, #f6f2ea 55%, #dcd3c3 100%);
  text-shadow: 0 1px 0 #fff;
}
.ach-big.silver { --mid: var(--silver); --hi: var(--silver-hi); --lo: var(--silver-lo); --rim: var(--silver-rim); }
.ach-big.gold { --mid: var(--gold); --hi: var(--gold-hi); --lo: var(--gold-lo); --rim: var(--gold-rim); }
/* レインボー：虹色の枠に光沢を重ねる */
.ach-big.rainbow { --rim: #2a2a33; }
.ach-big.rainbow::after {
  background:
    linear-gradient(150deg, rgba(255, 255, 255, .65) 0%, rgba(255, 255, 255, 0) 40%, rgba(0, 0, 0, .28) 100%),
    conic-gradient(from 200deg, #ff4d4d, #ffa64d, #ffe14d, #5be36b, #4dd2ff, #5b6bff, #c35bff, #ff4d4d);
}
/* キラキラ（全知全能）：メダルのまわりで小さな星がまたたく */
.ach-big.sparkle > b {
  position: absolute; z-index: 3; width: 22%; height: 22%; pointer-events: none;
  background: #fff; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 3px #fff); animation: twinkle 1.6s ease-in-out infinite;
}
.ach-big.sparkle > b:nth-of-type(1) { top: -6%; left: 6%; }
.ach-big.sparkle > b:nth-of-type(2) { top: 10%; right: -8%; animation-delay: .4s; }
.ach-big.sparkle > b:nth-of-type(3) { bottom: -6%; right: 12%; animation-delay: .8s; }
.ach-big.sparkle > b:nth-of-type(4) { bottom: 18%; left: -8%; animation-delay: 1.2s; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0deg); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
/* 獲得前の「全知全能」：何もわからないよう真っ黒 */
.ach-big.locked.secret, .ach-cell.locked .ach-big.locked.secret { --rim: #000; opacity: 1; filter: none; }
.ach-big.locked.secret::after { background: #0a0a0a; }
.ach-big.locked.secret > span, .ach-cell.locked .ach-big.locked.secret > span { background: #000; }
/* 詳しい表示の「〇の実績」の色 */
.ach-detail .grade.silver { color: var(--silver); }
.ach-detail .grade.gold { color: var(--gold); }
.ach-detail .grade.rainbow { background: linear-gradient(90deg, #ff6b6b, #ffd93b, #5be36b, #4dd2ff, #c35bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
/* 実績の一覧：1行に5つ。実績名を上に、マークを下に */
.ach-grid { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 20px 2px; }
.ach-cell { width: 100%; display: grid; justify-items: center; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink); }
.ach-cell .name { min-height: 2.5em; display: grid; align-items: end; text-align: center; font-family: var(--mincho); font-weight: 700; font-size: .82rem; line-height: 1.25; letter-spacing: -.03em; }
.ach-cell .name span span { white-space: nowrap; }
.ach-big { --bw: 5px; width: 56px; height: 56px; font-size: 1.45rem; }
.ach-cell .name span span { display: inline-block; }
.ach-cell.locked .name { color: var(--ink-2); }
/* 一覧で、まだ押していない新しい実績のマークを点滅させる */
.ach-cell.fresh .ach-big { animation: ach-fresh-blink 1s ease-in-out infinite; }
@keyframes ach-fresh-blink {
  0%, 100% { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5)) drop-shadow(0 0 0 rgba(240, 185, 135, 0)); transform: scale(1); }
  50% { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5)) drop-shadow(0 0 9px rgba(240, 185, 135, .95)); transform: scale(1.08); }
}
/* まだ取っていない実績は、灰色の枠で影なし・薄く */
.ach-big.locked, .ach-cell.locked .ach-big { --mid: #55524c; --hi: #6e6a63; --lo: #3d3a35; --rim: #2c2a26; color: #8a857c; opacity: .6; filter: none; }
.ach-big.locked::after { background: linear-gradient(150deg, var(--hi) 0%, var(--mid) 42%, var(--lo) 78%, var(--mid) 100%); }
.ach-big.locked > span, .ach-cell.locked .ach-big > span { background: #34312c; text-shadow: none; }
/* 実績を獲得したときの知らせ（画面の真ん中。メダルが押されるように出る） */
.ach-gain { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, .55); animation: gain-fade .25s ease-out both; cursor: pointer; }
.ach-gain .panel {
  width: min(340px, 100%); max-height: 86vh; overflow: auto; display: grid; justify-items: center; gap: 14px; padding: 22px 16px 16px;
  background: var(--paper); border: 1px solid var(--bronze); border-radius: 10px; text-align: center;
  box-shadow: 0 0 40px rgba(176, 112, 58, .45);
}
.ach-gain .head { font-family: var(--mincho); font-weight: 700; font-size: 1.15rem; letter-spacing: .12em; color: var(--bronze-hi); }
.ach-gain .medals { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 10px; }
.ach-gain .medal { display: grid; justify-items: center; gap: 6px; animation: done-stamp .45s cubic-bezier(.3, 1.4, .5, 1) both; }
.ach-gain .ach-big { --bw: 7px; width: 84px; height: 84px; font-size: 2.2rem; }
.ach-gain .medal .name { font-family: var(--mincho); font-weight: 700; font-size: 1rem; }
.ach-gain .medals.many .ach-big { --bw: 4px; width: 48px; height: 48px; font-size: 1.25rem; }
.ach-gain .medals.many .medal { width: 58px; }
.ach-gain .medals.many .medal .name { font-size: .66rem; line-height: 1.2; }
.ach-gain .tap { font-size: .72rem; color: var(--ink-2); }
@keyframes gain-fade { from { opacity: 0; } to { opacity: 1; } }

/* 実績の詳しい条件（画面の真ん中） */
.ach-detail { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, .55); }
.ach-detail .panel {
  width: min(320px, 100%); display: grid; justify-items: center; gap: 8px; padding: 24px 20px 18px;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; text-align: center;
}
.ach-detail .ach-big { --bw: 6px; width: 76px; height: 76px; font-size: 2rem; }
.ach-detail .name { font-family: var(--mincho); font-weight: 700; font-size: 1.3rem; margin-top: 4px; }
.ach-detail .grade { font-size: .75rem; color: var(--bronze); font-weight: 700; letter-spacing: .1em; }
.ach-detail .cond { margin: 4px 0 0; font-size: .88rem; line-height: 1.6; }
.ach-detail .cond.hidden-cond { color: var(--ink-2); font-size: .8rem; }
.ach-detail .state { font-size: .85rem; color: var(--shu); font-weight: 700; }
.ach-detail .btn { margin-top: 8px; min-width: 120px; }

/* 一番細かい範囲の行の右にある「復習」ボタン */
.toc li.with-review { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; border-bottom: 1px dashed var(--rule); }
.toc li.with-review .toc-item { border-bottom: 0; }
.review-btn {
  display: grid; justify-items: center; gap: 0; min-width: 52px; padding: 6px 8px; cursor: pointer;
  background: var(--shu-soft); border: 1px solid var(--shu); border-radius: 4px; color: var(--shu);
  font-size: .72rem; line-height: 1.3;
}
.review-btn b { font-family: var(--mincho); font-size: 1rem; }
.review-btn:hover:not(:disabled) { background: var(--shu); color: var(--paper); }
.review-btn:disabled { cursor: default; background: transparent; border-color: var(--rule); color: var(--ink-2); }
/* ホームの「復習」は件数の表示だけ（押せない）。見た目は範囲の「復習」ボタンと同じ枠にする */
.review-count {
  display: grid; justify-items: center; min-width: 64px; padding: 6px 8px;
  background: var(--shu-soft); border: 1px solid var(--shu); border-radius: 4px; color: var(--shu);
  font-size: .9rem; line-height: 1.3;
}
.review-count b { font-family: var(--mincho); font-size: 1.35rem; }
.review-count.zero { background: transparent; border-color: var(--rule); color: var(--ink-2); }

.toc { list-style: none; margin: 0; padding: 0; }
/* 出題範囲の一覧の下に付ける注意書き（ことわざの「全〜」の説明など） */
.scope-note { margin: 14px 0 0; font-size: .8rem; line-height: 1.7; color: var(--ink-2); }
.toc-item {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 4px 14px;
  width: 100%; padding: 14px 2px; cursor: pointer; text-align: left;
  background: none; border: 0; border-bottom: 1px dashed var(--rule);
}
.toc-item:hover .name { color: var(--shu); }
.mark {
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 1.5px solid var(--shu); color: var(--shu); border-radius: 3px;
  font-family: var(--mincho); font-weight: 700; font-size: 1.35rem;
}
.mark.two { font-size: 1.1rem; letter-spacing: -.04em; } /* 漢字2文字（準一）を同じ枠に収める */
.toc-item .name { font-family: var(--mincho); font-weight: 700; font-size: 1.08rem; letter-spacing: .04em; transition: color .15s; }
.toc-item .desc { display: block; font-size: .8rem; color: var(--ink-2); }
.toc-item .score { font-family: var(--mincho); font-size: .95rem; white-space: nowrap; }
.toc-item .score small { color: var(--ink-2); }
.toc-item .line { grid-column: 2 / -1; height: 2px; background: var(--rule); }
.toc-item .line span { display: block; height: 100%; background: var(--ink); transition: width .4s; }

.toc-item.locked { cursor: default; }
.toc-item.locked:hover .name { color: inherit; }
.toc-item.locked .mark { border-color: var(--rule); color: var(--ink-2); }
.toc-item.locked .name { color: var(--ink-2); }
.toc-item.locked .score { font-family: var(--gothic); font-size: .78rem; color: var(--ink-2); }

/* ---------- 問題 ---------- */
.quiz-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 16px 0 8px; font-size: .82rem; color: var(--ink-2);
}
.quiz-head .count { font-family: var(--mincho); }
.quiz-head .count b { color: var(--ink); font-size: 1rem; }
.meter { height: 2px; background: var(--rule); }
.meter span { display: block; height: 100%; background: var(--shu); transition: width .3s; }

.question { padding: 12px 0 20px; }
.question .no { font-family: var(--mincho); font-weight: 700; color: var(--shu); letter-spacing: .15em; font-size: 1.2rem; }
.question .text { font-family: var(--mincho); font-weight: 700; font-size: 1.3rem; line-height: 1.6; margin-top: 4px; }
/* 問題文が1〜3行のどれでも選択肢の位置が変わらないよう、3行分の高さをとっておく（line-height 2.1 × 3行） */
.question .text { min-height: 6.3em; }
.question .word { font-family: var(--mincho); font-weight: 700; font-size: 2.6rem; letter-spacing: .12em; line-height: 1.3; margin-top: 6px; }
.question .word.long { font-size: 1.6rem; letter-spacing: .06em; }
/* 英単語は長さによらず同じ大きさにし、文字の間を詰める */
.question .word.latin { font-size: 2rem; letter-spacing: .01em; }
/* ことわざ：短い語も長い語と同じ大きさにそろえる。ふりがなが「問〜」や前の行に重ならないよう行の高さを広げ、
   1行の語も2行分の高さをとって、どの問題でも選択肢の位置が変わらないようにする */
/* 英単語の発音記号（単語のすぐ下に小さく） */
.question .ipa { margin-top: 2px; font-family: "Lucida Sans Unicode", "Arial Unicode MS", "Segoe UI", sans-serif; font-size: .95rem; color: var(--ink-2); letter-spacing: .02em; }
.question .word.ruby-word { font-size: 1.6rem; letter-spacing: .06em; line-height: 1.95; min-height: 3.9em; margin-top: 10px; }
/* 文字を大きくしても選択肢の位置が変わらないよう、行の高さは前（.9rem × 1.7 ≒ 24.5px）と同じにする */
.question .sub { font-size: 1.2rem; line-height: 1.275; color: var(--ink-2); margin-top: 2px; }

.choices { display: grid; gap: 8px; }
.choice {
  /* 左右に同じ幅の列を置いて、答えの文字を枠の真ん中にする（右の列に○×が入る） */
  display: grid; grid-template-columns: 24px 1fr 24px; align-items: center; gap: 8px;
  width: 100%; text-align: center; cursor: pointer;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 4px;
  padding: 14px 12px; font-size: 1.25rem; line-height: 1.5;
  transition: background .12s, border-color .12s;
}
.choice .judge { font-family: var(--mincho); font-weight: 700; font-size: 1.2rem; text-align: center; }
.choice:hover:not(:disabled) { background: var(--paper-2); border-color: var(--ink-2); }
.choice:disabled { cursor: default; }
.choice:disabled:not(.correct):not(.wrong) { opacity: .55; }
.choice.correct { border-color: var(--shu); background: var(--shu-soft); }
.choice.correct .judge { color: var(--shu); }
.choice.wrong { border-color: var(--ai); background: var(--ai-soft); }
.choice.wrong .judge { color: var(--ai); }

.feedback { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--ink); }
.verdict { font-family: var(--mincho); font-weight: 700; font-size: 1.25rem; letter-spacing: .08em; text-align: center; }
.verdict.ok { color: var(--shu); }
.verdict.ng { color: var(--ai); }
.verdict .answer { font-size: 1rem; letter-spacing: 0; color: var(--ink); margin-left: 6px; }
.explain-label { display: inline-block; margin-top: 10px; font-size: .75rem; letter-spacing: .15em; color: var(--ink-2); border-bottom: 1px solid var(--rule); }
.feedback p { margin: 4px 0 0; }
.src { display: flex; justify-content: space-between; gap: 12px; font-size: .78rem; color: var(--ink-2); margin-top: 10px !important; }
.link-btn { border: 0; background: none; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; font-size: .78rem; white-space: nowrap; }
.link-btn:hover { color: var(--ink); }

.actions { display: flex; gap: 10px; margin-top: 22px; }
#confirmActions { flex-wrap: wrap; }
.btn.cancel { flex-basis: 100%; border-color: var(--ink-2); color: var(--ink); font-weight: 400; }
.btn {
  flex: 1; padding: 13px 18px; cursor: pointer; font-weight: 700; letter-spacing: .08em;
  background: transparent; border: 1px solid var(--ink); border-radius: 4px;
}
.btn.solid { background: var(--ink); color: var(--on-ink); }
.btn:hover { opacity: .88; }

/* ---------- 結果 ---------- */
.sheet { text-align: center; padding: 36px 0 24px; border-bottom: 3px double var(--rule); }
.sheet .label { font-size: .8rem; letter-spacing: .15em; color: var(--ink-2); }
.stamp {
  display: inline-grid; place-items: center; margin: 18px 0 10px;
  width: 132px; height: 132px; border: 3px solid var(--shu); border-radius: 50%;
  color: var(--shu); transform: rotate(-8deg);
  font-family: var(--mincho); font-weight: 700;
}
.stamp .pts { font-size: 2.6rem; line-height: 1; }
.stamp .of { font-size: 1rem; margin-left: 2px; }
.sheet .msg { font-family: var(--mincho); font-weight: 700; font-size: 1.1rem; }
.sheet .gain { font-size: .85rem; color: var(--ink-2); margin-top: 4px; }
.levelup { margin-top: 14px; font-family: var(--mincho); font-weight: 700; color: var(--shu); }

.miss-list { list-style: none; padding: 0; margin: 0; }
.miss-list li { padding: 12px 2px; border-bottom: 1px dashed var(--rule); font-size: .92rem; }
.miss-list .w { font-family: var(--mincho); font-weight: 700; margin-right: 6px; }
.miss-list .ans { display: block; color: var(--shu); font-weight: 700; }

/* ---------- 報告 ---------- */
dialog {
  border: 1px solid var(--ink); border-radius: 4px; padding: 0;
  background: var(--paper); color: var(--ink); width: min(92vw, 440px);
}
dialog::backdrop { background: rgba(20, 18, 15, .45); }
.report-form { padding: 20px; display: grid; gap: 12px; }
.report-form h2 { margin: 0; font-family: var(--mincho); font-size: 1.1rem; letter-spacing: .08em; }
.report-form label { display: grid; gap: 4px; font-size: .88rem; }
.report-form select, .report-form textarea {
  font: inherit; padding: 8px; border-radius: 4px; border: 1px solid var(--rule);
  background: var(--paper-2); color: var(--ink);
}
.report-form .actions { margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--on-ink); padding: 10px 18px; border-radius: 4px;
  font-size: .88rem; z-index: 20; white-space: nowrap;
}

/* ---------- ふりがな ---------- */
/* 読みが漢字より長くても漢字の間が空かないよう、読みは左右にはみ出させる */
ruby { display: inline-block; position: relative; }
rt {
  position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, .55em); white-space: nowrap; line-height: 1;
  font-family: var(--gothic); font-weight: 400; font-size: .65em; letter-spacing: 0; color: var(--ink-2);
}
/* 言葉が読み仮名から始まるとき（四字熟語など）は、読みが左の余白にはみ出さないよう最初の読みを左にそろえる */
.question .word.ruby-first ruby:first-child rt { left: 0; transform: translate(0, .55em); }
.question .text, .choice, .miss-list li, .verdict .answer { line-height: 2.1; }

/* ---------- 完（全問正解の印） ---------- */
.done {
  display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; margin-inline: 6px; vertical-align: 1px;
  background: var(--shu); color: var(--paper); border-radius: 3px;
  font-family: var(--mincho); font-weight: 700; font-size: .78rem; line-height: 1;
}
/* 初めて付いた「完」は、上から押し付けるように出す */
.done.stamp-in { animation: done-stamp .45s cubic-bezier(.3, 1.4, .5, 1) .25s both; }
.done.stamp-in.hold { animation: none; opacity: 0; } /* 合計の数字が上がりきるまで待つ */
@keyframes done-stamp {
  0% { opacity: 0; transform: scale(2.6) rotate(-20deg); }
  70% { opacity: 1; transform: scale(.88) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
/* 結果画面：その範囲で初めて全問正解したときに押す大きなハンコ */
.sheet { position: relative; }
.hanko {
  position: absolute; top: 22px; right: 4px; display: grid; place-items: center;
  width: 76px; height: 76px; border: 4px solid var(--shu); border-radius: 10px;
  color: var(--shu); background: var(--shu-soft);
  font-family: var(--mincho); font-weight: 700; font-size: 2.7rem; line-height: 1;
  transform: rotate(-14deg); box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 4px var(--shu);
  animation: hanko-press .6s cubic-bezier(.25, 1.5, .5, 1) .5s both;
}
@keyframes hanko-press {
  0% { opacity: 0; transform: scale(3) rotate(-30deg); }
  55% { opacity: 1; transform: scale(.86) rotate(-12deg); }
  75% { transform: scale(1.06) rotate(-15deg); }
  100% { opacity: 1; transform: scale(1) rotate(-14deg); }
}
.hanko + .stamp { animation: sheet-thud .25s ease-out .82s both; }
@keyframes sheet-thud { 0% { translate: 0 0; } 40% { translate: 0 3px; } 100% { translate: 0 0; } }

/* ---------- テスト用（一般公開の前に削除する） ---------- */
.test-tools { margin-top: 40px; padding-top: 12px; border-top: 1px dashed var(--rule); }
.test-tools .label { font-size: .75rem; letter-spacing: .15em; color: var(--ink-2); }
.test-tools .actions { margin-top: 8px; flex-wrap: wrap; }
.test-tools .btn { font-size: .85rem; padding: 10px 12px; letter-spacing: 0; }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------- 続きあり ---------- */
.resume-tag {
  display: inline-block; margin-left: 8px; padding: 0 6px; vertical-align: 2px;
  border: 1px solid var(--shu); border-radius: 3px; color: var(--shu);
  font-family: var(--gothic); font-weight: 700; font-size: .7rem; letter-spacing: .05em; line-height: 1.6;
}

/* ---------- 問題数を選ぶ ---------- */
.setup { padding: 28px 0 8px; border-top: 1px solid var(--ink); display: grid; gap: 16px; }
.setup-label { font-size: .8rem; letter-spacing: .15em; color: var(--ink-2); text-align: center; }
.setup-count { text-align: center; font-family: var(--mincho); font-weight: 700; font-size: 3.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.setup-count small { font-size: 1rem; margin-left: 4px; }
.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; }
.preset {
  padding: 10px 4px; cursor: pointer; font-weight: 700;
  background: transparent; border: 1px solid var(--rule); border-radius: 4px;
}
.preset:hover { border-color: var(--ink-2); }
.preset[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.slider-row { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 10px; }
.step {
  width: 44px; height: 44px; cursor: pointer;
  background: transparent; border: 1px solid var(--ink); border-radius: 50%;
  font-size: 1.3rem; font-weight: 700; line-height: 1;
}
.step:disabled { opacity: .3; cursor: default; }
input[type="range"] { width: 100%; min-width: 0; accent-color: var(--shu); }
.range-ends { display: flex; justify-content: space-between; padding-inline: 54px; margin-top: -10px; font-size: .78rem; color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .done.stamp-in, .hanko, .hanko + .stamp, .ach-gain, .ach-gain .medal { animation: none; }
}

/* 報告・目安箱が送れなかったときの知らせ（ダイアログの中に出す） */
.send-error { margin: 0; font-size: .82rem; color: var(--shu); }
.send-error[hidden] { display: none; }

/* ---------- このアプリについて ---------- */
.about-link { margin: 28px 0 0; text-align: center; }
.about-link button, .about-link a { border: 0; background: none; color: var(--ink-2); font: inherit; font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 8px; display: inline-block; }
.about { padding-bottom: 32px; }
.about section { padding: 16px 0; border-bottom: 1px solid var(--rule); }
.about h2 { margin: 0 0 8px; font-family: var(--mincho); font-size: 1.1rem; letter-spacing: .06em; }
.about h3 { margin: 14px 0 4px; font-size: .9rem; }
.about p, .about li { font-size: .9rem; line-height: 1.8; }
.about p { margin: 6px 0; }
.about ul { margin: 4px 0; padding-left: 1.3em; }
.about a { color: var(--ai); overflow-wrap: anywhere; }

/* 広告（結果画面のボタンの下と、ホームの目次の下） */
.ad { margin: 28px 0 0; min-height: 100px; }
.ad-label { display: block; font-size: .68rem; letter-spacing: .15em; color: var(--ink-2); margin-bottom: 4px; }

/* プライバシーポリシー（privacy.html） */
.policy { max-width: 640px; margin: 0 auto; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
.policy h1 { font-family: var(--mincho); font-size: 1.35rem; letter-spacing: .08em; margin: 24px 0 8px; }
.policy .date { font-size: .8rem; color: var(--ink-2); margin: 0 0 8px; }
