/* 秋の落ち着いた配色（文字は地より十分に濃く） */
:root {
  --bg: #fbf3e6; --card: #fffdf8; --ink: #1a1410; --sub: #5e4a3a; --brown: #5c3a21; --accent: #8a4b2a;
  --gold: #8a5a00; --olive: #5b6b1f; --red: #b02a30; --line: #e6d5bc; --sand: #f8f0e3;
}
* { box-sizing: border-box; }
body { margin: 0; overflow-x: clip; background: var(--bg); color: var(--ink); font-family: -apple-system, "Hiragino Sans", "Noto Sans CJK JP", sans-serif;
  font-size: 20px; line-height: 1.7; -webkit-text-size-adjust: 100%; }
main { max-width: 1600px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 120px max(10px, env(safe-area-inset-left)); }
h1 { font-size: 28px; margin: 0; color: var(--accent); } h2 { font-size: 22px; color: var(--brown); margin: 6px 0 10px; }
a { color: var(--accent); }
.muted { color: var(--sub); } .small { font-size: 16px; } .err { color: var(--red); }

.top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.top.play { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; border-bottom: 2px solid var(--line); }
.prog { font-weight: 700; color: var(--brown); }
.timer { margin-left: auto; font-weight: 800; font-size: 24px; color: var(--olive); font-variant-numeric: tabular-nums; }
.timer.paused { color: var(--sub); opacity: .7; } .timer.over { color: var(--red); }

.card { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 20px 24px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; } .row.end { justify-content: flex-end; }
.menu { display: grid; gap: 12px; margin-bottom: 14px; } .menu.sub { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 8px 20px; border-radius: 12px;
  border: 2px solid var(--accent); background: var(--card); color: var(--accent); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn.main { background: var(--accent); color: #fff; } .btn.big { min-height: 64px; font-size: 22px; }
.btn.small { min-height: 40px; padding: 4px 14px; font-size: 16px; } .btn.on { background: var(--sand); }
.btn.danger { border-color: var(--red); color: var(--red); } .btn:disabled, .btn.off { opacity: .4; pointer-events: none; }

.stats4 { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 8px; }
.stats4 b { display: block; font-size: 30px; color: var(--accent); } .stats4 span { color: var(--sub); font-size: 16px; } .stats4 .ng { color: var(--red); }
.resume { border-color: var(--gold); background: #fff6e6; }

.step { display: inline-block; background: var(--brown); color: #fff; font-weight: 800; border-radius: 10px; padding: 2px 14px; margin-bottom: 10px; }
.en { font-size: 22px; line-height: 1.8; } .en.big { font-size: 26px; }
.blank { display: inline-block; min-width: 5em; border-bottom: 3px solid var(--accent); }
.mark { color: var(--red); font-weight: 800; }
.prompt { font-size: 21px; font-weight: 700; }
/* 選択肢は必ず縦に並べる */
.choices { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.choice { width: 100%; text-align: left; font: inherit; font-size: 22px; padding: 12px 18px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); cursor: pointer; }
.choice.correct { border-color: var(--olive); background: #eef3e2; } .choice.wrong { border-color: var(--red); background: #fbe9e6; }
.choice:disabled { color: var(--ink); }
.verdict { font-size: 22px; font-weight: 800; margin: 16px 0 6px; } .verdict.ok { color: var(--olive); } .verdict.ng { color: var(--red); }
.explain { background: var(--sand); border-left: 6px solid var(--gold); border-radius: 8px; padding: 10px 16px; margin: 8px 0; }
.hint { margin-top: 12px; color: var(--sub); } .hint summary { cursor: pointer; color: var(--gold); font-weight: 700; }

/* 解説シート：左右にめくる */
/* 解説シートは縦に並べて、上下のスクロールで読む */
/* 画面の横幅いっぱいに広げる（カードの余白を超えて、左右の端まで使う） */
.sheets { display: flex; flex-direction: column; gap: 14px; width: 100vw; margin-left: calc(50% - 50vw); padding: 0 4px; }
.sheets img { border-radius: 4px; }
.sheets figure { margin: 0; }
/* 解説シートの画面のボタンは、スクロールしても画面の下に残す */
.card .row.end.stick { position: sticky; bottom: 0; background: var(--card, #fff); padding: 12px 0 6px; border-top: 2px solid var(--line); z-index: 2; }
.sheets img { width: 100%; border: 2px solid var(--line); border-radius: 8px; background: #fff; }
.sheets figcaption { text-align: center; color: var(--sub); font-size: 16px; }
.zoom { position: fixed; inset: 0; z-index: 50; background: rgba(26, 20, 16, .92); overflow: hidden; touch-action: none; display: flex; align-items: center; justify-content: center; }
.zoom img { max-width: 100%; max-height: 100%; transform-origin: center; background: #fff; }
.zoom .close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; } .tabs a { padding: 6px 16px; border-radius: 10px; border: 2px solid var(--line); text-decoration: none; color: var(--sub); font-weight: 700; }
.tabs a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tbl { width: 100%; border-collapse: collapse; background: #fff; } .tbl th, .tbl td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.tbl th { background: var(--sand); color: var(--brown); }
.bar { position: relative; background: var(--sand); border-radius: 6px; height: 26px; min-width: 160px; } .bar i { position: absolute; inset: 0 auto 0 0; background: #c9d3a6; border-radius: 6px; }
.bar span { position: relative; padding-left: 8px; font-weight: 700; font-size: 16px; }
.form label { display: block; margin-bottom: 10px; font-weight: 700; color: var(--brown); }
.form input, .form textarea, .form select, #newth { display: block; width: 100%; font: inherit; font-weight: 400; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
#newth { width: auto; flex: 1; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; } .thumbs figure { margin: 0; width: 220px; } .thumbs img { width: 100%; border: 1px solid var(--line); }
.themes li { margin-bottom: 6px; }
.note .meta { font-weight: 700; color: var(--brown); } .noteimg { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pick { float: right; font-size: 16px; }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: var(--brown); color: #fff; padding: 10px 22px; border-radius: 12px; z-index: 60; }

/* 質問欄：縦向きは下半分、横向きは右半分 */
.notepanel { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: 52vh; background: var(--card); border-top: 4px solid var(--accent);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .15); display: flex; flex-direction: column; gap: 8px; padding: 10px 14px max(10px, env(safe-area-inset-bottom)); }
@media (orientation: landscape) { .notepanel { left: auto; top: 0; width: 48vw; height: 100vh; border-top: 0; border-left: 4px solid var(--accent); } }
.np-head { display: flex; gap: 12px; align-items: baseline; } .np-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tool { font: inherit; font-size: 15px; padding: 4px 10px; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.tool.on { border-color: var(--accent); background: var(--sand); font-weight: 700; }
.np-canvas { position: relative; flex: 1; min-height: 120px; border: 2px dashed var(--line); border-radius: 10px; background: #fff; }
.np-canvas canvas { position: absolute; inset: 0; touch-action: none; }
.np-hint { position: absolute; inset: auto 0 45% 0; text-align: center; color: #b3a48f; pointer-events: none; }
.notepanel textarea { font: inherit; font-size: 18px; padding: 6px 10px; border: 2px solid var(--line); border-radius: 10px; }
.np-btns { display: flex; justify-content: flex-end; gap: 10px; }
/* 質問欄を開いている間も、隠れた所までスクロールして見られるようにする */
body.np-open main { padding-bottom: 56vh; }
@media (orientation: landscape) { body.np-open main { margin-right: 48vw; padding-bottom: 120px; } }
.code { font-family: ui-monospace, Menlo, monospace !important; font-size: 15px !important; }

/* 区分・セットの選択 */
.seg { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.seg .btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.sel { display: block; width: 100%; font: inherit; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); min-height: 50px; }
.chk { display: flex; align-items: center; gap: 10px; margin-top: 12px; } .chk input { width: 24px; height: 24px; }

/* 金のフレーズ：金のルールの見出しと、実戦問題中の表示 */
.rulebox{background:#FFF6E5;border-left:8px solid #8A5A00;border-radius:10px;padding:10px 14px;margin:8px 0 12px;line-height:1.6}
.rulebox p{margin:0;font-weight:700}
.rulebox p.rulenote{margin-top:6px;padding-top:6px;border-top:2px dotted #E6D5BC;font-weight:500;color:#7A2E1F}
.rulebox b{display:inline-block;background:#8A5A00;color:#fff;border-radius:6px;padding:0 8px;margin-right:10px}
.prog .ex{display:inline-block;margin-left:10px;background:#8A5A00;color:#fff;border-radius:6px;padding:0 8px;font-size:.9em}

.tbl .ck { width: 52px; text-align: center; }
.tbl .ck input { width: 26px; height: 26px; }
.btn.danger:disabled { opacity: .45; }

.card { padding: 16px 18px; }
@media (max-width: 900px) { .card { padding: 14px 12px; } }
