@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&display=swap');

/* Hollow Crown - Gothic redesign
   ダークファンタジー × 尖頭アーチ × 重厚な装飾。
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

:root {
  /* base palette */
  --color-bg: #0f0d12;
  --color-card-bg: #1a1410;
  --color-text: #e8dcc4;
  --color-text-muted: #a89878;
  --color-border: #4a3a28;
  --color-divider: #3a2f25;

  /* type accents (上書き先) */
  --card-accent: var(--color-border);
  --card-cost-bg: #2a2018;
  --card-glow: rgba(120, 100, 70, 0.35);

  /* font stacks */
  --font-display: 'Cinzel', 'Hiragino Mincho ProN', 'Yu Mincho', 'Times New Roman', serif;
  --font-body: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', sans-serif;
}

body {
  background-color: var(--color-bg);
  background-image: radial-gradient(
    ellipse 80% 60% at 50% 0%,
    rgba(60, 40, 70, 0.35) 0%,
    transparent 70%
  );
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 16px 16px;
}

.page-header {
  text-align: center;
  margin-bottom: 24px;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.6rem;
  letter-spacing: 0.16em;
  color: #c9b18a;
  margin: 0 0 8px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.page-subtitle {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.5em;
  text-transform: uppercase;
}

/* ---------- Card gallery ---------- */

.card-gallery {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
}

.error-message {
  color: #d88a8a;
  text-align: center;
  width: 100%;
}

/* ---------- Card ---------- */

/* =============================================
   LEGACY GOTHIC CSS (deactivated)
   フレーム画像ベースのレイアウトに切り替えたため、旧ゴシック装飾 CSS は
   @media not all で無効化して保持（ロールバック時はラッパーごと外せば復活）。
   ============================================= */

@media not all {
  .card {
    --card-w: 220px;
    --card-h: 310px;
    width: var(--card-w);
    height: var(--card-h);
    background-color: var(--color-card-bg);
    background-image:
      repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.04) 0, rgba(0, 0, 0, 0.04) 1px, transparent 1px, transparent 5px),
      radial-gradient(ellipse 100% 60% at 50% 0%, rgba(255, 230, 180, 0.04) 0%, transparent 60%);
    border: 1px solid var(--card-accent);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow:
      0 8px 18px rgba(0, 0, 0, 0.7),
      0 2px 4px rgba(0, 0, 0, 0.6),
      inset 0 0 24px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  .card[data-type="attack"]  { --card-accent: #8b1a1a; --card-cost-bg: #6b1010; }
  .card[data-type="defense"] { --card-accent: #1a4a6b; --card-cost-bg: #103050; }

  .card-corner {
    position: absolute;
    width: 6px;
    height: 6px;
    pointer-events: none;
    background:
      linear-gradient(var(--color-text-muted), var(--color-text-muted)) center / 100% 1px no-repeat,
      linear-gradient(var(--color-text-muted), var(--color-text-muted)) center / 1px 100% no-repeat;
    opacity: 0.5;
  }
  .card-corner--tl { top: 4px; left: 4px; }
  .card-corner--tr { top: 4px; right: 4px; }
  .card-corner--bl { bottom: 4px; left: 4px; }
  .card-corner--br { bottom: 4px; right: 4px; }

  .card-flourish {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 8px 22px 0;
    color: var(--card-accent); flex: 0 0 auto;
  }
  .card-flourish-mark { font-size: 11px; line-height: 1; }
  .card-flourish-line { flex: 1; height: 1px; background: currentColor; opacity: 0.7; }

  .card-header {
    display: flex; align-items: center;
    gap: 8px; padding: 6px 10px 6px; flex: 0 0 auto;
  }

  .card-image-wrap,
  .card-image-inner {
    clip-path: polygon(
      0% 100%, 0% 42%, 3% 28%, 10% 16%, 22% 7%, 36% 2%, 47% 0.3%,
      50% 0%, 53% 0.3%, 64% 2%, 78% 7%, 90% 16%, 97% 28%, 100% 42%, 100% 100%
    );
  }
  .card-image-wrap { position: relative; flex: 0 0 auto; height: 132px; background: var(--card-accent); }
  .card-image-inner { position: absolute; inset: 1.5px; background: linear-gradient(180deg, #1a1410 0%, #0a0805 100%); overflow: hidden; }
  .card-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
  .card-image-fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px; color: var(--card-accent); opacity: 0.5; }

  .card-type-banner {
    flex: 0 0 auto; height: 30px;
    display: flex; align-items: center; justify-content: center;
    gap: 0.7em;
    font-family: var(--font-display); font-size: 11px; font-weight: 500;
    letter-spacing: 0.45em; color: var(--color-text-muted);
    background: rgba(0, 0, 0, 0.28);
    border-top: 3px double var(--card-accent);
    border-bottom: 3px double var(--card-accent);
    margin-top: 4px;
  }
  .card-type-banner::before,
  .card-type-banner::after {
    content: "❦"; font-size: 1em; letter-spacing: 0;
    color: var(--card-accent); opacity: 0.85;
  }
}

/* =============================================
   NEW: FRAME-IMAGE BASED LAYOUT
   common.webp (583x800, RGBA) を背面に置き、コンテンツを絶対配置で重ねる。
   ============================================= */

.card {
  --card-w: 180px;
  width: var(--card-w);
  aspect-ratio: 583 / 800;
  position: relative;
  display: block;
  background: transparent;
  border: none;
  border-radius: 4px;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.7),
    0 2px 4px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* type 別の色調補正（薄い multiply オーバーレイ） */
.card[data-type="attack"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(139, 26, 26, 0.08);
  pointer-events: none;
  mix-blend-mode: multiply;
  z-index: 1;
  border-radius: inherit;
}
.card[data-type="defense"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(26, 74, 107, 0.08);
  pointer-events: none;
  mix-blend-mode: multiply;
  z-index: 1;
  border-radius: inherit;
}

/* type 別 hover グロウ色 */
.card[data-type="attack"]  { --card-glow: rgba(180, 30, 30, 0.55); }
.card[data-type="defense"] { --card-glow: rgba(50, 110, 190, 0.5); }

/* rarity placeholders（後で有効化） */
/* .card[data-rarity="uncommon"] { box-shadow: 0 0 12px rgba(192,192,192,0.35), 0 8px 18px rgba(0,0,0,0.7); } */
/* .card[data-rarity="rare"]     { box-shadow: 0 0 14px rgba(212,175,55,0.4),  0 8px 18px rgba(0,0,0,0.7); } */

.card:hover {
  transform: translateY(-6px);
  box-shadow:
    0 16px 30px rgba(0, 0, 0, 0.85),
    0 0 20px var(--card-glow, rgba(120, 100, 70, 0.35));
}

/* フレーム画像（背面） */
.card-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  user-select: none;
  display: block;
}

/* === 各エリアの位置（フレーム画像の比率を基準にした % 指定）
   実物の見え方で要微調整。 === */

.card-cost-position {
  position: absolute;
  top: 5%;
  left: 5%;
  width: 16%;
  height: 12%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.card-name-position {
  position: absolute;
  top: 6%;
  left: 24%;
  right: 8%;
  height: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.card-illustration-position {
  position: absolute;
  top: 18%;
  left: 12%;
  right: 12%;
  height: 42%;
  overflow: hidden;
  z-index: 2;
}

.card-type-position {
  position: absolute;
  top: 62%;
  left: 0;
  right: 0;
  height: 8%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.card-description-position {
  position: absolute;
  top: 70%;
  left: 12%;
  right: 12%;
  height: 22%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 2;
}

/* === 中身の文字・画像スタイル === */

.card-cost {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  color: #d4af37; /* 攻撃: ゴールド */
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.95),
    0 0 4px rgba(0, 0, 0, 0.7);
}
.card[data-type="defense"] .card-cost {
  color: #4a8fb5; /* 防御: ブルー */
}

.card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: #e8dcc4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  max-width: 100%;
}

.card-illustration-position .card-illustration {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 画像読み込み失敗時：img を隠してフォールバック（背面）を見せる */
.card-illustration-position .card-illustration--failed {
  display: none;
}

.card-illustration-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 48px;
  color: rgba(232, 220, 196, 0.18);
  pointer-events: none;
}

.card-type {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.4em;
  color: #c08080; /* 攻撃: 薄い赤 */
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
}
.card[data-type="defense"] .card-type {
  color: #80a0c0; /* 防御: 薄い青 */
}

.card-description {
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.5;
  color: #c0b090;
  margin: 0;
  text-align: center;
  max-width: 100%;
}

/* ---------- Mobile (画面幅 640px 以下) ---------- */

@media (max-width: 640px) {
  #app {
    padding: 24px 12px 32px;
  }

  h1 {
    font-size: 1.9rem;
    letter-spacing: 0.14em;
  }

  .page-subtitle {
    font-size: 0.72rem;
    letter-spacing: 0.4em;
  }

  .card-gallery {
    gap: 16px;
  }

  .card {
    --card-w: 160px;
  }

  .card-cost {
    font-size: 13px;
  }

  .card-name {
    font-size: 12px;
    letter-spacing: 0.01em;
  }

  .card-type {
    font-size: 9px;
    letter-spacing: 0.3em;
  }

  .card-description {
    font-size: 10px;
    line-height: 1.4;
  }

  .card-illustration-fallback {
    font-size: 32px;
  }
}

/* =============================================
   Battle Screen
   ============================================= */

.battle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.battle-header {
  text-align: center;
}

.battle-wave {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.4em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.battle-wave-current {
  color: #d4af37;
  font-weight: 700;
}

.battle-turn {
  margin-left: 0.4em;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--color-text);
}

/* ---------- Enemy ---------- */

/* 敵エリア（敵カードを中央配置するラッパー） */
.battle-enemy-area {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 8px; /* battle gap 24 と合わせて player までの空白を 32px に */
}

/* ---------- Enemy card（手札カードと同じフレーム画像を流用） ---------- */

.enemy-card {
  --card-w: 280px;
  width: var(--card-w);
  aspect-ratio: 583 / 800;
  position: relative;
  display: block;
  background: transparent;
  border: none;
  border-radius: 4px;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.7),
    0 2px 4px rgba(0, 0, 0, 0.6);
}

/* 敵カード共通の赤味補正 */
.enemy-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(139, 26, 26, 0.10);
  pointer-events: none;
  mix-blend-mode: multiply;
  z-index: 1;
  border-radius: inherit;
}

/* 数値・文字色のオーバーライド（敵を表す赤系） */
.enemy-card .card-cost {
  color: #c08080;
}
.enemy-card .card-type {
  color: #c08080;
}

/* 揺れアニメ（敵カード全体） */
.enemy-card.shaking {
  animation: enemy-shake 0.32s ease-out;
}

/* ステータス領域（HPバー + 行動予告） */
.card-description-position.enemy-card-stats {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  padding: 0 4px;
  text-align: center;
}

/* 敵カード内の小型 HP バー */
.hp-bar--enemy-card {
  width: 100%;
  max-width: none;
  height: 14px;
  border-width: 2px;
  margin: 0 auto;
}
.hp-bar--enemy-card .hp-bar-text {
  font-size: 9px;
}

.enemy-intent {
  margin: 0;
  font-family: var(--font-display);
  font-size: 11px;
  color: #c0b090;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- HP bar ---------- */

.hp-bar {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 22px;
  background: #c4b08a; /* 羊皮紙色 */
  border: 3px double #8b1a1a;
  border-radius: 1px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.hp-bar-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  background: linear-gradient(90deg, #6b1010 0%, #a51e1e 50%, #8b1a1a 100%);
  transition: width 0.3s ease;
}

.hp-bar-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  z-index: 1;
}

.hp-bar--player {
  width: 240px;
  max-width: 240px;
  flex: 0 0 240px;
}

/* .hp-bar--enemy: 旧横長レイアウト用、新敵カード形式では未使用（hp-bar--enemy-card を使用） */

/* ---------- Player info bar ---------- */

.battle-player {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: center;
  width: min(800px, 100%);
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--color-divider);
  border-radius: 4px;
}

.battle-player-stat {
  display: flex;
  align-items: center;
  gap: 8px;
}

.battle-stat-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.battle-player-shield {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: color 0.2s ease;
}

.battle-player-shield--active {
  color: #6ec0ff;
  text-shadow: 0 0 4px rgba(80, 160, 255, 0.5);
}

/* ---------- Mana ---------- */

.battle-player-mana {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.mana-pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #8a6a30;
  box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.6);
}

.mana-pip--full {
  background: radial-gradient(circle at 30% 30%, #ffd070, #b87010 80%);
}

.mana-pip--empty {
  background: rgba(0, 0, 0, 0.5);
}

.mana-text {
  margin-left: 6px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-text);
}

/* ---------- Hand ---------- */

.battle-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: flex-start;
  min-height: 247px;
  padding: 0 8px;
  width: 100%;
}

.battle-hand .card {
  cursor: pointer;
}

.battle-hand .card--unplayable {
  opacity: 0.42;
  filter: grayscale(0.7);
  cursor: not-allowed;
}

.battle-hand .card--unplayable:hover {
  transform: none;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.7),
    0 2px 4px rgba(0, 0, 0, 0.6),
    inset 0 0 24px rgba(0, 0, 0, 0.3);
}

/* 選択中のカード（金色フレーム + 浮き上がり + 拡大） */
.battle-hand .card--selected {
  transform: translateY(-16px) scale(1.05);
  border-color: #d4af37;
  box-shadow:
    0 22px 36px rgba(0, 0, 0, 0.85),
    0 0 24px rgba(212, 175, 55, 0.55),
    inset 0 0 24px rgba(0, 0, 0, 0.3);
  z-index: 5;
}

.battle-hand .card--selected:hover {
  transform: translateY(-16px) scale(1.05);
  box-shadow:
    0 22px 36px rgba(0, 0, 0, 0.85),
    0 0 28px rgba(212, 175, 55, 0.7),
    inset 0 0 24px rgba(0, 0, 0, 0.3);
}

/* 他のカードが選択されているとき、それ以外を薄く */
.battle-hand .card--dimmed {
  opacity: 0.55;
  filter: brightness(0.7);
}

.battle-hand .card--dimmed:hover {
  transform: none;
}

/* カード使用時の浮き上がり + フェードアウト */
.battle-hand .card--playing {
  animation: card-play 0.4s ease-out forwards;
  pointer-events: none;
  z-index: 10;
}

@keyframes card-play {
  0%   { transform: translateY(-16px) scale(1.05); opacity: 1; }
  60%  { transform: translateY(-44px) scale(1.05); opacity: 0.55; }
  100% { transform: translateY(-60px) scale(1);    opacity: 0; }
}

/* ---------- Footer ---------- */

.battle-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: min(640px, 100%);
  padding: 8px 4px 0;
}

.battle-deck-info {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
}

.battle-deck-count,
.battle-discard-count {
  color: var(--color-text);
  font-weight: 600;
}

.btn-end-turn,
.btn-restart {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 10px 28px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--color-text);
  border: 1px solid #8b1a1a;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.btn-end-turn:hover,
.btn-restart:hover {
  background: rgba(139, 26, 26, 0.32);
  box-shadow: 0 0 12px rgba(180, 30, 30, 0.55);
}

.btn-end-turn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* Victory オーバーレイ用：次の戦闘へボタン（金色テーマ） */
.btn-next-battle {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 10px 28px;
  background: rgba(60, 40, 20, 0.55);
  color: var(--color-text);
  border: 1px solid #d4af37;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.btn-next-battle:hover {
  background: rgba(120, 80, 30, 0.5);
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.6);
}

/* Restart / Next ボタンを横並びに */
.battle-result-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
}

/* ---------- Victory / Defeat overlay ---------- */

.battle-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.6) 0%,
    rgba(0, 0, 0, 0.95) 80%
  );
  display: grid;
  place-items: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.battle-overlay[hidden] {
  display: none;
}

.battle-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 40px 64px;
}

.battle-result-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 4rem;
  letter-spacing: 0.4em;
  text-align: center;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.8);
}

.battle-result-title--victory {
  color: #c9b18a;
}

.battle-result-title--defeat {
  color: #8b1a1a;
}

.battle-result-title--final {
  color: #d4af37;
  text-shadow:
    0 0 24px rgba(212, 175, 55, 0.55),
    0 4px 18px rgba(0, 0, 0, 0.85);
  animation: final-victory-pulse 2s ease-in-out infinite;
}

@keyframes final-victory-pulse {
  0%, 100% { text-shadow: 0 0 24px rgba(212, 175, 55, 0.55), 0 4px 18px rgba(0, 0, 0, 0.85); }
  50%      { text-shadow: 0 0 36px rgba(212, 175, 55, 0.8),  0 4px 18px rgba(0, 0, 0, 0.85); }
}

/* ---------- Animations ---------- */

@keyframes flash-damage {
  0% { color: inherit; transform: scale(1); }
  35% { color: #ff5050; transform: scale(1.18); text-shadow: 0 0 8px #ff3030, 0 1px 2px rgba(0,0,0,0.9); }
  100% { color: inherit; transform: scale(1); }
}

.flash-damage {
  animation: flash-damage 0.32s ease;
}

@keyframes flash-shield {
  0% { filter: brightness(1); transform: scale(1); }
  35% { filter: brightness(1.6) drop-shadow(0 0 8px #6ec0ff); transform: scale(1.15); }
  100% { filter: brightness(1); transform: scale(1); }
}

.flash-shield {
  animation: flash-shield 0.32s ease;
}

/* ---------- 敵の揺れ ---------- */

@keyframes enemy-shake {
  0%   { transform: translateX(0); }
  30%  { transform: translateX(10px); }
  60%  { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}

/* .battle-enemy-portrait.shaking: 旧レイアウト用、新敵カードでは .enemy-card.shaking を使用 */

/* ---------- ダメージ・シールドポップアップ ---------- */

.popup {
  position: absolute;
  top: 30%;
  left: 50%;
  font-family: var(--font-display);
  font-weight: 700;
  pointer-events: none;
  z-index: 30;
  white-space: nowrap;
  animation: float-up 1s ease-out forwards;
}

.popup--damage {
  font-size: 2.2rem;
  color: #ff5050;
  text-shadow:
    0 0 8px rgba(255, 50, 50, 0.85),
    0 2px 4px rgba(0, 0, 0, 0.95);
}

.popup--shield {
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  color: #6ec0ff;
  text-shadow:
    0 0 8px rgba(80, 160, 255, 0.85),
    0 2px 4px rgba(0, 0, 0, 0.95);
}

@keyframes float-up {
  0%   { transform: translate(-50%, 0)    scale(0.7); opacity: 0; }
  20%  { transform: translate(-50%, -8px) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -64px) scale(1);  opacity: 0; }
}

/* ---------- フェーズインジケータ ---------- */

.phase-indicator {
  position: fixed;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.6rem;
  letter-spacing: 0.4em;
  color: #ff8080;
  text-shadow:
    0 0 18px rgba(255, 60, 60, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.95);
  pointer-events: none;
  z-index: 60;
  animation: phase-pulse 0.5s ease-out forwards;
}

@keyframes phase-pulse {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  30%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.08); }
}

/* ---------- Page footer (view toggle) ---------- */

.page-footer {
  text-align: center;
  padding: 16px 16px 24px;
}

.view-toggle {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 8px 20px;
  cursor: pointer;
  border-radius: 2px;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.view-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

/* ---------- Battle / Gallery responsive ---------- */

@media (max-width: 640px) {
  .battle {
    gap: 14px;
  }

  /* 敵カードのモバイルサイズ（手札 160 より大きく） */
  .enemy-card {
    --card-w: 200px;
  }
  .enemy-card .card-cost { font-size: 13px; }
  .enemy-card .card-type { font-size: 9px; letter-spacing: 0.3em; }
  .hp-bar--enemy-card { height: 12px; }
  .hp-bar--enemy-card .hp-bar-text { font-size: 8px; }
  .enemy-intent { font-size: 10px; letter-spacing: 0.02em; }

  .battle-player {
    gap: 12px;
    padding: 10px 12px;
  }

  .hp-bar {
    height: 16px;
  }

  .hp-bar--player {
    width: 130px;
    max-width: 130px;
    flex: 0 0 130px;
  }

  .phase-indicator {
    font-size: 1.6rem;
    letter-spacing: 0.3em;
  }

  .popup--damage { font-size: 1.6rem; }
  .popup--shield { font-size: 1.05rem; }

  .battle-hand {
    gap: 10px;
    min-height: 240px;
  }

  .battle-footer {
    padding: 4px 2px 0;
  }

  .btn-end-turn,
  .btn-restart {
    font-size: 0.82rem;
    padding: 8px 18px;
    letter-spacing: 0.16em;
  }

  .battle-result-title {
    font-size: 2.4rem;
    letter-spacing: 0.3em;
  }

  .battle-result {
    gap: 22px;
    padding: 24px 28px;
  }
}

