/* なぞのかご：見た目（シリーズの決まり：生成りの方眼紙、こげ茶の線、強調はオレンジ #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-black.woff2") format("woff2"); font-weight: 900; font-display: swap; }
:root {
  --ink: #3A2621;
  --text: #3D3836;
  --accent: #E0663B;
  --paper: #FBF5E8;
  --card: #FFFDF8;
  --tan: #C9A77B;
  --cream: #FFF1D6;
  --cloth: #E3E9F0;
  --bw: min(15vw, 66px); /* A の積み木1こ */
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  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 { font-family: inherit; color: inherit; }
img { max-width: 100%; }
ruby rt { font-size: .5em; font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#app { max-width: 720px; 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); }
.top-right { display: flex; gap: 6px; margin-left: auto; }
.pill {
  min-height: 44px; padding: 6px 12px; border-radius: 999px; border: 3px solid var(--ink); background: var(--card);
  font-weight: 900; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.pill:active { transform: translateY(1px); }
.pill .ico { font-size: 18px; }
.pill.sound svg { width: 22px; height: 22px; }
@media (max-width: 480px) {
  .pill { font-size: 13px; padding: 6px 9px; }
  .pill.sound .lbl, .pill.home .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pill.home, .pill.sound { min-width: 44px; justify-content: center; }
}
.pill.sound .cross { display: none; }
.pill.sound.off .cross { display: inline; }
.pill.sound.off .wave { display: none; }
.pill[hidden] { display: none; }
.series { margin: 6px 2px 0; font-size: 12px; color: var(--text); opacity: .85; }
.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: 52px; padding: 10px 16px; border-radius: 18px; border: 3px solid var(--ink); background: var(--card);
  font-weight: 900; font-size: 18px; cursor: pointer; box-shadow: 0 4px 0 rgba(58,38,33,.18); line-height: 1.35;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(58,38,33,.18); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.main { min-height: 58px; background: var(--cream); font-size: 20px; width: 100%; }
.btn.big { font-size: 22px; }
.btn.big small { display: block; font-size: 13px; color: #9a4a2a; }
.btn.small { min-height: 44px; font-size: 15px; padding: 6px 12px; border-radius: 14px; }
.btn.picked { background: var(--cream); outline: 3px solid var(--accent); outline-offset: 2px; }
.pill.listen { min-height: 44px; font-size: 15px; }

.screen { margin-top: 8px; }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.screen-head h2 { margin: 6px 0; font-size: 20px; font-weight: 900; color: var(--ink); }
.guide { margin: 8px 0; padding: 8px 12px; border-radius: 14px; background: var(--card); border: 2px solid var(--ink); font-size: 17px; line-height: 1.6; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 12px; background: var(--card); border: 2.5px solid var(--ink); font-weight: 900; font-size: 15px; line-height: 1.5; margin: 2px; }
.tag.t-good { background: var(--cream); }
.tag.t-heads, .tag.t-legs { font-size: 20px; }
.tag.t-mark { border-color: var(--accent); }
.tag.hlt, b.hl { background: #FFE9A8; box-shadow: 0 0 0 3px #FFD25A; border-radius: 6px; }
.cond { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.ctag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 4px; border-radius: 12px; background: var(--card); border: 2.5px solid var(--ink); font-size: 14px; font-weight: 900; }
.ctag-img { height: 26px; width: auto; }
.fb { margin: 8px 0; padding: 8px 12px; border-radius: 12px; background: var(--card); border: 2px dashed var(--ink); line-height: 1.6; }
.fb.good { border-style: solid; background: var(--cream); }
.note { font-size: 12px; opacity: .8; margin: 4px 0; }
.controls { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.next-row, .more-row { display: flex; gap: 8px; flex-wrap: wrap; }
.next-row .btn, .more-row .btn { flex: 1 1 140px; }

/* はじめ */
.title { margin: 6px 0 2px; font-size: 30px; font-weight: 900; color: var(--ink); text-align: center; }
.start-problem { display: grid; gap: 6px; }
.q-big { text-align: center; font-size: clamp(30px, 9vw, 48px); font-weight: 900; color: var(--ink); }
.start-cage { position: relative; text-align: center; padding: 26px 0 30px; }
.start-cage .cage-svg { width: min(100%, 380px); height: auto; }
.start-cage .t-heads { position: absolute; top: 0; left: 50%; transform: translateX(-50%); }
.start-cage .t-legs { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); }
.start-side .cond { justify-content: center; }
.start-side .ctag { font-size: 17px; }
.start-side .ctag-img { height: 40px; }
.explain { text-align: center; margin: 4px 0; font-size: 16px; }
.start-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

/* 積み木の図（SVG） */
.diag-wrap { margin: 6px 0; background: rgba(255,255,255,.4); border-radius: 12px; }
.diag { width: 100%; height: auto; display: block; max-height: 56vh; }
.diag .board { fill: #fff; stroke: rgba(58,38,33,.12); stroke-width: 1; }
.diag .gl { stroke: rgba(58,38,33,.13); stroke-width: .5; }
.blk { fill: var(--tan); stroke: var(--ink); stroke-width: .8; }
.blk.or { fill: var(--accent); }
.diag .qt rect { fill: var(--card); stroke: var(--ink); stroke-width: .8; }
.diag .qt text { font-size: 7px; font-weight: 900; text-anchor: middle; fill: var(--text); font-family: "MPR", sans-serif; }
.diag .frame { fill: none; stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 2; }
.diag .rbase { fill: var(--tan); }
.diag .rbump { fill: var(--accent); }
.diag .rl { stroke: rgba(58,38,33,.45); stroke-width: .5; }
.diag .rout { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.diag .full { fill: none; stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 2; }
.diag .mark { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 4 2; animation: blink 1s ease-in-out 2; }
.diag .markline { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.diag .br { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-linejoin: round; }
.diag .ico.hl { filter: drop-shadow(0 0 2px #FFD25A) drop-shadow(0 0 2px #FFD25A); }
.diag-info { display: flex; flex-wrap: wrap; gap: 2px; min-height: 8px; }
.pop { animation: pop .45s cubic-bezier(.3,1.6,.5,1) both; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes pop { from { transform: translateY(-14px) scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes blink { 50% { opacity: .2; } }

/* A ためす */
.a-status { display: flex; justify-content: flex-end; gap: 4px; flex-wrap: wrap; }
.a-stage { position: relative; margin: 8px auto 0; width: calc(var(--bw) * 5); padding-top: 36px; }
.a-board {
  position: absolute; left: calc(var(--bw) * -0.3); right: calc(var(--bw) * -0.3); bottom: 0; height: calc(var(--bw) * 4.4);
  background: #fff; border-radius: 10px 10px 0 0; border-bottom: 6px solid var(--ink);
  background-image: linear-gradient(rgba(58,38,33,.16) 1.5px, transparent 1.5px), linear-gradient(90deg, rgba(58,38,33,.16) 1.5px, transparent 1.5px);
  background-size: var(--bw) var(--bw); background-position: calc(var(--bw) * .3) 0;
}
.a-cols { position: relative; display: flex; align-items: flex-end; height: calc(var(--bw) * 4 + var(--bw) * 1.5); }
.a-col { width: var(--bw); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; }
.a-animal {
  width: calc(var(--bw) * 1.3); height: calc(var(--bw) * 1.15); margin: 0 calc(var(--bw) * -0.15); padding: 0; border: none; background: transparent;
  cursor: pointer; display: flex; align-items: flex-end; justify-content: center; position: relative; z-index: 3; -webkit-tap-highlight-color: transparent;
}
.a-animal:disabled { cursor: default; }
.a-animal .a-img { width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; pointer-events: none; }
.a-animal.swapped .a-img { animation: swap .4s ease; }
@keyframes swap { 0% { transform: scale(.4,1.3); opacity: .3; } 60% { transform: scale(1.1,.92); } 100% { transform: none; } }
.a-animal.bounce .a-img { animation: bnc .5s ease 3; }
@keyframes bnc { 50% { transform: translateY(-14%); } }
.a-stack { display: flex; flex-direction: column; }
.ablk { width: var(--bw); height: var(--bw); border-radius: 6px; background: linear-gradient(160deg, #D9BC95, var(--tan) 60%); border: 3px solid var(--ink); animation: pop .35s cubic-bezier(.3,1.6,.5,1) both; }
.ablk.or { background: linear-gradient(160deg, #F08A5D, var(--accent) 60%); }
.a-frame { position: absolute; left: -4px; right: -4px; bottom: -4px; height: calc(var(--bw) * 2 + 8px); border: 3px dashed var(--ink); border-radius: 8px; pointer-events: none; z-index: 4; }
.a-bump-br { position: absolute; right: 0; top: auto; bottom: calc(var(--bw) * 5.3); width: calc(var(--bw) * var(--u)); height: 10px; border: 3px solid var(--accent); border-bottom: none; border-radius: 4px 4px 0 0; z-index: 4; }
.a-bump-br span { position: absolute; top: -26px; left: 50%; transform: translateX(-50%); font-size: 14px; white-space: nowrap; background: var(--paper); padding: 0 4px; }
.finger { position: absolute; left: 50%; top: 30%; width: 46px; height: 46px; pointer-events: none; z-index: 5; }
.finger svg { width: 46px; height: 46px; position: absolute; left: 4px; top: 10px; animation: tap 1.4s ease-in-out infinite; }
.finger .ring { position: absolute; left: -6px; top: -6px; width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--accent); opacity: 0; animation: ring 1.4s ease-out infinite; }
@keyframes tap { 50% { transform: translate(-3px,-5px); } }
@keyframes ring { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(1.4); opacity: 0; } }
.pitta { font-size: 24px; font-weight: 900; color: var(--ink); text-align: center; }
.pitta span { font-size: 18px; }
.qbox { padding: 10px 12px; border-radius: 16px; border: 3px solid var(--ink); background: var(--card); }
.qbox .q { font-size: 19px; font-weight: 900; margin: 0 0 8px; color: var(--ink); }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices .btn { flex: 1 1 90px; }

/* B 大きいかご */
.b-top { display: flex; gap: 8px; align-items: center; }
.b-cage { flex: 0 0 38%; }
.b-cage .cage-svg { width: 100%; height: auto; }
.b-cond .cond { margin: 2px 0; }
.b-cond .t-heads, .b-cond .t-legs { font-size: 16px; }
.num-row { display: flex; gap: 8px; align-items: stretch; }
.btn.pm { flex: 0 0 56px; min-height: 56px; font-size: 26px; padding: 0; }
.numbox { flex: 1; min-height: 56px; border-radius: 16px; border: 3px solid var(--ink); background: #fff; display: flex; align-items: center; justify-content: space-between; padding: 4px 14px; font-weight: 900; cursor: pointer; }
.nb-label { font-size: 16px; }
.nb-val { font-size: 30px; color: var(--ink); min-width: 1.5em; text-align: right; }
.hints { display: flex; flex-direction: column; gap: 8px; }
.hint { padding: 8px 12px; border-radius: 14px; background: var(--card); border: 2.5px dashed var(--ink); }
.hint b { font-size: 14px; color: #9a4a2a; }
.hint p { margin: 4px 0; line-height: 1.55; }
.hint .btn { margin-top: 4px; }
.hint.watch { border-style: solid; background: var(--cream); }
.h1-legs { display: flex; gap: 10px; flex-wrap: wrap; }
.legdemo { display: inline-flex; align-items: center; gap: 6px; }
.legpic { position: relative; display: inline-block; height: 52px; }
.legpic img { height: 52px; width: auto; }
.legdot { position: absolute; width: 14px; height: 14px; margin: -10px 0 0 -7px; border-radius: 50%; background: rgba(255,214,110,.85); box-shadow: 0 0 0 2px rgba(224,102,59,.6); animation: legglow 1.6s ease-in-out infinite; }
@keyframes legglow { 0%, 100% { opacity: .2; } 30% { opacity: 1; } }
.records { padding: 6px 12px; border-radius: 12px; background: rgba(255,255,255,.6); border: 2px solid rgba(58,38,33,.3); }
.rec-title { margin: 2px 0; font-size: 14px; }
.records ol { margin: 0; padding-left: 22px; font-size: 14px; line-height: 1.6; }
.book-ans { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 14px; background: var(--cream); border: 3px solid var(--ink); margin: 6px 0; }
.book-ans img { width: 64px; height: auto; border: 2px solid var(--ink); }
.book-ans .same { font-size: 18px; font-weight: 900; margin: 0 0 4px; color: var(--ink); }
.book-ans .book-read { margin: 0 0 4px; line-height: 1.8; }
.book-ans .src { font-size: 11px; margin: 0; opacity: .8; }

/* C */
.levels { display: flex; flex-direction: column; gap: 10px; }
.btn.level { text-align: left; }
.btn.level b { display: block; font-size: 22px; }
.btn.level small { font-size: 14px; }
.lv-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shop { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 6px; align-items: stretch; margin: 6px 0; }
.basket { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.basket img { height: 58px; width: auto; }
.basket .tag { font-size: 13px; text-align: center; }
.item-card { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 4px 6px; border-radius: 14px; background: var(--card); border: 2.5px solid var(--ink); min-width: 0; text-align: center; }
.item-card b { font-size: 15px; }
.item-card.hl { box-shadow: 0 0 0 4px #FFD25A; }
.item-img { height: 54px; width: auto; }
.item-fallback { display: inline-flex; width: 54px; height: 54px; border-radius: 12px; align-items: center; justify-content: center; background: #fff; border: 2px solid var(--ink); }
.item-card span { font-size: 14px; }
.cq { font-size: 18px; line-height: 1.7; padding: 8px 12px; border-radius: 14px; background: var(--card); border: 2px solid var(--ink); margin: 6px 0; }
.side { font-size: 13px; }
.check { padding: 8px 12px; border-radius: 14px; background: #fff; border: 3px solid var(--ink); }
.check.good { background: var(--cream); }
.check b { font-size: 15px; }
.check p { margin: 4px 0; line-height: 1.6; }
.chk-line { font-size: 19px; color: var(--ink); overflow-wrap: anywhere; display: flex; flex-direction: column; }
.chk-line small { font-size: 14px; color: var(--text); }
.diag .fbk circle { fill: #FFE9C9; stroke: var(--ink); stroke-width: .7; }
.diag .fbk text { font-size: 5.5px; font-weight: 900; text-anchor: middle; fill: var(--ink); }
.mini-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mini-names { display: flex; flex-direction: column; font-size: 14px; }
.mini { height: auto; max-height: 200px; }
.mini .hline { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 2; }
.mini .floor { stroke: var(--ink); stroke-width: 1.4; }
.mini .blk { stroke-width: .6; }
.formula { font-size: 24px; font-weight: 900; color: var(--ink); }

/* D */
.d-inputs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.d-card { margin: 10px 0; padding: 12px; border-radius: 18px; background: var(--card); border: 3px solid var(--ink); }
.d-card .ok { margin: 0; font-size: 22px; font-weight: 900; color: var(--ink); }
.d-q { font-size: 18px; line-height: 1.7; }
.d-ans { font-size: 18px; color: var(--ink); }
.d-fail { margin: 10px 0; }
.dfail-wrap { background: #fff; border-radius: 12px; border: 2px solid rgba(58,38,33,.3); padding: 6px; }
.dfail { width: 100%; height: auto; display: block; }
.dfail .rk { fill: var(--tan); stroke: var(--ink); stroke-width: 1.5; opacity: .9; }
.dfail .ru { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 3; }
.dfail .floor { stroke: var(--ink); stroke-width: 3; }
.dfail .you { stroke: var(--accent); stroke-width: 2.5; }
.dfail-lbl .lk-you { border-color: var(--accent); }

/* 重ねて出す画面 */
.overlay { position: fixed; inset: 0; background: rgba(58,38,33,.35); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 12px; overflow-y: auto; }
.overlay[hidden] { display: none; }
.ov-card { width: min(100%, 680px); max-height: calc(100svh - 24px); overflow-y: auto; background: var(--paper); border: 4px solid var(--ink); border-radius: 22px; padding: 14px; position: relative; }
.ov-card h2 { margin: 0 0 8px; 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.6em; }
.map td.none { color: rgba(58,38,33,.45); font-size: 10px; }
.map td.here { background: #FFE9A8; box-shadow: inset 0 0 0 3px var(--accent); }
.map td.here b { display: block; }
.map td span { display: block; font-size: 10px; line-height: 1.35; }
.map td .url { font-size: 9px; opacity: .7; }
.map-sub { margin: 12px 0 4px; font-weight: 900; color: var(--ink); }
.fields .tag { font-size: 13px; }
.fields .tag.now { background: #FFE9A8; border-color: var(--accent); }
.skills { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; 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); }
.stamps { display: flex; gap: 8px; }
.stamp { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px; border-radius: 50%; aspect-ratio: 1; justify-content: center; border: 3px dashed rgba(58,38,33,.3); opacity: .45; max-width: 120px; }
.stamp img { height: 40px; width: auto; }
.stamp img.strip { height: 46px; }
.stamp.on { opacity: 1; border: 3px solid var(--accent); background: var(--cream); transform: rotate(-6deg); }
.made { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.made li .btn { flex: 0 0 auto; white-space: nowrap; }
.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 { opacity: .7; }
.aha { padding: 12px; border-radius: 18px; background: #FFF6E0; border: 4px solid var(--ink); text-align: center; }
.aha-title { display: inline-block; margin: 0; padding: 2px 16px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 900; }
.aha-text { font-size: 20px; line-height: 1.8; color: var(--ink); font-weight: 900; }
.fbq p { margin: 10px 0 4px; font-weight: 900; }
.family { width: min(100%, 900px); min-height: 70svh; display: flex; flex-direction: column; justify-content: center; }
.family-q { font-size: clamp(24px, 6vw, 44px); line-height: 1.6; color: var(--ink); font-weight: 900; }
.family-pics { display: flex; gap: 20px; justify-content: center; }
.family-pics img { height: 90px; width: auto; }

/* 数字のボタン */
.pad { position: fixed; inset: 0; background: rgba(58,38,33,.25); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.pad[hidden] { display: none; }
.pad-sheet { width: min(100%, 520px); background: var(--paper); border: 4px solid var(--ink); border-bottom: none; border-radius: 22px 22px 0 0; padding: 12px 12px calc(14px + env(safe-area-inset-bottom)); }
.pad-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pad-label { font-size: 17px; font-weight: 900; }
.pad-val { font-size: 34px; color: var(--ink); min-width: 2em; text-align: right; }
.pad-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key { min-height: 58px; border-radius: 16px; border: 3px solid var(--ink); background: #fff; font-size: 26px; font-weight: 900; cursor: pointer; }
.key.sub { font-size: 17px; }
.key.ok { background: var(--cream); font-size: 19px; }

@media (min-width: 900px) {
  :root { --bw: 72px; }
  .btn.main { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.reduce * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
