/* からだの なかの だいぼうけん */
:root {
  --ink: #4a3a35;
  --bg: #fff3e0;
  --main: #ff8a50;
  --font: 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', 'Yu Gothic UI', 'Noto Sans JP', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body {
  font-family: var(--font); font-weight: 700; color: var(--ink);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { display: block; }

#app {
  height: 100vh; height: 100dvh; max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  background: radial-gradient(circle at 50% 30%, #fffaf2 0, var(--bg) 70%);
}

/* ---- 上の帯 ---- */
.bar { flex: none; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; }
.bar-title { flex: 1; text-align: center; font-size: 28px; letter-spacing: .08em; color: var(--c, var(--ink)); }
.back {
  flex: none; height: 52px; padding: 0 14px; border: 3px solid #e4d6c8; border-radius: 26px;
  background: #fffaf4; color: #8a7a70; font-size: 17px; opacity: .9;
}
.toggles { flex: none; display: flex; gap: 6px; }
.tg {
  width: 64px; height: 56px; border: 3px solid #e4d6c8; border-radius: 18px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-size: 13px; padding: 2px;
  position: relative;
}
.tg svg { width: 30px; height: 30px; }
.tg[aria-pressed="false"] { background: #eee; color: #999; }
.tg[aria-pressed="false"] svg { opacity: .35; }
.tg[aria-pressed="false"]::after {
  content: ''; position: absolute; left: 12px; right: 12px; top: 24px; height: 4px; background: #d9534f; border-radius: 2px; transform: rotate(-35deg);
}
.wiggle { animation: wiggle .5s 2; }
@keyframes wiggle { 25% { transform: rotate(-8deg) scale(1.1); } 75% { transform: rotate(8deg) scale(1.1); } }

/* ---- 下のボタン ---- */
.foot { flex: none; min-height: 112px; display: flex; align-items: center; justify-content: center; padding: 10px 16px 18px; }
.foot.two { flex-direction: column; gap: 12px; min-height: 172px; }
.btn {
  min-height: 68px; min-width: 200px; padding: 8px 26px; border: 4px solid #e4d6c8; border-radius: 34px;
  background: #fff; font-size: 22px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 5px 0 #e4d6c8; transition: transform .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #e4d6c8; }
.btn.primary { background: var(--main); border-color: #e06a32; color: #fff; box-shadow: 0 5px 0 #d4602a; }
.btn.primary:active { box-shadow: 0 1px 0 #d4602a; }
.btn.big { min-height: 80px; min-width: 240px; font-size: 26px; border-radius: 40px; }
.foot.two .btn { width: min(340px, 100%); }
.btn-icon { width: 36px; height: 36px; flex: none; }
.btn-star { width: 30px; height: 30px; }
.next { animation: rise .35s ease-out; }
.next[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.9); } }
.pop { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.05); } }

.caption {
  flex: none; margin: 0 14px; min-height: 64px; padding: 6px 12px; text-align: center;
  font-size: 21px; line-height: 1.45; display: flex; align-items: center; justify-content: center;
  word-break: keep-all; overflow-wrap: anywhere; text-wrap: balance;
}

/* ---- タイトル ---- */
.title-body { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 12px; }
.title { margin: 0 0 8px; text-align: center; font-size: 30px; line-height: 1.3; color: #e06a32; letter-spacing: .06em; }
.title span { font-size: 46px; color: #ff6b8b; text-shadow: 3px 3px 0 #fff, 5px 5px 0 #ffd0b0; }
.title-art { width: 100%; max-width: 420px; height: auto; max-height: 52vh; }

/* ---- マップ ---- */
.stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
.map-svg { width: 100%; height: 100%; }
.map-svg [data-go] { cursor: pointer; }
.tag-text { font-size: 32px; font-weight: 700; fill: var(--ink); font-family: var(--font); }
.pulse { pointer-events: none; }
.pulse circle { transform-box: fill-box; transform-origin: center; animation: pulse 2.2s ease-out infinite; }
.pulse.p2 circle { animation-delay: .7s; }
.pulse.p3 circle { animation-delay: 1.4s; }
@keyframes pulse { 0% { transform: scale(.8); opacity: .9; } 100% { transform: scale(1.25); opacity: 0; } }

/* ---- ずかん ---- */
.zukan { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 6px 12px 20px; align-content: start; }
.card {
  background: #fff; border: 4px solid var(--c); border-radius: 22px; padding: 10px 10px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
}
.card-art { position: relative; width: 96px; height: 96px; }
.card-art svg { width: 100%; height: 100%; }
.card-name { margin: 0; font-size: 22px; color: var(--c); }
.card-text { margin: 0; font-size: 15px; line-height: 1.5; flex: 1; word-break: keep-all; overflow-wrap: anywhere; }
.card.locked { border-color: #ddd; background: #f6f2ee; }
.card.locked .card-art svg { filter: brightness(0); opacity: .18; }
.card.locked .card-name, .card.locked .card-text { color: #aaa; }
.q { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 56px; color: #bbb; }
.listen { min-width: 0; min-height: 56px; font-size: 18px; padding: 4px 18px; margin-top: 4px; }
.listen svg { width: 28px; height: 28px; }

/* ---- ミニゲーム ---- */
.route { flex: none; list-style: none; margin: 0; padding: 0 16px; display: flex; justify-content: center; gap: 10px; }
.route li { width: 38px; height: 38px; border-radius: 50%; background: #fff; padding: 4px; opacity: .35; filter: grayscale(1); transition: all .3s; }
.route li.done { opacity: 1; filter: none; }
.route li.now { opacity: 1; filter: none; transform: scale(1.25); box-shadow: 0 0 0 3px #ffb08a; }
.route li svg { width: 100%; height: 100%; }
.game-svg { width: 100%; height: 100%; touch-action: none; overflow: visible; }
.ripple {
  position: absolute; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, .9); pointer-events: none; animation: ripple .55s ease-out forwards;
}
@keyframes ripple { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
.burst > g { animation: burst .85s ease-out forwards; }
@keyframes burst { from { transform: translate(0, 0) scale(.4); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; } }

/* くち */
.teeth-top, .teeth-bottom { transition: transform .12s; }
.chomp .teeth-top { animation: bite-top .26s ease-in-out; }
.chomp .teeth-bottom { animation: bite-bottom .26s ease-in-out; }
@keyframes bite-top { 50% { transform: translateY(34px); } }
@keyframes bite-bottom { 50% { transform: translateY(-34px); } }
.food-wrap { transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.chomp .food-wrap .onigiri { animation: squish .26s; transform-box: fill-box; transform-origin: center; }
@keyframes squish { 50% { transform: scale(1.08, .85); } }
.tap-food { cursor: pointer; }

/* しょくどう */
.arrive .stomach-end { animation: wobble .5s; transform-box: fill-box; transform-origin: center bottom; }

/* い */
.stomach-body { transform-box: fill-box; transform-origin: center; }
.wobble { animation: wobble .45s; }
@keyframes wobble { 25% { transform: scale(1.04, .96) rotate(-2deg); } 50% { transform: scale(.97, 1.03) rotate(2deg); } 75% { transform: scale(1.02, .98); } }

/* ちょう */
.light, .drop { cursor: pointer; }
.glow-in { animation: glow 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes glow { 50% { transform: scale(1.12); } }
.flying .glow-in { animation: none; }
.badge .badge-glow { transition: opacity .2s; }
.badge.glow .badge-glow { animation: badge 0.7s ease-out; }
@keyframes badge { 0% { opacity: .9; } 100% { opacity: 0; } }
.ileum, .colon { transition: opacity .5s; }
.part2 .ileum { opacity: .3; }
.done .colon { opacity: .4; }
.pop-in { animation: popin .6s cubic-bezier(.3, 1.6, .5, 1); transform-box: fill-box; transform-origin: center; }
@keyframes popin { from { transform: scale(.2); opacity: 0; } }
.lump-in { transform-box: fill-box; transform-origin: center; animation: glow 1.4s ease-in-out infinite; }

/* クイズ(説明のあと、ステージに重ねる 2択) */
.quiz {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: rgba(255, 243, 224, .88); animation: fadein .4s ease-out;
}
@keyframes fadein { from { opacity: 0; } }
.quiz-badge { padding: 6px 22px; border-radius: 22px; background: #ff6b8b; color: #fff; font-size: 22px; font-weight: 700; letter-spacing: .1em; animation: popin .5s cubic-bezier(.3, 1.6, .5, 1); }
.quiz-opts { display: flex; gap: 16px; justify-content: center; }
.quiz-opt {
  width: min(40vw, 180px); padding: 10px 8px 12px; border: 5px solid #e4d6c8; border-radius: 28px; background: #fff;
  box-shadow: 0 6px 0 #e4d6c8; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 24px;
  transition: opacity .3s, filter .3s, transform .08s; animation: popin .5s cubic-bezier(.3, 1.6, .5, 1) backwards;
}
.quiz-opt + .quiz-opt { animation-delay: .15s; }
.quiz-opt:active { transform: translateY(4px); box-shadow: 0 2px 0 #e4d6c8; }
.quiz-opt svg { width: 100%; aspect-ratio: 1; }
.quiz-opt span { line-height: 1.25; word-break: keep-all; }
.quiz-opt.no { opacity: .35; filter: grayscale(1); }
.quiz-opt.ok { border-color: #ffc928; box-shadow: 0 6px 0 #e8a800, 0 0 0 6px #fff3b0; animation: wiggle .6s ease-in-out; }
.quiz.solved .quiz-opt:not(.ok) { opacity: .35; filter: grayscale(1); }

/* ---- おしまい ---- */
.finish { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.finish-title { margin: 0 0 24px; text-align: center; font-size: 28px; line-height: 1.35; color: #e06a32; position: relative; z-index: 1; animation: rise .6s ease-out; }
.finish-title span { font-size: 42px; color: #ff6b8b; text-shadow: 3px 3px 0 #fff, 5px 5px 0 #ffd0b0; }
.trail { list-style: none; margin: 0; padding: 0 6px; display: flex; align-items: flex-start; justify-content: center; position: relative; z-index: 1; }
.trail li { width: 70px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; animation: rise .4s ease-out both; animation-delay: calc(.4s + var(--i) * .35s); }
.trail li svg { width: 56px; height: 56px; background: #fff; border-radius: 50%; padding: 4px; }
.trail .arrow { width: 12px; margin-top: 20px; font-size: 12px; color: #d8b8a0; }
.confetti i { position: absolute; top: -20px; left: var(--x); width: 12px; height: 18px; border-radius: 4px; background: var(--c); animation: fall 3.2s linear infinite; animation-delay: var(--d); }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* ---- 遊び方の手 ---- */
.hand { position: fixed; z-index: 10; width: 72px; height: 89px; margin: -6px 0 0 -36px; pointer-events: none; opacity: 0; transition: opacity .3s; left: -200px; top: -200px; }
.hand svg { width: 100%; height: 100%; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .2)); }
.hand.on { opacity: 1; }
.hand.on.tap svg { animation: tap 0.8s ease-in-out infinite; }
.hand.on.swipe svg { animation: swipe 1.2s ease-in-out infinite; }
@keyframes tap { 0%, 100% { transform: translateY(14px); } 50% { transform: translateY(0) scale(.94); } }
@keyframes swipe { 0%, 100% { transform: translateX(-60px) rotate(-8deg); } 50% { transform: translateX(60px) rotate(8deg); } }

@media (prefers-reduced-motion: reduce) {
  .pop, .pulse circle, .glow-in, .lump-in, .confetti i { animation: none; }
}
