/* 数のへや：見た目（シリーズの決まり：生成りの方眼紙、こげ茶の線、強調はオレンジ #E0663B を注目させるわく・道すじ・位の名前の札のふちだけ） */
@font-face { font-family: "MPR"; src: url("assets/fonts/mpr-bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "MPR"; src: url("assets/fonts/mpr-xbold.woff2") format("woff2"); font-weight: 800; font-display: swap; }
:root {
  --ink: #3A2621;
  --text: #3D3836;
  --muted: #5E534D;
  --accent: #E0663B;
  --paper: #FBF5E8;
  --card: #FFFDF8;
  --cream: #FFF1D6;
  --yellow: #FFE9A8;
  --oku: #EEF1F5;
  --man: #FBEFD9;
  --ichi: #FFFFFF;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  word-break: auto-phrase;
  background-color: var(--paper);
  background-image: linear-gradient(rgba(58,38,33,.06) 1.5px, transparent 1.5px), linear-gradient(90deg, rgba(58,38,33,.06) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  color: var(--text);
  font-family: "MPR", "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
  font-weight: 700;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
button, textarea { font-family: inherit; color: inherit; }
ruby rt { font-size: .5em; font-weight: 700; }
#app { max-width: 760px; margin: 0 auto; padding: 8px 12px calc(28px + env(safe-area-inset-bottom)); min-height: 100svh; }

/* 上の帯 */
.top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: env(safe-area-inset-top); flex-wrap: wrap; }
.top-left, .top-right { display: flex; gap: 6px; align-items: center; }
.top-right { margin-left: auto; }
.pill {
  min-height: 44px; padding: 6px 12px; border-radius: 999px; border: 3px solid var(--ink); background: var(--card);
  font-weight: 800; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--ink);
}
span.pill { min-height: 32px; padding: 3px 10px; font-size: 12px; border-width: 2.5px; }
button.pill { cursor: pointer; }
button.pill:active { transform: translateY(1px); }
.pill.sound svg { width: 22px; height: 22px; }
.pill.sound .cross { display: none; }
.pill.sound.off .cross { display: inline; }
.pill.sound.off .wave { display: none; }
@media (max-width: 480px) {
  button.pill { font-size: 13px; padding: 6px 9px; }
  .pill.sound .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pill.sound { min-width: 44px; justify-content: center; }
}
@media (max-width: 360px) {
  span.pill.tag-grade { display: none; }
}
.app-title { margin: 8px 2px 0; font-size: 13px; color: var(--muted); }
.series-line { margin: 18px 2px 0; font-size: 12px; color: var(--muted); }
.storage-note { margin: 6px 0; padding: 6px 10px; border-radius: 10px; background: var(--cream); border: 2px dashed var(--ink); font-size: 13px; }

/* ボタン */
.btn {
  min-height: 48px; padding: 9px 14px; border-radius: 16px; border: 3px solid var(--ink); background: var(--card);
  font-weight: 800; font-size: 17px; cursor: pointer; box-shadow: 0 4px 0 rgba(58,38,33,.18); line-height: 1.4; color: var(--ink);
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(58,38,33,.18); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.main { background: var(--ink); color: #FFFDF8; width: 100%; margin-top: 10px; }
.btn.small { min-height: 44px; font-size: 15px; padding: 6px 12px; border-radius: 14px; }
.btn.picked { background: var(--yellow); }
.pill.listen { min-height: 40px; font-size: 13px; flex: none; }

/* 問題 */
.screen { margin-top: 6px; }
.qhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin: 8px 0 4px; }
h1.q { margin: 0; min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; font-size: 22px; font-weight: 800; color: var(--ink); line-height: 1.6; }
h1.q .story { display: block; font-size: 16px; color: var(--text); }
h2.q2 { margin: 12px 0 4px; font-size: 19px; font-weight: 800; color: var(--ink); line-height: 1.6; }
.intro { margin: 4px 0; padding: 8px 12px; background: var(--card); border: 2px dashed var(--ink); border-radius: 12px; font-size: 14px; line-height: 1.5; }
.lead { margin: 10px 0 6px; font-size: 16px; line-height: 1.7; color: var(--text); }
.lead.small { font-size: 14px; }
.cap { margin: 10px 0 2px; font-size: 13px; color: var(--muted); }
.tip { margin: 6px 2px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.predicted { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.ncards { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.ncard { flex: 1; min-width: 0; background: var(--card); border: 4px solid var(--ink); border-radius: 16px; text-align: center; font-weight: 800; color: var(--ink); padding: 14px 4px 10px; box-shadow: 0 4px 0 rgba(58,38,33,.18); display: flex; flex-direction: column; align-items: center; }
.ncard .nmain { font-size: clamp(20px, 6.4vw, 34px); white-space: nowrap; line-height: 1.5; }
.ncard .nsub { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.ncards.cmp .ncard .nmain { font-size: clamp(17px, 5vw, 28px); }
.qmark { font-size: 28px; font-weight: 800; color: var(--ink); flex: none; }
.choices { display: grid; gap: 8px; margin-top: 6px; }
.choices.row3 { grid-template-columns: repeat(3, 1fr); }
.btn.choice { text-align: left; }
.choices.row3 .btn.choice { text-align: center; padding: 8px 4px; }

/* 位取り表（へや） */
.board-wrap { margin: 10px 0 4px; }
.board { position: relative; background: var(--card); border: 3px solid var(--ink); border-radius: 14px; padding: 4px; --s: 25px; --h: 44px; --fs: 20px; }
.rooms { display: flex; justify-content: center; }
.room { display: flex; flex-direction: column; align-items: stretch; padding: 0 1px 2px; border-radius: 8px; }
.room + .room { border-left: 6px solid var(--ink); border-radius: 0 8px 8px 0; }
.room2 { background: var(--oku); }
.room1 { background: var(--man); }
.room0 { background: var(--ichi); }
.room.mark { box-shadow: inset 0 0 0 3px var(--accent); }
.rname { display: block; width: 100%; min-height: 40px; padding: 2px 0; border: none; background: transparent; font-weight: 800; font-size: 13px; color: var(--ink); text-align: center; line-height: 1.5; }
button.rname { cursor: pointer; text-decoration: underline dotted rgba(58,38,33,.45); text-underline-offset: 3px; }
.labels, .row, .gaprow { display: flex; }
.lab { width: var(--s); margin: 0 1px; text-align: center; font-size: var(--lfs, 12px); white-space: nowrap; letter-spacing: -.3px; color: var(--muted); font-weight: 800; height: 20px; line-height: 20px; }
.seat {
  position: relative; width: var(--s); height: var(--h); margin: 4px 1px 0; padding: 0; border-radius: 7px; border: 2px dashed rgba(58,38,33,.38);
  background: transparent; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: var(--fs); color: var(--ink); line-height: 1;
}
button.seat { cursor: pointer; }
button.seat::before { content: ""; position: absolute; left: -1px; right: -1px; top: -4px; bottom: -6px; }
.seat.filled { border: 3px solid var(--ink); background: #fff; box-shadow: 0 2px 0 rgba(58,38,33,.18); }
.seat.zero { color: var(--ink); }
.seat.mark { outline: 3px solid var(--accent); outline-offset: 1px; z-index: 1; }
.seat.rowhl { background: var(--yellow); }
.seat.faded { opacity: .35; }
.seat.stacked { transform: translate(3px, calc(-1 * var(--h) - 1px)); z-index: 0; box-shadow: none; }
.seat.back { animation: back .33s ease-in forwards; }
@keyframes back { from { transform: translateY(0); opacity: 1; } to { transform: translateY(16px); opacity: 0; } }
.gaprow { height: 24px; }
.gapcell { width: var(--s); margin: 0 1px; font-size: 11px; font-weight: 800; color: var(--ink); text-align: center; line-height: 24px; white-space: nowrap; overflow: visible; }
.cmplabel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 0 3px; border-radius: 7px; background: #fff; border: 2px solid var(--ink); font-size: 11px; letter-spacing: -.5px; font-weight: 800; color: var(--ink); white-space: nowrap; line-height: 1.3; }
.cmplabel[hidden] { display: none; }
.cmpframe { position: absolute; border: 4px solid var(--accent); border-radius: 10px; pointer-events: none; transition: left .35s ease, top .35s ease; z-index: 2; }
.readouts { margin: 2px 2px 0; }
.readout { margin: 2px 0; display: flex; gap: 8px; align-items: baseline; font-size: 15px; font-weight: 800; color: var(--ink); min-height: 24px; flex-wrap: wrap; }
.readout .rlab { font-size: 12px; color: var(--muted); }
.readout .rdig { letter-spacing: 1px; font-size: 17px; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 800; color: var(--ink); padding: 4px 12px; min-height: 48px; display: flex; align-items: baseline; gap: 4px; box-shadow: 0 3px 0 rgba(58,38,33,.2); cursor: pointer; }
.chip .cd { font-size: 22px; letter-spacing: 1px; }
.chip .cu { font-size: 16px; }
.chip .cr { font-size: 12px; color: var(--muted); }
.chip.sel { background: var(--yellow); box-shadow: 0 0 0 3px var(--ink); }
.chip.used { opacity: .3; cursor: default; }
.board.locked .seat { cursor: default; }

/* 飛ぶカードと道すじ */
.fly { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.flyer { position: fixed; border-radius: 7px; border: 3px solid var(--ink); background: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--ink); box-shadow: 0 3px 6px rgba(58,38,33,.25); }
.path-svg { position: fixed; inset: 0; width: 100vw; height: 100vh; overflow: visible; }
.path-svg path { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 6 5; stroke-linecap: round; }

/* 案内 */
.msg { margin: 10px 0; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 10px 14px; font-weight: 700; font-size: 15px; line-height: 1.7; }
.msg.good { background: var(--cream); }
.msg.check { border-style: dashed; }
.msg .board-wrap { margin-top: 8px; }
.result { margin: 10px 0; padding: 12px 14px; border-radius: 16px; background: var(--cream); border: 3px solid var(--ink); line-height: 1.7; }
.result .eq { font-size: 18px; font-weight: 800; color: var(--ink); margin: 0 0 4px; }
.result p { margin: 4px 0; }
.ask { margin-top: 8px; }
.hints { margin-top: 12px; }
.hint { margin: 6px 0; padding: 8px 12px; border-radius: 12px; background: var(--card); border: 2.5px dashed var(--ink); line-height: 1.7; font-size: 15px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.next-row, .more-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.next-row .btn, .more-row .btn { flex: 1 1 140px; margin-top: 0; }

/* 答えの入れ方 */
.answer { margin-top: 12px; }
.ansbox { width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 6px 12px; cursor: pointer; text-align: left; }
.ansbox.focus { box-shadow: 0 0 0 3px var(--yellow), 0 0 0 6px var(--ink); }
.ansbox .alab { font-size: 13px; color: var(--muted); }
.ansbox .aval { font-size: 24px; font-weight: 800; color: var(--ink); letter-spacing: 1px; overflow-wrap: anywhere; text-align: right; }
.okuman { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.key { min-height: 52px; border-radius: 14px; border: 3px solid var(--ink); background: var(--card); font-size: 24px; font-weight: 800; color: var(--ink); cursor: pointer; box-shadow: 0 3px 0 rgba(58,38,33,.18); }
.key.del { font-size: 16px; }
.key:active { transform: translateY(2px); box-shadow: none; }
.cmpkeys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.btn.cmpk { display: flex; flex-direction: column; align-items: center; padding: 6px 4px; }
.btn.cmpk .sym { font-size: 28px; line-height: 1.1; }
.btn.cmpk .sm { font-size: 12px; }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.levels .btn { font-size: 15px; padding: 8px 4px; }
.key-sp { min-height: 52px; }
.result .eqn { font-size: 22px; font-weight: 800; color: var(--ink); margin: 2px 0 6px; white-space: nowrap; }

/* 課題5 */
.cloze { display: grid; gap: 10px; }
.ccard { position: relative; padding: 10px 12px 10px 44px; border-radius: 14px; background: var(--card); border: 3px solid var(--ink); }
.ccard.done { background: #fff; }
.ccard p { margin: 0 0 6px; line-height: 1.8; font-size: 16px; }
.ccard .cl { position: absolute; left: 10px; top: 10px; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.blank { display: inline-block; min-width: 3em; border-bottom: 3px solid var(--ink); text-align: center; }
.filled-blank { padding: 0 4px; background: var(--yellow); border-radius: 6px; }
.free { margin-top: 12px; }
.free textarea { width: 100%; min-height: 96px; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 10px; font-size: 16px; font-weight: 700; background: #fff; line-height: 1.6; }
.examples { margin: 8px 0; padding: 8px 12px; border-radius: 12px; background: #fff; border: 2px solid rgba(58,38,33,.4); line-height: 1.8; font-size: 15px; }
.checks { display: grid; gap: 6px; margin: 6px 0; }
.chk { display: flex; gap: 8px; align-items: center; min-height: 44px; padding: 4px 8px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; font-size: 14px; }
.chk input { width: 22px; height: 22px; flex: none; }

/* 課題6 */
.notecard { margin: 12px 0; padding: 12px; border-radius: 6px; background-color: #fff; background-image: repeating-linear-gradient(transparent 0 31px, rgba(80,120,170,.22) 31px 33px); border: 3px solid var(--ink); box-shadow: 0 4px 0 rgba(58,38,33,.15); }
.note-tag { display: inline-block; margin: 0; padding: 0 12px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 13px; }
.note-line { margin: 8px 0; font-size: 17px; line-height: 1.9; font-weight: 800; color: var(--ink); overflow-wrap: anywhere; }
.step { margin-top: 6px; }
.step.cmp .lead { color: var(--ink); }

/* なぞをつくる */
.notations { display: grid; gap: 8px; }
.btn.notation { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; text-align: left; }
.btn.notation .sm { font-size: 13px; color: var(--muted); }
.btn.notation .nt { font-size: 20px; overflow-wrap: anywhere; text-align: right; }
.pcard { margin: 12px 0; padding: 14px; border-radius: 18px; background: #fff; border: 4px solid var(--ink); text-align: center; box-shadow: 0 4px 0 rgba(58,38,33,.18); }
.pq { font-size: 20px; font-weight: 800; color: var(--ink); line-height: 1.7; margin: 0 0 8px; overflow-wrap: anywhere; }
.pa { font-size: 16px; margin: 6px 0; }

/* 道すじ（すごろく） */
.path { margin-top: 22px; padding: 10px; border-radius: 18px; background: rgba(255,253,248,.85); border: 3px solid var(--ink); }
.path-title { margin: 0 0 6px; font-size: 14px; font-weight: 800; color: var(--ink); }
.dots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.dot { width: 100%; min-height: 76px; border: none; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; padding: 2px 0; }
.dot .dn { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--ink); background: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; color: var(--ink); }
.dot.done .dn { background: var(--yellow); }
.dot.cur .dn { box-shadow: 0 0 0 3px var(--ink); }
.dot .dl { font-size: 11px; line-height: 1.35; color: var(--text); text-align: center; }
.dot .dk { font-size: 10px; color: var(--muted); }

/* 重ねる画面 */
.overlay { position: fixed; inset: 0; background: rgba(58,38,33,.38); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 10px; overflow-y: auto; }
.overlay[hidden] { display: none; }
.ov-card { width: min(100%, 720px); max-height: calc(100svh - 20px); overflow-y: auto; background: var(--paper); border: 4px solid var(--ink); border-radius: 22px; padding: 14px; position: relative; }
.ov-card h2 { margin: 2px 0 8px; font-size: 20px; color: var(--ink); }
.ov-close { margin-top: 12px; width: 100%; }
.map-wrap { overflow-x: auto; }
.map { border-collapse: collapse; width: 100%; font-size: 12px; table-layout: fixed; }
.map th, .map td { border: 2px solid var(--ink); padding: 4px; text-align: center; vertical-align: middle; background: var(--card); overflow-wrap: anywhere; }
.map th { background: var(--cream); font-size: 12px; }
.map thead th:first-child { width: 2.8em; }
.map td.here { background: var(--yellow); box-shadow: inset 0 0 0 3px var(--accent); }
.map td b { display: block; }
.map td span { display: block; font-size: 10px; line-height: 1.35; }
.map td .url { display: block; font-size: 9px; color: var(--muted); }
.map-sub { margin: 12px 0 4px; font-weight: 800; color: var(--ink); }
.fields { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-flex; padding: 3px 10px; border-radius: 12px; background: var(--card); border: 2px solid var(--ink); font-size: 13px; }
.tag.now { background: var(--yellow); }
.skills { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.skills li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 8px; background: var(--card); border-radius: 12px; border: 2px solid var(--ink); font-size: 14px; }
.stamps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stamp { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 14px; border: 2.5px dashed rgba(58,38,33,.35); opacity: .4; font-size: 12px; }
.stamp.on { opacity: 1; border-style: solid; border-color: var(--ink); background: #fff; }
.stamp.pop { animation: stamp .45s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes stamp { from { transform: scale(1.6) rotate(-8deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.stamp-svg { width: 100%; max-width: 132px; height: auto; }
.mstamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.mstamp { padding: 4px; background: #fff; border-radius: 10px; border: 2px solid var(--ink); }
.made { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.made li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 8px; background: var(--card); border-radius: 12px; border: 2px solid var(--ink); font-size: 14px; line-height: 1.5; }
.empty { font-size: 13px; color: var(--muted); }
.allmark { font-size: 14px; padding: 2px 10px; border-radius: 999px; background: var(--yellow); border: 2px solid var(--ink); }
.reason-text { padding: 8px; background: #fff; border-radius: 10px; border: 2px solid var(--ink); white-space: pre-wrap; font-size: 14px; }
.fin { text-align: center; }
.fin-title { font-size: 18px; font-weight: 800; color: var(--ink); line-height: 1.7; }
.rules { display: grid; gap: 6px; margin-top: 8px; }
.rule { margin: 0; padding: 6px 12px; border-radius: 12px; background: #fff; border: 3px solid var(--ink); opacity: 0; transform: translateY(6px); transition: opacity .35s, transform .35s; }
.rule.on { opacity: 1; transform: none; }
@media (min-width: 600px) {
  h1.q { font-size: 26px; }
  .lab { font-size: 13px; }
  .rname { font-size: 15px; }
  .gapcell { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01s !important; transition-duration: .01s !important; }
}

/* 英語版（Number Houses。2026-10-22 作り直し）：3けたの組（house）。組の地は本編と同じ色（billions はうすい紫）。日本語版の見た目には触らない */
.hboard .room.hk3 { background: #F2EEF7; }
.hboard .room.hk2 { background: #EEF1F5; }
.hboard .room.hk1 { background: #FBEFD9; }
.hboard .room.hk0 { background: #FFFFFF; }
.hboard .lab { letter-spacing: 0; }
.ncard .nmain.nmain-en { white-space: normal; font-size: clamp(17px, 4.8vw, 28px); line-height: 1.3; padding: 0 4px; overflow-wrap: anywhere; }
.ncards.cmp .ncard .nmain.nmain-en { font-size: clamp(15px, 4.2vw, 24px); }
.en-screen .chip .cu { font-size: 15px; }
.en-screen .result .eqn { white-space: normal; font-size: 19px; overflow-wrap: anywhere; }
.en-screen .cloze .ccard { min-width: 0; }
.en-screen .choices.row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.en-screen .choices.row3 .btn.choice { font-size: 15px; padding: 8px 2px; overflow-wrap: anywhere; }
