/* さわってそろばん / Tap Soroban：見た目（シリーズの決まり：生成りの方眼紙 #FBF5E8・こげ茶の線 #3A2621・オレンジ #E0663B は「いま・注意」だけ・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: #B9461F; --text: #3D3836; --card: #FFFDF8; --muted: #6F645D;
  --wood: #E9D2A8; --wood2: #D8B98A; --bead: #C98C55; --beadhi: #E2B07E; --rod: #8C6A4F; --soft: #FCE3D6;
}
* { 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; }
button { font: inherit; color: var(--line); cursor: pointer; touch-action: manipulation; }
button:focus-visible, textarea:focus-visible, a: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 24px; }

/* ---- 上の札 */
.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: 44px; height: 44px; border: 2.5px solid var(--line); border-radius: 22px; background: #fff; font-weight: 800; font-size: 16px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; }
.tbtn.sound { padding: 0; width: 44px; }
.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); }

/* ---- 課題の丸 */
.tasks { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.tasks button { width: 44px; height: 44px; border-radius: 50%; border: 2.5px solid var(--line); background: #fff; font-weight: 800; font-size: 17px; }
.tasks button.cur { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(224,102,59,.3); }
.tasks button.done { background: var(--wood); }

/* ---- 問題の札 */
.q { margin-top: 10px; background: var(--card); border: 3px solid var(--line); border-radius: 16px; padding: 8px 12px 10px; text-align: center; position: relative; }
.q .exrow { display: flex; align-items: center; justify-content: center; gap: 8px; }
.q .ex { font-size: 32px; font-weight: 800; color: var(--line); white-space: nowrap; line-height: 1.3; }
.q .ex.small { font-size: 22px; white-space: normal; }
.q .ins { font-size: 16px; color: var(--line); margin-top: 4px; line-height: 1.7; }
.q .lab { font-size: 14px; color: var(--muted); }
.listen { min-height: 44px; min-width: 64px; 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; gap: 4px; flex: none; }
.listen svg { width: 18px; height: 18px; }
.q .insrow { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.q .insrow .ins { flex: 1; margin-top: 0; }

/* ---- 予想 */
.predq { font-size: 14px; font-weight: 800; color: var(--accent-ink); text-align: center; margin-top: 8px; }
.pred { display: flex; gap: 8px; margin-top: 6px; }
.pred button { flex: 1; font-weight: 800; font-size: 17px; min-height: 48px; border: 2.5px solid var(--line); border-radius: 12px; background: #fff; }
.pred button.sel { border-color: var(--accent); background: var(--soft); }
.pred.wait button { animation: glow 1.6s ease-in-out infinite; }
.pred.ping button { box-shadow: 0 0 0 5px rgba(224,102,59,.45); }
@keyframes glow { 0%,100% { border-color: var(--line); } 50% { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224,102,59,.25); } }

/* ---- そろばん */
.sb { margin-top: 10px; position: relative; }
.sb[hidden] { display: none; }
.sb svg#svg { display: block; width: 100%; height: auto; touch-action: manipulation; border-radius: 14px; }
.sb .bead, .sb .rodhit { cursor: pointer; }
.sb.lock .bead { cursor: default; }
.sb.pick .rodhit:hover { fill: rgba(224,102,59,.12); }
.sb.tapme svg#svg { animation: tapme 1.6s ease-in-out infinite; }
@keyframes tapme { 0%,100% { box-shadow: 0 0 0 0 rgba(224,102,59,0); } 50% { box-shadow: 0 0 0 6px rgba(224,102,59,.4); } }
.places { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding: 0 3.4%; margin-bottom: 4px; text-align: center; color: var(--line); }
.places .chip { justify-self: center; display: inline-block; background: #fff; border: 1.5px solid var(--line); border-radius: 6px; padding: 0 2px; font-size: 14px; line-height: 1.15; font-weight: 800; white-space: nowrap; }
.places .chip .l2 { display: block; font-size: 14px; }
.places .chip ruby rt { font-size: 55%; }
.places.en { grid-template-rows: auto auto; row-gap: 2px; }
.places.en .chip { padding: 1px 4px; }
.places.en .chip.lo { grid-row: 2; }
.places.en .chip.hi { grid-row: 1; }
.places .chip.glow { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(224,102,59,.35); }
.digits { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding: 0 3.4%; margin-top: 4px; }
.digits div { height: 42px; display: flex; align-items: center; justify-content: center; }
.digits span { display: inline-flex; width: 38px; height: 40px; align-items: center; justify-content: center; background: #fff; border: 2.5px solid var(--line); border-radius: 9px; font-weight: 800; font-size: 25px; color: #2E2A28; }
.digits span.flash { animation: fl .55s ease-out; }
.digits span.bad { border-color: var(--accent); border-width: 3.5px; }
.digits span.link { border-style: dashed; border-color: var(--accent); }
.digits span.hide { color: transparent; background: repeating-linear-gradient(45deg, #fff 0 6px, #F1E6D6 6px 12px); }
@keyframes fl { from { background: var(--soft); } to { background: #fff; } }
.links { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

/* ---- 案内・ボタン */
.msg { margin-top: 10px; background: #fff; border: 2.5px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 16px; min-height: 52px; line-height: 1.75; }
.msg:empty { visibility: hidden; }
.msg.hint { border-color: var(--accent); }
.msg .want { display: inline-block; margin-top: 2px; font-size: 16px; }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row:empty { display: none; }
.row button { flex: 1; min-width: 0; font-weight: 800; background: #fff; border: 2.5px solid var(--line); border-radius: 12px; min-height: 52px; font-size: 15px; letter-spacing: -.04em; line-height: 1.3; padding: 2px 2px; }
.row button#reset { flex: 1.05; }
.row button#hint { flex: 1; }
.row button.main { flex: 1.2; line-height: 1.55; padding-top: 4px; }
.row button.main { background: var(--line); color: #fff; }
.row button.main ruby rt { color: #fff; }
.row button:disabled { opacity: .4; cursor: default; }
.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; }
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--line); }
.foot { margin-top: 14px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .foot { grid-template-columns: repeat(4, 1fr); } }
.foot button { min-height: 52px; font-weight: 800; font-size: 14px; line-height: 1.3; border: 2px dashed var(--line); border-radius: 12px; background: rgba(255,255,255,.4); padding: 2px 4px; }
.foot button.on { border-style: solid; background: #fff; }

/* ---- 札・カード */
.card { margin-top: 10px; background: #fff; border: 2.5px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 16px; line-height: 1.75; }
.card.rule { text-align: center; font-weight: 800; font-size: 18px; background: var(--card); border-width: 3px; }
.card.stamp { text-align: center; font-weight: 800; background: var(--card); display: flex; align-items: center; justify-content: center; gap: 10px; }
.card.stamp svg { width: 64px; flex: none; }
.choices { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.choices button { flex: 1 1 0; min-width: 64px; min-height: 48px; font-weight: 800; font-size: 16px; border: 2.5px solid var(--line); border-radius: 10px; background: #fff; padding: 4px 8px; line-height: 1.4; }
.choices.col { flex-direction: column; }
.choices.col button { text-align: left; padding: 6px 12px; }
.small { font-size: 14px; color: var(--muted); }

/* 課題5 */
.cloze { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.cloze .c { background: #fff; border: 2.5px solid var(--line); border-radius: 12px; padding: 8px 12px; line-height: 1.8; }
.cloze .c.cur { border-color: var(--accent); }
.cloze .slot { display: inline-block; min-width: 48px; 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); }
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: 96px; margin-top: 8px; background: #fff; color: var(--text); }
.checks label { display: flex; align-items: center; gap: 10px; min-height: 48px; font-size: 16px; }
.checks input { width: 26px; height: 26px; accent-color: var(--line); flex: none; }
.model { margin-top: 6px; padding: 6px 10px; border-left: 4px solid var(--wood2); 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 { border-color: var(--accent); background: var(--card); }
.tabs button.done::after { content: " ✓"; }
.note { margin-top: 8px; border: 2.5px solid var(--line); border-radius: 10px; padding: 6px 12px 6px 18px; font-size: 18px; line-height: 28px;
  background-color: #fff; background-image: repeating-linear-gradient(#fff 0 27px, #D9CFC4 27px 28px); position: relative; }
.note::before { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; border-left: 2px solid #E9B7A3; }
.note .head { font-size: 14px; color: var(--muted); }
.steps4 { display: flex; gap: 6px; margin-top: 8px; justify-content: center; }
.steps4 span { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; background: #fff; }
.steps4 span.cur { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224,102,59,.3); }
.steps4 span.done { background: var(--wood); }
.cmp { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; margin-top: 6px; }
.cmp .ds { display: flex; gap: 4px; }
.cmp .ds b { width: 30px; height: 34px; border: 2px solid var(--line); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; background: #fff; }
.cmp .ds b.diff { border-color: var(--accent); border-width: 3px; }

/* 数字キー・入れる所 */
.entry { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.entry .val { flex: 1; min-height: 52px; border: 2.5px solid var(--accent); border-radius: 12px; background: #fff; font-size: 26px; font-weight: 800; display: flex; align-items: center; padding: 0 12px; letter-spacing: .05em; color: var(--line); }
.entry .val.idle { border-color: var(--line); }
.keys { display: grid; grid-template-columns: repeat(6, 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: 10px; background: #fff; }
.keys button.del { font-size: 14px; }
.ops { display: flex; gap: 8px; margin-top: 10px; }
.ops button { flex: 1; min-height: 48px; font-weight: 800; border: 2.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px; }
.ops button.on { border-color: var(--accent); background: var(--soft); }

/* 課題4 筆算 */
.col { margin: 10px auto 0; display: grid; grid-template-columns: repeat(4, 52px); justify-content: center; row-gap: 4px; column-gap: 8px; font-size: 26px; font-weight: 800; color: var(--line); text-align: center; }
.col .d { height: 40px; line-height: 40px; }
.col .bar { grid-column: 1 / -1; border-top: 3px solid var(--line); height: 0; }
.col button { width: 52px; height: 48px; border: 2.5px solid var(--line); border-radius: 8px; background: #fff; font-size: 26px; font-weight: 800; padding: 0; }
.col button.c { font-size: 16px; height: 44px; border-style: dashed; color: var(--line); background: transparent; display: flex; align-items: center; justify-content: center; }
.col button.c span { width: 30px; height: 30px; border: 2px solid var(--line); border-radius: 6px; background: #fff; display: inline-flex; align-items: center; justify-content: center; }
.col button.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224,102,59,.3); }
.col button.bad { border-color: var(--accent); border-width: 3.5px; }
.col button.c.done, .col button.c.sel { border-color: var(--accent); }

/* もう1問・なぞ */
.lvbtns { display: flex; gap: 8px; margin-top: 10px; }
.lvbtns button { flex: 1; min-height: 48px; font-weight: 800; border: 2.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px; }
.lvbtns button.on { border-color: var(--accent); background: var(--soft); }
.pcard { margin-top: 10px; background: var(--card); border: 3px solid var(--line); border-radius: 14px; padding: 10px 12px; text-align: center; }
.pcard .pex { font-size: 28px; font-weight: 800; color: var(--line); }
.pcard ul { list-style: none; text-align: left; margin-top: 6px; }
.pcard li { padding-left: 1.2em; text-indent: -1.2em; font-size: 16px; }
.pcard li::before { content: "● "; color: var(--wood2); }
.pcard .acts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pcard .acts .btn { flex: 1 1 140px; }

/* ---- 重ねて出す画面 */
.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; }
.overlay[hidden] { display: none; }
.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; }
.sheet h3 { font-size: 16px; font-weight: 800; color: var(--line); margin-top: 14px; }
.sheet .close { position: absolute; right: 10px; top: 10px; min-height: 44px; min-width: 72px; border: 2.5px solid var(--line); border-radius: 22px; 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: 96px; background: #fff; border: 2.5px solid var(--line); border-radius: 10px; padding: 6px 4px 4px; text-align: center; font-size: 14px; }
.stampbox svg { width: 84px; 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 { margin-top: 8px; }
.saved-card .pcard { margin-top: 0; }
.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: 1120px; padding: 16px 24px 32px; }
  .layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .col-b { position: sticky; top: 12px; }
  .col-b #extra > :first-child, .col-b .msg { margin-top: 10px; }
  .places .chip, .places .chip .l2 { font-size: 16px; }
  .digits span { width: 48px; height: 48px; font-size: 30px; }
  .digits div { height: 52px; }
}
.sheet h2 { min-height: 44px; }
.sheet h2 + p, .sheet h2 + .stamps { margin-top: 10px; }
