/* パンダたんてい ときのぼうけん — RPGスタイル（全アセット自作） */
:root {
  --ink: #33302e; --bamboo: #7bc47f; --deep: #2a6b46; --cream: #fff6e3;
  --yellow: #ffd45e; --pink: #ff9db0; --sky: #bde3ff; --paper: #fffdf6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: #17301f; min-height: 100%; }
body { font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', sans-serif; color: var(--ink); }
.panda-app { max-width: 820px; margin: 0 auto; padding: 8px; }
.p-loading { color: #fff; text-align: center; padding: 40px 0; font-size: 18px; }

.stage { position: relative; width: 100%; aspect-ratio: 5 / 3; min-height: 400px; border-radius: 18px; overflow: hidden; background: #1c3826; box-shadow: 0 10px 30px rgba(0,0,0,.35); user-select: none; }
.stage, .stage * { touch-action: manipulation; }
.stage.shake { animation: st-shake .38s; }
@keyframes st-shake { 0%,100%{transform:translate(0)} 25%{transform:translate(-7px,3px)} 50%{transform:translate(6px,-4px)} 75%{transform:translate(-4px,2px)} }
.flash-layer { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 40; }
.flash-layer.on { animation: fl .3s; }
@keyframes fl { 0%{opacity:.9} 100%{opacity:0} }

/* ── マップ ── */
.map-viewport { position: absolute; inset: 0; overflow: hidden; }
.map-world { position: absolute; transition: transform .14s linear; will-change: transform; }
.tile { position: absolute; width: 48px; height: 48px; image-rendering: auto; pointer-events: none; }
.ent { position: absolute; width: 48px; height: 48px; pointer-events: none; transition: left .14s linear, top .14s linear; z-index: 3; }
.ent.player { z-index: 5; }
.ent.bob { animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-3px)} }
.map-name { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); background: rgba(51,48,46,.82); color: #fff; border-radius: 999px; padding: 6px 16px; font-size: 13px; font-weight: 700; z-index: 20; white-space: nowrap; }
.map-name ruby rt { font-size: 8px; color: var(--yellow); }

/* Dパッド＋メニュー */
.dpad { position: absolute; left: 10px; bottom: 10px; z-index: 30; display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); gap: 3px; opacity: .92; }
.dpad button { border: 3px solid var(--ink); border-radius: 12px; background: var(--paper); font-size: 18px; font-weight: 900; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.3); padding: 0; }
.dpad button:active { transform: translateY(2px); box-shadow: none; }
.dpad .blank { visibility: hidden; }
.hud { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; z-index: 30; }
.hud-btn { min-width: 44px; min-height: 44px; border-radius: 12px; border: 3px solid var(--ink); background: var(--paper); font-size: 18px; font-family: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.25); padding: 2px 8px; }
.hud-btn:active { transform: translateY(2px); box-shadow: none; }
.party-chip { position: absolute; top: 8px; left: 8px; z-index: 30; background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 5px 10px; font-size: 12px; font-weight: 900; box-shadow: 0 3px 0 rgba(0,0,0,.25); line-height: 1.5; }
.party-chip .hp { color: #c0392b; }

/* ── セリフ（ADV流用様式） ── */
.dialog { position: absolute; left: 3%; right: 3%; bottom: 3%; min-height: 28%; background: var(--paper); border: 4px solid var(--ink); border-radius: 16px; padding: 26px 16px 12px; z-index: 50; cursor: pointer; box-shadow: 0 6px 0 rgba(0,0,0,.28); }
.nameplate { position: absolute; top: -18px; left: 12px; background: var(--deep); color: #fff; font-weight: 900; border: 3px solid var(--ink); border-radius: 10px; padding: 4px 14px; font-size: 14px; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.dtext { font-size: 18px; line-height: 1.85; font-weight: 700; min-height: 56px; word-break: break-word; }
.dtext ruby rt { font-size: 9px; color: var(--deep); }
.dtext .ch { visibility: hidden; }
.dtext .ch.on { visibility: visible; }
.next-arrow { position: absolute; right: 14px; bottom: 8px; font-size: 17px; color: var(--deep); animation: bl 1s infinite; }
@keyframes bl { 0%,100%{opacity:1} 50%{opacity:.35} }
.d-portrait { position: absolute; right: 4%; bottom: 30%; width: 26%; max-width: 170px; z-index: 45; pointer-events: none; }
.d-portrait svg { width: 100%; height: auto; filter: drop-shadow(0 5px 8px rgba(0,0,0,.3)); }

/* ── バトル ── */
.battle-bg { position: absolute; inset: 0; }
.battle-bg img { width: 100%; height: 100%; object-fit: cover; }
.b-enemy { position: absolute; left: 50%; top: 8%; transform: translateX(-50%); width: 36%; max-width: 240px; z-index: 5; }
.b-enemy svg { width: 100%; height: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,.3)); }
.b-enemy.hurt { animation: hurt .4s; }
@keyframes hurt { 0%,100%{transform:translateX(-50%)} 25%{transform:translateX(-54%)} 50%{transform:translateX(-46%)} 75%{transform:translateX(-52%)} }
.b-ehp { position: absolute; left: 50%; top: 4%; transform: translateX(-50%); width: 40%; max-width: 260px; z-index: 6; background: var(--paper); border: 3px solid var(--ink); border-radius: 999px; padding: 3px; }
.b-ehp .bar { height: 12px; border-radius: 999px; background: linear-gradient(#ff8a80, #e5533d); transition: width .3s; }
.b-ename { position: absolute; left: 50%; top: -22px; transform: translateX(-50%); background: var(--deep); color: #fff; font-size: 12px; font-weight: 900; border-radius: 8px; padding: 2px 10px; white-space: nowrap; border: 2px solid var(--ink); }
.b-panel { position: absolute; left: 3%; right: 3%; bottom: 3%; background: var(--paper); border: 4px solid var(--ink); border-radius: 16px; padding: 10px 12px; z-index: 50; box-shadow: 0 6px 0 rgba(0,0,0,.28); }
.b-heroes { display: flex; gap: 10px; margin-bottom: 8px; }
.b-hero { flex: 1; border: 3px solid var(--ink); border-radius: 12px; padding: 6px 8px; background: #fff; font-size: 12px; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.b-hero img { width: 34px; height: 44px; object-fit: contain; }
.b-hero .hpbar { flex: 1; height: 10px; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: #eee; }
.b-hero .hpbar > div { height: 100%; background: var(--bamboo); transition: width .3s; }
.b-hero.ko { opacity: .45; }
.b-cmds { display: flex; gap: 8px; flex-wrap: wrap; }
.b-btn { flex: 1; min-height: 52px; border-radius: 12px; border: 3px solid var(--ink); font-family: inherit; font-weight: 900; font-size: 14px; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.25); line-height: 1.3; }
.b-btn:active { transform: translateY(2px); box-shadow: none; }
.b-btn.mei { background: var(--bamboo); }
.b-btn.rikky { background: var(--sky); }
.b-btn.item { background: var(--yellow); flex: 0 0 30%; }
.b-btn:disabled { opacity: .4; }
.b-msg { font-size: 14px; font-weight: 900; min-height: 20px; margin-bottom: 6px; }
.b-msg ruby rt { font-size: 8px; color: var(--deep); }

/* 問題モーダル */
.q-wrap { position: absolute; inset: 0; background: rgba(23,48,31,.8); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 14px; }
.q-card { background: var(--paper); border: 4px solid var(--ink); border-radius: 18px; padding: 16px; width: 100%; max-width: 470px; box-shadow: 0 8px 0 rgba(0,0,0,.3); }
.q-timer { height: 8px; border-radius: 999px; background: #eee; overflow: hidden; margin-bottom: 10px; border: 2px solid var(--ink); }
.q-timer > div { height: 100%; background: var(--yellow); width: 100%; }
.q-prompt { font-size: 20px; font-weight: 900; text-align: center; line-height: 1.7; margin-bottom: 12px; }
.q-prompt ruby rt { font-size: 9px; color: var(--deep); }
.q-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.q-choice { min-height: 54px; border-radius: 12px; border: 3px solid var(--ink); background: #fff; font-family: inherit; font-weight: 900; font-size: 17px; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.22); }
.q-choice:active { transform: translateY(2px); box-shadow: none; }
.q-choice.ok { background: var(--bamboo); }
.q-choice.ng { background: var(--pink); }

/* バナー・汎用 */
.banner { position: absolute; top: 36%; left: 50%; transform: translate(-50%,-50%) rotate(-5deg) scale(.5); z-index: 80; background: var(--yellow); border: 5px solid var(--ink); border-radius: 14px; padding: 12px 26px; font-family: 'Mochiy Pop One','Zen Maru Gothic',sans-serif; font-size: clamp(22px,5vw,38px); box-shadow: 8px 8px 0 rgba(0,0,0,.3); opacity: 0; pointer-events: none; white-space: nowrap; }
.banner.show { animation: bn 1.1s ease-out; }
@keyframes bn { 0%{opacity:0} 14%{opacity:1; transform:translate(-50%,-50%) rotate(-5deg) scale(1.1)} 24%{transform:translate(-50%,-50%) rotate(-5deg) scale(1)} 82%{opacity:1} 100%{opacity:0} }
.p-btn { display: inline-block; min-height: 50px; padding: 12px 26px; border-radius: 14px; border: 4px solid var(--ink); background: var(--yellow); color: var(--ink); font-family: inherit; font-weight: 900; font-size: 17px; cursor: pointer; box-shadow: 0 5px 0 rgba(0,0,0,.3); text-decoration: none; }
.p-btn:active { transform: translateY(3px); box-shadow: none; }
.p-btn.sub { background: var(--paper); font-size: 14px; padding: 9px 18px; min-height: 44px; }

/* ── ずかん・バッジ・モーダル ── */
.modal-wrap { position: absolute; inset: 0; background: rgba(23,48,31,.78); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal { background: var(--paper); border: 4px solid var(--ink); border-radius: 18px; padding: 14px; width: 100%; max-width: 470px; max-height: 92%; overflow-y: auto; box-shadow: 0 8px 0 rgba(0,0,0,.3); }
.modal h3 { margin: 2px 0 8px; font-size: 16px; color: var(--deep); }
.zk-row { display: flex; gap: 10px; align-items: center; border-bottom: 2px dashed #d8cfba; padding: 6px 2px; }
.zk-row img { width: 54px; height: 54px; flex: 0 0 54px; object-fit: contain; }
.zk-row img.zk-silhouette { filter: brightness(0) opacity(.35); }
.zk-name { font-weight: 900; font-size: 14px; }
.zk-flavor { font-size: 12px; color: #6b6257; line-height: 1.5; }
.bd-shelf { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bd-item { display: flex; align-items: center; gap: 6px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; padding: 6px 8px; font-size: 12px; font-weight: 900; }
.bd-item.off { opacity: .45; }
.bd-item .bd-ico { font-size: 18px; }
.b-btn.usami { background: var(--pink); }

/* タイトル */
.title-screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 60; text-align: center; padding: 12px; background: radial-gradient(circle at 50% 30%, #2a6b46, #17301f); }
.title-logo { font-family: 'Mochiy Pop One','Zen Maru Gothic',sans-serif; font-size: clamp(26px,7vw,44px); color: #fff; text-shadow: 3px 3px 0 var(--ink), 0 8px 0 rgba(0,0,0,.25); line-height: 1.3; }
.title-logo small { display: block; font-size: .5em; color: var(--yellow); }
.title-btns { display: flex; flex-direction: column; gap: 10px; }
.title-note { color: #cfe8d5; font-size: 11px; }

@media (max-width: 480px) {
  .stage { aspect-ratio: auto; height: 80vh; min-height: 0; }
  .dtext { font-size: 16px; }
  .d-portrait { width: 34%; }
  .q-choices { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .stage.shake, .banner.show, .flash-layer.on, .b-enemy.hurt, .ent.bob { animation: none; }
  .banner.show { opacity: 1; transform: translate(-50%,-50%) rotate(-5deg) scale(1); }
}
