/* ちりトレ：紙と深緑、伝票を読んで地図へ出荷する。 */
:root {
  --paper: #f5f4ed;
  --stage: #eef3e9;
  --line: #d6ded0;
  --ink: #233e3a;
  --sub: #637570;
  --brand: #244f45;
  --brand-dark: #183a32;
  --amber: #c9802b;
  --land: #f7faf6;
  --land-line: #819b88;
  --done: #8ac5b4;
  --ok: #2d887b;
  --ok-soft: #e3f1dd;
  --ng: #8b5528;
  --ng-soft: #f6e5ce;
  --gold: #d6a249;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); }
body { overscroll-behavior: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
#frame { position: fixed; inset: 0; background: var(--paper); }
#boot-fail { position: fixed; inset: auto 0 40% 0; text-align: center; color: var(--ink); }
button:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

.screen {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center;
  padding: calc(var(--safe-t) + 10px) 12px calc(var(--safe-b) + 12px);
  max-width: 560px; margin: 0 auto; overflow-y: auto;
}
.screen.active { display: flex; }
.screen > :first-child { margin-top: auto; }
.screen > :last-child { margin-bottom: auto; }
.screen.game { max-width: 1180px; gap: 10px; padding-left: 14px; padding-right: 14px; }
.screen.game > :first-child, .screen.game > :last-child { margin-top: 0; margin-bottom: 0; }

.eyebrow { margin: 0; font-size: 10px; letter-spacing: 2px; font-weight: 800; color: #648579; }
.helper { margin: 0; font-size: 12px; line-height: 1.7; color: #718070; }

/* ---- ボタン ---- */
.btn {
  font: inherit; font-weight: 700; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid #d6ddd6; border-radius: 12px; padding: 10px 18px; min-height: 46px;
  box-shadow: 0 3px 0 #c8d3c8; cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c8d3c8; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 0 var(--brand-dark); }
.btn.primary:active { box-shadow: 0 1px 0 var(--brand-dark); }
.btn.big { font-size: 22px; padding: 14px 44px; border-radius: 16px; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; }


.kmap { width: 100%; height: 100%; display: block; overflow: visible; }
.kmap .pref { fill: var(--land); stroke: var(--land-line); stroke-width: 3; stroke-linejoin: round; transition: fill .3s; }
.kmap-inset { fill: none; stroke: #9fb3a5; stroke-width: 3; stroke-dasharray: 8 8; }
.pref-label { font-size: 34px; font-weight: 800; text-anchor: middle; dominant-baseline: middle; fill: #304e42; stroke: #fff; stroke-width: 6px; paint-order: stroke; pointer-events: none; }

.hud { width:100%; display:flex; align-items:center; gap:8px; }
.hud-title { margin-right: auto; display: flex; flex-direction: column; line-height: 1.2; }
.hud-title small { font-size: 10px; letter-spacing: 1px; font-weight: 800; color: #648579; }
.hud-title b { font-size: 20px; letter-spacing: -.5px; white-space: nowrap; }
/* 地方を選ぶ所：地方名の上に見えない選択欄を重ねる（画面の大きさ・形は変えない） */
.hud-title { position: relative; }
.hud-title b::after { content: ' ▾'; font-size: .65em; color: #648579; }
#region-select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
.hud-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px 10px; text-align: center; min-width: 60px; }
.hud-item small { display: block; font-size: 10px; color: var(--sub); }
.hud-item b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---- 舞台（案Aの外枠） ---- */
.stage { width: 100%; background: var(--stage); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 12px 30px rgba(43, 73, 48, .05); flex-shrink: 0; }
.stage-top { display: flex; justify-content: space-between; padding: 10px 18px; border-bottom: 1px solid #d0dccc; font-size: 12px; color: var(--sub); }
.board { display: grid; grid-template-columns: 1fr; gap: 14px; padding: 14px; }
.board-side, .board-main { min-width: 0; position: relative; }
.board-side h3 { margin: 0 0 4px; font-size: 15px; }
@media (min-width: 760px) {
  .board { grid-template-columns: minmax(0, 42fr) minmax(0, 58fr); gap: 22px; padding: 20px 22px; }
  .board-side .map-box, .map-station .map-box { height: min(52vh, 380px); }
  .sort-board .map-station .map-box { height: min(46vh, 340px); }
  .board-side h3 { font-size: 17px; }
}

/* ---- 物流：地図型出口 ---- */
.sort-board { min-height: 0; }
.map-station .map-box { height: min(30vh, 250px); }
#s-sorter .kmap .pref { fill: #e3e9e1; stroke: #a9b9ab; }
#s-sorter .kmap .pref.exit-on { fill: #fff7e2; stroke: var(--brand); stroke-width: 6; cursor: pointer; }
#s-sorter .kmap .pref.hit { fill: var(--done); }
/* 物流：届いた県が地図の上でぽんと弾み、緑に光る（--sent は続けて正解するほど大きくなる倍率） */
#s-sorter .kmap .pref.sent { transform-box: fill-box; transform-origin: center; animation: sort-sent .8s cubic-bezier(.2,.9,.3,1.2); }
@keyframes sort-sent {
  0% { transform: scale(1); fill: var(--done); }
  35% { transform: scale(var(--sent, 1.1)); fill: var(--done); stroke: #fffef0; stroke-width: 9; filter: brightness(1.05) drop-shadow(0 6px 8px rgba(30, 60, 50, .35)); }
  75% { transform: scale(1); fill: var(--done); }
  100% { transform: scale(1); }
}
/* 物流：県の上に出る文字（地図の中の文字。--px は画面の1pxにあたる地図の目盛り） */
.kmap .map-pop {
  font-size: calc(30px * var(--px)); font-weight: 900; text-anchor: middle; dominant-baseline: middle; pointer-events: none;
  fill: #c9f0dc; stroke: var(--brand-dark); stroke-width: calc(8px * var(--px)); stroke-linejoin: round; paint-order: stroke fill;
  transform-box: fill-box; transform-origin: center; animation: map-pop 1.1s ease-out forwards;
}
@keyframes map-pop { 0% { transform: scale(.4); opacity: 0; } 15% { transform: scale(1.12); opacity: 1; } 30% { transform: scale(1); } 80% { opacity: 1; } 100% { transform: translateY(calc(-30px * var(--px))); opacity: 0; } }
/* 上のコンボの数字：正解のたびに弾み、3つ続くと金色になる */
#s-sorter .hud-item.bump b { display: inline-block; animation: combo-bump .35s cubic-bezier(.2,.9,.3,1.4); }
#s-sorter .hud-item.hot { background: #fff4d8; border-color: var(--gold); box-shadow: 0 0 0 2px #f6dc8f; }
#s-sorter .hud-item.hot b { color: #9a6413; }
@keyframes combo-bump { 40% { transform: scale(1.45); } }
/* 上ののこり時間：10秒を切ると赤くなり、1秒ごとに弾む */
#s-sorter .hud-item.hurry { background: #fde6df; border-color: #c8553d; box-shadow: 0 0 0 2px #f2b6a6; }
#s-sorter .hud-item.hurry b { color: #b23a22; }
#s-sorter .kmap .pref.answer { fill: #f2d59a; animation: blink .3s 3; }
#s-sorter .kmap.reveal .pref.exit-on { fill: #e3e9e1; stroke: #a9b9ab; stroke-width: 3; }
#s-sorter .kmap.reveal .pref.answer { fill: var(--gold); stroke: #8a5a12; stroke-width: 10; }
/* 沖縄は島が小さく、太いふちだと金色が隠れて茶色の点に見えるので、ふちを細くする */
#s-sorter .kmap.reveal .pref.answer[data-pref=okinawa] { stroke-width: 2; }
#s-sorter .kmap .pref-label.answer { font-size: 46px; font-weight: 900; }
/* 物流：ちがう県へ送ったとき、送ってしまった県は茶色でふちどって横にぷるっと揺れる（正解の県は金色のまま） */
#s-sorter .kmap.reveal .pref.wrong { fill: var(--ng-soft); stroke: var(--ng); stroke-width: 10; transform-box: fill-box; transform-origin: center; animation: wrong-shake .5s ease-out; }
@keyframes blink { 50% { filter: brightness(1.15); } }
/* 答えのボタン：いつも2行2列・高さ56px以上。答えの種類は色だけでなく形で見分ける */
.gate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.gate {
  position: relative; font: inherit; font-size: 15px; font-weight: 800; color: var(--ink); cursor: pointer;
  background: #fff; border: 1px solid #d6ddd6; border-radius: 10px; box-shadow: 0 3px 0 #c8d3c8;
  min-height: 56px; padding: 6px 8px; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .12s, opacity .2s; line-height: 1.25; overflow-wrap: anywhere;
}
.gate:active { transform: translateY(2px); }
/* 県：角のある四角、県の色の下線と◈ */
.gate.k-pref { border-bottom: 4px solid var(--pref); }
.gate .pref-symbol { color: var(--pref); font-size: 14px; }
/* ことば：丸い札（両はしが丸い）、伝票と同じクリーム色と茶色のふち */
.gate.k-word { border-radius: 999px; background: #fffcf2; border: 2px solid #b68d58; box-shadow: 0 3px 0 #d8b17c; padding: 6px 14px; }
/* 順位：左に番号の入る丸（押すと1・2が入る）、点線のふち */
.gate.k-rank { border: 2px dashed #7f9c8d; border-bottom: 4px solid var(--pref); justify-content: flex-start; padding-left: 10px; }
.gate .rank-slot {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; border: 2px dashed #9fb3a5; background: #f4f7f2;
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 900; color: #fff;
}
.gate .rank-slot.filled { border: 2px solid var(--brand-dark); background: var(--brand); }
.gate .rank-slot.answer { border-color: #8a5a12; background: var(--gold); color: #3c2a08; }
/* 段階2 ふたつ選ぶ：左に四角い番号の枠（押した順に1・2が入る）。県なら県のボタン、ことばなら丸い札の形のまま */
.gate.k-pick2.t-pref { border-bottom: 4px solid var(--pref); justify-content: flex-start; padding-left: 10px; }
.gate.k-pick2.t-word { border-radius: 999px; background: #fffcf2; border: 2px solid #b68d58; box-shadow: 0 3px 0 #d8b17c; justify-content: flex-start; padding: 6px 12px 6px 10px; text-align: left; }
.gate .pick-slot {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 5px; border: 2px dashed #9fb3a5; background: #f4f7f2;
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 900; color: #fff;
}
/* 1つ目（と2つ目）を選ぶと、太いふちと番号 */
.gate.k-pick2.picked { border: 4px solid var(--brand-dark); background: #fff7e2; }
.gate.k-pick2.t-pref.picked { border-bottom-color: var(--pref); }
.gate.k-pick2.picked .pick-slot { border: 2px solid var(--brand-dark); background: var(--brand); }
/* 段階2 光った県：特徴のボタンは、角の丸い札（ことばの丸い札とも、県の四角とも別の形）と左の◉ */
.gate.k-spot { border-radius: 16px; background: #fffcf2; border: 2px solid var(--gold); box-shadow: 0 3px 0 #e2c27e; justify-content: flex-start; padding: 6px 10px; text-align: left; }
.gate.k-spot::before { content: '◉'; color: #b07a1c; font-size: 14px; flex: 0 0 auto; }
#s-sorter .kmap .pref.spot { fill: #ffd76a; stroke: #8a5a12; stroke-width: 8; animation: spot-glow 1.2s ease-in-out infinite; }
#s-sorter .kmap .pref.spot[data-pref=okinawa] { stroke-width: 3; }
@keyframes spot-glow { 50% { fill: #ffe9a8; filter: drop-shadow(0 0 6px rgba(214, 162, 73, .9)); } }
.kmap .pref-label.spot-hide { visibility: hidden; }
.kmap .spot-q { display: none; font-size: 46px; font-weight: 900; text-anchor: middle; dominant-baseline: middle; fill: #8a5a12; stroke: #fff; stroke-width: 7px; paint-order: stroke; pointer-events: none; }
.kmap .spot-q.on { display: inline; }
.gate.hit { transform: scale(1.04); border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok); }
.gate.answer { animation: blink .3s 3; box-shadow: 0 0 0 4px var(--gold); opacity: 1; }
.gate.wrong { box-shadow: 0 0 0 4px var(--ng); }
.gate.answer::after, .gate.wrong::after { position: absolute; top: -9px; right: -6px; font-size: 18px; font-weight: 900; line-height: 1; background: #fff; border-radius: 50%; padding: 1px 3px; }
.gate.answer::after { content: '○'; color: #8a5a12; }
.gate.wrong::after { content: '×'; color: var(--ng); }
/* 答えの種類が前と変わったら、ボタンが先に弾んで知らせる（その間は1問の時間を止めている） */
.gate-grid.switching .gate { animation: gate-switch .5s ease-out; }
@keyframes gate-switch { 0% { transform: scale(.86); opacity: .2; } 60% { transform: scale(1.04); opacity: 1; } 100% { transform: scale(1); } }
/* 順位：押した県と番号（地図の中の文字。--px は画面の1pxにあたる地図の目盛り） */
#s-sorter .kmap .pref.picked { fill: #ffe9b8; stroke: var(--brand-dark); stroke-width: 8; }
.kmap .rank-badge circle { fill: var(--brand); stroke: #fff; stroke-width: calc(3px * var(--px, 1)); }
.kmap .rank-badge text { font-size: calc(17px * var(--px)); font-weight: 900; fill: #fff; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.kmap .rank-badge.answer circle { fill: var(--gold); stroke: #8a5a12; }
.kmap .rank-badge.answer text { fill: #3c2a08; }
.kmap .rank-badges, .kmap .word-cards, .kmap .card-links { pointer-events: none; }
/* ことば：正解すると、地図の県にカードがたまる */
.kmap .word-card rect { fill: #fffcf2; }
.kmap .word-card text { font-weight: 800; fill: #4b3518; text-anchor: middle; dominant-baseline: central; }
.kmap .card-link line { stroke-linecap: round; }
.kmap .word-card.arriving, .kmap .card-link.arriving { opacity: 0; }
.flies { position: fixed; inset: 0; pointer-events: none; z-index: 11; }
.word-fly { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-size: 15px; font-weight: 900; color: #4b3518; background: #fffcf2; border: 2px solid #b68d58; border-radius: 999px; padding: 6px 14px; box-shadow: 0 6px 14px rgba(60, 40, 10, .25); }
.dispatch { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.belt { width: 100%; }
.parcel {
  position: relative; background: #d8b17c; border: 1px solid #b68d58; border-radius: 12px; padding: 14px 16px 20px;
  box-shadow: 0 7px 0 #c09a68; max-width: 440px; margin: 0 auto; animation: arrive .22s ease-out;
}
.parcel-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 22px; }
/* 種類のタグ：ボタンと同じ形（県＝四角と◈、ことば＝丸い札、順位＝①→②） */
.kind-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 900; color: var(--brand-dark); background: #fff; border: 1px solid #b68d58; border-radius: 4px; padding: 2px 8px; }
.kind-tag[data-kind=pref]::before { content: '◈'; color: var(--brand); }
.kind-tag[data-kind=word] { border-radius: 999px; background: #fffcf2; border-width: 2px; }
.kind-tag[data-kind=rank] { border-style: dashed; border-color: var(--brand); }
.kind-tag[data-kind=rank]::before { content: '①→②'; letter-spacing: -1px; margin-right: 2px; }
.kind-tag[data-kind=pick2] { border-width: 2px; }
.kind-tag[data-kind=pick2]::before { content: '▢▢'; letter-spacing: -1px; margin-right: 2px; color: var(--brand); }
.kind-tag[data-kind=spot] { border-radius: 8px; border-color: var(--gold); background: #fff7e2; }
.kind-tag[data-kind=spot]::before { content: '◉'; color: #b07a1c; }
.stat-line { font-size: 12px; font-weight: 800; color: #4b3518; background: #fffcf2; border-radius: 4px; padding: 2px 6px; }
.stat-line[hidden] { display: none; }
.parcel-title { display: flex; align-items: center; gap: 12px; margin: 8px 0 10px; }
.parcel-title i { font-style: normal; font-size: 32px; line-height: 1; }
.parcel-title b { font-size: 24px; font-weight: 900; }
.parcel-title b.long { font-size: 19px; }
.condition { background: #fffcf2; padding: 12px 14px; border-radius: 6px; }
.condition small { display: block; color: #9d7942; font-size: 10px; margin-bottom: 6px; }
.condition .item-condition { font-size: 17px; line-height: 1.6; font-weight: 800; text-align: left; color: var(--ink); }
.ptimer { position: absolute; left: 16px; right: 16px; bottom: 8px; height: 5px; background: rgba(90, 60, 25, .25); border-radius: 99px; overflow: hidden; text-decoration: none; }
.ptimer u { display: block; height: 100%; background: var(--brand); transform-origin: left; }
@keyframes arrive { from { transform: translateY(10px) rotate(-1deg); opacity: 0; } }
.parcel.fly { transition: transform .25s ease-in, opacity .25s; transform: translateX(-40%) scale(.6) rotate(-6deg); opacity: 0; }
.parcel.shake { animation: shake .35s 2; }
.sort-hint { margin: 0; text-align: center; color: var(--sub); font-size: 12px; line-height: 1.7; }
.sort-hint[hidden] { display: none; }
/* 2026-10-31 見やすさ点検（iPhone SE 縦）：「残り時間・正答数・コンボ」が10px、問題の下の「ボタンをタップ！」が11pxで読みにくかった。12pxにする（ファイルの末尾に置くと idea-lab-1102 の試作差分が当たらなくなるため、ここに置く）。 */
.hud-item small { font-size: 12px; }
#s-sorter .sort-hint { font-size: 12px; }
@media (max-width: 759px) {
  .sort-board .dispatch { order: -1; }
  .parcel { padding: 10px 12px 18px; }
  .parcel-title { margin: 4px 0 8px; }
  .parcel-title b { font-size: 20px; }
  .condition { padding: 9px 11px; }
  .condition .item-condition { font-size: 15px; }
}

/* ---- タイトル：海に浮かぶ色付き地図（主役）＋飾りロゴ＋3メニュー ----
   色の役割：世界＝方眼の紙と水色の海／主役＝県の色と白い県名／操作＝黄色の「問題スタート」／
   名札＝赤いテープ（地理トレーニング）と荷札（地方名）／縁と厚み＝深緑。
   縦：上に地図、下にロゴとボタン。横：左に地図、右にロゴとボタン。どちらもスクロールなし。 */
#s-title, .book { max-width:none; background: linear-gradient(#e7ece3 1px,transparent 1px) 0 0/28px 28px, linear-gradient(90deg,#e7ece3 1px,transparent 1px) 0 0/28px 28px; }
#s-title {
  overflow: hidden; overflow: clip; justify-content: center;
  /* 地図の大きさ：画面の高さからロゴとボタンの分を引いた残り */
  --map: max(96px, min(92vw, 560px, calc(100vh - 446px - var(--safe-t) - var(--safe-b))));
}
@supports (height: 100dvh) {
  #s-title { --map: max(96px, min(92vw, 560px, calc(100dvh - 446px - var(--safe-t) - var(--safe-b)))); }
}
#s-title > .title-wrap { margin: auto 0; }
.title-wrap { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.title-side { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }

/* 地図の舞台：後ろの光（ゆっくり回る）→ 海の円盤 → 地図（ふわふわ浮く） */
.title-stage { position: relative; width: var(--map); aspect-ratio: 1; flex: none; }
.title-rays {
  position: absolute; inset: -16%; border-radius: 50%; pointer-events: none;
  background-image: repeating-conic-gradient(from 0deg, rgba(255, 214, 92, .38) 0deg 7deg, transparent 7deg 18deg);
  -webkit-mask-image: radial-gradient(circle, #000 34%, transparent 70%); mask-image: radial-gradient(circle, #000 34%, transparent 70%);
  animation: fade-in .8s .1s backwards;
}
.title-sea {
  position: absolute; inset: 3%; border-radius: 50%;
  background-image:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .85), rgba(255, 255, 255, 0) 38%),
    radial-gradient(circle at 50% 45%, #e6f6fa, #c6e8f1 62%, #a6d9e6);
  border: 4px solid #fff;
  box-shadow: 0 0 0 3px #7fb9c7, 0 9px 0 3px #6aa6b5, 0 18px 26px rgba(30, 70, 80, .28);
  animation: sea-in .6s cubic-bezier(.2, .9, .3, 1.25) backwards;
}
@keyframes sea-in { from { opacity: 0; transform: scale(.6); } }
.title-map { position: absolute; inset: 5%; animation: float 4.6s ease-in-out .8s infinite; will-change: transform; }
@keyframes float { 50% { transform: translateY(-7px) rotate(-1.2deg); } }
.title-map .kmap { overflow: visible; }
.title-map .kmap .pref {
  stroke: #fff; stroke-width: 3; transform-box: fill-box; transform-origin: center;
  animation: pref-in .5s cubic-bezier(.2, .9, .3, 1.4) calc(.25s + var(--i, 0) * 70ms) backwards;
}
.title-map .kmap-inset { stroke: #fff; stroke-width: 4; opacity: .9; }
.title-map .pref-label {
  font-size: 40px; font-weight: 900; fill: #fff; stroke: rgba(20, 44, 38, .7); stroke-width: 8px; paint-order: stroke fill;
  transform-box: fill-box; transform-origin: center;
  animation: label-in .35s cubic-bezier(.2, .9, .3, 1.6) calc(.6s + var(--i, 0) * 70ms) backwards;
}
@keyframes pref-in { from { transform: scale(.4); opacity: 0; } }
@keyframes label-in { from { transform: scale(.2); opacity: 0; } }
/* 荷物が届いた県：ぴょんと跳ねて明るくなる。白い波紋と、上から落ちる段ボール */
/* 波紋と荷物は地図の上に重ねた別の層で動かす（地図そのものは描き直さない。動かすのは位置と濃さだけ） */
.title-fx { position: absolute; inset: 0; pointer-events: none; }
.title-fx > div { position: absolute; width: 0; height: 0; }
.title-fx .ring {
  position: absolute; left: calc(var(--map) * -.07); top: calc(var(--map) * -.07); width: calc(var(--map) * .14); height: calc(var(--map) * .14);
  border-radius: 50%; border: 3px solid #fff; animation: ring 1.1s ease-out .35s both;
}
@keyframes ring { from { transform: scale(.3); opacity: .95; } to { transform: scale(1.8); opacity: 0; } }
.title-fx .parcel-drop {
  position: absolute; left: calc(var(--map) * -.035); top: calc(var(--map) * -.1); width: calc(var(--map) * .07); height: calc(var(--map) * .07);
  animation: parcel-drop 1.25s cubic-bezier(.4, 0, .6, 1) both;
}
.title-fx .parcel-drop svg { width: 100%; height: 100%; display: block; overflow: visible; }
@keyframes parcel-drop {
  0% { transform: translateY(-80px); opacity: 0; }
  12% { opacity: 1; }
  30% { transform: translateY(0) scale(1.15, .8); }
  40% { transform: translateY(-5px) scale(.95, 1.06); }
  52%, 78% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-2px) scale(.6); opacity: 0; }
}

/* ロゴ：赤いテープ「地理トレーニング」＋立体「ちりトレ！」 */
.logo {
  position: relative; z-index: 2; margin: calc(var(--map) * -.07) 0 0; display: flex; flex-direction: column; align-items: center;
  line-height: 1; transform: rotate(-3deg);
}
.logo-sub {
  position: relative; z-index: 1; font-size: 13px; letter-spacing: .3em; text-indent: .3em; color: #fff; font-weight: 900;
  background: linear-gradient(#f2704f, #d9452f); padding: 5px 18px 6px; margin-bottom: -4px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 50%, 100% 100%, 0 100%, 9px 50%);
  filter: drop-shadow(0 3px 0 #8f2a22);
  animation: tape-in .45s cubic-bezier(.2, .9, .3, 1.3) .35s backwards;
}
@keyframes tape-in { from { transform: translateX(-40px) scaleX(.4); opacity: 0; } }
.logo-main {
  display: flex; align-items: flex-end; font-size: clamp(54px, 17vw, 84px); font-weight: 900; letter-spacing: -.03em;
  animation: logo-drop .6s cubic-bezier(.2, .9, .3, 1.35) .45s backwards;
}
.logo-main > span { position: relative; display: inline-block; }
/* 本体：深緑の縁と、下へ7段の厚み */
.logo-word, .logo-bang {
  color: #ffd23f; -webkit-text-stroke: 5px #183a32; paint-order: stroke fill;
  text-shadow:
    0 1px 0 #2f7a62, 0 2px 0 #2f7a62, 0 3px 0 #286a55, 0 4px 0 #286a55, 0 5px 0 #21594a,
    0 6px 0 #1a4a3e, 0 7px 0 #183a32, 0 8px 0 #183a32, 0 14px 14px rgba(24, 58, 50, .35);
}
/* 面：上は白、下は黄色のグラデーション。厚みの影と混ざらないよう、上に同じ字を重ねて塗る */
.logo-word::before, .logo-bang::before, .logo-word::after, .logo-bang::after {
  content: attr(data-text); position: absolute; inset: 0; color: transparent; -webkit-text-stroke: 0; text-shadow: none;
  -webkit-background-clip: text; background-clip: text; pointer-events: none;
}
.logo-word::before { background-image: linear-gradient(#fff4b8 8%, #ffd23f 48%, #ffb800 92%); }
.logo-bang { margin-left: -.32em; transform: rotate(10deg) translateY(-.02em); transform-origin: 50% 90%; animation: bang 2.8s ease-in-out 1.4s infinite; }
.logo-bang::before { background-image: linear-gradient(#ffb39a 20%, #ff6a3d 60%, #e8432e); }
@keyframes bang { 0%, 70%, 100% { transform: rotate(10deg); } 78% { transform: rotate(-4deg) scale(1.12); } 86% { transform: rotate(14deg); } }
/* 流れる光 */
.logo-word::after, .logo-bang::after {
  background-image: linear-gradient(110deg, transparent 38%, rgba(255, 255, 255, .95) 48%, transparent 58%);
  background-size: 260% 100%; background-position: 130% 0;
}
@keyframes shine { from { background-position: 130% 0; } to { background-position: -130% 0; } }
#s-title.shining .logo-word::after, #s-title.shining .logo-bang::after { animation: shine 1.3s ease-in-out both; }
@keyframes logo-drop { from { transform: translateY(-36px) scale(1.25); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

/* メニュー：主は黄色で大きく。下の2つは段ボール色で横に並べ、件数を札で出す */
.title-menu { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-btn {
  position: relative; font: inherit; color: var(--ink); cursor: pointer; min-height: 62px; padding: 8px 10px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #fffcf2; border: 3px solid #b68d58; border-radius: 16px; box-shadow: 0 5px 0 #c9a06b;
  transition: transform .08s, box-shadow .08s, filter .08s;
  animation: btn-in .45s cubic-bezier(.2, .9, .3, 1.3) 1.05s backwards;
}
.menu-row .menu-btn { animation-delay: 1.15s; }
.menu-row .menu-btn + .menu-btn { animation-delay: 1.22s; }
@keyframes btn-in { from { transform: translateY(18px) scale(.9); opacity: 0; } }
.menu-text, .menu-ico, .menu-count { position: relative; z-index: 1; }
.menu-text { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.menu-btn b { display: block; font-size: 18px; font-weight: 900; white-space: nowrap; }
.menu-btn small { display: block; font-size: 11px; color: #8a6a3c; font-weight: 800; white-space: nowrap; }
.menu-count {
  flex: none; min-width: 40px; padding: 4px 7px; border-radius: 99px; background: #244f45; color: #fff;
  font-size: 14px; font-weight: 900; font-variant-numeric: tabular-nums; box-shadow: 0 2px 0 #183a32;
}
#title-weak.has .menu-count { background: #f08a24; box-shadow: 0 2px 0 #a3570e; }
#title-weak.has small { color: #c0620b; }
.menu-btn:active { transform: translateY(4px) scale(.97); box-shadow: 0 1px 0 #c9a06b; }
.menu-btn.primary {
  min-height: 78px; padding: 8px 16px; gap: 12px; border-radius: 22px;
  background: linear-gradient(#ffe27a, #ffc93a 55%, #f5ac1c); border-color: #183a32; color: #183a32;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .7), inset 0 -4px 0 rgba(176, 102, 8, .35), 0 7px 0 #183a32, 0 14px 18px rgba(24, 58, 50, .25);
  animation-delay: .95s;
}
.menu-btn.primary b { font-size: 27px; letter-spacing: .02em; }
.menu-btn.primary small { color: #6b4708; font-size: 12px; }
.menu-btn.primary:active { transform: translateY(6px) scale(.97); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .7), 0 1px 0 #183a32; filter: brightness(1.05); }
.menu-ico { width: 44px; height: 44px; flex: none; animation: ico-hop 2.4s ease-in-out 2s infinite; }
@keyframes ico-hop { 0%, 60%, 100% { transform: none; } 70% { transform: translateY(-6px) rotate(-8deg); } 80% { transform: translateY(0) scale(1.1, .9); } }
/* 押したくなる光：ボタンの形はそのまま、上を光が通り、まわりの輪が広がって消える */
.menu-btn.primary::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background-image: linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, .6) 50%, transparent 58%);
  background-size: 300% 100%; background-position: 130% 0;
}
.menu-btn.primary::before {
  content: ''; position: absolute; inset: -6px; border-radius: 28px; pointer-events: none;
  box-shadow: 0 0 0 4px rgba(255, 201, 58, .75), 0 0 18px 6px rgba(255, 201, 58, .55);
  opacity: 0; will-change: opacity; animation: halo 2.4s ease-in-out 2s 3;
}
@keyframes halo { 50% { opacity: 1; } }
#s-title.shining .menu-btn.primary::after { animation: shine 1.1s ease-in-out .5s both; }
/* 版はタイトル画面の右下に小さく（ボタンの流れから外す） */
#s-title .version { position: absolute; right: calc(10px + env(safe-area-inset-right, 0px)); bottom: calc(var(--safe-b) + 6px); margin: 0; text-align: right; }

/* 縦で低い画面（iPhone SE など）：ロゴとボタンを少し詰めて、地図の場所を残す */
@media (max-height: 700px) and (max-aspect-ratio: 4/3) {
  #s-title { --map: max(96px, min(86vw, 370px, calc(100vh - 372px - var(--safe-t) - var(--safe-b)))); padding-top: calc(var(--safe-t) + 6px); padding-bottom: calc(var(--safe-b) + 8px); }
  @supports (height: 100dvh) { #s-title { --map: max(96px, min(86vw, 370px, calc(100dvh - 372px - var(--safe-t) - var(--safe-b)))); } }
  .logo-main { font-size: clamp(42px, 13vw, 60px); }
  .logo-sub { font-size: 11px; padding: 4px 14px 5px; }
  .title-side { gap: 5px; }
  .title-menu { gap: 7px; }
  .menu-row { gap: 7px; }
  .menu-btn { min-height: 56px; padding: 4px 8px; }
  .menu-btn.primary { min-height: 62px; }
  .menu-btn.primary b { font-size: 22px; }
  .menu-ico { width: 34px; height: 34px; }
  .menu-btn b { font-size: 16px; }
  .menu-btn small { font-size: 10px; }
  .menu-count { min-width: 34px; font-size: 12px; padding: 3px 5px; }
  #s-title .version { margin-top: 2px; font-size: 10px; }
}
@media (max-height: 520px) and (max-aspect-ratio: 4/3) {
  #s-title { --map: max(80px, calc(100dvh - 362px)); }
  .logo-sub { display: none; }
}
@media (max-width: 360px) {
  .menu-row .menu-btn { flex-direction: column; gap: 2px; }
  .menu-row .menu-btn small { display: none; }
}

/* 横（スマホ横・iPad横・PC）：左に地図、右にロゴとボタン */
@media (min-aspect-ratio: 4/3) {
  #s-title {
    padding: calc(var(--safe-t) + 8px) calc(12px + env(safe-area-inset-right, 0px)) calc(var(--safe-b) + 8px) calc(12px + env(safe-area-inset-left, 0px));
    /* 地図の幅は、iPhone 横のノッチ側の余白（左右）を引いた残りの48% */
    --safe-x: calc(env(safe-area-inset-left, 0px) + env(safe-area-inset-right, 0px));
    --map: min(calc((100vw - var(--safe-x)) * .48), 560px, calc(100vh - 24px - var(--safe-t) - var(--safe-b)));
  }
  @supports (height: 100dvh) { #s-title { --map: min(calc((100vw - var(--safe-x)) * .48), 560px, calc(100dvh - 24px - var(--safe-t) - var(--safe-b))); } }
  .title-wrap { max-width: none; flex-direction: row; justify-content: center; gap: clamp(12px, 3vw, 40px); }
  .title-side { flex: 0 1 400px; min-width: 0; }
  .logo { margin-top: 0; }
}
@media (min-aspect-ratio: 4/3) and (max-height: 500px) {
  .title-side { gap: 5px; flex-basis: 360px; }
  .logo-main { font-size: clamp(40px, 7.4vw, 60px); }
  .logo-sub { font-size: 11px; padding: 4px 14px 5px; }
  .title-menu { gap: 7px; margin-top: 2px; }
  .menu-row { gap: 7px; }
  .menu-btn { min-height: 56px; padding: 4px 8px; }
  .menu-btn.primary { min-height: 60px; }
  .menu-btn.primary b { font-size: 22px; }
  .menu-ico { width: 32px; height: 32px; }
  .menu-btn b { font-size: 15px; }
  .menu-btn small { font-size: 10px; }
  .menu-count { min-width: 34px; font-size: 12px; padding: 3px 5px; }
  #s-title .version { margin-top: 0; font-size: 10px; }
}
@media (min-aspect-ratio: 4/3) and (max-height: 400px) {
  .menu-row .menu-btn { gap: 5px; padding: 4px 6px; }
  .menu-row .menu-btn b { font-size: 14px; }
  .menu-row .menu-count { min-width: 30px; }
  .menu-row .menu-btn small { display: none; }
}
@media (min-aspect-ratio: 4/3) and (max-height: 340px) {
  .logo-sub { display: none; }
  .logo-main { font-size: clamp(36px, 6.6vw, 48px); }
  /* iPhone SE（初代）横などノッチ側の余白で右が狭いとき：件数の札を文字の下へ回して幅を詰める */
  .menu-row .menu-btn { flex-direction: column; gap: 2px; }
}

/* ---- 苦手リスト・問題リスト ---- */
.book-card { width:100%; max-width:640px; background:#fff; border:1px solid var(--line); border-radius:20px; padding:16px 14px; box-shadow:0 12px 30px #2b493010; }
.book-head { display:flex; align-items:center; gap:12px; margin-bottom:8px; }
.book-head h1 { margin:0; font-size:20px; }
.book-empty { margin:28px 0; text-align:center; font-size:16px; line-height:1.8; color:var(--sub); font-weight:700; }
.book-list { list-style:none; margin:10px 0 0; padding:0; }
.book-list li { padding:12px 2px; border-top:1px solid var(--line); line-height:1.6; overflow-wrap:anywhere; }
.q-head { display:flex; align-items:center; gap:8px; }
.q-note { font-size:12px; color:var(--ng); font-weight:700; }
.q-text { margin:6px 0 4px; font-size:15px; font-weight:700; }
.q-answer { display:block; color:var(--brand); font-size:15px; margin-bottom:4px; }
.q-answer[hidden] { display:none; }
.q-acts { display:flex; flex-wrap:wrap; gap:8px; margin-top:6px; }

/* 結果は集計と再挑戦を先に、復習の一覧は全件読めるようにする。 */
#s-result { max-width:none; background: linear-gradient(#e7ece3 1px,transparent 1px) 0 0/28px 28px, linear-gradient(90deg,#e7ece3 1px,transparent 1px) 0 0/28px 28px; }
.result { width:100%; max-width:560px; background:#fff; border:1px solid var(--line); border-radius:20px; padding:22px 18px; text-align:center; box-shadow:0 12px 30px #2b493010; }
.result h1 { margin:0 0 14px; font-size:16px; color:var(--sub); }
.res-summary p { margin:3px 0; font-size:clamp(24px,5vw,34px); font-weight:900; font-variant-numeric:tabular-nums; }
#res-correct { color:var(--brand); }
.res-btns { display:flex; flex-direction:column; gap:12px; align-items:center; margin:18px 0 12px; }
.res-study-actions { min-height:40px; display:flex; flex-wrap:wrap; gap:10px; justify-content:center; }
.res-review { background:var(--ng-soft); border-radius:12px; padding:12px; text-align:left; }
.res-review h2 { font-size:14px; margin:0 0 6px; color:var(--ng); }
#res-miss { list-style:none; margin:0; padding:0; font-size:14px; }
#res-miss li { padding:8px 0; border-top:1px solid #dfcbae; line-height:1.6; overflow-wrap:anywhere; }
#res-miss p { margin:0 0 3px; }
#res-miss strong { color:var(--brand); }
/* 版の表示はタイトル画面の下だけに出す（遊んでいる間の答えのボタンに重ねない） */
.version { margin-top:10px; text-align:center; color:var(--sub); font-size:11px; pointer-events:none; position:relative; z-index:2; }
.screen { padding-bottom:calc(var(--safe-b) + 26px); }
.pops { position:fixed; inset:0; pointer-events:none; z-index:10; }
.pop { position:absolute; transform:translate(-50%,-50%); max-width:95vw; white-space:nowrap; font-size:clamp(16px,4vw,24px); font-weight:900; color:var(--ng); background:#fff8ec; padding:5px 10px; border-radius:8px; animation:pop 1.1s ease-out forwards; }
@keyframes pop { 0% { opacity:0; } 10%,80% { opacity:1; } 100% { opacity:0; } }
@keyframes shake { 25%,75% { transform:translateX(-4px); } 50% { transform:translateX(4px); } }
@keyframes wrong-shake { 25%,75% { transform:translateX(-6px); } 50% { transform:translateX(6px); } }
@media (min-width:760px) {
  .screen.game { padding-top:calc(var(--safe-t) + 18px); }
  .sort-board { grid-template-columns:minmax(0,48fr) minmax(0,52fr); }
  .sort-board .map-station .map-box { height:min(58vh,540px); }
}
@media (max-width:759px) {
  .hud-title b { font-size:16px; }
  .hud-title small { font-size:9px; letter-spacing:0; }
  .hud-item { min-width:56px; padding:3px 6px; }
  .screen.game { padding-left:10px; padding-right:10px; }
  .board { padding:10px; gap:12px; }
  .stage-top { padding:8px 12px; }
  .map-station .map-box { height:min(30vh,280px); }
}
/* スマホ縦：地図を残りの高さいっぱいに広げ、答えのボタンを親指の届く画面の下側に置く。 */
@media (orientation:portrait) and (max-width:759px) {
  .screen.game .stage { flex:1 0 auto; display:flex; flex-direction:column; }
  .sort-board { flex:1 0 auto; grid-template-rows:auto minmax(0,1fr); }
  .map-station { display:flex; flex-direction:column; min-height:0; }
  .map-station .map-box { flex:1 1 0; height:auto; min-height:180px; max-height:420px; margin:auto 0; }
}
/* Safariのバーがある小さい縦画面は、地図を残りの高さへ縮める。 */
@media (orientation:portrait) and (max-width:759px) and (max-height:740px) {
  .hud-title small { display:none; }
  .stage-top, .dispatch .eyebrow, .condition small { display:none; }
  .screen.game .stage { flex:1 0 auto; display:flex; flex-direction:column; }
  .sort-board { flex:1 0 auto; grid-template-rows:auto minmax(0,1fr); gap:8px; padding:8px; }
  .map-station { display:flex; flex-direction:column; min-height:0; }
  .map-station .map-box { flex:1 1 0; height:auto; min-height:100px; }
  .parcel { padding:6px 10px 14px; }
  .parcel-title { margin:2px 0 4px; gap:8px; }
  .parcel-title i { font-size:24px; }
  .condition { padding:6px 10px; }
  .condition .item-condition { line-height:1.5; }
  .sort-hint { font-size:11px; line-height:1.5; }
  .gate-grid { gap:6px; margin-top:6px; }
  .gate { padding:4px 6px; font-size:14px; }
  .result { padding:16px 12px; }
  .res-study-actions { min-height:24px; }
}
/* Safariのバーがある、とても低い縦画面（iPhone SE 初代など）：伝票の題の行を省き、種類のタグと条件だけにする */
@media (orientation:portrait) and (max-width:759px) and (max-height:500px) {
  .hud-item { padding:1px 6px; }
  .hud-item b { font-size:16px; }
  .parcel-title { display:none; }
  .parcel-tags { min-height:0; margin-bottom:4px; }
  .condition .item-condition { font-size:14px; line-height:1.45; }
  .map-station .map-box { min-height:64px; }
  .sort-board { gap:6px; padding:6px; }
}
@media (max-width:340px) {
  .hud-title { display:none; }
  .hud { justify-content:space-between; }
  .gate { font-size:13px; }
  .parcel-title b.long { font-size:17px; }
}
@media (orientation:landscape) and (max-height:500px) {
  .screen.game { gap:6px; padding-top:calc(var(--safe-t) + 6px); }
  .screen.game .stage { flex:1 1 auto; min-height:0; display:flex; flex-direction:column; }
  .stage-top, .dispatch .eyebrow, .condition small, .sort-hint { display:none; }
  .sort-board { flex:1 1 auto; min-height:0; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:14px; padding:8px 12px; }
  .sort-board .dispatch { order:0; }
  .map-station { display:flex; flex-direction:column; min-height:0; }
  .map-station .map-box { flex:1 1 0; height:auto; min-height:80px; }
  .gate-grid { gap:5px; }
  .gate { font-size:13px; }
  .parcel { padding:8px 10px 16px; }
  .parcel-title { margin:2px 0 6px; }
  .parcel-title b { font-size:18px; }
  .parcel-title i { font-size:24px; }
  .condition { padding:6px 8px; }
  .condition .item-condition { font-size:14px; }
}
/* 568×320 など特に低い横向き：ことばの丸い札の内側を詰め、長い答え（追加問題）でもボタンを画面内に残す（chiri-a2-foundation-pull-1030） */
@media (orientation:landscape) and (max-height:340px) {
  .gate.k-word { padding:4px 10px; }
}
/* はじめての1回の案内：ボタンのすぐ上に1行。押せない（下の地図・ボタンをそのまま押せる）。下向きの三角でボタンを指す */
.first-hint { position:fixed; z-index:11; margin:0; box-sizing:border-box; padding:7px 10px; border-radius:10px; background:var(--brand); color:#fff; font-size:clamp(14px,4.2vw,17px); font-weight:900; line-height:1.3; text-align:center; white-space:nowrap; pointer-events:none; box-shadow:0 4px 12px #0003; animation:hint-in .25s ease-out; }
.first-hint::after { content:''; position:absolute; left:50%; bottom:-6px; margin-left:-7px; border:7px solid transparent; border-bottom:0; border-top-color:var(--brand); }
.first-hint[hidden] { display:none; }
/* 地図の上の端へ移したとき（光っている県を隠さないため）は、ボタンを指す三角を出さない */
.first-hint.on-top::after { display:none; }
@keyframes hint-in { from { opacity:0; transform:translateY(6px); } }
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation:none !important; transition:none !important; }
}
