/* 画面でとくドリル（/drill/）。スマホの たて画面で、問題と数字ボタンが1画面におさまるようにする */
.drill-app { max-width: 460px; margin: 16px auto 0; scroll-margin-top: 72px; }
.drill-app button { font: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; cursor: pointer; }
.drill-on .drill-intro, .drill-on .drill-about, .drill-on .site-footer, .drill-on .breadcrumb { display: none; }
/* といているあいだは、上のメニューを画面に固定しない（筆算は たてに長いので、その分を問題に使う） */
.drill-on .site-header { position: static; }
.drill-on .drill-app { scroll-margin-top: 8px; }
.drill-on main { min-height: calc(100vh + 80px); }   /* ページを画面より少し長くして、問題をいつでも画面のいちばん上まで送れるようにする */

/* ---------- はじめ ---------- */
.dr-start { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 24px 20px; text-align: center; }
.dr-ex { font-size: 2.4rem; font-weight: 900; margin: 0 0 16px; display: flex; justify-content: center; align-items: center; gap: 10px; }
.dr-ex span { width: 1.6em; height: 1.4em; border: 3px solid var(--blue); border-radius: 12px; background: var(--blue-soft); }
.dr-go { width: 100%; font-size: 1.3rem; padding: 16px 24px; }
.dr-rec { margin: 14px 0 0; color: var(--muted); font-size: .9rem; }
.dr-dans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.dr-dans button { padding: 8px 0; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); font-size: 1.4rem; font-weight: 900; }
.dr-dans button small { font-size: .7rem; margin-left: 2px; }
.dr-dans button[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); color: var(--accent-text); }
.dr-dans-all { margin: 0 0 16px; }
.dr-dans-all button { border: 0; background: none; color: var(--accent-text); font-weight: 700; text-decoration: underline; padding: 6px 12px; }

/* ---------- 問題 ---------- */
.dr-play { user-select: none; -webkit-user-select: none; }
.dr-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dr-quit { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--line); color: var(--ink-2); font-size: 1.3rem; line-height: 1; }
.dr-review { margin: 0; font-weight: 700; color: var(--accent-text); font-size: .9rem; }
.dr-prog { flex: 1; display: flex; gap: 5px; list-style: none; margin: 0; padding: 0; min-width: 120px; }
.dr-prog li { flex: 1; height: 10px; border-radius: 5px; background: var(--line); }
.dr-prog .now { background: var(--blue); }
.dr-prog .r-o { background: var(--green); }
.dr-prog .r-t { background: #f2c14e; }
.dr-prog .r-x { background: var(--red); }
.dr-q { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px 12px; min-height: 120px; padding: 12px 0 4px; font-size: clamp(2.4rem, 12vw, 3.4rem); font-weight: 900; line-height: 1.2; }
.dr-q.is-long { font-size: clamp(1.6rem, 7.5vw, 2.6rem); gap: 6px 8px; }
.is-long .dr-box { min-width: 1.5em; }
.dr-word { font-size: .5em; }
.dr-box { display: inline-grid; place-items: center; min-width: 2em; height: 1.45em; padding: 0 .15em; border: 3px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.dr-box.on { border-color: var(--blue); background: var(--blue-soft); }
.is-ok .dr-box { border-color: var(--green); color: var(--green); }
.is-answer .dr-box { border-color: var(--red); color: var(--red); }
.dr-fb { min-height: 2em; text-align: center; font-size: 1.15rem; font-weight: 900; }
.dr-fb.ok { color: var(--green); }
.dr-fb.ng { color: var(--red); }
.dr-hint { margin: 4px 0 10px; padding: 10px 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; text-align: center; font-size: 1.1rem; font-weight: 700; line-height: 1.7; }
.dr-dots-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-bottom: 6px; }
.dr-dots-row i, .dr-array i { width: 20px; height: 20px; border-radius: 50%; background: var(--blue); }
.dr-dots-row .d2 { background: #3e7bfa; }
.dr-dots-row .off { background: none; border: 2px dashed var(--muted); }
.dr-array { display: grid; gap: 3px; justify-content: center; margin-bottom: 6px; }
.dr-array div { display: flex; gap: 3px; }
.dr-array i { width: 13px; height: 13px; }
.dr-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.dr-pad button { height: 60px; border: 0; border-radius: 14px; background: var(--surface); box-shadow: 0 3px 0 var(--line); color: var(--ink); font-size: 1.7rem; font-weight: 900; }
.dr-pad button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.dr-pad .k-del { font-size: 1.05rem; color: var(--ink-2); }
.dr-pad .k-ok { font-size: 1.15rem; background: var(--blue); color: #fff; box-shadow: 0 3px 0 var(--blue-dark); }
.shake .dr-q { animation: dr-shake .3s; }
@keyframes dr-shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) { .shake .dr-q { animation: none; } }

/* ---------- 結果 ---------- */
.dr-result { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 20px; text-align: center; }
.dr-stars { margin: 0; font-size: 2.4rem; line-height: 1.2; color: #f2b632; letter-spacing: .1em; }
.dr-stars span { color: var(--line); }
.dr-score { margin: 0; font-size: 1.3rem; font-weight: 700; }
.dr-score b { font-size: 3rem; font-weight: 900; color: var(--accent-text); }
.dr-msg { margin: 0 0 16px; font-size: 1.2rem; font-weight: 900; }
.dr-note, .dr-legend { margin: 8px 0 0; font-size: .82rem; color: var(--muted); }
.dr-list { list-style: none; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; text-align: left; }
.dr-list li { display: flex; justify-content: space-between; gap: 6px; padding: 6px 10px; border-radius: 8px; background: var(--bg); font-weight: 700; font-size: .95rem; }
.dr-list .r-o b { color: var(--green); }
.dr-list .r-t b { color: #b98300; }
.dr-list .r-x b { color: var(--red); }
.dr-legend { margin-bottom: 16px; }
.dr-list.is-long { grid-template-columns: 1fr; }
@media (max-width: 360px) { .dr-list { grid-template-columns: 1fr; } }

/* ---------- 保護者むけ（結果のあとにだけ出る） ---------- */
.drill-parents { max-width: 720px; margin-inline: auto; }
.drill-parents .drill-summary { margin: 0 0 16px; padding: 10px 14px; background: var(--bg); border-radius: 10px; }
.drill-parents h3 { margin-top: 16px; }
.drill-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }

/* ---------- 筆算 ---------- */
.dr-hissan { flex-direction: column; flex-wrap: nowrap; gap: 4px; font-size: clamp(2rem, 10vw, 2.6rem); min-height: 0; padding-top: 6px; }
.hz-row { display: grid; grid-template-columns: repeat(calc(var(--w) + 1), 1.25em); justify-items: center; align-items: center; }
.hz-memo { font-size: .5em; grid-template-columns: repeat(calc(var(--w) + 1), 2.5em); height: 1.9em; }
.hz-m { display: grid; place-items: center; width: 1.8em; height: 1.6em; border: 2px dashed var(--line); border-radius: 8px; color: var(--accent-text); cursor: pointer; }
.hz-m.on { border: 2px solid var(--blue); background: var(--blue-soft); }
.hz-b { padding-bottom: 6px; border-bottom: 4px solid var(--ink); margin-bottom: 6px; }
.hz-ans .dr-box { min-width: 0; width: 1.1em; height: 1.35em; padding: 0; border-radius: 10px; }
.dr-tip { margin: 2px 0 0; text-align: center; font-size: .8rem; color: var(--muted); }
.k-hissan .dr-fb { min-height: 1.7em; }
.k-hissan .dr-hint { font-size: .9rem; text-align: left; line-height: 1.6; }
.k-hissan .dr-pad button { height: 54px; }

/* ---------- 4つからえらぶ（漢字の読み） ---------- */
.dr-ex.is-word { font-size: 2.6rem; }
.dr-q.is-sent { flex-direction: column; gap: 6px; min-height: 150px; font-size: 1rem; }
.dr-sent { margin: 0; font-size: clamp(1.3rem, 6vw, 1.7rem); font-weight: 700; line-height: 1.6; text-align: center; }
.dr-sent b { font-size: 1.35em; font-weight: 900; color: var(--accent-text); border-bottom: 4px solid var(--blue); }
.dr-ask { margin: 6px 0 0; font-size: 1rem; font-weight: 700; color: var(--ink-2); }
.dr-ask b { font-size: 1.2em; }
.dr-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.dr-choices button { min-height: 68px; padding: 8px 6px; border: 0; border-radius: 14px; background: var(--surface); box-shadow: 0 3px 0 var(--line); color: var(--ink); font-size: 1.25rem; font-weight: 900; line-height: 1.3; }
.dr-choices button.ok { background: var(--green); color: #fff; box-shadow: none; }
.dr-choices button.ng { background: var(--line); color: var(--muted); box-shadow: none; text-decoration: line-through; }
.dr-choices button:disabled { cursor: default; }
.dr-next { width: 100%; margin-top: 12px; font-size: 1.15rem; }
.dr-next[hidden] { display: none; }
.dr-kanji { display: inline-block; margin-right: 10px; font-size: 1.6em; font-weight: 900; vertical-align: middle; }
.dr-dans button small { display: block; margin: 0; font-size: .68rem; }
.dr-dans button { line-height: 1.2; }

/* ---------- わり算の筆算（たてる・かける・ひく・おろす） ---------- */
.dr-steps { display: flex; justify-content: center; align-items: center; gap: 4px; margin: 8px 0 0; font-size: .8rem; font-weight: 700; color: var(--muted); }
.dr-steps span { padding: 2px 9px; border-radius: 999px; background: var(--line); }
.dr-steps span.on { background: var(--blue); color: #fff; }
.dr-steps i { font-style: normal; }
.dr-wari { display: block; min-height: 0; padding: 8px 0 2px; font-size: clamp(1.5rem, 7.2vw, 1.9rem); line-height: 1.25; }
.wz-row { display: grid; grid-template-columns: repeat(var(--w), 1.15em); justify-content: center; justify-items: center; align-items: center; min-height: 1.4em; grid-auto-flow: dense; }
.wz-row span { grid-row: 1; width: 100%; text-align: center; }
.wz-row .dv { border-top: 3px solid var(--ink); }
.wz-br { font-weight: 500; transform: scale(1, 1.25) translateX(.2em); }
.wz-row .ul { border-bottom: 3px solid var(--ink); }
.wz-row .dr-box { display: grid; place-items: center; min-width: 0; width: 1.05em; height: 1.25em; padding: 0; border-width: 2px; border-radius: 8px; font-size: 1em; justify-self: center; }
.wz-row .dr-box.ul { box-shadow: 0 5px 0 -2px var(--ink); border-bottom: 2px solid var(--line); }
.wz-row .dr-box.on.ul { border-bottom-color: var(--blue); }
.wz-row .dr-box.rev { border-color: var(--red); color: var(--red); }
.wz-row .oro { color: var(--accent-text); }
.k-wari .dr-fb { min-height: 1.6em; font-size: 1.05rem; }
.k-wari .dr-hint { margin: 0 0 6px; padding: 6px 10px; font-size: 1rem; }
.k-wari .dr-pad button { height: 50px; }
.k-wari.is-ok .dr-box { border-color: var(--line); color: inherit; }

/* ---------- 小数 ---------- */
.dr-pad.has-skip .k-dot { font-size: 1.9rem; line-height: 1; padding-bottom: .5em; }
.hz-d > span { position: relative; width: 100%; text-align: center; }
.hz-ans .dr-box { position: relative; }
.hz-d > .pt::after, .hz-ans .pt::after { content: ""; position: absolute; right: -.1em; bottom: .12em; width: .17em; height: .17em; border-radius: 50%; background: var(--ink); }
.hz-ans .pt::after { right: -.2em; bottom: .05em; }
.hz-pts { height: .75em; }
.hz-pt { position: relative; justify-self: end; width: 1.1em; height: .75em; transform: translateX(50%); border: 0; padding: 0; background: none; }
.hz-pt::after { content: ""; position: absolute; left: 50%; top: 50%; width: .24em; height: .24em; margin: -.14em 0 0 -.14em; border: 2px dashed var(--muted); border-radius: 50%; }
.hz-pt.on::after { border: 2px solid var(--ink); background: var(--ink); }
.is-answer .hz-pt.on::after { border-color: var(--red); background: var(--red); }

/* ---------- 手順ごとの筆算（わり算・2段のかけ算）の 小数点・式 ---------- */
.dr-wexpr { margin: 6px 0 0; text-align: center; font-weight: 900; font-size: 1.05rem; color: var(--ink-2); }
.dr-wask { margin: 4px 0 0; min-height: 1.5em; text-align: center; font-size: .9rem; font-weight: 700; color: var(--accent-text); }
.dr-steps { flex-wrap: wrap; }
.wz-row span { position: relative; }
.wz-row .pt::after { content: ""; position: absolute; right: -.1em; bottom: .14em; width: .17em; height: .17em; border-radius: 50%; background: var(--ink); z-index: 1; }
.wz-row .ext { color: var(--muted); }
.wz-pt { grid-row: 1; justify-self: end; align-self: end; position: relative; width: 1.1em; height: .8em; transform: translate(50%, 35%); border: 0; padding: 0; background: none; z-index: 2; }
.wz-pt::after { content: ""; position: absolute; left: 50%; top: 50%; width: .26em; height: .26em; margin: -.16em 0 0 -.16em; border: 2px dashed var(--blue-dark); border-radius: 50%; background: var(--surface); }
.wz-pt.on::after { border: 2px solid var(--ink); background: var(--ink); }
.wz-pt.rev::after { border-color: var(--red); background: var(--red); }
.wz-pts { min-height: .9em; }
.wz-pts .wz-pt { transform: translate(50%, 0); align-self: center; }
.wz-shift { margin: 18px 0; text-align: center; font-size: 1.15rem; font-weight: 700; line-height: 2.2; }
.wz-shift b { font-size: 1.6em; }
.wz-shift .dr-box { display: inline-grid; width: 1.6em; height: 1.6em; min-width: 0; vertical-align: middle; font-size: 1.3em; }
.dr-wari.is-dan { font-size: clamp(1.5rem, 7.6vw, 1.95rem); }
.is-dan .wz-row { min-height: 1.4em; }
.is-dan .wz-row { width: max-content; margin-inline: auto; }
.is-dan .wz-line { border-bottom: 3px solid var(--ink); margin-bottom: 4px; padding-bottom: 2px; }   /* 横線は、段ごとに1本で引く */
.is-dan .wz-row > span { align-self: stretch; display: grid; place-items: center; }   /* 空のますも同じ高さにして、横線をそろえる */
.is-dan .wz-row .dr-box.ul { box-shadow: none; border-bottom: 2px solid var(--line); }
.is-dan .wz-row .dr-box.on.ul { border-bottom-color: var(--blue); }
.k-dan .dr-fb { min-height: 1.6em; font-size: 1.05rem; }
.k-dan .dr-hint { margin: 0 0 6px; padding: 6px 10px; font-size: .9rem; text-align: left; line-height: 1.6; }
.k-wari .dr-hint { text-align: center; }
.k-dan .dr-pad button { height: 50px; }
.k-dan.is-ok .dr-box { border-color: var(--line); color: inherit; }

/* 「かかない」ボタンのある数字ボタン（さいごの段だけ4つ） */
.dr-pad.has-skip { grid-template-columns: repeat(12, 1fr); }
.dr-pad.has-skip button { grid-column: span 4; }
.dr-pad.has-skip .k-del, .dr-pad.has-skip .k-del ~ button { grid-column: span 3; }
.dr-pad.has-skip .k-del, .dr-pad.has-skip .k-skip, .dr-pad.has-skip .k-ok { font-size: .92rem; white-space: nowrap; padding: 0; }
.dr-pad.has-skip .k-skip { color: var(--ink-2); }

/* たての短い画面（小さめのスマホ）：わり算の筆算は行が多いので、字とボタンを少し小さくして1画面におさめる */
@media (max-height: 720px) {
  /* ヒントが出ているあいだは、上の式と手順の表示をたたんで、数字ボタンが画面から出ないようにする */
  .dr-play:has(.dr-hint:not([hidden])) .dr-wexpr, .dr-play:has(.dr-hint:not([hidden])) .dr-steps { display: none; }
  .dr-wari.is-dan { font-size: 1.45rem; }
  .k-dan .dr-pad { gap: 6px; }
  .k-dan .dr-pad button { height: 42px; font-size: 1.4rem; }
  .dr-wari { font-size: 1.45rem; padding-top: 4px; }
  .k-wari .dr-pad { gap: 6px; }
  .k-wari .dr-pad button { height: 42px; font-size: 1.4rem; }
  .k-wari .dr-steps { margin-top: 2px; }
  .k-hissan .dr-pad button { height: 48px; }
}
