/* 仕訳クエスト — 簿記3級RPG。スマホ縦持ち最優先のレイアウト。 */
:root {
  --bg: #0f1226;
  --bg2: #1a1f3d;
  --panel: #232a52;
  --ink: #eef1ff;
  --sub: #aab2e0;
  --accent: #ffd23f;
  --good: #46d39a;
  --bad: #ff5d6c;
  --hp: #ff5d6c;
  --mp: #46c5ff;
  --xp: #ffd23f;
  --line: #3a4280;
  --shadow: 0 6px 0 rgba(0,0,0,.35);
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: radial-gradient(120% 100% at 50% 0%, #1b2150 0%, var(--bg) 60%);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  -webkit-text-size-adjust: 100%;
}
#app {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== 共通パーツ ===== */
.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #2a230a;
  font-weight: 800;
  font-size: 17px;
  padding: 15px 16px;
  width: 100%;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .05s ease, filter .1s ease;
  letter-spacing: .02em;
}
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.btn.sub { background: var(--panel); color: var(--ink); box-shadow: 0 5px 0 #161a36; }
.btn.ghost { background: transparent; color: var(--sub); box-shadow: none; font-size: 14px; padding: 10px; font-weight: 700; }
.card {
  background: linear-gradient(180deg, var(--bg2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.center { text-align: center; }
.hide { display: none !important; }
.muted { color: var(--sub); font-size: 13px; line-height: 1.7; }
.tag { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: #3a4280; color: #dfe4ff; }

/* ===== タイトル ===== */
.title-wrap { display: flex; flex-direction: column; gap: 14px; justify-content: center; flex: 1; }
.logo { text-align: center; padding: 8px 0 0; }
.logo .em { font-size: 56px; line-height: 1; filter: drop-shadow(0 4px 0 rgba(0,0,0,.4)); }
.logo h1 { font-size: 30px; margin: 8px 0 2px; letter-spacing: .06em; }
.logo .by { color: var(--sub); font-size: 13px; font-weight: 700; }
.stat-row { display: flex; gap: 8px; }
.stat-box { flex: 1; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat-box .n { font-size: 22px; font-weight: 900; color: var(--accent); }
.stat-box .l { font-size: 11px; color: var(--sub); margin-top: 2px; }

/* ===== ステージ選択 ===== */
.stage { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line); margin-bottom: 10px; cursor: pointer; transition: transform .05s; }
.stage:active { transform: scale(.985); }
.stage.locked { opacity: .45; cursor: not-allowed; }
.stage.cleared { border-color: var(--good); }
.stage .ic { font-size: 30px; width: 42px; text-align: center; }
.stage .body { flex: 1; }
.stage .body .h { font-weight: 800; font-size: 15px; }
.stage .body .s { color: var(--sub); font-size: 12px; margin-top: 2px; }
.stage .right { font-size: 13px; font-weight: 800; color: var(--accent); }
.stage.locked .right { color: var(--sub); }

/* ===== バトル ===== */
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar .back { font-size: 22px; background: none; border: none; color: var(--sub); cursor: pointer; padding: 4px 6px; }
.topbar .who { font-weight: 800; font-size: 14px; }
.topbar .lv { margin-left: auto; font-size: 12px; }

.enemy-stage {
  position: relative;
  background: linear-gradient(180deg, #2a2350 0%, #1a1f3d 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 18px;
  overflow: hidden;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.enemy-stage::after { /* 地面 */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 34px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.35));
}
.enemy-name { font-weight: 800; font-size: 14px; margin-bottom: 4px; color: #ffe9a8; }
.enemy-emoji { font-size: 78px; line-height: 1; filter: drop-shadow(0 6px 0 rgba(0,0,0,.4)); }
.bar { height: 14px; border-radius: 999px; background: #11142b; overflow: hidden; border: 1px solid #000a; }
.bar > i { display: block; height: 100%; border-radius: 999px; transition: width .35s ease; }
.bar.enemy { width: 78%; margin-top: 12px; }
.bar.enemy > i { background: linear-gradient(90deg, #ff8a3d, var(--hp)); }
.enemy-hp-num { font-size: 11px; color: var(--sub); margin-top: 5px; }

/* ヒット演出 */
.dmg-float { position: absolute; font-weight: 900; font-size: 30px; color: var(--accent); text-shadow: 0 2px 0 #000; pointer-events: none; animation: floatUp 1s ease forwards; }
.dmg-float.crit { color: #fff; font-size: 40px; }
@keyframes floatUp { 0% { transform: translateY(0) scale(.6); opacity: 0; } 20% { opacity: 1; transform: translateY(-6px) scale(1.15); } 100% { transform: translateY(-52px) scale(1); opacity: 0; } }
.shake { animation: shake .35s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-9px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-6px)} 80%{transform:translateX(4px)} }
.hitflash { animation: hitflash .3s ease; }
@keyframes hitflash { 0%{filter:none} 50%{filter:brightness(2.4) sepia(1) hue-rotate(-20deg)} 100%{filter:none} }

/* プレイヤーHUD */
.player-hud { display: flex; align-items: center; gap: 10px; }
.player-hud .av { font-size: 30px; }
.player-hud .bars { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.player-hud .bar { height: 12px; }
.player-hud .bar.hp > i { background: linear-gradient(90deg, #ff8a3d, var(--hp)); }
.player-hud .bar.mp > i { background: linear-gradient(90deg, #46c5ff, var(--mp)); }
.player-hud .small { font-size: 10px; color: var(--sub); display: flex; justify-content: space-between; }

/* コンボ */
.combo { text-align: center; font-weight: 900; height: 22px; color: var(--accent); font-size: 16px; letter-spacing: .04em; transition: transform .1s; }
.combo.pop { animation: comboPop .3s ease; }
@keyframes comboPop { 0%{transform:scale(.6)} 60%{transform:scale(1.3)} 100%{transform:scale(1)} }

/* 問題 */
.q-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sub); }
.q-text { font-size: 17px; font-weight: 800; line-height: 1.6; margin: 8px 0 4px; }
.opts { display: flex; flex-direction: column; gap: 9px; margin-top: 8px; }
.opt {
  text-align: left; width: 100%; padding: 14px 15px; border-radius: 13px;
  background: var(--bg2); border: 1.5px solid var(--line); color: var(--ink);
  font-size: 16px; font-weight: 700; cursor: pointer; transition: transform .05s, background .1s, border-color .1s;
}
.opt:active { transform: scale(.99); }
.opt.correct { background: rgba(70,211,154,.18); border-color: var(--good); }
.opt.wrong { background: rgba(255,93,108,.16); border-color: var(--bad); }
.opt:disabled { cursor: default; }
.opt .key { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 6px; background: #3a4280; font-size: 13px; margin-right: 8px; font-weight: 900; }

.special-btn { background: linear-gradient(90deg,#ff8a3d,#ff5d6c); color: #fff; }
.special-btn:disabled { filter: grayscale(.7) brightness(.7); }

/* 結果モーダル */
.overlay { position: fixed; inset: 0; background: rgba(6,8,20,.78); display: flex; align-items: center; justify-content: center; padding: 22px; z-index: 50; backdrop-filter: blur(3px); }
.modal { width: 100%; max-width: 380px; background: linear-gradient(180deg, var(--bg2), var(--panel)); border: 1px solid var(--line); border-radius: 20px; padding: 24px 20px; text-align: center; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.modal .big { font-size: 46px; }
.modal h2 { margin: 8px 0 2px; font-size: 24px; }
.modal .reward { margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.reward-line { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; }
.reward-line b { color: var(--accent); }
.pop-in { animation: popIn .35s cubic-bezier(.2,1.2,.4,1); }
@keyframes popIn { 0%{transform:scale(.7);opacity:0} 100%{transform:scale(1);opacity:1} }

/* トースト（解説など） */
.explain { background: rgba(70,197,255,.12); border: 1px solid #3f6fa8; border-radius: 12px; padding: 11px 13px; font-size: 13px; line-height: 1.6; color: #d7ecff; }
.footer-note { text-align: center; color: var(--sub); font-size: 11px; padding: 6px 0 2px; }
a.link { color: var(--accent); text-decoration: none; font-weight: 700; }
