/* OH! KENO — 漆黒キャンバス + 青ピルCTA の静かなクローム。
   当たった瞬間だけ派手にする（fx-*）。 */

/* ---------- リセット ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* ダブルタップ拡大を全面的に無効化（touch-action は継承しないので全要素に。
     パンとピンチ拡大は残る） */
  touch-action: manipulation;
  /* テキスト選択・拡大鏡対策も全要素に直接当てる（継承頼みにしない） */
  -webkit-user-select: none;
  user-select: none;
}
[hidden] {
  display: none !important;
}
dialog {
  margin: auto; /* リセットで UA の中央寄せを消さない */
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- トークン ---------- */
:root {
  --canvas: #0a0b0d;
  --surface: #131519;
  --card: #1b1e24;
  --hairline: rgba(230, 233, 240, 0.14);
  --text: #f4f6fa;
  --text-body: rgba(244, 246, 250, 0.72);
  --text-mute: rgba(244, 246, 250, 0.45);
  --accent: #2b8cff;
  --accent-pressed: #1f6fd0;
  --buy: #e05a1a;
  --buy-pressed: #b84812;
  --gold: #ffd24a;
  --gold-deep: #f0a41f;
  --danger: #ff4d67;
  --weak: #ffd24a;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-pill: 999px;
  --sp-xs: 8px;
  --sp-sm: 12px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans JP", sans-serif;
}

html {
  height: 100%;
}
body {
  min-height: 100%;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  /* ゲームUIなのでテキスト選択・長押しメニューを無効化 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: var(--sp-md);
  z-index: 100;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus {
  top: var(--sp-md);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 共通レイアウト ---------- */
main {
  max-width: 520px;
  margin: 0 auto;
  /* body 側で safe-area 分を padding しているので、その分を引いておかないと
     ノッチ/ホームバーのある実機で main が body からはみ出して縦スクロールが出る。 */
  min-height: calc(
    100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)
  );
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--sp-md);
}

.screen-center {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: var(--sp-md);
}

.screen-heading {
  font-size: 34px;
  font-weight: 300;
  letter-spacing: 0.04em;
}
.screen-sub {
  color: var(--text-body);
}
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  width: 100%;
  max-width: 320px;
  margin-top: var(--sp-sm);
}

/* タイトルの設定ボタン（⚙） */
.title-settings {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  right: calc(env(safe-area-inset-right) + 10px);
  z-index: 5;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--hairline);
  font-size: 20px;
  line-height: 1;
}
.title-settings:active {
  transform: scale(0.94);
}
.title-settings img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  vertical-align: middle;
}

/* 設定パネル */
.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: var(--sp-md) 0;
}
.setting-row label {
  flex: none;
  width: 82px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
}
.setting-row input[type="range"] {
  flex: 1;
  height: 28px;
  accent-color: var(--accent);
  touch-action: none; /* ドラッグで値を変えられるように */
}
.setting-val {
  flex: none;
  width: 30px;
  text-align: right;
  font-size: 13px;
  color: var(--text-body);
  font-variant-numeric: tabular-nums;
}

/* 言語切り替え（日本語 / English） */
.setting-lang {
  flex-wrap: wrap;
}
.setting-lang-label {
  flex: none;
  font-size: 14px;
  font-weight: 600;
}
.lang-toggle {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.lang-btn {
  min-height: 40px;
  padding: 8px 18px;
  font-size: 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--hairline);
}
.lang-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------- ピルボタン ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 28px;
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: transform 0.06s, background-color 0.12s;
}
.pill:active {
  transform: scale(0.97);
}
.pill-primary {
  background: var(--accent);
  color: #fff;
}
.pill-primary:active {
  background: var(--accent-pressed);
}
.pill-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--hairline);
}
.pill-buy {
  background: var(--buy);
  color: #fff;
  min-height: 40px;
  padding: 8px 20px;
  font-size: 14px;
}
.pill-buy:active {
  background: var(--buy-pressed);
}
.pill-big {
  min-height: 56px;
  font-size: 18px;
  align-self: center;
  min-width: 240px;
}
.pill:disabled {
  opacity: 0.35;
  cursor: default;
}
.pill:disabled:active {
  transform: none;
}

/* ---------- タイトル ----------
   キーアートを主役に大きく見せ、ロゴと「はじめる」を画面中央付近に置く。
   縦センタリングだが、短い端末であふれても届くよう overflow-y:auto を保険に。 */
.screen-title {
  position: relative;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 0;
  overflow: hidden;
}
/* キーアートを画面いっぱいの背景にして、ロゴ・ボタンをその上にオーバーレイする */
.title-hero {
  position: absolute;
  inset: 0;
  width: 100%;
  display: block;
}
.title-logo {
  position: absolute;
  top: 5%;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
}
.title-logo-img {
  display: block;
  margin: 0 auto;
  width: clamp(240px, 66vw, 380px);
  height: auto;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.65))
    drop-shadow(0 0 22px rgba(43, 140, 255, 0.35));
}
/* ロゴの下・アート中央付近に、ボタンを縦積みでオーバーレイする
   （つづきから + さいしょから の2つが並んでも収まるよう縦センターの列にする） */
.title-actions {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: 92%;
}
#btn-continue,
#btn-start {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6), 0 0 26px rgba(43, 140, 255, 0.5);
}
.title-grid-deco {
  width: 150px;
  height: 90px;
  margin: var(--sp-xs) 0;
  background-image: radial-gradient(
    circle,
    rgba(43, 140, 255, 0.55) 3px,
    transparent 3.5px
  );
  background-size: 30px 30px;
  background-position: center;
}
.title-best {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  z-index: 2;
  font-size: 14px;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}
/* バージョン表記（右下・控えめ） */
.title-version {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 12px);
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 2;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(230, 233, 240, 0.6);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  font-variant-numeric: tabular-nums;
}
.howto {
  margin-top: var(--sp-lg);
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: var(--sp-md);
  text-align: left;
}
.howto-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--text-mute);
  margin-bottom: var(--sp-xs);
}
.howto-list {
  list-style: none;
  counter-reset: howto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--text-body);
}
.howto-list li {
  counter-increment: howto;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.howto-list li::before {
  content: counter(howto);
  flex: none;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(43, 140, 255, 0.18);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  transform: translateY(3px);
}

/* ---------- バトル画面 ----------
   スマホで縦スクロールなしに全UI（敵〜BATTLEボタン）が収まるよう、
   画面の高さに固定してグリッド側を伸縮させる。 */
.screen-battle {
  height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: hidden;
  gap: 8px;
  padding: 8px 12px 10px;
  /* 敵フィギュアのサイズ。画面が低い端末では自動で小さくして、はみ出さない */
  --enemy-size: clamp(104px, 20vh, 150px);
}
.battle-header {
  display: flex;
  flex-wrap: wrap; /* 進行バーは折り返して独自の行（全幅）に置く */
  align-items: center;
  gap: var(--sp-sm);
  row-gap: 4px;
  min-height: 30px;
  padding-right: 96px; /* グローバルトグルと重ねない */
  flex: none;
}
.world-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  white-space: nowrap; /* 「WORLD 1」を1段に */
  flex: none;
}
.world-progress {
  flex: 1 1 100%; /* 折り返して独自の行を全幅で使う（ラベル/スキルHUDと取り合わない） */
  min-width: 0;
  /* 親 battle-header の padding-right:96px（コインHUD回避）を打ち消し、この行だけは
     全幅で真ん中に寄せる（そうしないと中央寄せが 48px 左にズレる）。コインは上段の
     高さにあり、パンくずは中央に集まるので重ならない。 */
  margin-right: -96px;
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center; /* X方向の中央寄せ */
}
/* 進行ノード: モブ / ショップ / ボスを別アイコンで区別。
   ノード数が多い面（W3+ は11個）でも、幅を等分して縮めて末尾のボスまで必ず収める。 */
.pnode {
  flex: 0 1 18px; /* 18px 基準・伸びない（中央寄せの余白ができる）・狭ければ縮む */
  min-width: 0;
  aspect-ratio: 1;
  height: auto;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.2; /* 現在地以外はしっかり暗く */
  filter: grayscale(0.85);
  transition: opacity 0.2s, filter 0.2s, transform 0.2s;
}
.pnode-mob {
  background-image: url("../img/icons/node-mob.webp?v=2.5");
}
.pnode-shop {
  background-image: url("../img/icons/shop.webp?v=2.5");
}
.pnode-boss {
  flex-basis: 22px; /* ボスだけ少し大きめに */
  background-image: url("../img/icons/node-boss.webp?v=2.5");
}
.pnode.done {
  opacity: 0.45; /* 通過済みも控えめにして現在地を目立たせる */
  filter: grayscale(0.5);
}
.pnode.now {
  opacity: 1;
  transform: scale(1.45); /* 現在地は大きく */
  filter: drop-shadow(0 0 8px rgba(43, 140, 255, 0.95));
  z-index: 1;
}

/* 右上のコイン表示 */
.coin-hud {
  position: fixed;
  /* 上部ヘッダー行（WORLD/スキル・SHOP など、.screen の padding 内の先頭行）と
     縦中央をそろえる。以前は 8px で、ヘッダー行より 16px 高く浮いて見えていた。 */
  top: calc(env(safe-area-inset-top) + 24px);
  /* ゲーム内容（.screen の padding 16px の内側にある盤面・カード）の右端に合わせる。
     列は中央 max 520px。以前は列の端に合わせていたため、内容より 6px 右にはみ出て
     見えていた（PCで顕著）。padding 分の 16px を足して内容の右端にそろえる。 */
  right: max(
    calc(env(safe-area-inset-right) + 16px),
    calc(50% - 260px + 16px)
  );
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(10, 11, 13, 0.72);
  border: 1px solid var(--hairline);
  font-size: 16px;
  font-weight: 800;
  color: var(--gold);
}
.coin-hud .icon-inline {
  width: 18px;
  height: 18px;
}

.enemy-zone {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  background:
    linear-gradient(rgba(10, 11, 13, 0.62), rgba(10, 11, 13, 0.86)),
    var(--surface) url("../img/backdrop.webp?v=2.5") center / cover no-repeat;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  flex: none;
  overflow: hidden;
}
.enemy-figure-wrap {
  position: relative;
  flex: none;
  width: var(--enemy-size, 72px);
  height: var(--enemy-size, 72px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
img.enemy-figure {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.6));
}
.enemy-emoji {
  font-size: 46px;
  line-height: 1;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
}
/* ボス: 枠から上下・横にはみ出すほど大きく見せて迫力を出す。負のマージンで下寄せに
   拡大し、上・下・右（名前やHPの側）へはみ出させる。名前/HP/予告(.enemy-info)は
   position+z-index でボスより上に重ね、テキストは読めるまま・ボスは下のレイヤーに。
   ゾーンの overflow を解除してはみ出しを見せる。カード自体の高さはほぼ変えない。 */
.enemy-zone.boss {
  overflow: visible;
}
.enemy-zone.boss #enemy-visual {
  --enemy-size: 170px;
  align-self: flex-end;
  margin-top: -62px; /* 上へはみ出す */
  margin-bottom: -18px; /* 下へもはみ出す */
  margin-right: -44px; /* 名前・HP の下（右）へ回り込ませる */
  z-index: 0; /* テキストより下のレイヤー */
}
.enemy-zone.boss .enemy-info {
  position: relative;
  z-index: 1; /* 名前・HP・予告はボスの上に重ねて読めるように */
}
.enemy-zone.boss img.enemy-figure {
  filter: drop-shadow(0 12px 26px rgba(0, 0, 0, 0.72));
}

/* ---- モンスターのモーション（待機・瞬き・被弾・攻撃・瀕死・撃破） ---- */
/* 動きは #enemy-visual（枠）に掛ける。ベース絵と瞬き絵が同じ枠の中で一緒に
   動くので、瞬きは重ねた「目を閉じた絵」の不透明度だけで表現できる。
   待機は 呼吸(scale)＋左右の揺れ(rotate)＋うねうね(skewX) の合わせ技。 */
#enemy-visual {
  animation: enemy-idle 3.4s ease-in-out infinite;
  transform-origin: 50% 82%;
  will-change: transform;
}
@keyframes enemy-idle {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg) skewX(0deg) scale(1);
  }
  25% {
    transform: translateY(-2px) rotate(0.5deg) skewX(1.6deg) scale(1.008);
  }
  50% {
    transform: translateY(-3.5px) rotate(1.1deg) skewX(0deg) scale(1.016);
  }
  75% {
    transform: translateY(-2px) rotate(0.5deg) skewX(-1.6deg) scale(1.008);
  }
}
/* 瞬き: 目を閉じた絵を上に重ね、一瞬だけ不透明にする（JSが .blink を付与） */
img.enemy-blink {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 70ms ease-in-out;
  pointer-events: none;
}
#enemy-visual.blink img.enemy-blink {
  opacity: 1;
}
/* 副モーション（シッポ等）: もう1枚の「部位を動かした絵」を上に重ね、
   ゆっくり2つの絵を行き来させて部位が揺れているように見せる。瞬きと同じ差し替え方式。
   両端で少し留めて素早く切り替えるので、二重像が目立たず“動いている”ように見える。 */
img.enemy-alt {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
#enemy-visual.has-alt:not(.dead):not(.dying):not(.hurt):not(.attacking)
  img.enemy-alt {
  animation: enemy-altsway 3.8s ease-in-out infinite;
}
@keyframes enemy-altsway {
  0%,
  10% {
    opacity: 0;
  }
  38%,
  58% {
    opacity: 1;
  }
  90%,
  100% {
    opacity: 0;
  }
}
#enemy-visual.hurt {
  animation: enemy-hurt 0.45s;
  filter: brightness(2.4) saturate(1.6);
}
@keyframes enemy-hurt {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-7px) rotate(-4deg);
  }
  45% {
    transform: translateX(6px) rotate(3deg);
  }
  70% {
    transform: translateX(-4px);
  }
}
#enemy-visual.attacking {
  animation: enemy-attack 0.55s ease-in;
}
@keyframes enemy-attack {
  0% {
    transform: translateY(0) scale(1);
  }
  35% {
    transform: translateY(-9px) scale(1.06) rotate(-4deg);
  }
  60% {
    transform: translateY(12px) scale(1.22);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}
#enemy-visual.dying {
  animation: enemy-dying 1.5s ease-in-out infinite;
  filter: grayscale(0.45) brightness(0.8);
}
@keyframes enemy-dying {
  0%,
  100% {
    transform: rotate(-3deg) translateY(1px);
  }
  50% {
    transform: rotate(3deg) translateY(3px);
  }
}
#enemy-visual.dead {
  animation: none;
  filter: grayscale(1);
  opacity: 0.2;
  transform: rotate(20deg) scale(0.85);
  transition: all 0.4s;
}
/* 動きを減らす設定のときは待機・副モーションを止める（瞬きJSも抑制される） */
@media (prefers-reduced-motion: reduce) {
  #enemy-visual,
  #enemy-visual img.enemy-alt {
    animation: none;
  }
}
.enemy-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.enemy-name {
  font-size: 15px;
  font-weight: 300;
  letter-spacing: 0.06em;
}
/* 敵ライフゲージ: 10で1本。11以上は下のレイヤー色が背景に見える重ねゲージ */
.life-gauge {
  position: relative;
  height: 17px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(230, 233, 240, 0.18);
  overflow: hidden;
  margin: 3px 0;
  max-width: 240px;
}
/* 残り体力の数字（常時表示・ゲージ中央） */
.life-gauge-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 0 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.life-gauge-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  transition: width 0.25s ease-out, background-color 0.25s;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.18) inset;
}
.life-gauge-mult {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  letter-spacing: 0.05em;
}
.enemy-intent {
  font-size: 12px;
  color: var(--text-body);
}
.enemy-intent.soon {
  color: var(--danger);
  font-weight: 700;
}
.enemy-hidden {
  font-size: 12px;
  color: var(--text-mute);
}

.battle-log {
  min-height: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-body);
  flex: none;
}
.battle-log.loud {
  color: var(--gold);
  font-weight: 700;
}

.player-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  flex: none;
}
.player-hearts {
  font-size: 17px;
  letter-spacing: 2px;
}
/* 装備枠: 最大3つのスロットにアイコンを表示。埋まっていればタップで吹き出し */
.equip-slots {
  display: flex;
  gap: 8px;
}
.equip-slot {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.equip-slot img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.equip-slot:not(.empty):active {
  transform: scale(0.94);
}
/* 空きスロットは「枠がある」ことがはっきり分かるように（破線を明るめ・太めに、
   減光はやめ、中央に薄い＋を出して「ここに装備できる」と伝える） */
.equip-slot.empty {
  border-style: dashed;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.06);
  opacity: 1;
}
.equip-slot.empty::before {
  content: "+";
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  color: rgba(255, 255, 255, 0.4);
}
/* 消費アイテムには「使える」印 */
.slot-use-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--canvas);
  box-shadow: 0 0 6px rgba(255, 210, 74, 0.8);
}

/* 装備の吹き出し */
.equip-popover {
  position: fixed;
  z-index: 70;
  width: min(78vw, 260px);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
  animation: pop-in 0.14s ease-out;
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.pop-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.pop-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.pop-name {
  font-size: 15px;
}
.pop-desc {
  font-size: 13px;
  color: var(--text-body);
  line-height: 1.4;
}
.pop-use {
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
}

/* ---------- 数字グリッド ----------
   グリッドが余った高さを全部使う（セルは正方形にせず高さ追従） */
.number-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, minmax(0, 1fr));
  gap: 6px;
  flex: 1;
  min-height: 0;
  /* なぞり選択のためブラウザジェスチャを無効化（この画面はスクロールしない） */
  touch-action: none;
}
.cell {
  position: relative;
  min-height: 0;
  height: 100%;
  border-radius: var(--radius-md);
  background: var(--card) url("../img/ui/cell.webp?v=2.5") center / cover no-repeat;
  border: none;
  font-size: clamp(15px, 4.2vw, 19px);
  font-weight: 700;
  color: #eef2f8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, transform 0.08s, box-shadow 0.12s, opacity 0.15s,
    filter 0.15s;
  touch-action: none;
}
.cell:active {
  transform: scale(0.94);
}
.cell[aria-pressed="true"] {
  background-image: url("../img/ui/cell-selected.webp?v=2.5");
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 20, 50, 0.9), 0 0 12px rgba(43, 140, 255, 0.7);
  /* ポンっと手前に飛び出してネオン発光 */
  transform: scale(1.09);
  z-index: 2;
  box-shadow: 0 0 20px rgba(64, 200, 255, 0.85), 0 0 40px rgba(43, 140, 255, 0.4),
    0 6px 14px rgba(0, 0, 0, 0.55);
  filter: saturate(1.25) brightness(1.12);
  animation: cell-pop 0.2s ease-out;
}
@keyframes cell-pop {
  0% {
    transform: scale(1);
  }
  55% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1.09);
  }
}
.cell.checking {
  animation: cell-drawn 0.4s;
  filter: brightness(1.7);
  color: #fff;
}
/* 開いたマス（このバトル中はもう選べない） */
.cell.locked-hit {
  background-image: url("../img/ui/cell-hit.webp?v=2.5");
  color: #241a02;
  text-shadow: 0 1px 2px rgba(255, 240, 200, 0.65);
  box-shadow: 0 0 14px rgba(255, 210, 74, 0.4);
  cursor: default;
}
.cell.locked-miss {
  background-image: url("../img/ui/cell-miss.webp?v=2.5");
  color: rgba(244, 246, 250, 0.34);
  text-shadow: none;
  opacity: 0.85;
  cursor: default;
}
/* 最大数まで選んだら、これ以上選べないマスを暗くして「もう選べない」と知らせる */
.cell.cant-pick {
  opacity: 0.32;
  filter: grayscale(0.55) brightness(0.82);
}
/* 呪術で強制選択されたマス（このターンは外せない・青ではなく紫リング＋☠️） */
.cell.forced {
  box-shadow: 0 0 18px rgba(180, 90, 255, 0.9), 0 0 38px rgba(130, 50, 210, 0.5),
    0 6px 14px rgba(0, 0, 0, 0.55);
}
.cell.forced::after {
  content: "☠️";
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 0.58em;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.85));
  pointer-events: none;
}
.cell:disabled:active {
  transform: none;
}
.cell.limit-pulse {
  animation: limit-pulse 0.7s infinite alternate;
}
/* 鷹の目: 当たりマスを一瞬だけ見せる */
.cell.reveal {
  box-shadow: 0 0 16px rgba(255, 210, 74, 0.85);
  border-color: var(--gold);
}
.cell-mark {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  object-fit: contain;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.8));
  animation: reveal-pop 0.16s ease-out;
}
@keyframes reveal-pop {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes cell-drawn {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes limit-pulse {
  from {
    box-shadow: 0 0 6px rgba(255, 210, 74, 0.3);
  }
  to {
    box-shadow: 0 0 22px rgba(255, 210, 74, 0.8);
  }
}

/* ---------- 操作列（クリア廃止・QUICK PICK と BATTLE の2つ） ---------- */
.battle-controls {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  align-items: stretch;
  flex: none;
}
.battle-controls .pill-ghost {
  font-size: 13px;
  line-height: 1.2;
  padding: 6px 8px;
  min-height: 44px;
}
.pill-battle {
  min-height: 52px;
  font-size: 19px;
  letter-spacing: 0.12em;
  box-shadow: 0 6px 24px rgba(43, 140, 255, 0.35);
}
/* 押せる状態（有効・非LIMIT）は青くぼわぼわ光って「押していいよ」を伝える。
   busy で disabled になるとアニメが止まる（＝押せないのが分かる）。 */
.pill-battle:not(:disabled):not(.limit) {
  animation: battle-ready 1.3s ease-in-out infinite;
}
@keyframes battle-ready {
  0%,
  100% {
    box-shadow: 0 6px 24px rgba(43, 140, 255, 0.35);
  }
  50% {
    box-shadow: 0 6px 30px rgba(43, 140, 255, 0.8), 0 0 20px rgba(43, 140, 255, 0.55);
  }
}
.pill-battle.limit {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #221a02;
  box-shadow: 0 6px 28px rgba(255, 210, 74, 0.5);
  animation: limit-pulse 0.7s infinite alternate;
}

/* ---------- ショップ ---------- */
.screen-shop {
  gap: var(--sp-md);
}
.shop-caption {
  font-size: 14px;
  color: var(--text-body);
}
/* ショップでも現在の手持ちアイテム枠を視覚表示 */
.shop-owned {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
}
.shop-owned-label {
  flex: none;
  font-size: 13px;
  color: var(--text-mute);
}
.shop-items {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}
.shop-item {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: var(--sp-md);
}
.shop-item.sold {
  opacity: 0.45;
}
.shop-item-icon {
  font-size: 34px;
  flex: none;
  width: 44px;
  text-align: center;
}
.shop-item-body {
  flex: 1;
  min-width: 0;
}
.shop-item-name {
  font-weight: 600;
}
.shop-item-desc {
  font-size: 13px;
  color: var(--text-body);
}
.shop-item-tag {
  font-size: 11px;
  color: var(--text-mute);
}
#btn-shop-next {
  margin-top: auto;
}

/* ---------- 勝利・モーダル ---------- */
.modal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: var(--sp-xl) var(--sp-lg);
  width: min(92vw, 380px);
  text-align: center;
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
}
.modal .stack {
  margin: var(--sp-md) auto 0;
}
.modal-heading {
  font-size: 24px;
}
.clear-emoji {
  font-size: 56px;
  line-height: 1;
}
.drop-list {
  list-style: none;
  margin: var(--sp-sm) 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}
.drop-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 14px;
}
.drop-list .drop-icon {
  font-size: 22px;
}
.drop-list .drop-desc {
  color: var(--text-body);
  font-size: 12px;
}
#btn-inventory-close {
  margin-top: var(--sp-sm);
}
.equip-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--card);
  padding: 12px;
  text-align: left;
  font-size: 14px;
  min-height: 48px;
}
.equip-choice:active {
  background: var(--accent-pressed);
}
.equip-choice-img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: none;
}

/* ハートえらび（ラン開始時） */
.screen-heartpick {
  justify-content: center;
  padding: var(--sp-md);
}
.heart-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 360px;
  margin-top: var(--sp-md);
}
.heart-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0.02)
  ), var(--card);
  padding: 12px 14px;
  min-height: 66px;
  transition: transform 0.08s, border-color 0.15s, box-shadow 0.15s;
}
.heart-choice:active {
  transform: scale(0.98);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 22px rgba(43, 140, 255, 0.28);
}
/* 4マス配分（❤=ハート／■=アイテム枠）を横一列に。4記号は等間隔（4等分グリッド）。 */
.style-cells {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  justify-items: center;
  gap: 3px;
  width: 116px;
}
.style-cell {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.style-cell.heart img {
  width: 23px;
  height: 23px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
/* アイテム枠: 四角の中に小さく番号（1/2/3） */
.style-cell.slot {
  width: 23px;
  height: 23px;
  border-radius: 6px;
  border: 1.5px solid rgba(43, 140, 255, 0.55);
  background: rgba(43, 140, 255, 0.12);
  color: #8fc3ff;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.heart-choice-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.heart-choice-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.heart-choice-desc {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mute);
  line-height: 1.25;
}
/* おすすめバッジ（バランスの横・金） */
.reco-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1205;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  vertical-align: 2px;
}
/* おすすめ（初期選択）カードは金の枠線で強調 */
.heart-choice--recommended {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(255, 176, 46, 0.55),
    0 6px 18px rgba(255, 176, 46, 0.18);
}
.heart-choice--recommended:active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold), 0 8px 22px rgba(255, 176, 46, 0.3);
}
/* 説明文（リード＋補足） */
.heartpick-lead {
  margin-top: 2px;
}
.heartpick-sub2 {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 4px;
}

/* ---------- 危険表示（残り1ハートで、しのげないと死ぬ敵ターン） ---------- */
.danger-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 45;
  opacity: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 30, 50, 0) 42%,
    rgba(255, 30, 50, 0.28) 78%,
    rgba(255, 20, 45, 0.6) 100%
  );
}
.danger-overlay.on {
  animation: danger-pulse 1.2s ease-in-out infinite;
}
@keyframes danger-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.9;
  }
}

/* ---------- FX ---------- */
#fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}
.fx-arrow-img {
  position: absolute;
  width: 52px;
  height: 52px;
  object-fit: contain;
  transform: translate(-50%, -50%);
  will-change: transform;
  filter: drop-shadow(0 0 10px rgba(255, 210, 74, 0.6));
}
.fx-boom {
  position: absolute;
  width: 90px;
  height: 90px;
  object-fit: contain;
  mix-blend-mode: screen;
  transform: translate(-50%, -50%);
  animation: boom 0.55s ease-out forwards;
}
.fx-boom-big {
  width: 170px;
  height: 170px;
}
@keyframes boom {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 1;
  }
  60% {
    transform: translate(-50%, -50%) scale(1.25);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
  }
}
/* 命中箇所から広がる衝撃波リング */
.fx-hitring {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 14px rgba(255, 220, 120, 0.85), inset 0 0 8px rgba(255, 220, 120, 0.6);
  transform: translate(-50%, -50%) scale(0.3);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: hitring 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.fx-hitring-big {
  border-width: 4px;
  border-color: rgba(255, 210, 74, 0.95);
}
@keyframes hitring {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.8);
    opacity: 0;
  }
}
.fx-damage {
  position: absolute;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
  animation: dmg-float 0.85s ease-out forwards;
}
.fx-damage-weak {
  color: var(--gold);
  font-size: 32px;
}
@keyframes dmg-float {
  0% {
    transform: translate(-50%, -50%) translateY(0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) translateY(-46px);
    opacity: 0;
  }
}
.fx-weak-tag {
  position: absolute;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--gold);
  transform: translate(-50%, -50%);
  animation: dmg-float 0.85s ease-out forwards;
}
.fx-drop-tag {
  position: absolute;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #57d97a;
  text-shadow: 0 0 12px rgba(87, 217, 122, 0.8), 0 2px 6px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
  animation: dmg-float 1s ease-out forwards;
}
.fx-float {
  position: absolute;
  font-size: 18px;
  font-weight: 800;
  transform: translate(-50%, -50%);
  animation: dmg-float 1.05s ease-out forwards;
  white-space: nowrap;
}
.fx-float-coin {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 210, 74, 0.7), 0 2px 6px rgba(0, 0, 0, 0.8);
}
.fx-spark {
  position: absolute;
  mix-blend-mode: screen;
  transform: translate(-50%, -50%);
  animation: spark 0.65s ease-out forwards;
}
@keyframes spark {
  to {
    transform: translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%))
      scale(0.3);
    opacity: 0;
  }
}
/* 採掘マシンのドリル: 対象マスの上に重ねて描画（JS 側の animate で降下・振動） */
.fx-drill {
  position: absolute;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
  will-change: transform, opacity;
  pointer-events: none;
}
/* 掘られている最中のマス: 小刻みに揺れて明滅（砕ける手応え） */
.cell.cracking {
  animation: cell-crack 0.46s ease-in-out;
  z-index: 1;
}
@keyframes cell-crack {
  0%, 100% {
    transform: translate(0, 0);
    filter: brightness(1);
  }
  25% {
    transform: translate(-2px, 1px) rotate(-1.2deg);
    filter: brightness(1.35);
  }
  50% {
    transform: translate(2px, -1px) rotate(1.2deg);
    filter: brightness(0.7);
  }
  75% {
    transform: translate(-2px, 1px) rotate(-0.8deg);
    filter: brightness(1.2);
  }
}
/* ミラクル②: 敵をすり抜けた矢の大きな「MISS!」 */
.fx-miss-big {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: clamp(34px, 10vw, 58px);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: rgba(244, 246, 250, 0.92);
  text-shadow: 0 0 18px rgba(120, 150, 200, 0.7), 0 4px 12px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  animation: miss-big 0.9s ease-out forwards;
}
@keyframes miss-big {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-6deg); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(-3deg); }
  75% { opacity: 1; transform: translate(-50%, -58%) scale(1) rotate(-3deg); }
  100% { opacity: 0; transform: translate(-50%, -76%) scale(0.96) rotate(-3deg); }
}

/* ミラクル④〜⑦: 期待値の反転カットイン（全画面） */
.fx-miracle {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: transparent;
}
/* ④ ブラウン管オフ: 一瞬で真っ黒 */
.fx-miracle.black {
  background: #000;
}
/* ④ 白い横線が中央へ一気に収縮して消える（ブラウン管の電源オフ） */
.fx-crt-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  background: #fff;
  box-shadow: 0 0 24px 6px rgba(255, 255, 255, 0.95), 0 0 60px 12px rgba(180, 210, 255, 0.6);
  transform: translateY(-50%) scaleX(1);
  animation: crt-off 0.34s cubic-bezier(0.7, 0, 0.9, 0.2) forwards;
}
@keyframes crt-off {
  0% { transform: translateY(-50%) scaleX(1) scaleY(1); opacity: 1; }
  55% { transform: translateY(-50%) scaleX(1) scaleY(3.5); opacity: 1; }
  100% { transform: translateY(-50%) scaleX(0.006) scaleY(0.4); opacity: 0; }
}
/* ⑥ 暗闇から現れる巨大な黄金の矢（ゆっくり回転＋チャージ発光） */
.fx-miracle-arrow {
  position: absolute;
  width: min(88vw, 78vh);
  height: auto;
  filter: drop-shadow(0 0 30px rgba(255, 210, 74, 0.95)) drop-shadow(0 0 80px rgba(255, 180, 40, 0.7));
  animation: miracle-arrow-charge 1.2s ease-out both, miracle-arrow-spin 6s linear infinite;
  will-change: transform, filter;
}
@keyframes miracle-arrow-charge {
  0% { opacity: 0; transform: scale(0.55); filter: drop-shadow(0 0 0 rgba(255,210,74,0)) brightness(0.4); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: scale(1); filter: drop-shadow(0 0 40px rgba(255,210,74,1)) drop-shadow(0 0 100px rgba(255,180,40,0.85)) brightness(1.25); }
}
@keyframes miracle-arrow-spin {
  from { rotate: 0deg; }
  to { rotate: 360deg; }
}
/* ⑦ 超高速で貫通（画面奥へ突き抜ける） */
.fx-miracle-arrow.pierce {
  animation: miracle-arrow-pierce 0.22s cubic-bezier(0.6, 0, 0.9, 0.4) forwards;
}
@keyframes miracle-arrow-pierce {
  0% { transform: scale(1) translate(0, 0); opacity: 1; }
  100% { transform: scale(0.12) translate(0, 0); opacity: 0; }
}
/* ⑥ チャージのオーラリング */
.fx-miracle-aura {
  position: absolute;
  width: min(96vw, 86vh);
  height: min(96vw, 86vh);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 210, 74, 0.28) 0%, rgba(255, 180, 40, 0.12) 40%, transparent 68%);
  animation: miracle-aura 1.1s ease-out infinite alternate;
  pointer-events: none;
}
@keyframes miracle-aura {
  from { transform: scale(0.85); opacity: 0.5; }
  to { transform: scale(1.12); opacity: 0.95; }
}
/* ⑦ 敵登場（暗転解除して敵の全景を出す） */
.fx-miracle.reveal {
  background: radial-gradient(circle at 50% 50%, rgba(30, 20, 6, 0.9), #000 75%);
}
.fx-miracle-foe {
  width: min(70vw, 52vh);
  height: min(70vw, 52vh);
  object-fit: contain;
  font-size: min(56vw, 42vh);
  line-height: 1;
  text-align: center;
  opacity: 0;
  filter: drop-shadow(0 12px 40px rgba(0, 0, 0, 0.9));
}
.fx-miracle.reveal .fx-miracle-foe {
  animation: miracle-foe-in 0.2s ease-out forwards;
}
@keyframes miracle-foe-in {
  from { opacity: 0; transform: scale(0.86); }
  to { opacity: 1; transform: scale(1.06); }
}
.fx-miracle.finish .fx-miracle-foe {
  animation: miracle-foe-blow 1.4s ease-out forwards;
}
@keyframes miracle-foe-blow {
  0% { opacity: 1; transform: scale(1.06); filter: brightness(4); }
  28% { transform: scale(1.24) rotate(5deg); filter: brightness(2); }
  100% { opacity: 0; transform: scale(1.02) rotate(20deg) translateY(22vh); filter: grayscale(1) brightness(0.5); }
}
/* ⑦ 爆発 */
.fx-miracle-burst {
  position: absolute;
  width: 160vmin;
  height: 160vmin;
  object-fit: contain;
  mix-blend-mode: screen;
  opacity: 0;
}
.fx-miracle.finish .fx-miracle-burst {
  animation: miracle-burst 1.2s ease-out forwards;
}
@keyframes miracle-burst {
  0% { opacity: 0; transform: scale(0.35) rotate(0deg); }
  16% { opacity: 1; }
  100% { opacity: 0.55; transform: scale(1.2) rotate(16deg); }
}
/* ⑦ MIRACLE!! ラベル */
.fx-miracle-label {
  position: absolute;
  top: 17%;
  font-size: clamp(52px, 15vw, 112px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-shadow: 0 0 48px rgba(255, 210, 74, 0.95), 0 6px 20px rgba(0, 0, 0, 0.8);
  opacity: 0;
  white-space: nowrap;
}
.fx-miracle.finish .fx-miracle-label {
  animation: miracle-label 1s ease-out forwards;
}
@keyframes miracle-label {
  0% { opacity: 0; transform: scale(0.4) rotate(-4deg); }
  22% { opacity: 1; transform: scale(1.18) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
/* ⑦ 特大ダメージ（999999 など） */
.fx-miracle-dmg {
  position: absolute;
  top: 62%;
  font-size: clamp(40px, 13vw, 92px);
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.04em;
  text-shadow: 0 0 30px rgba(255, 90, 90, 0.95), 0 0 60px rgba(255, 210, 74, 0.7), 0 4px 16px rgba(0, 0, 0, 0.8);
  opacity: 0;
}
.fx-miracle.finish .fx-miracle-dmg {
  animation: miracle-dmg 1.3s ease-out forwards;
}
@keyframes miracle-dmg {
  0% { opacity: 0; transform: translateY(16px) scale(0.5); }
  20% { opacity: 1; transform: translateY(0) scale(1.16); }
  80% { opacity: 1; transform: translateY(-6px) scale(1); }
  100% { opacity: 1; transform: translateY(-10px) scale(1); }
}
/* ⑦ カットイン内の白フラッシュ（オーバーレイの最前面に出す） */
.fx-miracle-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  animation: flash 0.4s ease-out forwards;
  pointer-events: none;
}
.fx-miracle.out {
  opacity: 0;
  transition: opacity 0.34s;
}
.fx-flash {
  position: absolute;
  inset: 0;
  animation: flash 0.6s ease-out forwards;
}
.fx-flash-gold {
  background: radial-gradient(
    circle,
    rgba(255, 210, 74, 0.55),
    rgba(255, 210, 74, 0)
  );
}
.fx-flash-white {
  background: rgba(255, 255, 255, 0.5);
}
.fx-flash-red {
  background: rgba(255, 77, 103, 0.35);
}
@keyframes flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
.fx-bigtext {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(40px, 12vw, 72px);
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
  animation: bigtext 0.9s ease-out forwards;
}
.fx-bigtext-gold {
  color: var(--gold);
  text-shadow: 0 0 30px rgba(255, 210, 74, 0.8), 0 4px 12px rgba(0, 0, 0, 0.6);
}
.fx-bigtext-white {
  color: #fff;
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.7);
}
.fx-bigtext-red {
  color: var(--danger);
  text-shadow: 0 0 24px rgba(255, 77, 103, 0.7);
}
@keyframes bigtext {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.08);
    opacity: 1;
  }
  80% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
  }
}
.fx-shake {
  animation: shake 0.3s;
}
.fx-shake-strong {
  animation: shake 0.5s;
  animation-timing-function: linear;
}
@keyframes shake {
  0%, 100% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-6px, 2px);
  }
  40% {
    transform: translate(5px, -3px);
  }
  60% {
    transform: translate(-4px, 3px);
  }
  80% {
    transform: translate(3px, -2px);
  }
}

/* ---------- 生成アイコン ---------- */
.icon-inline {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: inline-block;
  vertical-align: -2px;
}
.heart-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  margin-right: 2px;
}
.clear-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.6));
}
.title-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.loot-from {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
}

/* ---------- アイテム画像 ---------- */
img.item-icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5));
}
img.item-icon-sm {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
.loot-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin: 0 auto var(--sp-xs);
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.6));
}

/* ---------- 最後の一撃カットイン（既存UIの上に全画面描画） ---------- */
.fx-cinema {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(4, 4, 7, 0.92);
  display: grid;
  place-items: center;
  overflow: hidden;
  animation: cinema-in 0.25s ease-out;
}
@keyframes cinema-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.fx-cinema.out {
  opacity: 0;
  transition: opacity 0.3s;
}
.fx-cinema-burst {
  position: absolute;
  width: 150vmin;
  height: 150vmin;
  object-fit: contain;
  mix-blend-mode: screen;
  opacity: 0;
}
.fx-cinema.impact .fx-cinema-burst {
  animation: cinema-burst 1.1s ease-out forwards;
}
@keyframes cinema-burst {
  0% {
    opacity: 0;
    transform: scale(0.4) rotate(0deg);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0.6;
    transform: scale(1.15) rotate(14deg);
  }
}
.fx-cinema-foe {
  width: min(62vw, 44vh);
  height: min(62vw, 44vh);
  object-fit: contain;
  filter: drop-shadow(0 12px 40px rgba(0, 0, 0, 0.8));
  animation: cinema-zoom 1.5s cubic-bezier(0.2, 0.6, 0.3, 1) forwards;
  font-size: min(50vw, 36vh);
  line-height: 1;
  text-align: center;
}
@keyframes cinema-zoom {
  from {
    transform: scale(0.72);
  }
  to {
    transform: scale(1.12);
  }
}
.fx-cinema.impact .fx-cinema-foe {
  animation: cinema-blowout 1.1s ease-out forwards;
}
@keyframes cinema-blowout {
  0% {
    transform: scale(1.12);
    filter: drop-shadow(0 12px 40px rgba(0, 0, 0, 0.8)) brightness(4);
  }
  30% {
    transform: scale(1.3) rotate(6deg);
    filter: drop-shadow(0 12px 40px rgba(0, 0, 0, 0.8)) brightness(2.2);
  }
  100% {
    transform: scale(1.05) rotate(22deg) translateY(26vh);
    opacity: 0;
    filter: grayscale(1) brightness(0.6);
  }
}
.fx-cinema-arrow {
  position: absolute;
  left: 0;
  top: 0;
  width: min(26vw, 140px);
  height: auto;
  will-change: transform;
  filter: drop-shadow(0 0 18px rgba(255, 210, 74, 0.85));
}
.fx-cinema-label {
  position: absolute;
  top: 20%;
  font-size: clamp(48px, 14vw, 96px);
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255, 210, 74, 0.9), 0 6px 18px rgba(0, 0, 0, 0.7);
  opacity: 0;
}
.fx-cinema.impact .fx-cinema-label {
  animation: cinema-label 1s ease-out forwards;
}
@keyframes cinema-label {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  25% {
    opacity: 1;
    transform: scale(1.15);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
/* トドメのダメージ値（FINISH! の下に浮かせる） */
.fx-cinema-dmg {
  position: absolute;
  top: 44%;
  font-size: clamp(34px, 11vw, 68px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 22px rgba(255, 90, 90, 0.95), 0 4px 14px rgba(0, 0, 0, 0.75);
  opacity: 0;
  pointer-events: none;
}
.fx-cinema-dmg.fx-damage-weak {
  color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 210, 74, 0.95), 0 4px 14px rgba(0, 0, 0, 0.75);
}
.fx-cinema.impact .fx-cinema-dmg {
  animation: cinema-dmg 1.2s ease-out forwards;
}
@keyframes cinema-dmg {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.6);
  }
  22% {
    opacity: 1;
    transform: translateY(0) scale(1.12);
  }
  78% {
    opacity: 1;
    transform: translateY(-6px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-30px) scale(1);
  }
}

/* LIMIT BREAK の全画面プレート（screen 合成） */
.fx-limitplate {
  position: fixed;
  inset: 0;
  z-index: 55;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  mix-blend-mode: screen;
  pointer-events: none;
  animation: limitplate 1.2s ease-out forwards;
}
@keyframes limitplate {
  0% {
    opacity: 0;
    transform: scale(1.25);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

/* ---------- PC 向け微調整 ---------- */
@media (min-width: 700px) {
  .screen {
    padding: var(--sp-lg);
  }
  /* ロック済み（ヒット/ハズレ＝disabled）のマスはホバーで変化させない */
  .cell:not(:disabled):hover {
    background: #262a32;
  }
  .cell[aria-pressed="true"]:not(:disabled):hover {
    background: var(--accent);
  }
  .pill-primary:hover {
    background: #3f98ff;
  }
  .pill-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* ダメージ数字・💥・WEAK・大テキストは動かさず静止表示する
     （forwards の最終フレームが opacity:0 のため、上の全称ルールだと即透明になる） */
  .fx-boom,
  .fx-damage,
  .fx-weak-tag,
  .fx-bigtext {
    animation: none !important;
  }
}

/* ---------- スキル（ルーレット・HUD・レア度） ---------- */
.skill-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* バトル上部のスキル表示 */
.skill-hud {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--hairline);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  max-width: 46%;
}
.skill-hud[data-rarity="rare"] { border-color: #3fa9ff; }
.skill-hud[data-rarity="epic"] { border-color: #b06bff; }
.skill-hud[data-rarity="legendary"] {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(255, 176, 46, 0.4);
}
.skill-hud-icon {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex: none;
}
.skill-hud-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ルーレット画面 */
.roulette {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(84vw, 340px);
  padding: 22px 16px;
  border-radius: 20px;
  background: var(--surface);
  border: 2px solid var(--hairline);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.roulette-icon {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 76px;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
}
/* 回転前の初期エンブレム（ルーレット絵） */
.roulette-icon > img:not(.skill-img) {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* 回転中: emoji を下敷きに、読めた生成アイコンを上に重ねる */
.roulette-emoji {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.roulette-icon img.skill-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.1s;
}
.roulette-icon img.skill-img.ready {
  opacity: 1;
}
.roulette-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.roulette-rarity {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
}
.roulette-desc {
  font-size: 14px;
  color: var(--text-mute);
  min-height: 1.2em;
  text-align: center;
}
.roulette.final {
  animation: roulette-pop 0.4s ease-out;
}
.roulette.final.rarity-rare { border-color: #3fa9ff; box-shadow: 0 0 30px rgba(63, 169, 255, 0.4); }
.roulette.final.rarity-epic { border-color: #b06bff; box-shadow: 0 0 34px rgba(176, 107, 255, 0.45); }
.roulette.final.rarity-legendary {
  border-color: var(--gold);
  box-shadow: 0 0 44px rgba(255, 176, 46, 0.6);
}
.roulette.final.rarity-legendary .roulette-icon {
  animation: roulette-glow 1.1s ease-in-out infinite;
}
@keyframes roulette-pop {
  0% { transform: scale(0.86); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes roulette-glow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 176, 46, 0.6)); }
  50% { filter: drop-shadow(0 0 20px rgba(255, 176, 46, 0.95)); }
}

/* 予知スキルの当たりマスヒント */
.cell.hint::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd24a 40%, rgba(255, 210, 74, 0.2) 70%);
  box-shadow: 0 0 8px rgba(255, 210, 74, 0.8);
  animation: hint-pulse 1s ease-in-out infinite;
}
@keyframes hint-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ショップの売却行 */
.shop-sell {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 4px 0 2px;
}
.sell-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hairline);
}
.sell-item:active { transform: scale(0.95); }
.sell-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  object-fit: contain;
}
.sell-price {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
}
