/* 算数ドリルだけの見た目（quiz.css・study.css のあとに読む）。教科の色＝オレンジ（study.css の html[data-subj="math"]） */
html[data-subj="math"] { --math: #E8590C; --math-soft: #FFF0E0; --accent: var(--math); --accent-soft: var(--math-soft); --ground: var(--math-soft); }

/* ---- ホーム ---- */
.mx-recbox { width: 100%; font: inherit; text-align: left; cursor: pointer; }
.mx-allhana { margin: 18px 0 0; padding: 12px 16px; border: var(--edge); border-radius: 16px; background: var(--paper); font-weight: 800; text-align: center; }
.mx-grades button { padding: 8px 2px; line-height: 1.2; }
.mx-grades small { display: block; font-size: 11px; font-weight: 700; opacity: .8; }
.mx-drills { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 12px; }
.mx-tile { position: relative; grid-template-columns: 46px 1fr; padding: 8px 10px; min-height: 66px; }
.mx-tile .q-gname { font-size: 15px; }
.mx-tile .q-gbest:empty { display: none; }
.mx-sym { width: 46px; height: 46px; font-family: var(--display); font-weight: 800; font-size: calc(38px / max(var(--n, 1), 1.4)); }
.mx-hmini { position: absolute; right: 4px; bottom: 4px; width: 30px; height: 30px; }
.mx-recmark { position: absolute; right: -4px; top: -9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 99px; border: 2px solid var(--line); rotate: 4deg; }
.mx-kuku { margin-top: 12px; background: var(--paper); border: var(--edge); border-radius: var(--radius-s); padding: 8px 10px 12px; box-shadow: var(--pop-s); }
.mx-kuku-h { margin: 0 0 8px; font-weight: 800; font-size: 15px; }
.mx-chips { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.mx-chip { position: relative; aspect-ratio: 1; min-width: 0; font: inherit; font-family: var(--display); font-weight: 800; font-size: clamp(16px, 4.6vw, 22px); border: var(--edge); border-radius: 50%; background: var(--paper); color: var(--ink); cursor: pointer; padding: 0; box-shadow: 0 2px 0 var(--line); }
.mx-chip.on { background: var(--accent); color: #fff; }
.mx-chip.hana { border-color: var(--red); }
.mx-chip .mx-hmini { right: -6px; bottom: auto; top: -8px; width: 22px; height: 22px; }
.mx-recdot { position: absolute; left: -2px; top: -3px; width: 12px; height: 12px; border-radius: 50%; background: var(--red); border: 2px solid var(--line); }
.mx-note { margin: -4px 0 10px; font-size: 13px; text-align: center; }
.q-seg button:disabled { opacity: .45; cursor: not-allowed; }
.mx-startbar { position: sticky; bottom: 0; z-index: 5; margin: 6px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(rgba(255, 254, 249, 0), var(--bg) 26%); }
.mx-startbar .q-start { margin-top: 0; font-size: clamp(16px, 4.6vw, 20px); }

/* ---- 出題 ---- */
.mx-q { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 140px; }
body.q-playing .mx-card { flex: 1 1 auto; min-height: 0; }
body.q-playing .mx-q { flex: 1; min-height: 0; }
.mx-expr { margin: 0; text-align: center; white-space: nowrap; font-family: var(--display); font-weight: 800; line-height: 1.35; color: var(--ink); font-variant-numeric: tabular-nums;
  font-size: min(calc((min(100vw, 680px) - 64px) / var(--w, 6)), 64px); }
body.q-playing .mx-expr { font-size: min(calc((min(100vw, 680px) - 64px) / var(--w, 6)), 64px, 10dvh); }
.mx-expr-a { font-size: min(calc((min(100vw, 680px) - 64px) / var(--w, 6)), 44px) !important; }
.mx-box { display: inline-block; min-width: 1.5em; padding: 0 .14em; border: 3px dashed var(--accent); border-radius: .22em; color: var(--accent); background: #fff; text-align: center; line-height: 1.15; vertical-align: middle; }
.mx-box:empty::before { content: "\200b"; }
.mx-box.mx-in { cursor: pointer; }
.mx-box.on { border-style: solid; background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(232, 89, 12, .22); }
.mx-box.on:empty::after, .mx-box.on::after { content: ""; display: inline-block; width: 3px; height: .9em; background: var(--accent); vertical-align: -.08em; margin-left: 1px; animation: mxblink 1s steps(1) infinite; }
@keyframes mxblink { 50% { opacity: 0; } }
.mx-box.is-ok { border-style: solid; border-color: var(--science); color: var(--science); }
.mx-box.is-ng { border-style: solid; border-color: var(--red); color: var(--red); }
.mx-whole { min-width: 1em; margin-right: .08em; border-width: 2px; }
.mx-u { font-size: .6em; margin-left: .12em; }
.mx-amari { font-size: .5em; margin: 0 .3em; color: var(--muted); font-weight: 800; vertical-align: middle; }
.fr { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: .78em; line-height: 1.12; margin: 0 .08em; }
.fr-n { border-bottom: .09em solid currentColor; padding: 0 .22em .05em; }
.fr-d { padding: .05em .22em 0; }
.fr .mx-box { font-size: .9em; min-width: 1.3em; }
.mx-seq { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .1em .25em; font-family: var(--display); font-weight: 800; font-size: clamp(26px, 8.4vw, 52px); font-variant-numeric: tabular-nums; }
.mx-sep { color: var(--muted); }
.mx-text { margin: 0; text-align: center; font-weight: 800; font-size: clamp(20px, 5.8vw, 32px); line-height: 1.5; }
.mx-text b { color: var(--accent); }
.mx-kan { font-family: var(--display); font-size: min(7.4vw, 40px); word-break: keep-all; overflow-wrap: anywhere; }
.mx-big { font-size: min(9vw, 52px); letter-spacing: .03em; font-variant-numeric: tabular-nums; }
/* 時計：問題用紙の残りの高さいっぱいに */
.mx-clock { position: relative; width: 100%; flex: 1 1 auto; min-height: 150px; }
.mx-clock-svg { position: absolute; inset: 0; margin: auto; width: 100%; height: 100%; }
body.q-playing .mx-q-clock .mx-clock { min-height: 0; }
.q-card .mx-clock-svg text { paint-order: stroke; }

/* 4つの答え */
.q-opt.mx-opt { display: flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden; padding-left: 28px; padding-right: 8px;
  font-family: var(--display); font-variant-numeric: tabular-nums; font-size: clamp(14px, calc((min(100vw, 680px) / 2 - 62px) / var(--w, 3)), 32px); }
.mx-opt .fr { font-size: .8em; }
.mx-opt .mx-u { font-size: .62em; }
.mx-opt .mx-amari { font-size: .55em; margin: 0 .2em; }
body.q-playing .mx-opts .q-opt { min-height: 62px; }

/* テンキー */
.mx-pad { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, clamp(42px, 7.4dvh, 62px)); gap: 7px; width: 100%; max-width: 440px; margin: 0 auto; }
.mx-k { font: inherit; font-family: var(--display); font-size: 26px; font-weight: 800; border: var(--edge); border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: var(--pop-s); cursor: pointer; padding: 0; transition: transform .06s, box-shadow .06s; touch-action: manipulation; }
.mx-k:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--line); }
.mx-k:disabled { opacity: .5; cursor: default; }
.mx-k-f { background: var(--ground-2); font-size: 20px; }
.mx-k-s { font-size: 15px; }
.mx-k-0 { grid-column: span 2; }
.mx-k-ok { grid-column: 4; grid-row: 3 / span 2; background: var(--btn); color: #fff; font-size: 17px; writing-mode: horizontal-tb; }
.mx-k-ok:disabled { background: #F4C9A8; opacity: 1; }

/* タイムアタック */
.mx-timer { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 4.6em; text-align: center; font-size: 17px; }
.mx-count { margin: 0; font-family: var(--display); font-weight: 800; color: var(--accent); font-size: min(34vw, 30dvh, 170px); line-height: 1; }
.mx-count.mx-go { font-size: min(14vw, 12dvh, 80px); color: var(--red); }
.mx-ready { margin: 10px 0 0; font-weight: 800; color: var(--muted); }
.mx-fbta { grid-template-columns: 1fr !important; }
.mx-fbta small { font-size: 14px; }

/* 答えあわせの帯：式も分数も1行で */
.mx-full { font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums; }
.q-answer .mx-full { font-size: 19px; }
.q-answer .mx-full .fr { font-size: .8em; }
.mx-a { color: var(--accent); font-size: 1.12em; }
.mx-full .mx-clock, .mx-full .mx-wq .mx-clock { display: none; }
.mx-full .mx-text, .mx-full .mx-seq { display: inline; font-size: 1em; }
.mx-full .mx-seq { display: inline-flex; flex-wrap: wrap; }
.mx-full .mx-kan, .mx-full .mx-big { font-size: 1em; }
.mx-wq { margin-right: .4em; }

/* けっか */
.mx-rname { margin: 6px 0 0; font-weight: 800; color: var(--accent); }
.mx-time { margin: 6px 0 0; font-size: 18px; font-weight: 800; }
.mx-time b { font-size: 34px; color: var(--accent); }
.mx-time small { display: block; font-size: 13px; color: var(--muted); }
.mx-best { margin: 2px 0 0; }
.mx-newrec { display: inline-block; margin: 8px 0 0; padding: 2px 14px; background: var(--hl); border: 2px solid var(--line); border-radius: 99px; font-weight: 800; animation: stampin .35s cubic-bezier(.2, 1.6, .4, 1); }
.mx-nextdrill { width: 100%; margin-top: 12px; }
.mx-wrong { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; text-align: left; }
.mx-wrong li { display: flex; align-items: center; gap: 12px; border: var(--edge); border-radius: var(--radius-s); padding: 10px 14px; background: var(--paper); font-size: 20px; }
.mx-wrong .mx-full { overflow-wrap: anywhere; }
.mx-wclock { flex: none; width: 76px; height: 76px; }
.mx-wclock svg { width: 100%; height: 100%; display: block; }
.mx-wrong .mx-text { font-size: 16px; }
/* テンキー：答えたら隠して、帯の分の高さを問題用紙にまわす */
#quiz.answered .mx-pad { display: none; }
.mx-small { display: block; font-size: 11px; font-weight: 700; line-height: 1.1; }
