/* =========================================================
   クイズバトル スタイル
   - 横画面専用 / レスポンシブ
   - テーマは #app[data-theme] で切替（JSON meta.theme に対応）
   ========================================================= */

:root {
  --bg-1: #1a1030;
  --bg-2: #2b1b4d;
  --accent: #ffcc33;
  --accent-2: #ff5577;
  --player: #4fc3f7;
  --enemy: #e35d6a;
  --text: #ffffff;
  --hp: #44dd66;
  --hp-low: #ff4444;
  --bubble: #ffffff;
  --bubble-text: #222222;
  /* キャラの大きさ。画面に合わせて clamp（dvh＝スマホの実表示高さ基準で はみ出さない） */
  --char-size: clamp(110px, 26dvh, 260px);
}

/* テーマ例：データの meta.theme で雰囲気を変えられる */
#app[data-theme="fantasy"] { --bg-1:#15203a; --bg-2:#243b6b; --accent:#ffd166; --accent-2:#ef476f; }
#app[data-theme="trivia"]  { --bg-1:#16263a; --bg-2:#1f4d6b; --accent:#4fd1c5; --accent-2:#f6ad55; }
#app[data-theme="dark"]    { --bg-1:#0d0d12; --bg-2:#23232e; --accent:#9b8cff; --accent-2:#ff7ab6; }
#app[data-theme="eco"]     { --bg-1:#0e3a2c; --bg-2:#1f7a52; --accent:#ffd34d; --accent-2:#34c759; --player:#5bbf86; --enemy:#7a8a91; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  position: fixed; top: 0; left: 0; width: 100%;
  /* スマホはアドレスバーで高さが変わるので 動的ビューポート高さ(dvh) を使う */
  height: 100%;
  height: 100dvh;
  background: radial-gradient(circle at 30% 20%, var(--bg-2), var(--bg-1) 70%);
  overflow: hidden;
}

/* ===== 画面切替 =====
   入りきらない画面はスクロールできるように。中央寄せは margin:auto で行い、
   はみ出したときに 上も下も スクロールで届く（align-items の未対応に依存しない）。 */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column; align-items: center;   /* 横は中央。縦は子の margin:auto で中央＆スクロール両立 */
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 2vh max(3vw, env(safe-area-inset-right, 0px)) max(2vh, env(safe-area-inset-bottom, 0px)) max(3vw, env(safe-area-inset-left, 0px));
}
.screen.is-active { display: flex; }
.screen > * { margin-top: auto; margin-bottom: auto; }  /* はみ出すと上下とも スクロールで届く */
/* バトルだけは画面に固定（スクロールさせない） */
#screen-battle { overflow: hidden; }
#screen-battle.is-active { display: block; }

/* ===== ボタン ===== */
.btn {
  font: inherit; cursor: pointer;
  border: none; border-radius: 999px;
  padding: 0.7em 2.2em;
  font-size: clamp(16px, 2.6vh, 26px);
  font-weight: 700;
  color: #1a1030;
  background: var(--accent);
  box-shadow: 0 6px 0 rgba(0,0,0,0.3);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.3); }
.btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color:#fff; }

/* ===== タイトル ===== */
.title-inner { text-align: center; }
.game-title {
  font-size: clamp(40px, 9vh, 96px);
  font-weight: 900;
  letter-spacing: .05em;
  text-shadow: 0 4px 0 var(--accent-2), 0 0 30px rgba(255,204,51,.5);
  margin-bottom: .3em;
  animation: bob 2.4s ease-in-out infinite;
}
.title-sub { font-size: clamp(14px, 2.4vh, 22px); opacity:.9; margin-bottom: 1.4em; }
.title-hint { margin-top: 1.6em; font-size: clamp(11px, 1.8vh, 16px); opacity:.65; }
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-10px);} }

/* ===== キャラ選択 ===== */
.select-inner { width: 100%; max-width: 1100px; text-align: center; }
.screen-head { font-size: clamp(20px, 4vh, 38px); margin-bottom: 3vh; }
.char-list { display: flex; gap: 2.5vw; justify-content: center; flex-wrap: wrap; }
.char-card {
  cursor: pointer; background: rgba(255,255,255,.08);
  border: 3px solid transparent; border-radius: 18px;
  padding: 2vh 1.5vw; width: clamp(120px, 18vw, 200px);
  transition: transform .12s, border-color .12s, background .12s;
}
.char-card:hover { transform: translateY(-8px); background: rgba(255,255,255,.16); }
.char-card.is-selected { border-color: var(--accent); background: rgba(255,204,51,.18); }
.char-card .char-thumb {
  width: 100%; aspect-ratio: 1/1; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(36px, 7vh, 72px); font-weight: 900; color: #fff;
  overflow: hidden;
}
.char-card .char-thumb img { width: 100%; height: 100%; object-fit: contain; }
.char-card .char-name { margin-top: 1vh; font-size: clamp(14px, 2.4vh, 20px); font-weight: 700; }

/* =========================================================
   バトル画面
   ========================================================= */
#screen-battle { padding: 0; }

/* === 敵HPプレート：敵リグの下部に少し重ねて表示（右側＝敵の持ち物） === */
.enemy-plate {
  position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%);
  z-index: 16; width: clamp(220px, 30vw, 380px); pointer-events: none;
}
/* 敵の絵に重なっても読めるよう、背後にうっすら暗い下地を敷く */
.enemy-plate::before {
  content: ""; position: absolute; inset: -10px -16px; z-index: -1;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.5), rgba(0,0,0,0) 72%);
}
.enemy-info { display: flex; align-items: baseline; justify-content: center; gap: .8em; margin-bottom: .5vh; }
.enemy-name { font-size: clamp(15px, 2.8vh, 26px); font-weight: 800; text-shadow: 0 2px 4px rgba(0,0,0,.7); }
.enemy-count { font-size: clamp(11px, 1.8vh, 16px); opacity:.85; text-shadow: 0 1px 3px rgba(0,0,0,.8); }

.hpbar {
  position: relative; height: clamp(14px, 2.6vh, 24px);
  background: rgba(0,0,0,.5); border-radius: 999px;
  border: 2px solid rgba(255,255,255,.35); overflow: hidden;
  box-shadow: 0 3px 8px rgba(0,0,0,.4);
}
.hpbar-fill {
  position: absolute; inset: 0; transform-origin: left center;
  background: linear-gradient(90deg, var(--hp), #aaffaa);
  transition: transform .2s cubic-bezier(.2,.85,.25,1);
  transform: scaleX(1);
}
.hpbar-fill.is-low { background: linear-gradient(90deg, var(--hp-low), #ff9999); }
/* 減った瞬間にバーをピカッと光らせる */
.hpbar.hit { animation: hpHit .25s ease; }
@keyframes hpHit { 0%{ filter: brightness(2.4); } 100%{ filter: brightness(1); } }
.hpbar-text {
  position: absolute; inset: 0; display:flex; align-items:center; justify-content:center;
  font-size: clamp(10px, 1.6vh, 14px); font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.8);
}

/* === コンボ：プレイヤー側（左下・ハートの上）。上部は問題帯が使うので下へ集約 === */
.combo {
  position: absolute; bottom: calc(max(2vh, env(safe-area-inset-bottom, 0px)) + clamp(28px, 4.4vh, 44px));
  left: max(2vw, env(safe-area-inset-left, 0px)); z-index: 30; pointer-events: none;
  font-size: clamp(16px, 3.4vh, 34px); font-weight: 900; min-height: 1.1em;
  color: var(--accent); text-shadow: 0 2px 6px rgba(0,0,0,.6);
  transition: transform .15s;
}
.combo.pop { animation: comboPop .35s ease; }
@keyframes comboPop { 0%{transform:scale(1);} 40%{transform:scale(1.5) rotate(-4deg);} 100%{transform:scale(1);} }

/* === ハート（残機）：プレイヤー側（左下） === */
.hearts {
  position: absolute; left: max(2vw, env(safe-area-inset-left, 0px)); bottom: max(2vh, env(safe-area-inset-bottom, 0px)); z-index: 30; pointer-events: none;
  display: flex; gap: .2em;
}
.heart { font-size: clamp(20px, 3.6vh, 36px); transition: transform .2s, opacity .2s; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.heart.lost { animation: heartBreak .5s forwards; }
@keyframes heartBreak {
  0%{ transform: scale(1.4) rotate(0);} 30%{ transform: scale(1.5) rotate(-15deg);}
  100%{ transform: scale(0) rotate(40deg); opacity:0; }
}

/* 対戦ステージ */
.stage {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: 1fr 1.15fr; align-items: center;
  /* 上部の問題帯（画面トップ固定）のぶん、キャラ全体を少し下げる。中心線は揃ったまま。 */
  padding-top: 11dvh;
}
/* ヒット時の画面ゆれ＋カメラパンチ（ぐっと寄る）を1つの transform で */
.stage.shake { animation: shake .4s; }
.stage.shake-big { animation: shakeBig .52s; }
@keyframes shake { 0%,100%{transform:translate(0,0) scale(1);} 25%{transform:translate(-6px,3px) scale(1.012);} 50%{transform:translate(5px,-4px) scale(1.018);} 75%{transform:translate(-4px,2px) scale(1.006);} }
@keyframes shakeBig { 0%,100%{transform:translate(0,0) scale(1);} 15%{transform:translate(-15px,9px) scale(1.04);} 35%{transform:translate(13px,-11px) scale(1.03);} 55%{transform:translate(-11px,7px) scale(1.02);} 80%{transform:translate(8px,-5px) scale(1.01);} }

/* --- 自キャラゾーン ---
   padding-left で左に答えスペースを確保し、キャラを少し右へ寄せる。
   .player-rig はキャラと同じ大きさの基準枠。選択肢はこの枠に密着して配置する。 */
.player-zone { position: relative; height: 100%; display:flex; align-items:center; justify-content:center; padding-left: max(env(safe-area-inset-left, 0px), clamp(150px, 24vw, 330px)); }
.player-rig  { position: relative; width: var(--char-size); height: var(--char-size); }
/* 敵は自キャラと同じ高さ（横中心線）に合わせるため、上下の余白は入れず中央に置く。
   HPは敵リグの下部へ重ねるので下の余白も不要。 */
.enemy-zone  { position: relative; height: 100%; display:flex; align-items:center; justify-content:center; }
/* 敵リグが敵のサイズを決め、中の #enemy-char は --char-size を継承する。
   迫力重視で大きく（自キャラの約2〜2.5倍）。ボスはさらに大きく。 */
.enemy-rig      { position: relative; width: var(--char-size); height: var(--char-size); --char-size: clamp(190px, 64dvh, 580px); }
.enemy-rig.boss { --char-size: clamp(210px, 70dvh, 640px); }

.char-sprite {
  width: var(--char-size); height: var(--char-size);
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--char-size) * .5); font-weight: 900; color:#fff;
  position: relative; overflow: visible;
  filter: drop-shadow(0 12px 18px rgba(0,0,0,.5));
}
.char-sprite img { width: 100%; height: 100%; object-fit: contain; }
.char-sprite .ph {
  width:100%; height:100%; border-radius:24px; display:flex; align-items:center; justify-content:center;
}
/* 自キャラは いつもちょっと動く（息づかい＋ゆれ） */
.player-sprite { animation: idle 2.4s ease-in-out infinite; }
@keyframes idle {
  0%,100%{ transform: translateY(0) rotate(0deg) scale(1);}
  25%{ transform: translateY(-6px) rotate(-2deg) scale(1.01);}
  50%{ transform: translateY(-9px) rotate(0deg) scale(1.03);}
  75%{ transform: translateY(-6px) rotate(2deg) scale(1.01);}
}
.player-sprite.attack { animation: playerAttack .5s ease; }
@keyframes playerAttack { 0%{transform:translateX(0) scale(1);} 20%{transform:translateX(-26px) scale(.92);} 55%{transform:translateX(34px) scale(1.16);} 100%{transform:translateX(0) scale(1);} }
/* 撃破時の よろこびジャンプ／被弾時の ひるみ */
.player-sprite.cheer { animation: playerCheer .55s ease; }
@keyframes playerCheer { 0%{transform:translateY(0) scale(1);} 30%{transform:translateY(-30px) scale(1.1) rotate(-4deg);} 60%{transform:translateY(0) scale(.95);} 80%{transform:translateY(-8px) scale(1.02);} 100%{transform:translateY(0) scale(1);} }
.player-sprite.flinch { animation: playerFlinch .4s ease; }
@keyframes playerFlinch { 0%,100%{transform:translateX(0) rotate(0);} 25%{transform:translateX(-12px) rotate(-5deg);} 60%{transform:translateX(7px) rotate(4deg);} }

.enemy-sprite { animation: enemyIdle 3s ease-in-out infinite; }
@keyframes enemyIdle { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-6px);} }
.enemy-sprite.recoil { animation: enemyRecoil .45s ease; }
@keyframes enemyRecoil { 0%{transform:translateX(0) rotate(0);} 25%{transform:translateX(34px) rotate(8deg);} 55%{transform:translateX(18px) rotate(4deg);} 100%{transform:translateX(0) rotate(0);} }
.enemy-sprite.enter { animation: enemyEnter .6s cubic-bezier(.2,.8,.3,1.2); }
@keyframes enemyEnter { 0%{ transform: translateX(120%) scale(.6); opacity:0;} 100%{ transform: translateX(0) scale(1); opacity:1;} }
.enemy-sprite.defeat { animation: enemyDefeat .7s forwards; }
@keyframes enemyDefeat { 0%{transform:rotate(0) scale(1); opacity:1;} 40%{transform:rotate(10deg) translateY(-10px);} 100%{transform:rotate(80deg) translateY(140%) scale(.8); opacity:0; filter:grayscale(1);} }
.enemy-sprite.hit-flash { filter: brightness(3) drop-shadow(0 0 20px #fff); }

/* --- 放射状の選択肢（上・左・下） --- */
.choice {
  position: absolute; z-index: 20;
  font: inherit; cursor: pointer;
  border: 3px solid rgba(255,255,255,.5);
  background: rgba(20,12,40,.82);
  color: #fff; font-weight: 700;
  border-radius: 16px;
  padding: .6em .95em;
  width: clamp(150px, 22vw, 300px);
  min-height: clamp(52px, 9vh, 76px);
  font-size: clamp(16px, 2.5vh, 24px);
  line-height: 1.35;
  display: flex; align-items: center; justify-content: center; text-align: center;
  box-shadow: 0 6px 14px rgba(0,0,0,.4);
  transition: transform .1s, background .1s, border-color .1s;
}
/* 中央そろえは translate プロパティ、ホバーは scale プロパティ、ゆらぎは transform を使い分けて衝突回避 */
.choice:hover { background: rgba(60,40,100,.95); border-color: var(--accent); scale: 1.06; }
.choice:active { scale: .96; }
/* 方向矢印：大きく・太く・ボタンにかぶせて、押す方向へ動く */
.choice { overflow: visible; }
.choice .answer-text { display: block; }
.choice .dir-key {
  position: absolute; z-index: 22; pointer-events: none;
  font-size: clamp(30px, 6vh, 54px); font-weight: 900; line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 4px #000, 0 2px 4px rgba(0,0,0,.7), 0 0 12px var(--accent);
}
/* 各方向：キャラ側のフチ（隙間）にかぶせ、その方向へぴょこぴょこ動く（文字は隠さない） */
.choice[data-dir="up"]   .dir-key { left: 50%; top: calc(100% - 12px);    animation: arrUp .7s ease-in-out infinite; }
.choice[data-dir="down"] .dir-key { left: 50%; bottom: calc(100% - 12px); animation: arrDown .7s ease-in-out infinite; }
.choice[data-dir="left"] .dir-key { top: 50%; left: calc(100% - 12px);    animation: arrLeft .7s ease-in-out infinite; }
@keyframes arrUp   { 0%,100%{ transform: translateX(-50%) translateY(0);} 50%{ transform: translateX(-50%) translateY(-9px);} }
@keyframes arrDown { 0%,100%{ transform: translateX(-50%) translateY(0);} 50%{ transform: translateX(-50%) translateY(9px);} }
@keyframes arrLeft { 0%,100%{ transform: translateY(-50%) translateX(0);} 50%{ transform: translateY(-50%) translateX(-9px);} }
.choice.correct { background: var(--hp); border-color:#fff; color:#06310f; }
.choice.wrong   { background: var(--hp-low); border-color:#fff; }
.choice.disabled { pointer-events: none; }

/* 配置：自キャラ（.player-rig）のすぐ上・左・下に密着。中央そろえは translate プロパティで。
   ゆらぎ（transform アニメ）と両立する。 */
.choice {
  --gap: clamp(8px, 1.6vh, 16px);
}
.choice[data-dir="up"]   { left: 50%; bottom: calc(100% + var(--gap)); translate: -50% 0; animation: bobY 3.4s ease-in-out infinite; }
.choice[data-dir="left"] { top: 50%; right: calc(100% + var(--gap)); translate: 0 -50%; max-width: 22vw; animation: bobX 3.8s ease-in-out infinite .3s; }
.choice[data-dir="down"] { left: 50%; top: calc(100% + var(--gap)); translate: -50% 0; animation: bobY 3.4s ease-in-out infinite .6s; }
@keyframes bobY { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-5px);} }
@keyframes bobX { 0%,100%{ transform: translateX(0);} 50%{ transform: translateX(-5px);} }

/* --- 問題文：上部いっぱいの大きな帯（メリハリ重視で大きく） --- */
.speech-bubble {
  position: absolute; top: 1.4dvh; left: 50%; transform: translateX(-50%);
  z-index: 15;
  background: var(--bubble); color: var(--bubble-text);
  border-radius: 22px; padding: .6em 1.4em;
  width: min(94vw, 1100px);
  font-size: clamp(19px, 4.1dvh, 44px); font-weight: 900; line-height: 1.28;
  letter-spacing: .01em;
  box-shadow: 0 10px 26px rgba(0,0,0,.5);
  border: 3px solid var(--accent);
  text-align: center;
  /* 2行ぶんを確保しつつ、長い問題は3行まで自然に伸びる */
  min-height: calc(2 * 1.3em + 1.2em);
  display: flex; align-items: center; justify-content: center;
}
/* 「クイズ！」バッジ（メリハリ） */
.speech-bubble::before {
  content: "クイズ！"; position: absolute; top: -14px; left: 22px;
  background: var(--accent-2); color: #fff; font-size: clamp(11px, 1.8vh, 16px);
  font-weight: 800; padding: .25em .9em; border-radius: 999px;
  box-shadow: 0 3px 8px rgba(0,0,0,.4); letter-spacing: .04em;
}
/* しっぽは右下（敵の方）に出して「敵が出題している」感を残す */
.speech-bubble::after {
  content: ""; position: absolute; bottom: -16px; right: 16%;
  border: 12px solid transparent; border-top-color: var(--bubble); border-bottom: 0;
}
.speech-bubble.pop { animation: bubblePop .34s cubic-bezier(.2,.9,.3,1.3); }
@keyframes bubblePop { 0%{ transform: translateX(-50%) scale(.88); opacity:0;} 100%{ transform: translateX(-50%) scale(1); opacity:1;} }

/* --- 演出レイヤ（技） --- */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 25; overflow: hidden; }
.projectile {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--accent) 40%, var(--accent-2) 100%);
  box-shadow: 0 0 30px var(--accent), 0 0 60px var(--accent-2);
  transform: translate(-50%, -50%);
  will-change: left, top, transform, opacity;
}
.impact {
  position: absolute; border-radius: 50%;
  border: 6px solid #fff; transform: translate(-50%,-50%) scale(0);
  animation: impact .4s ease-out forwards;
}
@keyframes impact { 0%{ transform:translate(-50%,-50%) scale(.2); opacity:1;} 100%{ transform:translate(-50%,-50%) scale(2.4); opacity:0;} }
.spark {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); transform: translate(-50%,-50%);
  animation: spark .55s ease-out forwards;
}
@keyframes spark { to { opacity:0; } }
.dmg-num {
  position: absolute; transform: translate(-50%,-50%);
  font-size: clamp(28px, 7vh, 70px); font-weight: 900; color: #fff;
  text-shadow: 0 0 12px var(--accent-2), 0 3px 0 #b00;
  animation: dmgNum .7s ease-out forwards;
}
@keyframes dmgNum { 0%{ transform: translate(-50%,-50%) scale(.4);} 30%{ transform: translate(-50%,-130%) scale(1.3);} 100%{ transform: translate(-50%,-220%) scale(1); opacity:0;} }
.dmg-num.big { font-size: clamp(40px, 10vh, 100px); color: var(--accent); text-shadow: 0 0 16px var(--accent), 0 0 30px var(--accent-2), 0 3px 0 #b00; }

/* --- フラッシュ（正解・解説の一瞬表示） --- */
.flash {
  position: absolute; left: 50%; bottom: 6vh; transform: translateX(-50%) translateY(20px);
  z-index: 40; opacity: 0; pointer-events: none;
  background: rgba(0,0,0,.8); color:#fff;
  padding: .8em 1.4em; border-radius: 14px;
  font-size: clamp(13px, 2.4vh, 22px); font-weight: 700; max-width: 80vw; text-align:center;
  border: 2px solid var(--accent);
}
.flash.show { animation: flashIn 1.1s ease; }
.flash.correct-banner { border-color: var(--hp); }
.flash.wrong-banner { border-color: var(--hp-low); }
@keyframes flashIn { 0%{ opacity:0; transform: translateX(-50%) translateY(20px);} 15%,80%{ opacity:1; transform: translateX(-50%) translateY(0);} 100%{ opacity:0; transform: translateX(-50%) translateY(-10px);} }

/* コンボ大／ボスヒット時の金色フチ光（ご褒美演出） */
.stage.rim::after {
  content:""; position:absolute; inset:0; z-index:48; pointer-events:none;
  box-shadow: inset 0 0 0 6px var(--accent), inset 0 0 40px 6px var(--accent);
  animation: rimFlash .36s ease-out;
}
@keyframes rimFlash { 0%{ opacity:.9; } 100%{ opacity:0; } }

/* 正解時の画面フラッシュ。
   既定 opacity:0・pointer-events:none にしておき、アニメ中だけ白くする。
   （fill-mode を使わないので、アニメ終了後は必ず opacity:0 へ戻る＝白が残らない） */
.stage.flash-white::before {
  content:""; position:absolute; inset:0; background:#fff; z-index:50;
  pointer-events:none; opacity:0;
  animation: whiteFlash .25s ease-out;
}
@keyframes whiteFlash { 0%{opacity:.42;} 100%{opacity:0;} }
/* ヒットストップ：着弾の一瞬、全アニメを止めて“重み”を出す */
.stage.hitstop, .stage.hitstop * { animation-play-state: paused !important; }

/* =========================================================
   クリア画面
   ========================================================= */
.clear-inner { text-align: center; padding: 2vh 1vw; width: 100%; max-width: 860px; }
.clear-title { font-size: clamp(30px, 7vh, 70px); font-weight: 900; color: var(--accent); text-shadow: 0 4px 0 var(--accent-2); margin-bottom: .4vh; animation: bob 2s ease-in-out infinite; }
.clear-sub { font-size: clamp(14px, 2.6vh, 22px); margin-bottom: 1.6vh; opacity: .95; }
.clear-top { display: flex; align-items: center; justify-content: center; gap: clamp(16px, 4vw, 48px); flex-wrap: wrap; margin-bottom: 1.6vh; }
/* きょう まなんだこと */
.learn-box { background: rgba(0,0,0,.3); border-radius: 16px; padding: 1.2em 1.2em; margin: 0 auto 2vh; max-width: 760px; text-align: left; }
.learn-title { font-size: clamp(16px, 3vh, 24px); font-weight: 900; color: var(--accent); margin-bottom: .6em; text-align: center; }
.learn-list { list-style: none; display: flex; flex-direction: column; gap: .7em; max-height: clamp(120px, 30dvh, 320px); overflow-y: auto; }
.learn-list li { background: rgba(255,255,255,.07); border-radius: 10px; padding: .55em .8em; display: flex; flex-direction: column; gap: .15em; }
.learn-q { font-size: clamp(12px, 2vh, 17px); font-weight: 700; }
.learn-a { font-size: clamp(12px, 2vh, 17px); color: var(--accent); font-weight: 800; }
.learn-e { font-size: clamp(11px, 1.8vh, 15px); opacity: .85; }
.rank-badge {
  width: clamp(110px, 22vh, 200px); height: clamp(110px, 22vh, 200px);
  margin: 0 auto 2vh; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(60px, 14vh, 130px); font-weight: 900; color:#1a1030;
  background: radial-gradient(circle at 35% 30%, #fff, var(--accent) 60%, var(--accent-2));
  box-shadow: 0 0 40px var(--accent), inset 0 0 20px rgba(255,255,255,.6);
  animation: rankPop .6s cubic-bezier(.2,.8,.3,1.4);
}
@keyframes rankPop { 0%{ transform: scale(0) rotate(-30deg);} 100%{ transform: scale(1) rotate(0);} }
.result-list { list-style: none; font-size: clamp(16px, 3vh, 28px); margin-bottom: 3vh; line-height: 1.8; }
.result-list span { color: var(--accent); font-weight: 800; }

/* =========================================================
   縦持ち回転案内
   ========================================================= */
.orientation-overlay {
  position: fixed; inset: 0; z-index: 999;
  display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 3vh;
  background: #11091f; color: #fff; text-align: center;
  font-size: clamp(18px, 5vw, 32px); font-weight: 700; padding: 6vw;
}
.rotate-icon { font-size: clamp(60px, 18vw, 120px); animation: rotateHint 2s ease-in-out infinite; }
@keyframes rotateHint { 0%,100%{ transform: rotate(0);} 50%{ transform: rotate(90deg);} }

/* 縦持ち時：本体を隠してオーバーレイを出す。
   ただし「タッチ端末（スマホ／タブレット）の縦持ち」だけに限定する。
   → PC・プレビュー（マウス操作=pointer:fine）では、ウィンドウが縦長でも遊べる。
     実機スマホを縦に持ったときだけ回転案内が出る（仕様書どおり）。 */
@media (orientation: portrait) and (pointer: coarse) {
  #app { display: none; }
  .orientation-overlay { display: flex; }
}
/* 横でも極端に低い高さは選択肢が窮屈なので少し詰める */
@media (orientation: landscape) and (max-height: 380px) {
  :root { --char-size: clamp(90px, 22vh, 160px); }
  .choice { padding: .4em .6em; }
  .speech-bubble { font-size: clamp(18px, 5vh, 30px); }
}

/* =========================================================
   追加演出・画面（リッチ化／ストーリー／あそびかた／音声）
   ========================================================= */

/* ふわふわ漂う粒（環境エフェクト） */
.ambient { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.particle { position: absolute; bottom: -40px; will-change: transform, opacity; opacity: 0; }
@keyframes floatUp {
  0%   { transform: translateY(0) translateX(0) rotate(0); opacity: 0; }
  12%  { opacity: .65; }
  88%  { opacity: .65; }
  100% { transform: translateY(-112vh) translateX(40px) rotate(300deg); opacity: 0; }
}

/* 撃破時の はじけ */
.burst {
  position: absolute; transform: translate(-50%,-50%);
  font-size: clamp(40px, 10vh, 90px); font-weight: 900; color: #fff;
  text-shadow: 0 0 16px var(--accent), 0 0 30px var(--accent-2);
  animation: burst .8s ease-out forwards; pointer-events: none;
}
@keyframes burst { 0%{ transform: translate(-50%,-50%) scale(.3) rotate(-10deg); opacity:1;} 60%{ transform: translate(-50%,-60%) scale(1.2) rotate(6deg); opacity:1;} 100%{ transform: translate(-50%,-80%) scale(1) rotate(0); opacity:0;} }

/* ボタン類 */
.title-btns { display: flex; gap: 1.2em; justify-content: center; flex-wrap: wrap; }
.btn-sub {
  background: rgba(255,255,255,.16); color: #fff; border: 2px solid rgba(255,255,255,.5);
}
.voice-toggle {
  position: absolute; top: max(1.2vh, env(safe-area-inset-top,0px));
  right: max(1.4vw, env(safe-area-inset-right,0px)); z-index: 200;
  width: clamp(40px, 7vh, 56px); height: clamp(40px, 7vh, 56px);
  border-radius: 50%; border: 2px solid rgba(255,255,255,.5);
  background: rgba(0,0,0,.4); color: #fff; font-size: clamp(18px, 3.4vh, 28px);
  cursor: pointer; line-height: 1; padding: 0;
}
.voice-toggle:active { transform: scale(.92); }

/* ストーリー／あそびかた（1枚絵） */
.info-inner { width: 100%; max-width: 860px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1.6vh; }
.info-art, .story-art {
  width: min(86vw, 720px); aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden;
  background: rgba(0,0,0,.25); box-shadow: 0 10px 30px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff;
}
#story-art { width: min(80vw, 680px); }
.info-art img, #story-art img { width: 100%; height: 100%; object-fit: cover; }
.info-title { font-size: clamp(22px, 4.4vh, 40px); font-weight: 900; color: var(--accent); text-shadow: 0 3px 0 var(--accent-2); }
.info-text { list-style: none; text-align: left; font-size: clamp(13px, 2.4vh, 20px); line-height: 1.5; max-width: 720px; display: flex; flex-direction: column; gap: .6em; }
.info-text li { position: relative; padding-left: 1.6em; }
.info-text li::before { content: "✔"; position: absolute; left: 0; color: var(--accent); font-weight: 900; }
.story-text {
  font-size: clamp(15px, 3vh, 26px); font-weight: 700; line-height: 1.6; max-width: 760px;
  background: rgba(0,0,0,.3); padding: .9em 1.2em; border-radius: 14px; border-left: 5px solid var(--accent);
}
#screen-story.is-active .info-art, #screen-story.is-active .story-text,
#screen-story.is-active .btn { animation: riseIn .5s ease both; }
#screen-story.is-active .story-text { animation-delay: .12s; }
#screen-story.is-active .btn { animation-delay: .24s; }
@keyframes riseIn { 0%{ opacity:0; transform: translateY(18px);} 100%{ opacity:1; transform: translateY(0);} }

/* 動きを減らす設定の人には控えめに */
@media (prefers-reduced-motion: reduce) {
  .player-sprite, .enemy-sprite, .choice, .particle, .combo, .game-title, .clear-title { animation: none !important; }
}
