:root {
  --bg1: #7c5cff; --bg2: #39c6ff;
  --ink: #2a2350; --card: #ffffff; --soft: #f3f0ff;
  --ok: #22c55e; --ng: #f87171; --gold: #ffc531; --accent: #ff6aa2;
  --radius: 22px;
  font-family: system-ui, "Noto Sans JP", "Hiragino Maru Gothic ProN", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  overscroll-behavior: none; user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
#app { height: 100dvh; max-width: 520px; margin: 0 auto; position: relative; overflow: hidden; }
button { font: inherit; color: inherit; border: none; cursor: pointer; touch-action: manipulation; }
svg { width: 100%; height: 100%; display: block; }

/* ───── ボタン ───── */
.btn {
  min-height: 60px; padding: 12px 22px; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 900; font-size: 20px;
  box-shadow: 0 5px 0 rgba(0,0,0,.18); transition: transform .08s; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn.huge { min-height: 72px; font-size: 26px; padding: 14px 36px; }
.btn.small { min-height: 48px; font-size: 16px; padding: 8px 16px; }
.btn.ghost { background: #fff; color: var(--ink); }
.btn:disabled { opacity: .55; }
.icon-btn { width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.85); font-size: 22px; }
.screen { height: 100%; display: flex; flex-direction: column; align-items: center; padding: 18px; gap: 14px; overflow-y: auto; }
h1 { color: #fff; font-size: 26px; margin: 8px 0; text-shadow: 0 3px 0 rgba(0,0,0,.2); }

/* ───── タイトル ───── */
.title { justify-content: center; }
.logo { display: flex; flex-direction: column; align-items: center; color: #fff; font-weight: 900; text-shadow: 0 5px 0 #3b2a9e; transform: rotate(-4deg); }
.logo span:first-child { font-size: 36px; }
.logo span:last-child { font-size: 52px; letter-spacing: 2px; }
.title-mons { display: flex; gap: 6px; width: 100%; max-width: 380px; }
.tm { flex: 1; aspect-ratio: 1; animation: bob 1.6s ease-in-out infinite; }
.tm:nth-child(2) { animation-delay: .3s; } .tm:nth-child(3) { animation-delay: .6s; }
.ver { color: rgba(255,255,255,.8); font-size: 13px; }
@keyframes bob { 50% { transform: translateY(-10px); } }

/* ───── あいぼう えらび ───── */
.choose-list { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.mon-card { display: grid; grid-template-columns: 110px 1fr; grid-template-rows: auto auto; align-items: center; background: #fff; border-radius: var(--radius); padding: 10px 16px; border: 5px solid var(--c); text-align: left; box-shadow: 0 6px 0 rgba(0,0,0,.15); }
.mc-img { grid-row: span 2; width: 100px; height: 100px; }
.mc-name { font-size: 26px; font-weight: 900; }
.mc-kind { font-size: 16px; opacity: .7; }
.note { color: #fff; font-size: 15px; text-align: center; }

/* ───── ホーム ───── */
.home-top { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.xp { background: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 900; }
.home-partner { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hp-sprite { width: 190px; height: 190px; animation: bob 2s ease-in-out infinite; }
.hp-name { color: #fff; font-size: 28px; font-weight: 900; text-shadow: 0 3px 0 rgba(0,0,0,.2); }
.map { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.node { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: var(--radius); padding: 12px 18px; min-height: 72px; box-shadow: 0 6px 0 rgba(0,0,0,.15); font-weight: 900; font-size: 20px; }
.node-no { width: 48px; height: 48px; border-radius: 50%; background: var(--bg1); color: #fff; display: grid; place-items: center; font-size: 24px; }
.node.boss { background: linear-gradient(90deg, #fff3c4, #ffe08a); }
.node.boss .node-no { background: #ff7a45; }

/* ───── バトル ───── */
.battle { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 12px 4px; }
.dots { display: flex; gap: 6px; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,.45); border: 2px solid #fff; }
.dot.now { background: var(--gold); transform: scale(1.2); }
.dot.ok { background: var(--ok); }
.dot.retry { background: #ffb347; }
.stage-name { color: #fff; font-weight: 900; margin-left: auto; font-size: 15px; text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.arena { position: relative; flex: 0 0 auto; height: 40dvh; min-height: 250px; margin: 0 10px; border-radius: var(--radius);
  background: linear-gradient(#bfe9ff 0 58%, #9be38f 58% 100%); overflow: hidden; box-shadow: inset 0 -8px 0 rgba(0,0,0,.08); }
.boss .arena { background: linear-gradient(#ffd6a8 0 58%, #f2c16b 58% 100%); }
.enemy-box { position: absolute; right: 4%; top: 4%; width: 46%; display: flex; flex-direction: column; align-items: center; }
.ally-box { position: absolute; left: 4%; bottom: 3%; width: 42%; display: flex; flex-direction: column; align-items: center; }
.sprite { position: relative; width: 100%; aspect-ratio: 1; }
.sprite.enemy { width: 82%; }
.sprite.enemy.big { width: 100%; }
.sprite.ally svg { position: relative; z-index: 1; }
.nameplate { background: rgba(255,255,255,.9); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 900; white-space: nowrap; }
.nameplate.small { margin-top: -6px; }
.hpbar { width: 92%; height: 14px; border-radius: 999px; background: rgba(0,0,0,.18); border: 2px solid #fff; overflow: hidden; margin-top: 3px; }
.hpfill { height: 100%; width: 100%; background: linear-gradient(#5ff08f, #22c55e); transition: width .45s ease-out; }
.hpfill.low { background: linear-gradient(#ffd36b, #ff9f1a); }
.ally-bar .hpfill { background: linear-gradient(#7cc8ff, #3b82f6); }
.aura { position: absolute; inset: 0; border-radius: 50%; z-index: 0; opacity: 0; transform: scale(.6);
  background: radial-gradient(circle, rgba(255,240,120,.95), rgba(255,170,40,.55) 45%, rgba(255,120,0,0) 70%);
  transition: transform .12s, opacity .12s; }
.aura.on { opacity: calc(.35 + var(--p, 0) * .65); transform: scale(calc(.8 + var(--p, 0) * .8)); }

/* 演出レイヤー */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.fx { position: absolute; transform: translate(-50%, -50%); }
.pop { font-weight: 900; font-size: 22px; color: #fff; text-shadow: 0 2px 0 #000, 0 0 6px rgba(0,0,0,.4); white-space: nowrap; }
.pop.dmg { color: #fff; font-size: 30px; }
.pop.dmg.big { color: var(--gold); font-size: 44px; }
.pop.dmg.ally { color: #9ed0ff; font-size: 24px; }
.pop.move { font-size: 18px; background: rgba(255,255,255,.92); color: var(--ink); text-shadow: none; padding: 2px 10px; border-radius: 999px; }
.pop.heal { color: #b6ffb9; }
.banner { left: 50%; top: 22%; z-index: 9; font-size: 24px; font-weight: 900; color: #fff; text-align: center; line-height: 1.15;
  padding: 10px 22px; border-radius: 18px; background: linear-gradient(90deg, #ff5f6d, #ffc371); text-shadow: 0 3px 0 rgba(0,0,0,.25); white-space: nowrap; box-shadow: 0 6px 0 rgba(0,0,0,.2); }
.banner.special { background: linear-gradient(90deg, #7b2ff7, #f107a3, #ffb300); font-size: 25px; }
.spark { line-height: 1; }
.fire { left: 0; top: 0; width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle, #fff8b0, #ffb300 40%, #ff4d00 70%, rgba(255,77,0,0) 72%); }
.trail { left: 0; top: 0; font-size: 30px; }
.beam { left: 0; top: 0; font-size: 40px; }
.friend { width: 90px; height: 90px; }
.bubble { border-radius: 50%; border: 5px solid rgba(255,255,255,.9); background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.8), rgba(120,200,255,.45) 40%, rgba(60,130,255,.25)); }
.speedlines { inset: 0; transform: none; background: repeating-linear-gradient(170deg, rgba(255,255,255,0) 0 18px, rgba(255,255,255,.75) 18px 22px); }
.wave { left: 0; top: auto; bottom: 0; width: 140%; height: 70%; transform: none; border-radius: 50% 50% 0 0;
  background: linear-gradient(#7fd8ff, #2f8cff); opacity: .85; box-shadow: inset 0 14px 0 rgba(255,255,255,.6); }
.dizzy { font-size: 22px; }
body[data-effect="soft"] .aura.on { transform: scale(calc(.8 + var(--p, 0) * .4)); }

/* ───── 問題パネル ───── */
.panel { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 10px 14px 16px; overflow-y: auto; }
.q-prompt { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.q-label { color: #fff; font-size: 22px; font-weight: 900; text-shadow: 0 2px 0 rgba(0,0,0,.2); text-align: center; }
.big-msg { font-size: 28px; }
.voice-ok { font-size: 34px; color: #fff59d; }
.q-big { background: #fff; border-radius: var(--radius); width: 130px; height: 110px; display: grid; place-items: center; box-shadow: 0 5px 0 rgba(0,0,0,.15); }
.emo { line-height: 1; }
.emo.big { font-size: 78px; } .emo.mid { font-size: 56px; } .emo.small { font-size: 44px; } .emo.opt-img { font-size: 56px; }
.swatch { display: inline-block; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.1); }
.swatch.big { width: 80px; height: 80px; } .swatch.opt-img { width: 58px; height: 58px; } .swatch.small { width: 44px; height: 44px; }
.options { width: 100%; display: grid; gap: 10px; }
.options.list { grid-template-columns: 1fr 1fr; }
.options.grid { grid-template-columns: 1fr 1fr; }
.opt { position: relative; background: #fff; border-radius: 18px; min-height: 70px; padding: 8px; font-weight: 900; box-shadow: 0 5px 0 rgba(0,0,0,.15); display: flex; align-items: center; justify-content: center; gap: 6px; }
.options.grid .opt { min-height: 92px; }
.opt-en { font-size: 26px; letter-spacing: .5px; }
.opt-en.small { font-size: 17px; line-height: 1.2; padding-right: 26px; }
.mini-say { position: absolute; right: 6px; top: 6px; font-size: 20px; padding: 4px; }
.opt-scene { display: flex; flex-direction: column; align-items: center; font-size: 13px; gap: 2px; }
.opt-scene .emo.small { font-size: 34px; }
.opt.correct { background: #d8ffe4; outline: 5px solid var(--ok); animation: pop .35s; }
.opt.wrong { background: #ffe1e1; opacity: .6; animation: shake .4s; }
.opt.hint { outline: 5px dashed var(--gold); animation: glow 1s ease-in-out infinite; }
.speak-btn { width: 96px; height: 96px; border-radius: 50%; background: #fff; font-size: 48px; box-shadow: 0 6px 0 rgba(0,0,0,.18); }
.tts-fallback { background: #fff; border-radius: 12px; padding: 4px 12px; font-size: 22px; font-weight: 900; }
.q-scene { background: #fff; border-radius: var(--radius); padding: 8px 16px; display: flex; align-items: center; gap: 10px; box-shadow: 0 5px 0 rgba(0,0,0,.15); }
.scene-text { font-size: 18px; font-weight: 900; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; }
.match .col { display: flex; flex-direction: column; gap: 10px; }
.m-card { background: #fff; border-radius: 18px; min-height: 76px; font-size: 24px; font-weight: 900; box-shadow: 0 5px 0 rgba(0,0,0,.15); display: grid; place-items: center; }
.m-card.sel { outline: 5px solid var(--bg1); transform: scale(1.04); }
.m-card.matched { background: #d8ffe4; outline: 4px solid var(--ok); opacity: .75; }
.m-card.shake { animation: shake .4s; }

/* 発声カード */
.voice-card { width: 100%; background: linear-gradient(160deg, #fff, #fff4d6); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; box-shadow: 0 6px 0 rgba(0,0,0,.15); border: 4px solid var(--gold); }
.v-title { font-weight: 900; color: #e0572e; font-size: 18px; }
.v-text { font-size: 34px; font-weight: 900; text-align: center; line-height: 1.15; color: var(--ink); }
.v-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; width: 100%; }
.v-row.sub { margin-top: 2px; }
.btn.mic { background: linear-gradient(90deg, #ff5f6d, #ff9a3c); font-size: 22px; flex: 1; min-height: 70px; }
.btn.mic.listening { animation: pulse .7s ease-in-out infinite; }
.v-meter { position: relative; width: 100%; height: 22px; border-radius: 999px; background: #eee; overflow: hidden; }
.v-level { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #b9c3ff; transition: width .05s; }
.v-level.voiced { background: #8ef0a8; }
.v-progress { position: absolute; left: 0; bottom: 0; height: 6px; width: 0; background: var(--accent); transition: width .08s; }
.v-msg { font-weight: 900; text-align: center; min-height: 1.4em; font-size: 16px; }
.parent-hold { position: relative; overflow: hidden; }
.parent-hold.holding::after, .adult-open.holding::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; background: rgba(124,92,255,.35); animation: fill var(--hold, 1500ms) linear forwards; }
.adult-open { position: relative; overflow: hidden; }

/* ───── リザルト ───── */
.result { justify-content: center; }
.win-title { font-size: 44px; font-weight: 900; color: #fff59d; text-shadow: 0 4px 0 #b4501b; }
.stars { display: flex; gap: 8px; }
.star { font-size: 60px; color: rgba(255,255,255,.4); }
.star.on { color: var(--gold); text-shadow: 0 4px 0 #b97f00; }
.res-sprite { width: 160px; height: 160px; }
.res-rows { background: #fff; border-radius: var(--radius); padding: 14px 20px; font-size: 18px; font-weight: 900; display: flex; flex-direction: column; gap: 6px; text-align: center; }
.xp-gain { color: #7c5cff; font-size: 26px; }
.res-btns { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: stretch; }

/* ───── せってい ───── */
.settings .row { width: 100%; display: flex; justify-content: space-between; align-items: center; background: #fff; border-radius: 18px; padding: 10px 14px; font-weight: 900; gap: 8px; }
.switch { min-width: 76px; min-height: 44px; border-radius: 999px; background: #ddd; font-weight: 900; }
.switch.on { background: var(--ok); color: #fff; }
.seg { display: flex; gap: 4px; }
.seg button { min-height: 44px; padding: 0 8px; border-radius: 12px; background: var(--soft); font-weight: 900; font-size: 13px; white-space: nowrap; }
.settings .row:has(.seg) { flex-wrap: wrap; }
.seg button.on { background: var(--bg1); color: #fff; }
.adult { width: 100%; display: flex; flex-direction: column; gap: 10px; background: rgba(255,255,255,.25); border-radius: var(--radius); padding: 12px; }
.adult h2 { color: #fff; margin: 0; font-size: 18px; }
.small-note { color: #fff; font-size: 13px; margin: 0; }

/* ───── そのほか ───── */
.modal { position: absolute; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 20; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 20px; width: 86%; text-align: center; font-size: 20px; font-weight: 900; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(30,20,70,.92); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; z-index: 50; width: max-content; max-width: 90vw; text-align: center; }
.update-bar { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); background: var(--gold); padding: 12px 18px; border-radius: 999px; font-weight: 900; z-index: 60; box-shadow: 0 4px 0 rgba(0,0,0,.2); }

@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes glow { 50% { box-shadow: 0 0 0 6px rgba(255,197,49,.5); } }
@keyframes pulse { 50% { transform: scale(1.05); } }
@keyframes fill { from { width: 0; } to { width: 100%; } }

@media (prefers-reduced-motion: reduce) {
  .tm, .hp-sprite { animation: none; }
}
