/* そろばん たしかめボード / Soroban Check Board：見た目（シリーズの決まり：生成りの方眼紙 #FBF5E8・こげ茶の線 #3A2621・
   オレンジ #E0663B は「いまのけたのわく・まとまりで動く玉・筆算の□とけたのつながり・見直すけたの印」だけ・玉は1色（位置で数を表す）・M PLUS Rounded 1c） */
@font-face { font-family: "MPR"; src: url("assets/fonts/mpr-bold.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "MPR"; src: url("assets/fonts/mpr-xbold.woff2") format("woff2"); font-weight: 800 900; font-display: swap; }
:root {
  --bg: #FBF5E8; --line: #3A2621; --accent: #E0663B; --accent-ink: #B4431D; --text: #3D3836; --card: #FFFDF8; --muted: #6F645D;
  --wood: #D7B48A; --board: #FFF9EE; --beam: #EAD6B2; --bead: #BE8A5A; --rod: #8C6B4F; --soft: #FCE3D6; --paper: #F1E6D6;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: "MPR", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif; font-weight: 700; color: var(--text); background-color: var(--bg); min-height: 100vh;
  background-image: linear-gradient(rgba(58,38,33,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(58,38,33,.05) 1px, transparent 1px);
  background-size: 24px 24px; font-size: 16px; line-height: 1.6; overflow-x: hidden; }
button { font: inherit; color: var(--line); cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
ruby rt { font-size: 50%; font-weight: 700; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.app.wait { visibility: hidden; }
.app { max-width: 460px; margin: 0 auto; padding: 10px 12px 28px; }
[hidden] { display: none !important; }

/* ---- 上の札 */
.top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tr { display: flex; gap: 8px; margin-left: auto; }
.pill { border: 2.5px solid var(--line); border-radius: 20px; padding: 2px 10px; background: #fff; white-space: nowrap; font-weight: 800; font-size: 14px; color: var(--line); line-height: 1.7; }
.tbtn { min-width: 48px; height: 48px; border: 2.5px solid var(--line); border-radius: 14px; background: #fff; font-weight: 800; font-size: 16px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; }
.tbtn.sound { padding: 0; width: 48px; }
.tbtn svg { width: 22px; height: 22px; }
.tbtn.sound .cross { display: none; }
.tbtn.sound[aria-pressed="false"] .cross { display: inline; }
.tbtn.sound[aria-pressed="false"] { color: var(--muted); }
.storage-note { margin-top: 8px; font-size: 14px; color: var(--muted); }

/* ---- 課題の道すじ（6つの丸） */
.tasks { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.tasks button { width: 46px; height: 46px; border-radius: 50%; border: 2.5px solid var(--line); background: #fff; font-weight: 800; font-size: 17px; }
.tasks button.cur { box-shadow: 0 0 0 4px rgba(58,38,33,.18); background: var(--card); }
.tasks button.done { background: var(--line); color: #fff; }

/* ---- 問題の札 */
.q { margin-top: 10px; background: var(--card); border: 3px solid var(--line); border-radius: 16px; padding: 6px 12px 8px; }
.q .exrow { display: flex; align-items: center; justify-content: center; gap: 10px; }
.q .ex { font-size: 30px; font-weight: 800; color: var(--line); white-space: nowrap; line-height: 1.35; }
.q .ex.small { font-size: 22px; white-space: normal; }
.q .ins { font-size: 16px; color: var(--line); line-height: 1.7; }
.q .story { font-size: 16px; color: var(--line); line-height: 1.7; }
.q .insrow { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.q .insrow .ins { flex: 1; }
.listen { min-height: 44px; min-width: 72px; border: 2.5px solid var(--line); border-radius: 22px; background: #fff; font-weight: 800; font-size: 14px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex: none; }
.listen svg { width: 18px; height: 18px; }

/* ---- そろばん */
.over-wrap, .zoom-wrap { display: flex; justify-content: center; margin-top: 10px; }
.soro { display: block; max-width: 100%; height: auto; }
.soro text { font-family: "MPR", sans-serif; font-weight: 800; }
.soro .bead { transition: transform .18s ease-out; }
.soro .bead path { fill: var(--bead); stroke: var(--line); }
.soro .bead.glow path { stroke: var(--accent); stroke-width: 5px; }
.soro .bead .hit { fill: transparent; }
.soro.hit .bead { cursor: pointer; }
.soro .focusr { fill: none; stroke: var(--accent); stroke-width: 3; }
.soro .markr { fill: rgba(224,102,59,.10); stroke: var(--accent); stroke-width: 3; stroke-dasharray: 6 5; }
.soro .glowr { fill: rgba(224,102,59,.12); stroke: var(--accent); stroke-width: 3.5; animation: glowr 1.2s ease-out 2; }
@keyframes glowr { 0% { stroke-opacity: .2; } 40% { stroke-opacity: 1; } 100% { stroke-opacity: 1; } }
.over { cursor: default; }
.zoom-wrap svg { border-radius: 12px; }
.zoom-wrap.flash svg { animation: fl 1.2s ease-out 1; }
@keyframes fl { 0% { box-shadow: 0 0 0 0 rgba(224,102,59,0); } 30% { box-shadow: 0 0 0 8px rgba(224,102,59,.55); } 100% { box-shadow: 0 0 0 0 rgba(224,102,59,0); } }
.zoom-wrap.lock .bead { cursor: default; }
@media (prefers-reduced-motion: reduce) { .soro .bead { transition: none; } .zoom-wrap.flash svg, .soro .glowr { animation: none; } }
.banner { margin-top: 10px; padding: 6px 12px; border-radius: 14px; background: #fff; border: 3px solid var(--line); font-weight: 800; font-size: 18px; color: var(--line); line-height: 1.6; }
.banner b { font-size: 24px; }
.predq { font-size: 16px; font-weight: 800; color: var(--line); text-align: center; margin-top: 10px; }
.pred { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.pred button { font-weight: 800; font-size: 17px; min-height: 48px; border: 2.5px solid var(--line); border-radius: 12px; background: #fff; text-align: left; padding: 4px 14px; }
.pred.wait button { animation: pglow 1.8s ease-in-out infinite; }
@keyframes pglow { 0%,100% { box-shadow: 0 0 0 0 rgba(224,102,59,0); } 50% { box-shadow: 0 0 0 3px rgba(224,102,59,.3); } }

/* ---- ボタン（画面の下半分・高さ48px 以上） */
.btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.btns:empty { display: none; }
.btns button { min-height: 48px; font-weight: 800; background: #fff; border: 2.5px solid var(--line); border-radius: 14px; font-size: 16px; line-height: 1.3; padding: 2px 4px; }
.btns button.main { grid-column: 1 / -1; background: var(--line); color: #fff; min-height: 54px; font-size: 20px; }
.btns button.wide, .btns button.restart, .btns #b-komattara { grid-column: 1 / -1; }
.btns button.plus { min-height: 54px; font-size: 20px; border-color: var(--line); }
.btns button.restart { min-height: 44px; font-size: 14px; border-style: dashed; background: rgba(255,255,255,.5); }
.btns button:disabled { opacity: .4; }
.btn { min-height: 48px; font-weight: 800; background: #fff; border: 2.5px solid var(--line); border-radius: 12px; font-size: 16px; padding: 4px 12px; line-height: 1.35; }
.btn.main { background: var(--line); color: #fff; }
.btn.wide { width: 100%; margin-top: 10px; display: block; }
.btn:disabled { opacity: .5; }
.foot { margin-top: 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.foot button { min-height: 52px; font-weight: 800; font-size: 15px; line-height: 1.3; border: 2px dashed var(--line); border-radius: 12px; background: rgba(255,255,255,.5); padding: 2px 4px; }
.foot button.on { border-style: solid; background: #fff; }

/* ---- 案内（×は出さない。オレンジのふちの札） */
.msg { margin-top: 10px; }
.msg:empty { display: none; }
.box { border: 3px solid var(--line); border-radius: 14px; background: #fff; padding: 8px 12px; font-size: 16px; line-height: 1.75; color: var(--line); margin-top: 8px; }
.box:first-child { margin-top: 0; }
.box.guide { border-color: var(--accent); }
.box ol { padding-left: 1.4em; }
.box .hhead { font-size: 14px; color: var(--muted); }
.box .btn { margin-top: 8px; }
.cardsbtn { min-height: 44px; font-size: 14px; margin-top: 8px; }
.pcards { margin-top: 8px; display: grid; gap: 6px; }
.pcards div { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 16px; }
.pcards b { font-size: 14px; color: var(--muted); min-width: 5.5em; }
.pcards span { border: 2px solid var(--line); border-radius: 8px; padding: 0 8px; background: var(--card); }

/* ---- 記録の札（罫線の紙） */
.rec, .note { margin-top: 10px; border: 3px solid var(--line); border-radius: 14px; background: #fff; padding: 6px 10px 6px 18px; position: relative;
  background-image: repeating-linear-gradient(transparent 0 37px, rgba(80,120,170,.18) 37px 39px); }
.rec::before, .note::before { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; border-left: 2px solid #E9B7A3; }
.rec h2, .note .head { font-size: 14px; color: var(--muted); }
.rrow, .nrow { display: flex; align-items: center; gap: 8px; min-height: 39px; font-size: 16px; color: var(--line); line-height: 1.4; padding: 2px 0; }
.rrow .pl, .nrow .pl { width: 3.2em; font-weight: 800; flex: none; }
html[lang=en] .rrow .pl, html[lang=en] .nrow .pl { width: 6.2em; font-size: 14px; overflow-wrap: anywhere; }
.rrow .dd, .nrow .dd { background: var(--paper); border-radius: 8px; padding: 0 6px; color: var(--muted); font-size: 14px; flex: none; }
.rrow.hl, .nrow.hl { outline: 3px solid var(--accent); border-radius: 8px; }
.nrow.pick { width: 100%; text-align: left; border: 2px dashed var(--line); border-radius: 10px; background: rgba(255,255,255,.7); min-height: 48px; margin-top: 6px; padding: 2px 8px; font-weight: 700; }
.note .nex { font-size: 22px; font-weight: 800; color: var(--line); }
.small { font-size: 14px; color: var(--muted); }

/* ---- 筆算でたしかめる（けたの真下にそろえる） */
.colcard { margin-top: 10px; border: 3px solid var(--line); border-radius: 14px; background: #fff; padding: 8px 6px 12px; }
.colcard > .box { margin: 0 6px 8px; }
.colwrap { width: fit-content; margin: 8px auto 0; }
.colsb { margin-left: 26px; }
.cgrid { display: grid; grid-template-columns: 24px repeat(var(--n), var(--cw)); column-gap: 8px; row-gap: 4px; align-items: center; justify-items: center; margin-top: 6px; font-size: 26px; font-weight: 800; color: var(--line); }
.cgrid .sg { font-size: 26px; width: 24px; text-align: center; }
.cgrid .d { height: 40px; line-height: 40px; position: relative; width: var(--cw); text-align: center; }
.cgrid .d.struck::after { content: ""; position: absolute; left: 20%; right: 20%; top: 50%; border-top: 3px solid var(--line); transform: rotate(-35deg); }
.cgrid .pt::before { content: "."; position: absolute; right: -9px; bottom: 2px; font-size: 26px; line-height: 1; color: var(--line); }
.cgrid .bar { grid-column: 1 / -1; width: 100%; border-top: 4px solid var(--line); height: 0; }
.cgrid .cin { position: relative; width: var(--cw); height: 50px; border: 2px dashed rgba(58,38,33,.5); border-radius: 8px; background: #fff; font-size: 26px; font-weight: 800; padding: 0; }
.cgrid .cin.sel { border: 3px solid var(--line); box-shadow: 0 0 0 3px rgba(58,38,33,.15); }
.cgrid .cin.bad { border: 3.5px solid var(--accent); }
.cgrid .cin.fix { border: 2px solid transparent; opacity: 1; }
.cgrid .cy { width: var(--cw); height: 44px; border: 0; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; }
.cgrid .cy span { width: 28px; height: 28px; border: 2px dashed rgba(58,38,33,.45); border-radius: 6px; background: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.cgrid .cy.on span { border: 2px solid var(--line); }
.cgrid .cy.glow span { border: 3px solid var(--accent); background: var(--soft); animation: cyglow 1.2s ease-out 2; }
.cgrid .cy:disabled { opacity: 1; }
@keyframes cyglow { 0% { box-shadow: 0 0 0 0 rgba(224,102,59,.0); } 40% { box-shadow: 0 0 0 6px rgba(224,102,59,.45); } 100% { box-shadow: 0 0 0 0 rgba(224,102,59,0); } }
.tip { margin-top: 6px; text-align: center; }
.entry { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.entry .val { flex: 1; min-height: 54px; border: 3px solid var(--line); border-radius: 12px; background: #fff; font-size: 28px; font-weight: 800; display: flex; align-items: center; padding: 0 12px; letter-spacing: .05em; color: var(--line); }
.entry .val.idle { border-style: dashed; }
.entry .main { min-height: 54px; min-width: 104px; border: 2.5px solid var(--line); border-radius: 12px; background: var(--line); color: #fff; font-weight: 800; font-size: 18px; padding: 0 10px; }
.keys { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.keys button { min-height: 52px; font-size: 22px; font-weight: 800; border: 2.5px solid var(--line); border-radius: 12px; background: #fff; }
.keys button.del { font-size: 15px; }

/* ---- 課題5 */
.lead { margin-top: 10px; font-size: 16px; color: var(--line); }
.cloze { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.cloze .c { background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 8px 12px; line-height: 1.85; font-size: 16px; }
.cloze .c.cur { border-color: var(--accent); }
.cloze .cid { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--line); color: #fff; align-items: center; justify-content: center; font-size: 14px; }
.cloze .slot { display: inline-block; min-width: 56px; border-bottom: 3px solid var(--line); text-align: center; color: var(--line); font-weight: 800; padding: 0 4px; }
.cloze .c.cur .slot { border-bottom-color: var(--accent); }
.guide-inline { margin-top: 6px; color: var(--line); border-left: 4px solid var(--accent); padding-left: 8px; }
.choices { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.choices button { flex: 1 1 0; min-width: 72px; min-height: 48px; font-weight: 800; font-size: 16px; border: 2.5px solid var(--line); border-radius: 12px; background: #fff; padding: 4px 8px; line-height: 1.4; }
.choices.col { flex-direction: column; }
.choices.col button { text-align: left; padding: 6px 12px; }
.card { margin-top: 10px; background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 8px 12px; font-size: 16px; line-height: 1.75; }
.card h2, .card h3 { font-size: 16px; color: var(--line); }
.card.after { background: var(--card); }
textarea { width: 100%; font-family: system-ui, sans-serif; font-size: 16px; border: 2.5px solid var(--line); border-radius: 12px; padding: 8px; min-height: 104px; margin-top: 8px; background: #fff; color: var(--text); }
.fb h4 { font-size: 14px; color: var(--muted); margin-top: 10px; }
.checks label { display: flex; align-items: center; gap: 10px; min-height: 48px; font-size: 16px; }
.checks input { width: 28px; height: 28px; accent-color: var(--line); flex: none; }
.model { margin-top: 6px; padding: 6px 10px; border-left: 4px solid var(--wood); background: var(--card); font-size: 16px; line-height: 1.75; }

/* ---- 課題6 */
.tabs { display: flex; gap: 8px; margin-top: 10px; }
.tabs button { flex: 1; min-height: 48px; font-weight: 800; border: 2.5px solid var(--line); border-radius: 12px 12px 4px 4px; background: #fff; font-size: 16px; }
.tabs button.cur { background: var(--card); box-shadow: inset 0 -4px 0 var(--line); }
.tabs button.done::after { content: " ✓"; }
.steps5 { list-style: none; margin-top: 10px; display: grid; gap: 4px; }
.steps5 li { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--muted); }
.steps5 li span { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex: none; background: #fff; }
.steps5 li em { font-style: normal; }
.steps5 li.cur { color: var(--line); font-weight: 800; }
.steps5 li.cur span { border-color: var(--line); background: var(--line); color: #fff; }
.steps5 li.done span { border-color: var(--line); background: var(--wood); color: var(--line); }
.cmp { display: grid; gap: 8px; margin-top: 10px; background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.cmprow { display: flex; align-items: center; gap: 8px; }
.cmprow .lab { width: 4.2em; font-size: 14px; color: var(--muted); flex: none; }
.cmprow .ds { display: flex; gap: 8px; }
.cmprow .dg { width: 44px; height: 48px; border: 2.5px solid var(--line); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800; background: #fff; color: var(--line); padding: 0; }
.cmprow b.dg.diff { border-color: var(--accent); border-width: 3.5px; }
.card.why { background: var(--card); }

/* ---- もう1問・なぞ */
.vh { font-size: 18px; color: var(--line); }
.lvbtns, .ops { display: flex; gap: 8px; margin-top: 8px; }
.lvbtns button, .ops button { flex: 1; min-height: 48px; font-weight: 800; border: 2.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px; padding: 2px 4px; }
.lvbtns button.on, .ops button.on { background: var(--line); color: #fff; }
.mh { font-size: 14px; color: var(--muted); margin-top: 10px; }
.dials { display: flex; gap: 8px; justify-content: center; margin-top: 4px; }
.dial { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 56px; }
.dial button { width: 56px; height: 44px; border: 2.5px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px; }
.dial .dv { font-size: 28px; font-weight: 800; color: var(--line); line-height: 1.2; }
.dial .dl { font-size: 14px; color: var(--muted); }
html[lang=en] .dial .dl { font-size: 14px; text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
.make .pex, .pcard .pex { font-size: 28px; font-weight: 800; color: var(--line); text-align: center; margin-top: 8px; }
.trap { display: flex; align-items: center; gap: 10px; min-height: 48px; font-size: 16px; margin-top: 4px; }
.trap input { width: 28px; height: 28px; accent-color: var(--line); }
.pcard { margin-top: 10px; background: var(--card); border: 3px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.pcard p { margin-top: 4px; }
.pcard .acts { display: flex; gap: 8px; margin-top: 8px; }
.pcard .acts .btn { flex: 1; }
.small-note { padding-top: 0; }
.nextcard h2 { font-size: 16px; }

/* ---- 重ねて出す画面（ノート・地図・6つおわった時） */
.overlay { position: fixed; inset: 0; background: rgba(58,38,33,.35); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 12px; z-index: 10; }
.sheet { background: var(--bg); border: 3px solid var(--line); border-radius: 18px; padding: 12px 14px 18px; width: 100%; max-width: 640px; margin: auto 0; position: relative; }
.sheet h2 { font-size: 20px; font-weight: 800; color: var(--line); padding-right: 96px; line-height: 1.5; min-height: 44px; }
.sheet h3 { font-size: 16px; font-weight: 800; color: var(--line); margin-top: 14px; }
.sheet .close { position: absolute; right: 10px; top: 10px; min-height: 48px; min-width: 76px; border: 2.5px solid var(--line); border-radius: 24px; background: #fff; font-weight: 800; font-size: 16px; padding: 0 12px; }
.mark6 { display: inline-block; margin-left: 8px; font-size: 14px; border: 2.5px solid var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 0 8px; transform: rotate(-4deg); }
.stamps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.stampbox { width: 100px; background: #fff; border: 2.5px solid var(--line); border-radius: 10px; padding: 6px 4px 4px; text-align: center; font-size: 14px; line-height: 1.4; }
.stampbox svg { width: 88px; height: auto; display: block; margin: 0 auto 2px; }
.stampbox.new { animation: pop .45s cubic-bezier(.3,1.6,.6,1) both; }
@keyframes pop { from { transform: scale(.3) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.saved-card .pcard { margin-top: 8px; }
.mapgrid { width: 100%; border-collapse: separate; border-spacing: 4px; margin-top: 8px; font-size: 14px; }
.mapgrid th { font-size: 14px; color: var(--line); }
.mapgrid td { vertical-align: top; }
.ep { background: #fff; border: 2px solid var(--line); border-radius: 8px; padding: 4px 6px; margin-bottom: 4px; font-size: 14px; line-height: 1.5; }
.ep.cur { border-color: var(--accent); border-width: 3px; }
.ep .lvf { color: var(--muted); font-size: 14px; }
.maplist { display: none; }
.maplist .mg { margin-top: 10px; }
.maplist .none { color: var(--muted); }
@media (max-width: 640px) { .mapwrap { display: none; } .maplist { display: block; } }

/* ---- 広い画面：そろばんを左、ボタン・記録・筆算を右に */
@media (min-width: 860px) {
  .app { max-width: 1040px; padding: 16px 24px 32px; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .col-b { position: sticky; top: 12px; }
  .over-wrap svg { zoom: 1.25; }
  .zoom-wrap svg { zoom: 1.3; }
}
