/* ===== リセット ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ===== ボタンタッチキャンセル ===== */
/* 指をボタン外にドラッグした時、pointer-eventsを切って:activeを解除 */
button.btn-touch-cancelled {
  pointer-events: none !important;
}

/* 準備中も最終レイアウトを計算し、途中の形だけ画面に出さない。 */
.popup-preparing {
  visibility: hidden !important;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

body {
  width: 100%;
  max-width: 430px;
  height: 100vh;
  height: 100dvh;
  max-height: 900px;
  margin: 0 auto;
  margin-top: max(0px, calc(50dvh - 450px));
  position: relative;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 40px 8px rgba(255, 255, 255, 0.12);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
}

/* ===== アプリ外枠 ===== */
#app {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, 1.2vw, 6px);
  padding: 4px clamp(4px, 1.5vw, 8px);
  background: rgba(15, 10, 30, 0.95);
  border-bottom: 1px solid rgba(80, 80, 140, 0.25);
  flex-shrink: 0;
  z-index: 10;
}

/* ===== ヘッダー（旧フッター） ===== */
#footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(15, 10, 30, 0.95);
  border-bottom: 1px solid rgba(80, 80, 140, 0.25);
  flex-shrink: 0;
  z-index: 10;
}

.footer-btn {
  padding: 4px clamp(4px, 1.5vw, 12px);
  font-size: clamp(10px, 2.8vw, 12px);
  font-weight: bold;
  color: rgba(200, 210, 255, 0.85);
  background: rgba(30, 25, 60, 0.9);
  border: 1px solid rgba(80, 90, 160, 0.4);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  letter-spacing: 0px;
  white-space: nowrap;
  text-align: center;
}

.footer-btn:not(:disabled):active {
  background: rgba(60, 50, 120, 0.9);
  border-color: rgba(120, 140, 230, 0.6);
}

.footer-btn:disabled {
  opacity: 0.4;
  cursor: default;
}


@media (min-width:600px) {
  body {
    max-width: 520px;
  }
}

@media (min-width:900px) {
  body {
    max-width: 600px;
  }
}

@media (min-width:1200px) {
  body {
    max-width: 700px;
  }
}

/* ===== フィールド全体 ===== */
#field {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* 相手の場以外を縮小し、両者の場を広めに確保 */
  grid-template-rows: 0.8fr 1.2fr 0.9fr 2.3fr auto 2.3fr 1.2fr 1.2fr 1.3fr;
  width: 100%;
  overflow: hidden;
}

/* ===== 背景色 ===== */
#opp-hand-zone,
#opp-soul-zone {
  background: rgba(60, 20, 20, 0.35);
}

#opp-mid-zones .zone {
  background: rgba(60, 20, 20, 0.30);
}

#opp-field {
  background: rgba(60, 20, 20, 0.25);
}

#player-field {
  background: rgba(18, 22, 42, 0.40);
}

#player-mid-zones .zone {
  background: rgba(18, 22, 42, 0.35);
}

#player-soul-zone {
  background: rgba(18, 22, 42, 0.30);
}

#player-hand-zone {
  background: rgba(18, 22, 42, 0.35);
}

/* ===== 中央エリア ===== */
#center-area {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-height: 30px;
  overflow: visible;
  z-index: 1;
}

#center-controls {
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  gap: 0;
}

.type-btns {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

/* 左ボタン群＝自分→下寄せ */
.type-btns.left-btns {
  align-items: flex-end;
}

/* 右ボタン群＝相手→上寄せ */
.type-btns.right-btns {
  align-items: flex-start;
}

.type-btn {
  font-size: 10px;
  font-weight: bold;
  padding: 3px 4px;
  border-radius: 2px;
  border: none;
  cursor: pointer;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), inset 0 -1px 0 rgba(0, 0, 0, 0.22);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.16);
}

.type-btn.basho-btn {
  background: linear-gradient(180deg, #b94a45, #963430);
  color: #fff0ed;
}

.type-btn.kaii-btn {
  background: linear-gradient(180deg, #9953c8, #7437a0);
  color: #f6efff;
}

.type-btn.dougu-btn {
  background: linear-gradient(180deg, #f0eeeb, #d3d1cf);
  color: #111;
}

.type-btn.season-btn {
  background: linear-gradient(180deg, #e8b74a, #cc912b);
  color: #111;
}

.type-btn.used {
  background: #555 !important;
  color: #888 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -1px 0 rgba(0, 0, 0, 0.16);
  text-shadow: none;
}

#center-mid {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 40px;
  overflow: hidden;
}

#center-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-50%);
}

/* 攻撃ボタン：最前面レイヤー */
#attack-btn {
  position: relative;
  z-index: 600;
  background: linear-gradient(180deg, #982b2b 0%, #781a1a 45%, #5c1010 100%);
  color: #ffd4d4;
  border: 1px solid rgba(255, 100, 100, 0.4);
  padding: 4px 18px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 215, 205, 0.22), inset 0 -1px 0 rgba(20, 0, 0, 0.42);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
}

#attack-btn:active {
  transform: scale(0.95);
}

/* 選択した手札・公開場のカードの真上に表示する使用ボタン */
#play-card-btn {
  position: absolute;
  z-index: 520;
  min-height: 44px;
  min-width: 124px;
  max-width: calc(100% - 16px);
  padding: 10px 16px;
  border: 1px solid rgba(221, 187, 103, 0.7);
  border-radius: 4px;
  background: linear-gradient(180deg, #70552b, #493619);
  color: #fff0cb;
  font: bold 12px 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: 1px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 236, 184, 0.2), 0 0 10px rgba(197, 154, 62, 0.22);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

#play-card-btn:disabled {
  color: #b3aaa0;
  background: #302c28;
  border-color: #61584c;
  box-shadow: none;
  cursor: not-allowed;
}

#play-card-btn:not(:disabled):active {
  background: #846432;
}

/* 中央ターン終了ボタン */
#end-turn-center {
  position: relative;
  z-index: 10;
  background: linear-gradient(135deg, #1a3a6b, #102a50);
  color: #aac4ee;
  border: 1px solid rgba(80, 140, 255, 0.35);
  padding: 4px 14px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
}

/* ボタン本体の外で光を描き、中央の overflow:hidden に切られないようにする。 */
#end-turn-aura {
  position: absolute;
  z-index: 0;
  display: none;
  border-radius: 4px;
  pointer-events: none;
  box-shadow: 0 0 8px 3px rgba(165, 210, 255, 0.8), 0 0 20px 7px rgba(90, 155, 245, 0.55);
  opacity: 0.75;
}

#end-turn-aura.active {
  display: block;
  animation: turnEndAura 2.6s ease-in-out infinite;
}

@keyframes turnEndAura {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #end-turn-aura.active {
    animation: none;
  }
}

#end-turn-center:active,
#center-area:has(#end-turn-center:active) #end-turn-aura {
  transform: scale(0.95);
}

/* ===== 場の行（ライフ＋場） ===== */
.field-row {
  display: flex;
  overflow: visible;
}

.field-row .row-zone.field-zone {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.life-area {
  width: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.07);
  gap: 2px;
  flex-shrink: 0;
}

.life-label {
  color: rgba(255, 255, 255, 0.35);
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
}

.life-value {
  color: #fff;
  font-size: 20px;
  font-weight: bold;
}

#opp-life-area {
  background: rgba(60, 20, 20, 0.35);
}

#player-life-area {
  background: rgba(18, 22, 42, 0.45);
}

/* ===== 通常行ゾーン ===== */
.row-zone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 1px 2px;
}

/* 魂ゾーン：カード列+右端の季節エリア */
#player-soul-zone,
#opp-soul-zone {
  justify-content: flex-start;
}

#player-soul-zone .card-row,
#opp-soul-zone .card-row {
  flex: 1;
  width: auto;
  min-width: 0;
}

/* ===== ゾーンラベル ===== */
.zone-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.13);
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 5px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 0;
}

/* ===== カウント（黒丸の上に表示） ===== */
.zone-count {
  position: absolute;
  bottom: 2px;
  right: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  z-index: 2;
  pointer-events: none;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ===== 3列行 ===== */
.triple-zone {
  display: grid;
  width: 100%;
  overflow: hidden;
}

#opp-mid-zones {
  grid-template-columns: 1fr 1fr 8fr;
}

#player-mid-zones {
  grid-template-columns: 8fr 1fr 1fr;
}

.triple-zone .zone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.triple-main {
  padding: 1px 2px;
}

/* ===== カード列共通 ===== */
.card-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
}

/* ===== 場のcard-row: 画面中央揃え＋枠内に収まる ===== */
.field-card-row {
  overflow: visible;
  min-width: 0;
  align-items: center;
  gap: clamp(4px, 3vw, 14px);
  height: 100%;
}

/* 自分の場：左にライフ(38px)→右に同じ分パディングで画面中央に揃える */
#player-field-row .field-card-row {
  padding-right: 38px;
}

/* 相手の場：右にライフ(38px)→左に同じ分パディングで画面中央に揃える */
#opp-field-row .field-card-row {
  padding-left: 38px;
}

/* ===== カード共通 ===== */
.battle-card {
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.12s ease;
  border-radius: 6px;
  overflow: hidden;
  touch-action: none;
  height: calc(100% - 2px);
  aspect-ratio: 5/7;
}

.battle-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  display: block;
}

/* 手札 */
.battle-card.in-hand {
  border: 1px solid rgba(80, 140, 255, 0.15);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* 使用可能なカード（緑オーラ） */
.battle-card.in-hand.playable {
  border: 1px solid rgba(60, 200, 80, 0.55);
  box-shadow: 0 0 6px 2px rgba(60, 200, 80, 0.4), 0 0 12px 4px rgba(60, 200, 80, 0.18);
}

.basho-slot.playable {
  border: 1px solid rgba(60, 200, 80, 0.55) !important;
  box-shadow: 0 0 6px 2px rgba(60, 200, 80, 0.4), 0 0 12px 4px rgba(60, 200, 80, 0.18) !important;
}

/* 場カード（コンテナ幅に連動・親の高さに依存しない） */
.battle-card.on-field {
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  width: clamp(40px, 16vw, 72px);
  height: auto !important;
  flex-shrink: 0;
  aspect-ratio: 5/7;
}

/* ===== 場所札 力表示 ===== */
.power-badge {
  position: absolute;
  left: 1px;
  bottom: 1px;
  width: 16px;
  height: 16px;
  background: #111;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.power-badge span {
  color: #e53935;
  font-size: 10px;
  font-weight: bold;
  line-height: 1;
}

/* ===== 場グループ ===== */
.field-group {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.field-group .season-slot {
  z-index: 1;
  position: relative;
}

.field-group .basho-slot {
  z-index: 2;
  position: relative;
}

.field-group.has-season .basho-slot {
  margin-top: clamp(-82px, -18vw, -36px);
}

.field-group .kaii-row {
  display: flex;
  align-items: flex-start;
  z-index: 3;
  margin-top: clamp(-28px, -5.5vw, -14px);
}

.battle-card.kaii-attached {
  width: clamp(18px, 7vw, 32px);
  height: auto !important;
  aspect-ratio: 5/7;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.kaii-row .battle-card.kaii-attached:not(:first-child) {
  margin-left: clamp(-18px, -3.5vw, -8px);
}

/* 怪異札カウントバッジ */
.kaii-count-badge {
  width: 20px;
  height: 20px;
  background: #111;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: -8px;
  flex-shrink: 0;
  border: 1px solid rgba(160, 80, 255, 0.3);
}

.kaii-count-badge span {
  color: #b060ff;
  font-size: 10px;
  font-weight: bold;
  line-height: 1;
}

/* 怪異札仮付けプレビュー */
.kaii-ghost-preview {
  width: clamp(18px, 7vw, 32px);
  height: auto !important;
  aspect-ratio: 5/7;
  border-radius: 3px;
  overflow: hidden;
  animation: kaiiBlink 0.6s ease-in-out infinite;
}

.kaii-ghost-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@keyframes kaiiBlink {

  0%,
  100% {
    opacity: 0.1;
  }

  50% {
    opacity: 0.9;
  }
}

/* ===== 魂カード：上下反転 ===== */
.battle-card.in-soul {
  border: 1px solid rgba(255, 200, 50, 0.12);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.battle-card.in-soul img {
  transform: rotate(180deg);
}

/* ===== 魂行の季節アイコンミニエリア ===== */
.soul-info-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0px;
  width: 22px;
  flex-shrink: 0;
  padding: 1px 0;
  z-index: 2;
}

.season-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.season-icon {
  width: 15px;
  height: 11px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6px;
  font-weight: bold;
  line-height: 1;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(80, 80, 80, 0.5);
  transition: background 0.3s, color 0.3s;
}

.season-icon.lit-spring {
  background: rgba(220, 100, 140, 0.75);
  color: #fff;
}

.season-icon.lit-summer {
  background: rgba(50, 170, 80, 0.75);
  color: #fff;
}

.season-icon.lit-autumn {
  background: rgba(210, 140, 40, 0.75);
  color: #fff;
}

.season-icon.lit-winter {
  background: rgba(60, 120, 210, 0.75);
  color: #fff;
}

.soul-count-mini {
  color: #fff;
  font-size: 9px;
  font-weight: bold;
  width: 15px;
  height: 15px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  margin-top: 1px;
}

/* 山札裏面 */
.deck-card-back {
  height: 72%;
  aspect-ratio: 5/7;
  border-radius: 2px;
  object-fit: cover;
  opacity: 0.6;
  pointer-events: none;
}

/* 除外ゾーン：最後のカード表示 */
.exile-zone {
  cursor: pointer;
  transition: background 0.15s ease;
}

.exile-zone:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

.exile-top-card {
  height: 72%;
  aspect-ratio: 5/7;
  border-radius: 2px;
  object-fit: cover;
  opacity: 0.85;
  pointer-events: none;
}

/* 山札クリッカブル */
#player-deck,
#opp-deck {
  cursor: pointer;
  transition: background 0.15s ease;
}

#player-deck:hover,
#opp-deck:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

#player-deck:hover .deck-card-back,
#opp-deck:hover .deck-card-back {
  opacity: 0.85;
}

/* ===== ホバー・選択 ===== */
.battle-card.glow {
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-4px);
}

.battle-card.on-field.glow {
  transform: translateY(-4px);
}

.battle-card.on-field.summon-sick.glow {
  transform: rotate(-90deg) translateY(-4px);
}

/* 怪異札のホバーはtranslateYで視覚のみ移動（レイアウトシフト防止） */
.battle-card.kaii-attached.glow {
  transform: translateY(-3px);
}

/* 持ち上がった手札・魂だけ、カード列と枠の外まで表示する。 */
:is(#player-hand-cards, #player-open-cards, #player-soul-cards, #opp-soul-cards):has(> :is(.in-hand, .in-soul):is(.glow, .overflow-selected, .selected-card)) > :is(.in-hand, .in-soul):not(:hover):not(.glow):not(.overflow-selected):not(.selected-card) {
  clip-path: var(--hand-rest-clip, none);
}

:is(#player-hand-zone, #player-open, #player-soul-zone, #opp-soul-zone):has(:is(.in-hand, .in-soul):is(.glow, .overflow-selected, .selected-card)) {
  overflow: visible;
  min-width: 0;
  min-height: 0;
  z-index: 2;
}

:is(#player-hand-cards, #player-open-cards, #player-soul-cards, #opp-soul-cards):has(:is(.in-hand, .in-soul):is(.glow, .overflow-selected, .selected-card)) {
  overflow: visible;
  min-width: 0;
  min-height: 0;
}

#player-mid-zones:has(#player-open .in-hand:is(.glow, .overflow-selected, .selected-card)) {
  overflow: visible;
  min-width: 0;
  min-height: 0;
}

/* ===== PC マウスオーバー（タッチデバイスには影響しない） ===== */
@media (hover: hover) and (pointer: fine) {
  :is(#player-hand-cards, #player-open-cards, #player-soul-cards, #opp-soul-cards):has(> :is(.in-hand, .in-soul):hover) > :is(.in-hand, .in-soul):not(:hover):not(.glow):not(.overflow-selected):not(.selected-card) {
    clip-path: var(--hand-rest-clip, none);
  }

  :is(#player-hand-zone, #player-open, #player-soul-zone, #opp-soul-zone):has(:is(.in-hand, .in-soul):hover) {
    overflow: visible;
    min-width: 0;
    min-height: 0;
    z-index: 2;
  }

  :is(#player-hand-cards, #player-open-cards, #player-soul-cards, #opp-soul-cards):has(:is(.in-hand, .in-soul):hover) {
    overflow: visible;
    min-width: 0;
    min-height: 0;
  }

  #player-mid-zones:has(#player-open .in-hand:hover) {
    overflow: visible;
    min-width: 0;
    min-height: 0;
  }

  .battle-card:hover {
    transform: translateY(-4px);
    transition: transform 0.12s ease;
  }

  .battle-card.on-field:hover {
    transform: translateY(-4px);
  }

  .battle-card.on-field.summon-sick:hover {
    transform: rotate(-90deg) translateX(4px);
  }

  .battle-card.kaii-attached:hover {
    transform: translateY(-3px);
  }

  #zero-search-cards .battle-card:hover {
    transform: none;
    top: -4px;
    filter: brightness(1.04);
    box-shadow: 0 0 0 1px rgba(175, 192, 225, 0.4), 0 4px 12px rgba(110, 143, 194, 0.2);
  }

}

/* ===== 召喚酔い（場所札横向き） ===== */
.battle-card.on-field.summon-sick {
  transform: rotate(-90deg);
  transform-origin: center center;
}

/* ===== 場ドラッグオーバー（白く柔らかい光のループ） ===== */
@keyframes dropGlow {
  0% {
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.12), 0 0 12px rgba(255, 255, 255, 0.08);
  }

  50% {
    box-shadow: inset 0 0 40px rgba(255, 255, 255, 0.35), 0 0 24px rgba(255, 255, 255, 0.18);
  }

  100% {
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.12), 0 0 12px rgba(255, 255, 255, 0.08);
  }
}

.row-zone.field-zone.drag-over {
  background: rgba(255, 255, 255, 0.10);
  animation: dropGlow 0.9s ease-in-out infinite;
}

.row-zone.drag-over-soul {
  background: rgba(255, 200, 50, 0.15) !important;
  animation: dropGlow 0.9s ease-in-out infinite;
}

.exile-zone.drag-over-exile {
  background: rgba(180, 80, 255, 0.25) !important;
  box-shadow: inset 0 0 12px rgba(180, 80, 255, 0.5), 0 0 8px rgba(180, 80, 255, 0.3);
  animation: dropGlow 0.9s ease-in-out infinite;
}

.field-group.drop-target {
  outline: 2px solid rgba(120, 180, 255, 0.7);
  outline-offset: 2px;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(120, 180, 255, 0.4);
}

/* ===== カード拡大プレビュー ===== */
#card-preview {
  position: absolute;
  left: 0;
  right: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 510;
  pointer-events: none;
  padding: 4px;
}

#card-preview.active {
  display: flex;
}

#card-preview.show-top {
  top: 0;
  height: 50%;
}

#card-preview.show-bottom {
  top: 50%;
  height: 50%;
}

#card-preview img {
  max-height: 80%;
  max-width: 55%;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 0 24px 8px rgba(255, 255, 255, 0.18), 0 0 40px 12px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

/* ===== モーダル内カードプレビュー（最前面） ===== */
#modal-preview {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.6);
}

#modal-preview.active {
  display: flex;
  pointer-events: auto;
}

#modal-preview img {
  max-height: 70%;
  max-width: 60%;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 0 30px 10px rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

/* ===== 怪異札確認中の拡大プレビュー（最前面・中央） ===== */
#kaii-preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 420;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.5);
}

#kaii-preview-overlay.active {
  display: flex;
}

#kaii-preview-overlay img {
  max-height: 70%;
  max-width: 65%;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* ===== カード使用エフェクト ===== */
#play-effect {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  pointer-events: none;
}

#play-effect.active {
  display: flex;
}

#play-effect img {
  max-height: 75%;
  max-width: 65%;
  object-fit: contain;
  border-radius: 14px;
  animation: playAppear 0.55s ease-out forwards;
}

@keyframes playAppear {
  0% {
    opacity: 0;
    transform: scale(1.0);
  }

  20% {
    opacity: 1;
    transform: scale(1.0);
  }

  70% {
    opacity: 1;
    transform: scale(1.0);
  }

  100% {
    opacity: 0;
    transform: scale(1.0);
  }
}

/* ===== 季節札警告（画面中央） ===== */
#season-warning {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 180;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(255, 200, 50, 0.3);
  border-radius: 8px;
  padding: 10px 16px;
  pointer-events: none;
  max-width: 80%;
}

#season-warning.active {
  display: flex;
}

#season-warning span {
  color: rgba(255, 220, 100, 0.9);
  font-size: 10px;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* ===== 魂不足ポップアップ ===== */
#soul-shortage-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 80, 80, 0.35);
  border-radius: 8px;
  padding: 10px 18px;
  pointer-events: none;
  max-width: 80%;
}

#soul-shortage-msg.active {
  display: flex;
}

#soul-shortage-msg span {
  color: rgba(255, 180, 180, 0.95);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* ===== 季節不足ポップアップ ===== */
#season-shortage-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 180, 50, 0.4);
  border-radius: 8px;
  padding: 10px 18px;
  pointer-events: none;
  max-width: 80%;
}

#season-shortage-msg.active {
  display: flex;
}

#season-shortage-msg span {
  color: rgba(255, 220, 150, 0.95);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* ===== 召喚酔いポップアップ ===== */
#summon-sick-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 160, 60, 0.35);
  border-radius: 8px;
  padding: 10px 18px;
  pointer-events: none;
  max-width: 80%;
}

#summon-sick-msg.active {
  display: flex;
}

#summon-sick-msg span {
  color: rgba(255, 200, 140, 0.95);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* ===== 攻撃済みポップアップ ===== */
#attack-used-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 80, 80, 0.35);
  border-radius: 8px;
  padding: 10px 18px;
  pointer-events: none;
  max-width: 80%;
}

#attack-used-msg.active {
  display: flex;
}

#attack-used-msg span {
  color: rgba(255, 180, 180, 0.95);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* ===== 1ターン1回制限ポップアップ ===== */
#type-used-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(180, 120, 255, 0.35);
  border-radius: 8px;
  padding: 10px 18px;
  pointer-events: none;
  max-width: 80%;
}

#type-used-msg.active {
  display: flex;
}

#type-used-msg span {
  color: rgba(200, 180, 255, 0.95);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* ===== ダメージ演出 ===== */
#damage-overlay {
  position: absolute;
  left: 0;
  right: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  pointer-events: none;
}

#damage-overlay.show-top {
  top: 0;
  height: 50%;
  display: flex;
}

#damage-overlay.show-bottom {
  top: 50%;
  height: 50%;
  display: flex;
}

/* ダメージ背景エフェクト（赤黒い衝撃波） */
.dmg-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: dmgBurst 0.8s ease-out forwards;
}

.dmg-burst-core {
  background: radial-gradient(ellipse at center,
      rgba(120, 0, 0, 0.95) 0%,
      rgba(80, 0, 0, 0.8) 25%,
      rgba(40, 0, 0, 0.6) 50%,
      rgba(20, 0, 0, 0.3) 75%,
      transparent 100%);
  z-index: 0;
}

.dmg-burst-ring {
  border: 3px solid rgba(180, 20, 20, 0.6);
  background: transparent;
  z-index: 0;
  animation: dmgRing 0.8s ease-out forwards;
}

/* 飛び散りパーティクル */
.dmg-splatter {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(180, 10, 10, 0.9), rgba(60, 0, 0, 0.7));
  pointer-events: none;
  z-index: 0;
  animation: dmgSplatter 0.7s ease-out forwards;
}

@keyframes dmgBurst {
  0% {
    width: 0;
    height: 0;
    opacity: 1;
  }

  30% {
    width: 220px;
    height: 220px;
    opacity: 0.9;
  }

  60% {
    width: 260px;
    height: 260px;
    opacity: 0.7;
  }

  100% {
    width: 280px;
    height: 280px;
    opacity: 0;
  }
}

@keyframes dmgRing {
  0% {
    width: 0;
    height: 0;
    opacity: 0.8;
    border-width: 4px;
  }

  50% {
    width: 200px;
    height: 200px;
    opacity: 0.5;
    border-width: 2px;
  }

  100% {
    width: 300px;
    height: 300px;
    opacity: 0;
    border-width: 1px;
  }
}

@keyframes dmgSplatter {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(1);
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--sx), var(--sy)) scale(0.3);
  }
}

#damage-text {
  color: #ff3333;
  font-size: 52px;
  font-weight: 900;
  font-style: italic;
  text-shadow:
    0 0 30px rgba(255, 0, 0, 0.7),
    0 0 60px rgba(150, 0, 0, 0.4),
    2px 2px 0 #000,
    -1px -1px 0 #000;
  transform: rotate(-12deg);
  animation: dmgAppear 0.8s ease-out forwards;
  z-index: 1;
  position: relative;
}

@keyframes dmgAppear {
  0% {
    opacity: 0;
    transform: rotate(-12deg) scale(0.3) translateY(20px);
  }

  25% {
    opacity: 1;
    transform: rotate(-12deg) scale(1.15);
  }

  50% {
    opacity: 1;
    transform: rotate(-12deg) scale(1.0);
  }

  80% {
    opacity: 0.8;
    transform: rotate(-12deg) scale(1.0);
  }

  100% {
    opacity: 0;
    transform: rotate(-12deg) scale(0.95) translateY(-10px);
  }
}

/* ===== 蟲憑き連続ダメージばらまき ===== */
.barrage-hit {
  position: absolute;
  color: #ff2222;
  font-size: 72px;
  font-weight: 900;
  font-style: italic;
  text-shadow:
    0 0 30px rgba(255, 0, 0, 0.8),
    0 0 60px rgba(150, 0, 0, 0.5),
    3px 3px 0 #000,
    -2px -2px 0 #000;
  transform: translate(-50%, -50%) rotate(-12deg);
  pointer-events: none;
  z-index: 2;
  animation: barrageAppear 0.45s ease-out forwards;
}

.barrage-hit.barrage-finish {
  font-size: 100px;
  color: #ff0000;
  text-shadow:
    0 0 40px rgba(255, 0, 0, 1),
    0 0 80px rgba(200, 0, 0, 0.6),
    0 0 120px rgba(150, 0, 0, 0.3),
    4px 4px 0 #000,
    -3px -3px 0 #000;
  animation: barrageFinish 1.5s ease-out forwards;
}

.barrage-burst {
  transform: translate(-50%, -50%);
  animation: barrageBurstAnim 0.45s ease-out forwards;
}

.barrage-splatter {
  top: auto;
  left: auto;
  transform: translate(-50%, -50%);
}

@keyframes barrageAppear {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-12deg) scale(0.3);
  }

  20% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-12deg) scale(1.2);
  }

  50% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-12deg) scale(1.0);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-12deg) scale(0.9) translateY(-8px);
  }
}

@keyframes barrageFinish {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-12deg) scale(0.3);
  }

  15% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-12deg) scale(1.4);
  }

  40% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-12deg) scale(1.1);
  }

  80% {
    opacity: 0.8;
    transform: translate(-50%, -50%) rotate(-12deg) scale(1.05);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-12deg) scale(1.0) translateY(-10px);
  }
}

@keyframes barrageBurstAnim {
  0% {
    width: 0;
    height: 0;
    opacity: 1;
  }

  40% {
    width: 240px;
    height: 240px;
    opacity: 0.8;
  }

  100% {
    width: 300px;
    height: 300px;
    opacity: 0;
  }
}

/* ===== 攻撃アニメ（下にくいっ→上に突撃＋ブラー）===== */
@keyframes attackSlideUp {
  0% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }

  15% {
    opacity: 1;
    transform: translateY(18px);
    filter: blur(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-80px);
    filter: blur(1px);
  }

  70% {
    opacity: 0.6;
    transform: translateY(-160px);
    filter: blur(4px);
  }

  100% {
    opacity: 0;
    transform: translateY(-220px);
    filter: blur(8px);
  }
}

.field-group.attacking {
  animation: attackSlideUp 0.5s ease-in forwards;
  pointer-events: none;
  z-index: 9000;
  position: relative;
}

/* CPU攻撃アニメ（上から下へ） */
@keyframes cpuAttackSlideDown {
  0% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }

  15% {
    opacity: 1;
    transform: translateY(-18px);
    filter: blur(0);
  }

  40% {
    opacity: 1;
    transform: translateY(80px);
    filter: blur(1px);
  }

  70% {
    opacity: 0.6;
    transform: translateY(160px);
    filter: blur(4px);
  }

  100% {
    opacity: 0;
    transform: translateY(220px);
    filter: blur(8px);
  }
}

/* ===== 怪異札ポップアップ（相手エリア中央部分に表示） ===== */
#kaii-popup {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 250;
  background: rgba(0, 0, 0, 0.75);
}

#kaii-popup.active {
  display: flex;
}

#kaii-popup-title {
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 3px;
  margin-bottom: 14px;
}

#kaii-popup-cards {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

#kaii-popup-cards .battle-card {
  width: 95px;
  height: 133px;
  aspect-ratio: auto;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

/* ポップアップ内カードは上に動くエフェクト無効（ジッター防止） */
#kaii-popup-cards .battle-card.glow {
  transform: none !important;
  margin-top: 0 !important;
  padding-bottom: 0 !important;
}

/* ===== 除外カード一覧モーダル ===== */
#exile-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 400;
  background: rgba(0, 0, 0, 0.8);
  pointer-events: auto;
}

#exile-modal.active {
  display: flex;
}

#exile-modal-title {
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 3px;
}

#exile-modal-cards {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 90%;
  max-height: 70%;
  overflow-y: auto;
  padding: 8px;
}

#exile-modal-cards .battle-card {
  width: 80px;
  height: 112px;
  aspect-ratio: auto;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

#exile-modal-cards .battle-card.glow {
  transform: none !important;
}

#exile-modal-empty {
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
}

#exile-modal-desc {
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  line-height: 1.6;
  letter-spacing: 0.5px;
  max-width: 90%;
}

#exile-modal-desc:empty {
  display: none;
}

/* ===== 盤面確認中の除外閲覧モーダル ===== */
#exile-view-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 500;
  background: rgba(0, 0, 0, 0.85);
  pointer-events: auto;
}

#exile-view-modal.active {
  display: flex;
}

#exile-view-title {
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 3px;
}

#exile-view-cards {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 90%;
  max-height: 70%;
  overflow-y: auto;
  padding: 8px;
}

#exile-view-cards .battle-card {
  width: 80px;
  height: 112px;
  aspect-ratio: auto;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

#exile-view-empty {
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
}

/* 2択は長い文言に合わせて等幅にし、片方が非表示なら1列にする。 */
#exile-modal-buttons,
#card-select-buttons,
#reset-confirm-buttons,
#soul-absorb-ask-buttons {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  max-width: calc(100% - 24px);
}

#exile-modal-buttons {
  gap: 12px;
  margin-top: 4px;
  margin-bottom: 4px;
}

#exile-modal-confirm {
  background: linear-gradient(135deg, #555, #444);
  color: #888;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: default;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
}

#exile-modal-confirm.ready {
  background: linear-gradient(135deg, #1a5aab, #103a70);
  color: #aac4ff;
  border: 1px solid rgba(80, 160, 255, 0.5);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(80, 160, 255, 0.3);
}

#exile-modal-confirm.ready:active {
  transform: scale(0.96);
}

#exile-modal-skip {
  background: linear-gradient(135deg, #8b1a1a, #5c1010);
  color: #ffd4d4;
  border: 1px solid rgba(255, 100, 100, 0.4);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 80, 80, 0.2);
}

#exile-modal-skip:active {
  transform: scale(0.96);
}

#exile-modal-cards .battle-card.exile-selectable {
  box-shadow: 0 0 8px rgba(80, 160, 255, 0.4);
}

#exile-modal-cards .battle-card.exile-selected {
  border: 1px solid rgba(80, 160, 255, 0.8) !important;
  box-shadow: 0 0 14px rgba(80, 160, 255, 0.6);
}

/* 山札検索：画像の寸法を保ち、移動による描画レイヤーの切り替えを避ける。 */
#exile-modal.deck-search-mode #exile-modal-cards .battle-card {
  top: 0;
  transform: none;
  transition: top 0.12s ease, box-shadow 0.15s ease;
}

/* 選択枠・オーラ・拡大表示でカード画像の描画を切り替えない。 */
#exile-modal.active #exile-modal-cards .battle-card img,
#exile-view-modal.active #exile-view-cards .battle-card img,
#opp-hand-exile-overlay.active #opp-hand-exile-cards .battle-card img,
:is(#player-hand-cards, #player-open-cards, #player-soul-cards) .battle-card img {
  will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
  #exile-modal.deck-search-mode #exile-modal-cards .battle-card:hover {
    top: -4px;
  }
}

/* ===== 相手怪異札ブロック（小型中央ポップアップ） ===== */
#kaii-block-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(160, 80, 255, 0.35);
  border-radius: 8px;
  padding: 10px 18px;
  pointer-events: none;
  max-width: 80%;
}

#kaii-block-msg.active {
  display: flex;
}

#kaii-block-text {
  color: rgba(200, 180, 255, 0.95);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* ===== デッキ/除外検索モーダル：カード部分でも縦スクロール可能に ===== */
#exile-modal-cards {
  touch-action: pan-y;
  /* カード画像を掴んでも縦スクロールを許可 */
}

#exile-modal-cards .battle-card {
  touch-action: pan-y;
  /* 個別カードでも縦スクロール優先 */
}

:is(#exile-view-cards, #opp-hand-exile-cards),
:is(#exile-view-cards, #opp-hand-exile-cards) .battle-card {
  touch-action: pan-y;
}

/* ===== ドラッグトレイル（オーラのみ） ===== */
@keyframes dragTrailFade {
  from { opacity: 0.45; transform: rotate(-2deg) scale(1.0); }
  to   { opacity: 0;   transform: rotate(-2deg) scale(0.55); }
}
.drag-trail {
  position: fixed;
  width: 50px;
  height: 70px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 9997;
  animation: dragTrailFade 0.5s ease-out forwards;
  background: radial-gradient(ellipse at center,
    rgba(140, 200, 255, 0.55) 0%,
    rgba(90, 155, 255, 0.25) 50%,
    transparent 78%);
  filter: blur(5px);
  will-change: transform, opacity;
}

/* ===== ドラッグゴースト ===== */
.drag-ghost {
  position: fixed;
  width: 50px;
  height: 70px;
  border-radius: 3px;
  overflow: hidden;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.8;
  transform: rotate(-2deg) scale(1.06);
  box-shadow: 0 6px 18px rgba(80, 140, 255, 0.3);
}

.drag-ghost img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== フッター ===== */
#footer {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  height: 34px;
  background: rgba(10, 10, 25, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.footer-btn {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 11px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
}

.footer-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.footer-btn:not(:disabled):active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.96);
}

/* ===== 手札超過オーバーレイ（上半分のみ覆い、下部の手札/公開場/魂は操作可能） ===== */
#hand-overflow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 350;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.65);
}

#hand-overflow-overlay.active {
  display: flex;
}

#hand-overflow-title {
  color: #ff3333;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 6px;
  text-shadow: 0 0 20px rgba(255, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.7);
}

#hand-overflow-desc {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  line-height: 1.7;
  letter-spacing: 0.5px;
  max-width: 90%;
}

/* 手札超過：決定ボタン */
#hand-overflow-buttons {
  margin-top: 8px;
  pointer-events: auto;
}

#hand-overflow-confirm {
  background: linear-gradient(135deg, #555, #444);
  color: #888;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: default;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
}

#hand-overflow-confirm.ready {
  background: linear-gradient(135deg, #1a5aab, #103a70);
  color: #aac4ff;
  border: 1px solid rgba(80, 160, 255, 0.5);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(80, 160, 255, 0.3);
}

#hand-overflow-confirm.ready:active {
  transform: scale(0.96);
}

#hand-overflow-remaining {
  color: rgba(255, 220, 100, 0.95);
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 1px;
  margin-top: 6px;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

/* ===== 手札超過：タップ選択ハイライト ===== */
.battle-card.overflow-selected {
  border: 1px solid rgba(255, 200, 50, 0.8) !important;
  box-shadow: 0 0 10px 3px rgba(255, 200, 50, 0.5), 0 0 20px 6px rgba(255, 200, 50, 0.2) !important;
  transform: translateY(-4px);
  opacity: 0.7;
}

/* ===== カード選択フェイズオーバーレイ（上55%のみ覚い、下の手札は操作可能） ===== */
#card-select-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55%;
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  z-index: 360;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.82);
}

#card-select-overlay.active {
  display: flex;
}

/* 上段: 選択中カードの拡大表示エリア */
#card-select-top {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  min-height: 0;
}

#card-select-top img {
  max-height: 100%;
  max-width: 55%;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 0 20px 6px rgba(255, 215, 0, 0.3), 0 0 40px 12px rgba(255, 215, 0, 0.12);
  display: none;
}

#card-select-top img.active {
  display: block;
}

/* 選択前のプレースホルダーテキスト */
#card-select-placeholder {
  color: rgba(255, 255, 255, 0.2);
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 2px;
  text-align: center;
}

/* 中段: タイトル + 説明 + ボタン */
#card-select-mid {
  background: rgba(0, 0, 0, 0.6);
  border-top: 1px solid rgba(68, 170, 255, 0.2);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  flex-shrink: 0;
}

#card-select-title {
  color: #44aaff;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 0 14px rgba(68, 170, 255, 0.4), 0 2px 4px rgba(0, 0, 0, 0.7);
}

#card-select-desc {
  color: rgba(255, 255, 255, 0.88);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.6;
  letter-spacing: 0.3px;
  max-width: 95%;
}

#card-select-buttons {
  gap: 10px;
  margin-top: 2px;
  pointer-events: auto;
}

#card-select-confirm {
  background: linear-gradient(135deg, #555, #444);
  color: #888;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: default;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
}

#card-select-confirm.ready {
  background: linear-gradient(135deg, #1a5aab, #103a70);
  color: #aac4ff;
  border: 1px solid rgba(80, 160, 255, 0.5);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(80, 160, 255, 0.3);
}

#card-select-confirm.ready:active {
  transform: scale(0.96);
}

#card-select-skip {
  background: linear-gradient(135deg, #8b1a1a, #5c1010);
  color: #ffd4d4;
  border: 1px solid rgba(255, 100, 100, 0.4);
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255, 80, 80, 0.2);
}

#card-select-skip:active {
  transform: scale(0.96);
}

/* カード選択中のハイライト（手札＆公開場の光らせ） */
.card-select-zone-glow {
  animation: selectZoneGlow 1.5s ease-in-out infinite;
}

@keyframes selectZoneGlow {
  0% {
    box-shadow: inset 0 0 8px rgba(68, 170, 255, 0.15);
  }

  50% {
    box-shadow: inset 0 0 20px rgba(68, 170, 255, 0.35);
  }

  100% {
    box-shadow: inset 0 0 8px rgba(68, 170, 255, 0.15);
  }
}

/* 選択対象カードのハイライト */
.battle-card.tap-play-selected {
  border-color: rgba(226, 191, 112, 0.9) !important;
  box-shadow: 0 0 9px 2px rgba(216, 175, 85, 0.5), 0 0 18px rgba(216, 175, 85, 0.2) !important;
}

#tap-play-dialog {
  position: absolute;
  inset: 0;
  z-index: 9150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  background: rgba(0, 0, 0, 0.83);
}

.tap-play-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 540px;
  max-height: 100%;
  min-height: 0;
  padding: 22px 16px 16px;
  border: 1px solid rgba(193, 161, 99, 0.38);
  border-radius: 8px;
  background: linear-gradient(160deg, #181715, #0b0b0d);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 244, 214, 0.05);
}

#tap-play-title {
  flex-shrink: 0;
  color: #e3c994;
  text-align: center;
  font-size: 18px;
  letter-spacing: 2px;
}

#tap-play-desc {
  flex-shrink: 0;
  margin: 10px 0 18px;
  color: #c4c0ba;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-line;
}

#tap-play-options {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  min-height: 0;
  padding: 6px 2px;
  overflow-y: auto;
  touch-action: pan-y;
}

.tap-play-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 122px;
  max-width: calc(50% - 6px);
  padding: 8px 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: #141416;
  color: #d0ccc5;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.tap-play-option[aria-pressed="true"] {
  border-color: #c6a463;
  background: #292318;
  box-shadow: inset 0 0 0 1px rgba(218, 181, 111, 0.15), 0 0 12px rgba(184, 139, 58, 0.18);
}

.tap-play-option img,
.tap-play-new-slot {
  display: block;
  width: 96px;
  max-width: 100%;
  height: 134px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 6px;
  pointer-events: none;
}

.tap-play-new-slot {
  display: grid;
  place-items: center;
  border: 1px dashed #776444;
  color: #bca273;
  font-size: 36px;
}

.tap-play-option-name {
  width: 100%;
  min-height: 34px;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.tap-play-actions {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  gap: 10px;
  padding-top: 18px;
}

.tap-play-actions button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-width: 190px;
  padding: 10px 12px;
  border: 1px solid #56514a;
  border-radius: 5px;
  background: #232220;
  color: #d2cec6;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}

#tap-play-confirm:not(:disabled) {
  border-color: #bd9a59;
  background: linear-gradient(180deg, #71572f, #49371c);
  color: #fff0cc;
  box-shadow: inset 0 1px 0 rgba(255, 235, 183, 0.15);
}

#tap-play-confirm:disabled {
  color: #77736d;
  border-color: #3b3936;
  background: #242321;
  cursor: not-allowed;
}

.battle-card.selection-unavailable {
  cursor: not-allowed;
  box-shadow: none !important;
  transform: none !important;
}

.battle-card.selection-unavailable::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(0, 0, 0, 0.58);
  border-radius: inherit;
  pointer-events: none;
}

.battle-card.selectable {
  border: 1px solid rgba(68, 170, 255, 0.5);
  box-shadow: 0 0 6px 2px rgba(68, 170, 255, 0.35);
  cursor: pointer;
}

.battle-card.selected-card {
  border: 1px solid rgba(255, 215, 0, 0.8) !important;
  box-shadow: 0 0 10px 3px rgba(255, 215, 0, 0.5), 0 0 20px 6px rgba(255, 215, 0, 0.2) !important;
  transform: translateY(-6px);
}

/* 外枠1pxに内側1pxを重ね、選択時も画像の表示領域を保つ。 */
.battle-card:is(.selected-card, .overflow-selected, .soul-absorb-selected, .exile-selected)::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid;
  border-color: inherit;
  border-radius: 5px;
  pointer-events: none;
}

/* ===== スタート画面 ===== */
#start-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    /* 上部：行燈の淡い光 */
    radial-gradient(ellipse 75% 32% at 50% 0%, rgba(160, 105, 18, 0.20) 0%, transparent 70%),
    /* 下部：霧と墨の闇 */
    radial-gradient(ellipse 110% 28% at 50% 108%, rgba(6, 10, 18, 0.75) 0%, transparent 65%),
    /* 左右の深い影 */
    radial-gradient(ellipse 30% 90% at 0% 50%, rgba(4, 2, 1, 0.6) 0%, transparent 70%),
    radial-gradient(ellipse 30% 90% at 100% 50%, rgba(4, 2, 1, 0.6) 0%, transparent 70%),
    /* ベース：温かみのある漆黒 */
    linear-gradient(170deg, #0d0a07 0%, #110e0a 20%, #0e0b0f 50%, #09070c 80%, #070508 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
  gap: 0;
  padding: 24px 20px 56px;
  /* padding-bottom: フッター高さ分を確保し、コンテンツの視覚的中心を維持 */
}

/* 中身だけ非表示 → readyで表示（背景は常に不透明で戦闘場を隠す） */
#start-overlay>* {
  opacity: 0;
  transition: opacity 0.4s ease;
}

#start-overlay.ready>* {
  opacity: 1;
}

#start-title {
  color: #c4b48a;
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 3px;
  text-align: center;
  line-height: 2.0;
  text-shadow: 0 0 18px rgba(180, 130, 35, 0.35), 0 2px 8px rgba(0, 0, 0, 0.9);
  margin-bottom: 18px;
}

#start-deck-img {
  max-width: 90%;
  max-height: 32%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow:
    0 0 15px 4px rgba(255, 255, 255, 0.09),
    0 0 40px 10px rgba(255, 255, 255, 0.04),
    0 0 70px 20px rgba(255, 255, 255, 0.02);
  margin-bottom: 24px;
}

#start-buttons-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  width: 100%;
  margin-bottom: 14px;
}

.start-btn-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#start-btn {
  background: linear-gradient(160deg, #6e1212 0%, #3e0808 55%, #2d0606 100%);
  color: #f0ece4;
  border: 1px solid rgba(190, 90, 60, 0.38);
  padding: 11px 28px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 4px;
  text-indent: 4px;
  cursor: pointer;
  text-shadow: 0 1px 8px rgba(180, 40, 20, 0.6), 0 0 2px rgba(0, 0, 0, 0.9);
  transition: transform 0.1s ease;
  box-shadow: 0 4px 28px rgba(140, 15, 15, 0.55), inset 0 1px 0 rgba(240, 140, 100, 0.10);
  margin-bottom: 6px;
}

#start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(140, 15, 15, 0.7), inset 0 1px 0 rgba(240, 140, 100, 0.15);
}

#start-btn:active {
  background: linear-gradient(160deg, #7e1818 0%, #4e0e0e 55%, #3a0a0a 100%);
  transform: scale(0.97);
}

#start-sub {
  color: rgba(195, 175, 140, 0.6);
  font-size: 11px;
  margin-bottom: 0;
  letter-spacing: 0.5px;
}

#solo-btn {
  background: linear-gradient(160deg, #0e3018 0%, #082010 55%, #051508 100%);
  color: #f0ece4;
  border: 1px solid rgba(60, 140, 85, 0.32);
  padding: 11px 28px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 4px;
  text-indent: 4px;
  cursor: pointer;
  text-shadow: 0 1px 8px rgba(20, 90, 50, 0.6), 0 0 2px rgba(0, 0, 0, 0.9);
  transition: transform 0.1s ease;
  box-shadow: 0 4px 28px rgba(8, 60, 25, 0.5), inset 0 1px 0 rgba(100, 200, 130, 0.08);
  margin-bottom: 6px;
}

#solo-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(8, 60, 25, 0.65), inset 0 1px 0 rgba(100, 200, 130, 0.12);
}

#solo-btn:active {
  background: linear-gradient(160deg, #143c20 0%, #0a2814 55%, #071a0a 100%);
  transform: scale(0.97);
}

#solo-sub {
  color: rgba(195, 175, 140, 0.6);
  font-size: 11px;
  margin-bottom: 0;
  letter-spacing: 0.5px;
}

#deck-list-link {
  color: #b08830;
  font-size: 12px;
  font-weight: bold;
  text-decoration: none;
  letter-spacing: 1px;
  margin-bottom: 4px;
  display: inline-block;
  text-shadow: 0 0 12px rgba(180, 130, 30, 0.4);
}

#deck-list-link::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 7px;
  border-color: transparent transparent transparent #b08830;
  margin-right: 4px;
  vertical-align: middle;
}

#deck-list-link:active {
  opacity: 0.6;
}

#start-note {
  color: rgba(190, 172, 140, 0.72);
  font-size: 10px;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* デッキリスト画像ポップアップ */
#deck-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#deck-popup {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
}

#deck-popup-img {
  display: block;
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7), 0 0 20px 4px rgba(220, 180, 60, 0.4);
}

#deck-popup-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #333;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#deck-popup-close:active {
  background: #555;
}

/* ===== 開門演出 ===== */
#gate-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 460;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.75);
}

#gate-overlay.active {
  display: flex;
  pointer-events: auto;
  cursor: pointer;
}

#gate-text {
  color: #fff;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 16px;
  text-indent: 16px;
  text-shadow: 0 0 50px rgba(255, 255, 255, 0.5), 0 0 80px rgba(255, 255, 255, 0.2), 0 4px 12px rgba(0, 0, 0, 0.8);
}

@keyframes gateAppear {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }

  30% {
    opacity: 1;
    transform: scale(1.1);
  }

  50% {
    opacity: 1;
    transform: scale(1.0);
  }

  100% {
    opacity: 1;
    transform: scale(1.0);
  }
}

@keyframes gateFadeOut {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

#coin-text {
  color: #fff;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 6px;
  text-indent: 6px;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* 先攻/後攻 確定エフェクト */
@keyframes coinStamp {
  0% {
    opacity: 0;
    transform: scale(1.12);
    text-shadow:
      0 0 60px rgba(255, 255, 255, 1),
      0 0 120px rgba(200, 220, 255, 0.8),
      0 0 200px rgba(150, 180, 255, 0.4);
  }

  35% {
    opacity: 1;
    transform: scale(1.0);
    text-shadow:
      0 4px 30px rgba(255, 255, 255, 1),
      0 0 50px rgba(255, 255, 255, 0.9),
      0 0 90px rgba(200, 220, 255, 0.8),
      0 0 140px rgba(150, 180, 255, 0.5),
      0 8px 60px rgba(100, 140, 255, 0.3);
  }

  60% {
    text-shadow:
      0 3px 25px rgba(255, 255, 255, 0.7),
      0 0 45px rgba(255, 255, 255, 0.5),
      0 0 80px rgba(200, 220, 255, 0.35),
      0 6px 50px rgba(100, 140, 255, 0.15);
  }

  100% {
    opacity: 1;
    transform: scale(1.0);
    text-shadow:
      0 2px 20px rgba(255, 255, 255, 0.5),
      0 0 40px rgba(255, 255, 255, 0.25),
      0 0 70px rgba(200, 220, 255, 0.12),
      0 4px 40px rgba(100, 140, 255, 0.08);
  }
}

#coin-text.coin-stamp {
  animation: coinStamp 0.5s ease-out forwards;
}

/* ===== 開門演出（リッチ版・GPU最適化） ===== */

/* 横帯：中央から左右に伸びる金色ライン */
.kaimon-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-50%) scaleX(0);
  background: linear-gradient(90deg, transparent 0%, rgba(180, 140, 60, 0.15) 15%, rgba(200, 160, 80, 0.5) 40%, rgba(220, 180, 100, 0.8) 50%, rgba(200, 160, 80, 0.5) 60%, rgba(180, 140, 60, 0.15) 85%, transparent 100%);
  pointer-events: none;
  z-index: -1;
  animation: kaimonLineExpand 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.kaimon-line:nth-child(2) {
  height: 40px;
  opacity: 0.15;
  background: linear-gradient(90deg, transparent 5%, rgba(200, 160, 80, 0.6) 30%, rgba(220, 180, 100, 1) 50%, rgba(200, 160, 80, 0.6) 70%, transparent 95%);
  animation-delay: 0.05s;
}

@keyframes kaimonLineExpand {
  0% {
    transform: translateY(-50%) scaleX(0);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: translateY(-50%) scaleX(1);
    opacity: 1;
  }
}

/* 文字フェードイン */
@keyframes kaimonTextIn {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }
  100% {
    opacity: 1;
    transform: scale(1.0);
  }
}

/* 文字の金色発光 */
#gate-text.kaimon-glow {
  text-shadow:
    0 0 20px rgba(220, 180, 100, 0.8),
    0 0 50px rgba(200, 150, 60, 0.5),
    0 0 80px rgba(180, 120, 30, 0.25),
    0 4px 12px rgba(0, 0, 0, 0.8);
}

/* 全体フェードアウト */
@keyframes kaimonAllOut {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* ===== ターン告知 ===== */
#turn-announce {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 450;
  pointer-events: none;
  background: transparent;
}

#turn-announce.active {
  display: flex;
}

#turn-announce-text {
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 6px;
  text-indent: 6px;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.4), 0 2px 8px rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.85);
  width: 100%;
  text-align: center;
  padding: 18px 0;
  animation: turnAnnounceIn 0.8s ease-out forwards;
}

#turn-announce-text.enemy {
  color: #ff4444;
  text-shadow: 0 0 30px rgba(255, 50, 50, 0.5), 0 2px 8px rgba(0, 0, 0, 0.6);
}

@keyframes turnAnnounceIn {
  0% {
    opacity: 0;
    transform: scaleY(0.3);
  }

  20% {
    opacity: 1;
    transform: scaleY(1.05);
  }

  35% {
    transform: scaleY(1.0);
  }

  80% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* ===== 場所札なしポップアップ ===== */
#no-basho-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 80, 80, 0.35);
  border-radius: 8px;
  padding: 10px 18px;
  pointer-events: none;
  max-width: 80%;
}

#no-basho-msg.active {
  display: flex;
}

#no-basho-msg span {
  color: rgba(255, 180, 180, 0.95);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* ===== 相手手札タッチポップアップ ===== */
#opp-hand-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 160, 60, 0.4);
  border-radius: 8px;
  padding: 10px 18px;
  pointer-events: none;
  max-width: 85%;
}

#opp-hand-msg.active {
  display: flex;
}

#opp-hand-msg span {
  color: rgba(255, 220, 150, 0.95);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* ===== 相手山札タッチポップアップ ===== */
#opp-deck-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 160, 60, 0.4);
  border-radius: 8px;
  padding: 10px 18px;
  pointer-events: none;
  max-width: 85%;
}

#opp-deck-msg.active {
  display: flex;
}

#opp-deck-msg span {
  color: rgba(255, 220, 150, 0.95);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

/* ===== フィニッシュブロー：フィールドズーム演出 ===== */
#finish-blow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  z-index: 460;
  pointer-events: none;
  overflow: hidden;
}

#finish-blow-overlay.active {
  display: block;
}

#finish-blow-field {
  position: absolute;
  left: 0;
  right: 0;
  height: 100%;
  animation: finishBlowZoom 1.8s ease-out forwards;
  transform-origin: center 35%;
}

#finish-blow-overlay.target-bottom #finish-blow-field {
  transform-origin: center 65%;
}

@keyframes finishBlowZoom {
  0% {
    transform: scale(1.0);
    filter: brightness(1);
  }

  20% {
    transform: scale(1.6);
    filter: brightness(1.3);
  }

  50% {
    transform: scale(1.5);
    filter: brightness(1.1);
  }

  100% {
    transform: scale(1.4);
    filter: brightness(0.8);
    opacity: 0;
  }
}

.finish-impact-line {
  position: absolute;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9), transparent);
  height: 2px;
  width: 120%;
  left: -10%;
  animation: impactLineFlash 0.6s ease-out forwards;
}

@keyframes impactLineFlash {
  0% {
    opacity: 1;
    transform: scaleX(0);
  }

  30% {
    opacity: 1;
    transform: scaleX(1);
  }

  100% {
    opacity: 0;
    transform: scaleX(1.2);
  }
}

.finish-radial-burst {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 100, 0.6) 0%, rgba(255, 100, 50, 0.3) 40%, transparent 70%);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: radialBurst 1.0s ease-out forwards;
}

@keyframes radialBurst {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }

  40% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0.8;
  }

  100% {
    transform: translate(-50%, -50%) scale(3);
    opacity: 0;
  }
}

.finish-shock-ring {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.8);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: shockRingExpand 0.8s ease-out forwards;
}

@keyframes shockRingExpand {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
    border-width: 3px;
  }

  100% {
    transform: translate(-50%, -50%) scale(5);
    opacity: 0;
    border-width: 1px;
  }
}

.finish-screen-flash {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  animation: screenFlash 0.4s ease-out forwards;
}

@keyframes screenFlash {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* フィニッシュダメージ：ズーム＋スロー（全ライフ0共通） */
#damage-overlay.finish-damage {
  z-index: 470;
  animation: finishDmgZoom 1.5s ease-out forwards;
}

#damage-overlay.finish-damage #damage-text {
  animation: dmgAppearSlow 1.5s ease-out forwards;
  font-size: 80px;
}

@keyframes finishDmgZoom {
  0% {
    transform: scale(1.0);
  }

  15% {
    transform: scale(1.5);
  }

  50% {
    transform: scale(1.4);
  }

  85% {
    transform: scale(1.35);
  }

  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

@keyframes dmgAppearSlow {
  0% {
    opacity: 0;
    transform: rotate(-12deg) scale(0.3) translateY(20px);
  }

  20% {
    opacity: 1;
    transform: rotate(-12deg) scale(1.3);
  }

  50% {
    opacity: 1;
    transform: rotate(-12deg) scale(1.15);
  }

  80% {
    opacity: 0.9;
    transform: rotate(-12deg) scale(1.1);
  }

  100% {
    opacity: 0;
    transform: rotate(-12deg) scale(1.0) translateY(-10px);
  }
}

/* スロー攻撃アニメ（プレイヤー：3倍遅い） */
@keyframes attackSlideUpSlow {
  0% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }

  15% {
    opacity: 1;
    transform: translateY(18px);
    filter: blur(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-80px);
    filter: blur(1px);
  }

  70% {
    opacity: 0.6;
    transform: translateY(-160px);
    filter: blur(4px);
  }

  100% {
    opacity: 0;
    transform: translateY(-220px);
    filter: blur(8px);
  }
}

.field-group.attacking-slow {
  animation: attackSlideUpSlow 1.5s ease-in forwards;
  pointer-events: none;
  z-index: 9000;
  position: relative;
}

/* スロー攻撃アニメ（CPU：3倍遅い） */
@keyframes cpuAttackSlideDownSlow {
  0% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }

  15% {
    opacity: 1;
    transform: translateY(-18px);
    filter: blur(0);
  }

  40% {
    opacity: 1;
    transform: translateY(80px);
    filter: blur(1px);
  }

  70% {
    opacity: 0.6;
    transform: translateY(160px);
    filter: blur(4px);
  }

  100% {
    opacity: 0;
    transform: translateY(220px);
    filter: blur(8px);
  }
}

/* ===== 勝敗結果 ===== */
#result-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 38px;
  z-index: 480;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.7);
}

#result-overlay.active {
  display: flex;
  pointer-events: auto;
}

#result-text {
  color: #fff;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 4px;
  text-indent: 8px;
  text-shadow: 0 0 40px rgba(255, 255, 255, 0.5), 0 2px 8px rgba(0, 0, 0, 0.7);
  animation: resultFadeIn 1.0s ease-out forwards;
}

#retry-btn {
  background: linear-gradient(135deg, #1e3a5f, #16213e);
  color: #fafafa;
  border: 1px solid rgba(80, 140, 255, 0.25);
  padding: 10px 30px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  animation: resultFadeIn 1.0s ease-out forwards;
  animation-delay: 0.5s;
  opacity: 0;
}

#retry-btn:active {
  background: linear-gradient(135deg, #2a4f7f, #1e3a5f);
  transform: scale(0.97);
}

#result-shop-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  animation: resultFadeIn 1.0s ease-out forwards;
  animation-delay: 0.7s;
  opacity: 0;
}

#result-shop-img {
  width: 260px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

#result-shop-text {
  color: rgba(200, 220, 255, 0.9);
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 2px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

#result-shop-link:active #result-shop-img {
  opacity: 0.8;
}

#result-overlay.win #result-text {
  color: #ffd700;
  text-shadow: 0 0 40px rgba(255, 215, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.7);
}

#result-overlay.lose #result-text {
  color: #ff4444;
  text-shadow: 0 0 40px rgba(255, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.7);
}

#win-streak {
  display: none;
  color: #ffd700;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.7);
  animation: resultFadeIn 1.0s ease-out forwards;
  animation-delay: 0.3s;
  opacity: 0;
}

@keyframes resultFadeIn {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }

  60% {
    opacity: 1;
    transform: scale(1.05);
  }

  100% {
    opacity: 1;
    transform: scale(1.0);
  }
}

/* ===== 札種類ボタンハイライト（白く光る） ===== */
@keyframes typeHighlight {
  0% {
    box-shadow: 0 0 8px 3px rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.7);
  }

  50% {
    box-shadow: 0 0 14px 5px rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.9);
  }

  100% {
    box-shadow: none;
    border-color: transparent;
  }
}

.battle-card.type-highlight {
  animation: typeHighlight 1.0s ease-out forwards;
}

/* ===== 召喚波動エフェクト ===== */
.summon-ripple {
  position: absolute;
  border-radius: 14px;
  /* カード型角丸（円形から変更） */
  border: 2px solid rgba(220, 60, 60, 0.85);
  background: linear-gradient(135deg, rgba(220, 60, 60, 0.2), transparent 70%);
  pointer-events: none;
  z-index: 0;
  transform: translate(-50%, -50%) scale(0);
  animation: summonRippleExpand 0.6s ease-out forwards;
}

.summon-ripple.ripple-purple {
  border-color: rgba(160, 60, 220, 0.85);
  background: linear-gradient(135deg, rgba(160, 60, 220, 0.2), transparent 70%);
}

.summon-ripple.ripple-yellow {
  border-color: rgba(230, 200, 40, 0.85);
  background: linear-gradient(135deg, rgba(230, 200, 40, 0.2), transparent 70%);
}

/* 縦長（怪異・季節・速攻場所札） */
.summon-ripple.ripple-portrait {
  border-radius: 14px;
}

/* 横長（場所札通常召喚） */
.summon-ripple.ripple-landscape {
  border-radius: 10px;
}

@keyframes summonRippleExpand {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
    border-width: 2px;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    transform: translate(-50%, -50%) scale(2.2);
    opacity: 0;
    border-width: 1px;
  }
}

/* ===== ドロー飛行アニメーション ===== */
.draw-fly-card {
  position: fixed;
  z-index: 9000;
  border-radius: 4px;
  overflow: hidden;
  pointer-events: none;
  box-shadow: 0 0 14px rgba(100, 200, 255, 0.6), 0 4px 12px rgba(0, 0, 0, 0.6);
  opacity: 0;
  will-change: transform, left, top, opacity;
  transition: left 0.4s cubic-bezier(0.22, 0.68, 0.35, 1),
    top 0.4s cubic-bezier(0.22, 0.68, 0.35, 1),
    opacity 0.4s ease;
}

.draw-fly-card.fly-active {
  opacity: 1;
}

.draw-fly-card.fly-arrived {
  opacity: 0;
  box-shadow: none;
}

.draw-fly-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== 除外飛行アニメーション ===== */
.exile-fly-card {
  position: fixed;
  z-index: 9000;
  border-radius: 4px;
  overflow: hidden;
  pointer-events: none;
  box-shadow: 0 0 14px rgba(200, 30, 30, 0.7), 0 4px 12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  will-change: transform, left, top, opacity;
  transition: left 0.45s cubic-bezier(0.22, 0.68, 0.35, 1),
    top 0.45s cubic-bezier(0.22, 0.68, 0.35, 1),
    opacity 0.35s ease,
    transform 0.45s ease;
}

.exile-fly-card.exile-fly-active {
  opacity: 1;
}

.exile-fly-card.exile-fly-shrink {
  opacity: 0;
  transform: scale(0.3);
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.9);
}

.exile-fly-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== 手札公開場飛行アニメーション（除外→公開場） ===== */
.open-fly-card {
  position: fixed;
  z-index: 9000;
  border-radius: 4px;
  overflow: hidden;
  pointer-events: none;
  box-shadow: 0 0 14px rgba(220, 170, 50, 0.8), 0 4px 12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  will-change: transform, left, top, opacity;
  transition: left 0.42s cubic-bezier(0.22, 0.68, 0.35, 1),
    top 0.42s cubic-bezier(0.22, 0.68, 0.35, 1),
    opacity 0.3s ease,
    transform 0.42s ease;
}

.open-fly-card.open-fly-active {
  opacity: 1;
}

.open-fly-card.open-fly-shrink {
  opacity: 0;
  transform: scale(0.4);
  box-shadow: 0 0 20px rgba(220, 170, 50, 0.9);
}

.open-fly-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== 魂飛行アニメーション ===== */
.soul-fly-card {
  position: fixed;
  z-index: 9000;
  border-radius: 4px;
  overflow: hidden;
  pointer-events: none;
  box-shadow: 0 0 14px rgba(80, 120, 255, 0.7), 0 4px 12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  will-change: transform, left, top, opacity;
  transition: left 0.42s cubic-bezier(0.22, 0.68, 0.35, 1),
    top 0.42s cubic-bezier(0.22, 0.68, 0.35, 1),
    width 0.42s cubic-bezier(0.22, 0.68, 0.35, 1),
    height 0.42s cubic-bezier(0.22, 0.68, 0.35, 1),
    opacity 0.3s ease,
    transform 0.42s ease;
}

.soul-fly-card.soul-fly-active {
  opacity: 1;
}

.soul-fly-card.soul-fly-shrink {
  opacity: 0;
  transform: scale(0.25);
  box-shadow: 0 0 20px rgba(80, 120, 255, 0.9);
}

.soul-fly-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== 効果発動オーバーレイ ===== */
#effect-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 9500;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

#effect-overlay.active {
  display: flex;
  animation: effectOverlayFade 0.8s ease-out forwards;
}

@keyframes effectOverlayFade {
  0% {
    opacity: 0;
  }

  15% {
    opacity: 1;
  }

  75% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

#effect-label {
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 6px;
  text-indent: 6px;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.5), 0 2px 8px rgba(0, 0, 0, 0.7);
}

#effect-label.effect-failed {
  color: #ff4444;
  text-shadow: 0 0 20px rgba(255, 68, 68, 0.5), 0 2px 8px rgba(0, 0, 0, 0.7);
}

#effect-card-img {
  max-height: 45%;
  max-width: 55%;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 0 30px 8px rgba(255, 255, 255, 0.2);
  animation: effectAppear 0.8s ease-out forwards;
}

@keyframes effectAppear {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }

  20% {
    opacity: 1;
    transform: scale(1.05);
  }

  35% {
    opacity: 1;
    transform: scale(1.0);
  }

  75% {
    opacity: 1;
    transform: scale(1.0);
  }

  100% {
    opacity: 0;
    transform: scale(0.95);
  }
}

/* キラキラエフェクト */
@keyframes sparkle {
  0% {
    opacity: 0;
    transform: scale(0) rotate(0deg);
  }

  50% {
    opacity: 1;
    transform: scale(1) rotate(180deg);
  }

  100% {
    opacity: 0;
    transform: scale(0) rotate(360deg);
  }
}

.sparkle-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: radial-gradient(circle, #fff, transparent);
  border-radius: 50%;
  pointer-events: none;
  animation: sparkle 0.6s ease-out forwards;
}

/* ===== 怪異札表向きフリップ ===== */
@keyframes kaiiFlipReveal {
  0% {
    transform: scaleX(1);
  }

  50% {
    transform: scaleX(0);
  }

  100% {
    transform: scaleX(1);
  }
}

.battle-card.kaii-flipping {
  animation: kaiiFlipReveal 0.4s ease-in-out forwards;
}

/* ===== フローティングテキスト（ドロー・憑依・除外） ===== */
.floating-text {
  position: absolute;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  pointer-events: none;
  z-index: 100;
  animation: floatingTextUp 0.9s ease-out forwards;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  transform: translateX(-50%);
}

.floating-text.ft-draw {
  color: rgba(100, 200, 255, 0.95);
}

.floating-text.ft-hyoui {
  color: rgba(180, 120, 255, 0.95);
}

.floating-text.ft-exile {
  color: rgba(255, 100, 100, 0.95);
}

.floating-text.ft-summon {
  color: rgba(255, 80, 80, 0.95);
}

.floating-text.ft-tenkai {
  color: rgba(255, 220, 80, 0.95);
}

.floating-text.ft-handdes {
  color: rgba(180, 80, 255, 0.95);
}

/* ===== リセット確認ポップアップ ===== */
/* タイトル確認ポップアップ（リセット確認と同構造） */
#title-confirm {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 500;
  background: rgba(0, 0, 0, 0.75);
}

#title-confirm.active {
  display: flex;
}

#title-confirm-title {
  color: #ffcc44;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(255, 200, 50, 0.4), 0 2px 6px rgba(0, 0, 0, 0.7);
}

#title-confirm-yes {
  background: linear-gradient(135deg, #1a5aab, #103a70);
  color: #aac4ff;
  border: 1px solid rgba(80, 160, 255, 0.5);
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(80, 160, 255, 0.3);
}

#title-confirm-yes:active {
  transform: scale(0.96);
}

#title-confirm-no {
  background: linear-gradient(135deg, #8b1a1a, #5c1010);
  color: #ffd4d4;
  border: 1px solid rgba(255, 100, 100, 0.4);
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 80, 80, 0.2);
}

#title-confirm-no:active {
  transform: scale(0.96);
}

#reset-confirm {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 500;
  background: rgba(0, 0, 0, 0.75);
}

#reset-confirm.active {
  display: flex;
}

#reset-confirm-title {
  color: #ffcc44;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(255, 200, 50, 0.4), 0 2px 6px rgba(0, 0, 0, 0.7);
}

#reset-confirm-buttons {
  gap: 16px;
}

#reset-confirm-yes {
  background: linear-gradient(135deg, #1a5aab, #103a70);
  color: #aac4ff;
  border: 1px solid rgba(80, 160, 255, 0.5);
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(80, 160, 255, 0.3);
}

#reset-confirm-yes:active {
  transform: scale(0.96);
}

#reset-confirm-no {
  background: linear-gradient(135deg, #8b1a1a, #5c1010);
  color: #ffd4d4;
  border: 1px solid rgba(255, 100, 100, 0.4);
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 80, 80, 0.2);
}

#reset-confirm-no:active {
  transform: scale(0.96);
}

/* ===== 攻撃前のターンエンド確認 ===== */
#end-turn-confirm {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9200;
  background: rgba(0, 0, 0, 0.78);
}

.end-turn-confirm-panel {
  width: 100%;
  max-width: 420px;
  padding: 24px 18px 18px;
  border: 1px solid rgba(118, 143, 182, 0.4);
  border-radius: 8px;
  background: #10141c;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  text-align: center;
}

#end-turn-confirm-title {
  color: #e1e8f3;
  font-size: 19px;
  line-height: 1.5;
}

#end-turn-confirm-desc {
  margin-top: 10px;
  color: #d8c394;
  font-size: 14px;
  line-height: 1.7;
}

.end-turn-confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.end-turn-confirm-actions button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 8px;
  border: 1px solid #50596a;
  border-radius: 6px;
  background: #252a34;
  color: #d8deea;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}

#end-turn-confirm-yes {
  border-color: rgba(80, 140, 255, 0.5);
  background: linear-gradient(135deg, #1a3a6b, #102a50);
  color: #aac4ee;
}

.end-turn-confirm-actions button:active {
  box-shadow: inset 0 0 0 1px rgba(190, 210, 255, 0.4);
}

/* ===== 魂ダメージ吸収：質問ポップアップ ===== */
#soul-absorb-ask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9050;
  background: rgba(0, 0, 0, 0.75);
}

#soul-absorb-ask.active {
  display: flex;
}

#soul-absorb-ask-title {
  color: #ffcc44;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(255, 200, 50, 0.4), 0 2px 6px rgba(0, 0, 0, 0.7);
}

#soul-absorb-ask-buttons {
  gap: 16px;
}

#soul-absorb-yes {
  background: linear-gradient(135deg, #1a5aab, #103a70);
  color: #aac4ff;
  border: 1px solid rgba(80, 160, 255, 0.5);
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(80, 160, 255, 0.3);
}

#soul-absorb-yes:active {
  transform: scale(0.96);
}

#soul-absorb-no {
  background: linear-gradient(135deg, #8b1a1a, #5c1010);
  color: #ffd4d4;
  border: 1px solid rgba(255, 100, 100, 0.4);
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 80, 80, 0.2);
}

#soul-absorb-no:active {
  transform: scale(0.96);
}

#soul-absorb-ask-img {
  width: 180px;
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(255, 100, 100, 0.4), 0 4px 12px rgba(0, 0, 0, 0.6);
  margin-bottom: 8px;
}

/* 致死ダメージ時だけ、判断に必要な情報をひとつの案内にまとめる。 */
.soul-lethal-notice {
  --notice-accent: #ef9a86;
  width: min(440px, 90%);
  flex-shrink: 0;
  padding: 14px 16px;
  border: 1px solid rgba(188, 155, 87, 0.45);
  border-radius: 2px;
  background: rgba(10, 9, 12, 0.96);
  box-shadow: inset 0 1px 0 rgba(235, 210, 155, 0.08), 0 4px 16px rgba(0, 0, 0, 0.5);
  color: #e8dfce;
  text-align: left;
}

.soul-lethal-notice[hidden] {
  display: none;
}

.soul-lethal-heading {
  display: flex;
  align-items: center;
  color: var(--notice-accent);
}

.soul-lethal-title {
  font-size: clamp(15px, 3.9vw, 17px);
  line-height: 1.5;
  letter-spacing: 0.25px;
}

.soul-lethal-message {
  margin: 6px 0 12px;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(232, 223, 206, 0.8);
}

.soul-lethal-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(188, 155, 87, 0.25);
  font-size: clamp(12px, 3vw, 13px);
  color: rgba(232, 223, 206, 0.7);
}

.soul-lethal-stats b {
  margin-left: 6px;
  color: #e8dfce;
  font-size: 22px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.soul-lethal-notice.is-safe {
  --notice-accent: #e3c78f;
}

.soul-lethal-stats .soul-lethal-life {
  color: var(--notice-accent);
}

#soul-absorb-ask.lethal-damage {
  gap: 12px;
  padding: 16px 0;
}

#soul-absorb-ask.lethal-damage #soul-absorb-ask-title {
  width: 90%;
  font-size: clamp(16px, 3.8vw, 20px);
  line-height: 1.6;
  letter-spacing: 1px;
  text-align: center;
}

#soul-absorb-ask.lethal-damage #soul-absorb-ask-img {
  width: auto;
  height: min(25dvh, 216px);
  margin-bottom: 0;
}

/* ===== 魂ダメージ吸収：魂選択フェイズ ===== */
#soul-absorb-select {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 9050;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.7);
}

#soul-absorb-select.active {
  display: flex;
}

#soul-absorb-select-title {
  color: #ffcc44;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 5px;
  text-shadow: 0 0 20px rgba(255, 200, 50, 0.4), 0 2px 6px rgba(0, 0, 0, 0.7);
}

#soul-absorb-select-desc {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  line-height: 1.7;
  letter-spacing: 0.5px;
  max-width: 90%;
}

#soul-absorb-select-buttons {
  margin-top: 8px;
  pointer-events: auto;
}

#soul-absorb-confirm {
  background: linear-gradient(135deg, #555, #444);
  color: #888;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: default;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
}

#soul-absorb-confirm.ready {
  background: linear-gradient(135deg, #b58a1a, #7a5c10);
  color: #fff3c4;
  border: 1px solid rgba(255, 200, 80, 0.5);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 200, 80, 0.3);
}

#soul-absorb-confirm.ready:active {
  transform: scale(0.96);
}

/* 魂選択中のハイライト */
.battle-card.soul-absorb-selected {
  border: 1px solid rgba(255, 200, 50, 0.8) !important;
  box-shadow: 0 0 12px rgba(255, 200, 50, 0.5);
}

.battle-card.soul-selectable {
  box-shadow: 0 0 8px rgba(255, 200, 50, 0.3);
}

@keyframes floatingTextUp {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(0);
  }

  15% {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
  }

  60% {
    opacity: 1;
    transform: translateX(-50%) translateY(-18px);
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-30px);
  }
}

/* ===== 魂ダメージ表示 ===== */
.soul-damage-num {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.3);
  color: #2c51f5;
  font-size: 36px;
  font-weight: 900;
  font-style: italic;
  text-shadow: 0 0 14px rgba(28, 31, 207, 0.5), 2px 2px 0 #000;
  pointer-events: none;
  z-index: 100;
  animation: soulDmgAppear 0.85s ease-out forwards;
}

@keyframes soulDmgAppear {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }

  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }

  45% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.0);
  }

  75% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.0);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95) translateY(-8px);
  }
}

.soul-damage-num.soul-damage-finish {
  font-size: 48px;
  z-index: 470;
  animation: soulDmgAppearSlow 1.5s ease-out forwards;
}

@keyframes soulDmgAppearSlow {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }

  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.3);
  }

  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }

  80% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1.1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.0) translateY(-8px);
  }
}

/* ===== 魂バースト（青系）エフェクト ===== */
.soul-burst-core {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 99;
  background: radial-gradient(ellipse at center,
      rgba(30, 80, 220, 0.95) 0%,
      rgba(10, 50, 180, 0.8) 25%,
      rgba(0, 20, 120, 0.5) 55%,
      transparent 100%);
  animation: dmgBurst 0.8s ease-out forwards;
}

.soul-burst-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 99;
  border: 3px solid rgba(80, 140, 255, 0.7);
  background: transparent;
  animation: dmgRing 0.8s ease-out forwards;
}

.soul-splatter {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(80, 160, 255, 0.95), rgba(20, 60, 200, 0.8));
  pointer-events: none;
  z-index: 99;
  animation: dmgSplatter 0.7s ease-out forwards;
}

/* ===== 除外カード順番選択 ===== */
.exile-order-done {
  opacity: 0.5;
  position: relative;
  cursor: pointer;
}

.exile-order-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #000;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* ===== 相手手札除外選択モーダル ===== */
#opp-hand-exile-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 390;
  background: rgba(0, 0, 0, 0.85);
}

#opp-hand-exile-overlay.active {
  display: flex;
}

#opp-hand-exile-title {
  color: #ff6644;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(255, 102, 68, 0.4);
}

#opp-hand-exile-desc {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  line-height: 1.7;
  max-width: 90%;
}

#opp-hand-exile-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 12px;
  max-width: 95%;
  max-height: 55%;
  overflow-y: auto;
}

#opp-hand-exile-cards .battle-card {
  width: 70px;
  height: 98px;
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  border: 2px solid transparent;
  border-radius: 6px;
}

#opp-hand-exile-cards .battle-card.opp-exile-selected {
  border-color: #ff6644;
  box-shadow: 0 0 12px rgba(255, 102, 68, 0.7);
  transform: scale(1.05);
}

#opp-hand-exile-cards .battle-card.opp-exile-done {
  opacity: 0.3;
  pointer-events: none;
}

#opp-hand-exile-cards .opp-exile-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  width: 100%;
  margin-top: 4px;
}

#opp-hand-exile-buttons {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

#opp-hand-exile-confirm {
  background: linear-gradient(135deg, #555, #444);
  color: #888;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: default;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
}

#opp-hand-exile-confirm.ready {
  background: linear-gradient(135deg, #ff6644, #ee4422);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 102, 68, 0.5);
}

/* ===== スクロールバー非表示 ===== */
::-webkit-scrollbar {
  display: none;
}

/* ===== exile-modal プレビューエリア ===== */
#exile-modal-preview-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 120px;
  padding: 8px 0 4px;
  flex-shrink: 0;
}

#exile-modal-preview-placeholder {
  font-size: 12px;
  color: rgba(200, 200, 240, 0.5);
  letter-spacing: 1px;
}

#exile-modal-preview-img {
  max-height: 250px;
  max-width: 60%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 0 18px 5px rgba(255, 215, 0, 0.40), 0 0 36px 10px rgba(255, 215, 0, 0.15);
}

/* 初回選択や画像読み込みで一覧の高さ・スクロール位置を変えない。 */
#exile-modal.deck-search-mode #exile-modal-preview-wrap {
  height: 262px;
  max-height: 40%;
  min-height: 0;
}

#exile-modal.deck-search-mode #exile-modal-preview-img {
  height: 100%;
}

/* ===== メニューモーダル ===== */
#menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 9899;
  background: rgba(5, 3, 15, 1);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#menu-overlay.active {
  display: block !important;
  opacity: 1;
}

#menu-modal {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 72%;
  max-width: 300px;
  z-index: 9900;
  display: flex;
  flex-direction: column;
  background: rgba(12, 10, 28, 0.98);
  border-right: 1px solid rgba(80, 100, 180, 0.3);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow: hidden;
}

#menu-modal.active {
  transform: translateX(0);
}

#menu-modal-header {
  padding: 12px 16px;
  font-size: 16px;
  font-weight: bold;
  color: #e0e8ff;
  letter-spacing: 4px;
  text-align: center;
  border-bottom: 1px solid rgba(80, 100, 160, 0.3);
  flex-shrink: 0;
  background: rgba(15, 12, 35, 0.95);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#menu-close-x {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 57px;
  height: 32px;
  border: 1px solid rgba(80, 120, 220, 0.4);
  border-radius: 6px;
  background: rgba(25, 35, 70, 0.8);
  color: #aac4ff;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

#menu-close-x:active {
  transform: translateY(-50%) scale(0.92);
  background: rgba(40, 60, 130, 0.95);
}

#menu-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
}

.menu-item {
  display: block;
  padding: 14px 20px;
  color: rgba(200, 210, 255, 0.9);
  text-decoration: none;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(80, 100, 160, 0.15);
  transition: background 0.15s ease;
}

.menu-item:active {
  background: rgba(60, 50, 120, 0.5);
}

/* ===== 操作方法モーダル ===== */
#howto-modal {
  position: absolute;
  inset: 0;
  z-index: 9800;
  display: none;
  flex-direction: column;
  background: rgb(8, 6, 20);
  overflow: hidden;
}

#howto-modal.active {
  display: flex;
}

#howto-modal-header {
  padding: 12px 16px;
  font-size: 16px;
  font-weight: bold;
  color: #e0e8ff;
  letter-spacing: 4px;
  text-align: center;
  border-bottom: 1px solid rgba(80, 100, 160, 0.3);
  flex-shrink: 0;
  background: rgba(15, 12, 35, 0.95);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#howto-close-x {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 57px;
  height: 32px;
  border: 1px solid rgba(80, 120, 220, 0.4);
  border-radius: 6px;
  background: rgba(25, 35, 70, 0.8);
  color: #aac4ff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

#howto-close-x:active {
  transform: translateY(-50%) scale(0.92);
  background: rgba(40, 60, 130, 0.95);
}

#howto-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  -webkit-overflow-scrolling: touch;
}

.howto-text {
  color: rgba(210, 220, 255, 0.9);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
  margin: 0;
}

.howto-gif {
  width: 90%;
  height: auto;
  max-width: 340px;
  border-radius: 8px;
  border: 1px solid rgba(80, 100, 160, 0.3);
}

.howto-link {
  color: rgba(180, 190, 230, 0.8);
  font-size: 13px;
  text-align: center;
  margin: 4px 0 0;
}

.howto-link a {
  color: #7eb4ff;
  text-decoration: underline;
}

.howto-divider {
  width: 80%;
  border: none;
  border-top: 1px dashed rgba(80, 100, 160, 0.4);
  margin: 18px 0;
}

#howto-modal-footer {
  padding: 10px;
  display: flex;
  justify-content: center;
  border-top: 1px solid rgba(80, 100, 160, 0.3);
  flex-shrink: 0;
  background: rgba(15, 12, 35, 0.95);
}

#howto-close-btn {
  padding: 8px 32px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 3px;
  color: #aac4ff;
  background: linear-gradient(135deg, rgba(25, 40, 80, 0.95), rgba(15, 25, 55, 0.95));
  border: 1px solid rgba(80, 120, 220, 0.5);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

#howto-close-btn:active {
  transform: scale(0.96);
  background: rgba(40, 60, 130, 0.95);
}

/* ===== 行動履歴モーダル ===== */
#history-modal {
  position: absolute;
  inset: 0;
  z-index: 9800;
  display: none;
  flex-direction: column;
  background: rgb(8, 6, 20);
  overflow: hidden;
}

#history-modal.active {
  display: flex;
}

#history-modal-header {
  padding: 12px 16px;
  font-size: 16px;
  font-weight: bold;
  color: #e0e8ff;
  letter-spacing: 4px;
  text-align: center;
  border-bottom: 1px solid rgba(80, 100, 160, 0.3);
  flex-shrink: 0;
  background: rgba(15, 12, 35, 0.95);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#history-close-x {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 57px;
  height: 32px;
  border: 1px solid rgba(80, 120, 220, 0.4);
  border-radius: 6px;
  background: rgba(25, 35, 70, 0.8);
  color: #aac4ff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

#history-close-x:active {
  transform: translateY(-50%) scale(0.92);
  background: rgba(40, 60, 130, 0.95);
}

#history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  touch-action: pan-y;
}

.history-entry {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  max-width: 85%;
  word-break: break-all;
  color: #ffffff;
}

.history-damage {
  color: #ff9494;
  font-weight: 700;
  text-shadow: 0 0 5px rgba(255, 90, 90, 0.2);
}

/* 自分の行動は青枠・左寄せ */
.history-entry.history-player {
  align-self: flex-start;
  border: 1.5px solid rgba(80, 140, 255, 0.7);
  background: rgba(20, 40, 100, 0.6);
  box-shadow: 0 0 8px rgba(80, 140, 255, 0.15);
}

/* 相手の行動は赤枠・右寄せ */
.history-entry.history-opponent {
  align-self: flex-end;
  border: 1.5px solid rgba(220, 60, 60, 0.7);
  background: rgba(80, 15, 15, 0.6);
  box-shadow: 0 0 8px rgba(220, 60, 60, 0.15);
}

/* システム（ターン境界など）はグレー中央 */
.history-entry.history-system {
  align-self: center;
  max-width: 95%;
  border: 1px solid rgba(140, 140, 140, 0.3);
  background: rgba(30, 30, 50, 0.5);
  color: rgba(200, 200, 200, 0.7);
  font-size: 11px;
  text-align: center;
}

#history-modal-footer {
  padding: 10px;
  display: flex;
  justify-content: center;
  border-top: 1px solid rgba(80, 100, 160, 0.3);
  flex-shrink: 0;
  background: rgba(15, 12, 35, 0.95);
}

#history-close-btn {
  padding: 8px 32px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 3px;
  color: #aac4ff;
  background: linear-gradient(135deg, rgba(25, 40, 80, 0.95), rgba(15, 25, 55, 0.95));
  border: 1px solid rgba(80, 120, 220, 0.5);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

#history-close-btn:active {
  transform: scale(0.96);
  background: rgba(40, 60, 130, 0.95);
}

* {
  scrollbar-width: none;
}

/* ===== PC レスポンシブ ===== */
@media (min-width:600px) {
  .field-card-row {
    gap: 18px;
  }

  .zone-label {
    font-size: 15px;
  }

  .zone-count {
    font-size: 12px;
    width: 22px;
    height: 22px;
  }

  .life-value {
    font-size: 24px;
  }

  .life-label {
    font-size: 11px;
  }

  .life-area {
    width: 46px;
  }

  #player-field-row .field-card-row {
    padding-right: 46px;
  }

  #opp-field-row .field-card-row {
    padding-left: 46px;
  }

  .battle-card.on-field {
    width: 82px;
  }

  .field-group.has-season .basho-slot {
    margin-top: -88px;
  }

  .field-group .kaii-row {
    margin-top: -32px;
  }

  .battle-card.kaii-attached {
    width: 38px;
  }

  .kaii-row .battle-card.kaii-attached:not(:first-child) {
    margin-left: -22px;
  }

  .power-badge {
    width: 20px;
    height: 20px;
  }

  .power-badge span {
    font-size: 12px;
  }

  #footer {
    height: 40px;
  }

  .footer-btn {
    font-size: 13px;
    padding: 5px 16px;
  }

  #attack-btn {
    font-size: 13px;
    padding: 4px 18px;
  }

  #end-turn-center {
    font-size: 11px;
    padding: 6px 18px;
  }

  .type-btn {
    font-size: 10px;
    padding: 4px 6px;
  }

  .drag-ghost, .drag-trail {
    width: 60px;
    height: 84px;
  }

  #card-preview img {
    border-radius: 18px;
  }

  #play-effect img {
    border-radius: 18px;
  }

  .kaii-ghost-preview {
    width: 38px;
  }

  .soul-info-area {
    width: 28px;
  }

  .season-icon {
    width: 18px;
    height: 13px;
    font-size: 7px;
  }

  .soul-count-mini {
    width: 17px;
    height: 17px;
    font-size: 10px;
  }
}

@media (min-width:900px) {
  .field-card-row {
    gap: 22px;
  }

  .battle-card.on-field {
    width: 82px;
  }

  .field-group.has-season .basho-slot {
    margin-top: -88px;
  }

  .field-group .kaii-row {
    margin-top: -36px;
  }

  .battle-card.kaii-attached {
    width: 44px;
  }

  .kaii-row .battle-card.kaii-attached:not(:first-child) {
    margin-left: -26px;
  }

  .life-area {
    width: 54px;
  }

  #player-field-row .field-card-row {
    padding-right: 54px;
  }

  #opp-field-row .field-card-row {
    padding-left: 54px;
  }

  .life-value {
    font-size: 28px;
  }

  .zone-count {
    font-size: 13px;
    width: 24px;
    height: 24px;
  }

  .drag-ghost, .drag-trail {
    width: 70px;
    height: 98px;
  }

  .kaii-ghost-preview {
    width: 44px;
  }

  #kaii-popup-cards .battle-card {
    width: 110px;
    height: 154px;
  }

  .type-btn {
    font-size: 11px;
    padding: 4px 8px;
  }

  .soul-info-area {
    width: 32px;
  }

  .season-icon {
    width: 20px;
    height: 15px;
    font-size: 8px;
  }

  .soul-count-mini {
    width: 18px;
    height: 18px;
    font-size: 11px;
  }
}

/* ===== 零探しオーバーレイ ===== */
#zero-search-overlay {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.85) 100%),
    linear-gradient(180deg, #060810 0%, #0a0d1a 35%, #0d1122 65%, #06080f 100%);
  overflow: hidden;
}

/* 上部: 先後案内 */
#zero-search-order {
  padding: clamp(3px, 0.8vh, 8px) 0 clamp(1px, 0.3vh, 2px);
  text-align: center;
  color: rgba(180, 200, 255, 0.85);
  font-size: clamp(11px, 1.5vh, 14px);
  font-weight: bold;
  letter-spacing: 2px;
  text-shadow: 0 0 12px rgba(120, 160, 255, 0.5);
  flex-shrink: 0;
}

/* 中部: タイトル+説明+プレビュー+ボタン */
#zero-search-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0px 52px 12px;
  flex: 1;
  /* 余ったスペースを上部エリアが伸縮して使う */
  min-height: 0;
  gap: 0;
}

#zero-search-title {
  font-size: clamp(18px, 3.2vh, 26px);
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 6px;
  margin-bottom: clamp(2px, 0.8vh, 8px);
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.8);
  flex-shrink: 0;
  white-space: nowrap;
}

#zero-search-desc {
  font-size: clamp(10px, 1.3vh, 12px);
  color: rgba(200, 210, 240, 0.85);
  text-align: center;
  line-height: 1.8;
  letter-spacing: 0.5px;
  margin-bottom: clamp(4px, 1vh, 10px);
  flex-shrink: 0;
  white-space: nowrap;
}

/* 選択カードプレビューエリア（横幅60%の大きな画像） */
#zero-search-preview-wrap {
  width: 75%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: clamp(4px, 1vh, 12px);
  min-height: 0;
  /* flex:1の縮小を許可 */
  flex: 1;
}

#zero-search-preview-img {
  /* width:auto + height:autoでimg要素のボックス = カード画像の実際サイズになる */
  /* → border-radiusとbox-shadowが正確にカードの輪郭に出る */
  width: auto;
  height: auto;
  max-height: 100%;
  max-width: 100%;
  display: block;
  border-radius: 12px;
  box-shadow: 0 0 8px 3px rgba(207, 177, 120, 0.2), 0 0 18px 5px rgba(207, 177, 120, 0.08);
}

@media (min-width:600px) {
  #zero-search-cards {
    margin: 0 auto;
    width: 73%;
  }
}

#zero-search-preview-img.active {
  display: block;
}

/* 零探し 初期8枚：下からフェードインで同時登場 */
#zero-search-overlay.zs-loading :is(#zero-search-preview-wrap, #zero-search-count, #zero-search-buttons, #zero-search-cards) {
  visibility: hidden;
}
#zero-search-overlay.zs-loading .battle-card.zs-initial {
  animation: none;
}

@keyframes zsCardAppear {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
#zero-search-cards .battle-card.zs-initial {
  animation: zsCardAppear 0.28s ease backwards;
  /* 登場後にアニメーションのtransformを残さず、選択とホバーに戻す。 */
}

/* 零探し カード退場アニメーション（非キープ：上へシュッと消える） */
@keyframes zsCardExit {
  from { opacity: 1;   transform: translateY(0) scale(1); }
  to   { opacity: 0;   transform: translateY(-30px) scale(0.92); }
}
/* 零探し カード登場アニメーション（新ドロー：下から現れる） */
@keyframes zsCardEnter {
  from { opacity: 0;   transform: translateY(20px) scale(0.92); }
  to   { opacity: 1;   transform: translateY(0) scale(1); }
}
/* 零探し キープ札は色・オーラ・不透明度を保ったまま詰め移動する。 */
@keyframes zsKeepMove {
  from { transform: translate(var(--zs-move-x), var(--zs-move-y)); }
  to   { transform: translate(0, 0); }
}

/* 先行/後攻の強調（真っ白） */
.zs-order-highlight {
  color: #ffffff;
  font-weight: 900;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

/* 選択枚数バッジ */
#zero-search-count {
  text-align: center;
  font-size: clamp(10px, 1.3vh, 12px);
  color: #d8c69f;
  font-weight: bold;
  letter-spacing: 1px;
  margin-bottom: clamp(2px, 0.7vh, 8px);
  flex-shrink: 0;
  padding: 0 12px;
  white-space: nowrap;
}

/* 決定ボタン */
#zero-search-buttons {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  margin-bottom: clamp(2px, 0.5vh, 0px);
  max-width: 100%;
  flex-shrink: 0;
}

#zero-search-confirm {
  padding: clamp(5px, 0.9vh, 8px) 28px;
  background: linear-gradient(135deg, #1a3a6a, #0d2044);
  color: rgba(160, 180, 230, 0.8);
  border: 1px solid rgba(80, 120, 220, 0.3);
  border-radius: 8px;
  font-size: clamp(12px, 1.6vh, 14px);
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

#zero-search-confirm.ready {
  background: linear-gradient(135deg, #1a5aab, #103a70);
  color: #aac4ff;
  border-color: rgba(80, 160, 255, 0.5);
  box-shadow: 0 0 12px rgba(80, 160, 255, 0.3);
}

#zero-search-confirm.ready:active {
  transform: scale(0.96);
}

/* 全選択は決定より控えめな補助ボタンにする。 */
#zero-search-keep-all {
  min-width: calc(5em + 29px);
  padding: clamp(5px, 0.9vh, 8px) 12px;
  background: linear-gradient(135deg, #172238, #101827);
  color: #b2bfd5;
  border: 1px solid rgba(143, 161, 191, 0.35);
  border-radius: 8px;
  font-size: clamp(11px, 1.5vh, 13px);
  font-weight: bold;
  letter-spacing: 0.5px;
  white-space: nowrap;
  cursor: pointer;
  filter: brightness(1);
  transition: filter 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

@media (hover: hover) and (pointer: fine) {
  #zero-search-keep-all:not(:disabled):hover {
    filter: brightness(1.12);
    border-color: rgba(163, 182, 211, 0.55);
    box-shadow: 0 0 10px rgba(123, 160, 213, 0.18);
  }
}

#zero-search-keep-all:not(:disabled):active {
  transform: scale(0.96);
}

/* 下部: カード一覧（4×2, 中央密着, 全身像表示） */
#zero-search-cards {
  flex-shrink: 0;
  /* カードエリアはカード自体のサイズだけ使う（伸びない） */
  padding: 3px 3px 3px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  align-content: start;
  justify-content: center;
  justify-items: center;
}

#zero-search-cards .battle-card {
  border-radius: 10px;
  touch-action: pan-y;
  /* 通常のホバーはtopで動かし、画像の描画レイヤー切り替えを避ける。 */
  top: 0;
  transition: top 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  overflow: hidden;
}

#zero-search-cards .battle-card img {
  display: block;
  width: 100%;
  height: auto;
}

#zero-search-cards .battle-card.zs-selected {
  box-shadow: 0 0 0 1px rgba(246, 225, 183, 0.35), 0 0 8px 2px rgba(221, 185, 113, 0.38), 0 0 18px 3px rgba(188, 143, 67, 0.2) !important;
}

/* 枠を画像に重ね、選択のたびに画像の表示領域が縮まるのを防ぐ。 */
#zero-search-cards .battle-card.zs-selected::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid rgba(207, 177, 120, 0.82);
  border-radius: inherit;
  pointer-events: none;
}

/* ===== 盤面確認ボタン ===== */
.banmen-btn {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5a2d82, #3a1a5e);
  color: #d4b0ff;
  border: 1px solid rgba(160, 100, 255, 0.5);
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 0;
  touch-action: manipulation;
  pointer-events: auto;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.banmen-btn:active {
  background: linear-gradient(135deg, #7a3da2, #5a2d82);
  box-shadow: 0 0 12px rgba(160, 100, 255, 0.4);
}


#banmen-floating-btn {
  position: fixed;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  z-index: 9999;
  background: linear-gradient(135deg, #5a2d82, #3a1a5e);
  color: #d4b0ff;
  border: 1px solid rgba(160, 100, 255, 0.5);
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 0;
  touch-action: manipulation;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

#banmen-floating-btn:active {
  background: linear-gradient(135deg, #7a3da2, #5a2d82);
  box-shadow: 0 0 12px rgba(160, 100, 255, 0.4);
}

/* ===== ドラッグ攻撃 ===== */
.drag-attack-source {
  box-shadow: 0 0 12px 4px rgba(255, 120, 60, 0.6),
    0 0 24px 8px rgba(255, 80, 30, 0.3) !important;
  animation: dragAttackPulse 0.8s ease-in-out infinite;
  z-index: 100 !important;
}

@keyframes dragAttackPulse {

  0%,
  100% {
    box-shadow: 0 0 12px 4px rgba(255, 120, 60, 0.6), 0 0 24px 8px rgba(255, 80, 30, 0.3);
  }

  50% {
    box-shadow: 0 0 18px 6px rgba(255, 120, 60, 0.8), 0 0 32px 12px rgba(255, 80, 30, 0.5);
  }
}

#opp-field-row.drag-attack-ready {
  background: rgba(255, 60, 60, 0.15);
  box-shadow: inset 0 0 30px rgba(255, 80, 60, 0.2), 0 0 20px rgba(255, 80, 60, 0.1);
  animation: oppFieldDragGlow 0.6s ease-in-out infinite;
}

@keyframes oppFieldDragGlow {

  0%,
  100% {
    box-shadow: inset 0 0 30px rgba(255, 80, 60, 0.2), 0 0 20px rgba(255, 80, 60, 0.1);
  }

  50% {
    box-shadow: inset 0 0 40px rgba(255, 80, 60, 0.35), 0 0 30px rgba(255, 80, 60, 0.2);
  }
}

/* ===== スクリーンシェイク（大ダメージ演出） ===== */
body.screen-shake {
  animation: screenShake 0.4s ease-out;
}

@keyframes screenShake {
  /* transform で fixed の飛行カードの座標基準を変えず、盤面だけを揺らす。 */
  0% {
    left: 0;
    top: 0;
  }

  10% {
    left: -12px;
    top: 9px;
  }

  20% {
    left: 15px;
    top: -12px;
  }

  30% {
    left: -18px;
    top: -6px;
  }

  40% {
    left: 12px;
    top: 15px;
  }

  50% {
    left: -9px;
    top: -15px;
  }

  60% {
    left: 15px;
    top: 6px;
  }

  70% {
    left: -6px;
    top: 12px;
  }

  80% {
    left: 9px;
    top: -6px;
  }

  90% {
    left: -3px;
    top: 3px;
  }

  100% {
    left: 0;
    top: 0;
  }
}

/* ========== スタート画面フッター ========== */
.start-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 10px 10px;
  background: rgba(15, 10, 30, 0.95);
  border-top: 1px solid rgba(80, 90, 160, 0.25);
}

.start-footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.start-footer-links a {
  color: rgba(200, 210, 255, 0.7);
  text-decoration: none;
  font-size: 11px;
  transition: color 0.2s;
}

.start-footer-links a:hover {
  color: rgba(200, 210, 255, 1);
}

.start-footer-sep {
  color: rgba(200, 210, 255, 0.25);
  font-size: 11px;
}

.start-footer-copy {
  color: rgba(200, 210, 255, 0.35);
  font-size: 10px;
  margin: 4px 0 0;
}

/* 高さが足りない画面だけ、場の札が手札・魂の領域を押し潰さないようにする。 */
@media (max-height: 500px) {
  #field {
    min-height: 0;
    grid-template-rows: minmax(0, 0.8fr) minmax(0, 1.2fr) minmax(0, 0.9fr) minmax(0, 2.3fr) auto minmax(0, 2.3fr) minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 1.3fr);
  }

  .field-row, .row-zone, .triple-zone {
    min-height: 0;
  }

  .battle-card.on-field {
    width: clamp(22px, 7dvh, 36px);
  }

  .field-group.has-season .basho-slot {
    margin-top: calc(clamp(22px, 7dvh, 36px) * -1.08);
  }

  .field-group .kaii-row {
    margin-top: calc(-2.8dvh);
  }

  .battle-card.kaii-attached {
    width: clamp(10px, 3dvh, 16px);
  }

  .kaii-row .battle-card.kaii-attached:not(:first-child) {
    margin-left: calc(-1.8dvh);
  }

  #start-overlay {
    justify-content: flex-start;
    overflow-y: auto;
    padding: 8px 20px;
  }

  #start-overlay > * {
    flex-shrink: 0;
  }

  #start-title {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 8px;
  }

  #start-deck-img {
    max-height: 22dvh;
    margin-bottom: 8px;
  }

  #start-buttons-row {
    margin-bottom: 6px;
  }

  #start-btn, #solo-btn {
    padding: 6px 20px;
    font-size: 14px;
    letter-spacing: 2px;
    text-indent: 2px;
  }

  .start-footer {
    position: static;
    align-self: stretch;
    margin-top: 12px;
  }
}

/* スマホ横画面だけ、手札を上下に保ちながら場の左右に補助エリアを置く。 */
@media (orientation: landscape) and (max-height: 600px) {
  body {
    --landscape-field-card-width: clamp(28px, 12dvh, 58px);
    width: calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-width: none;
    height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  #app { padding: 3px 8px; }
  .footer-btn { font-size: 12px; padding: 4px 14px; }
  #field {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr) minmax(0, 1fr);
    grid-template-rows: minmax(34px, .7fr) minmax(0, 1.6fr) 32px minmax(0, 1.6fr) minmax(48px, 1fr);
  }
  #opp-hand-zone { grid-area: 1 / 1 / 2 / 4; }
  #opp-mid-zones { grid-area: 2 / 1; }
  #opp-field-row { grid-area: 2 / 2; }
  #opp-soul-zone { grid-area: 2 / 3; }
  #center-area { grid-area: 3 / 1 / 4 / 4; }
  #player-soul-zone { grid-area: 4 / 1; }
  #player-field-row { grid-area: 4 / 2; }
  #player-mid-zones { grid-area: 4 / 3; }
  #player-hand-zone { grid-area: 5 / 1 / 6 / 4; }
  .field-row, .row-zone, .triple-zone { min-width: 0; min-height: 0; }
  #player-mid-zones, #opp-mid-zones {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  #opp-open { grid-area: 1 / 1 / 2 / 3; }
  #opp-exile { grid-area: 2 / 1; }
  #opp-deck { grid-area: 2 / 2; }
  #player-open { grid-area: 2 / 1 / 3 / 3; }
  #player-deck { grid-area: 1 / 1; }
  #player-exile { grid-area: 1 / 2; }
  .field-card-row { gap: 8px; }
  .life-area { width: 34px; }
  .life-value { font-size: 22px; }
  .life-label { font-size: 9px; letter-spacing: 0; white-space: nowrap; }
  #player-field-row .field-card-row { padding-right: 34px; }
  #opp-field-row .field-card-row { padding-left: 34px; }
  .battle-card.on-field { width: var(--landscape-field-card-width); }
  .field-group.has-season .basho-slot { margin-top: calc(var(--landscape-field-card-width) * -1.08); }
  .field-group .kaii-row { margin-top: -3dvh; }
  .battle-card.kaii-attached, .kaii-ghost-preview { width: clamp(14px, 5dvh, 24px); }
  .kaii-row .battle-card.kaii-attached:not(:first-child) { margin-left: -2.5dvh; }
  .battle-card.in-soul { height: min(56px, calc(100% - 8px)); }
  .soul-info-area { width: 24px; }
  .season-icon { width: 16px; height: 11px; font-size: 7px; }
  .soul-count-mini { width: 16px; height: 16px; font-size: 10px; }
  .zone-label { font-size: 12px; letter-spacing: 3px; }
  .zone-count { width: 18px; height: 18px; font-size: 10px; }
  .power-badge { width: 16px; height: 16px; }
  .power-badge span { font-size: 10px; }
  .drag-ghost { transform: none; border: 1px solid transparent; }
  #card-preview { width: 30%; right: auto; }
  #card-preview.show-top, #card-preview.show-bottom { top: 0; height: 100%; }
  #card-preview img { max-height: 90%; max-width: 95%; }

  /* 零探しは左に説明とプレビュー、右に8枚。交換中も同じ2行を使う。 */
  #zero-search-overlay {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) minmax(0, 2fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 4px 10px;
    padding: 6px 10px;
  }
  #zero-search-order { grid-area: 1 / 1 / 2 / 3; padding: 0; }
  #zero-search-mid { grid-area: 2 / 1; padding: 0 0 4px; }
  #zero-search-title { font-size: 19px; margin-bottom: 4px; }
  #zero-search-desc { white-space: normal; font-size: 10px; line-height: 1.5; margin-bottom: 4px; }
  #zero-search-preview-wrap { width: 100%; margin-bottom: 4px; }
  #zero-search-count {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 28px;
    padding: 0;
    font-size: 10px;
    line-height: 1.4;
    letter-spacing: 0;
    white-space: normal;
    margin: 4px 0;
  }
  #zero-search-buttons { gap: 8px; }
  #zero-search-confirm { padding: 8px 18px; }
  #zero-search-keep-all { min-width: 88px; padding: 8px 10px; }
  #zero-search-cards {
    grid-area: 2 / 2;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    align-items: center;
  }
  #zero-search-cards .battle-card {
    width: auto;
    height: auto;
    max-height: 100%;
    max-width: 100%;
    aspect-ratio: 5 / 7;
  }
  #zero-search-cards .battle-card img { height: 100%; }

  /* 一覧はプレビューと選択欄を左右に分け、決定ボタンを常に画面内へ。 */
  #exile-modal.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 6px 12px;
    padding: 10px 12px;
  }
  #exile-modal #exile-modal-preview-wrap {
    grid-area: 1 / 1 / 5 / 2;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    padding: 4px;
  }
  #exile-modal #exile-modal-preview-img { max-height: 100%; max-width: 100%; height: auto; }
  #exile-modal-preview-placeholder { text-align: center; line-height: 1.6; }
  #exile-modal-title { grid-area: 1 / 2; text-align: center; }
  #exile-modal-desc { grid-area: 2 / 2; max-width: 100%; }
  #exile-modal-cards {
    grid-area: 3 / 2;
    min-height: 0;
    height: 100%;
    max-height: none;
    max-width: 100%;
    width: 100%;
    align-content: flex-start;
  }
  #exile-modal-empty { grid-area: 3 / 2; text-align: center; }
  #exile-modal-buttons { grid-area: 4 / 2; justify-self: center; margin: 0; }
  #exile-view-cards { min-height: 0; max-height: 75%; }
  #card-select-overlay { flex-direction: row; }
  #card-select-top { flex: 0 0 30%; height: 100%; }
  #card-select-top img { max-width: 100%; }
  #card-select-mid { flex: 1; min-width: 0; justify-content: center; padding: 6px 12px; }
  #card-select-title { font-size: 16px; }
  #card-select-desc { font-size: 11px; }
  #hand-overflow-overlay { gap: 4px; }
  #hand-overflow-title, #soul-absorb-select-title { font-size: 20px; letter-spacing: 3px; }
  #hand-overflow-desc { font-size: 11px; line-height: 1.5; }
  #hand-overflow-remaining, #hand-overflow-buttons { margin-top: 0; }

  #soul-absorb-select.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    align-content: center;
    justify-items: center;
    gap: 6px 14px;
    padding: 8px 12px;
  }
  #soul-absorb-select-title { grid-area: 1 / 1; }
  #soul-absorb-select-desc { grid-area: 2 / 1; font-size: 12px; }
  #soul-absorb-select-buttons { grid-area: 3 / 1; margin-top: 0; }
  #soul-absorb-select-warning { grid-area: 1 / 2 / 4 / 3; }
  #soul-absorb-select:not(:has(.soul-lethal-notice:not([hidden]))) { grid-template-columns: minmax(0, 1fr); }
  .soul-lethal-notice { width: 100%; padding: 10px 12px; }
  .soul-lethal-title { font-size: 14px; line-height: 1.4; }
  .soul-lethal-message { font-size: 12px; margin: 4px 0 8px; }
  .soul-lethal-stats { gap: 8px; font-size: 11px; padding-top: 6px; }
  .soul-lethal-stats b { font-size: 20px; }
  #soul-absorb-ask { gap: 8px; }
  #soul-absorb-ask-title { font-size: 16px; text-align: center; }
  #soul-absorb-ask.lethal-damage.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr);
    grid-template-rows: auto auto auto;
    align-content: center;
    justify-items: center;
    gap: 8px 16px;
    padding: 12px 16px;
  }
  #soul-absorb-ask.lethal-damage #soul-absorb-ask-img {
    grid-area: 1 / 1 / 4 / 2;
    height: min(65dvh, 260px);
    max-height: 100%;
    max-width: 100%;
    margin: 0;
  }
  #soul-absorb-ask.lethal-damage #soul-absorb-ask-title { grid-area: 1 / 2; width: 100%; font-size: 16px; }
  #soul-absorb-ask-warning { grid-area: 2 / 2; }
  #soul-absorb-ask-buttons { grid-area: 3 / 2; }
  #soul-absorb-ask.lethal-damage:has(#soul-absorb-ask-img[style*="display: none"]) { grid-template-columns: minmax(0, 1fr); }
  #soul-absorb-ask.lethal-damage:has(#soul-absorb-ask-img[style*="display: none"]) > :not(img) { grid-column: 1; max-width: 440px; }
  #soul-absorb-ask-img { max-height: 45%; }

  .tap-play-panel { padding: 12px; }
  #tap-play-desc { margin: 6px 0 10px; }
  .tap-play-actions { padding-top: 10px; }
  .tap-play-option { width: 110px; padding: 6px; gap: 4px; }
  .tap-play-option img, .tap-play-new-slot { width: auto; height: min(30dvh, 120px); aspect-ratio: 5 / 7; }
  #kaii-popup { padding: 6px; }
  #kaii-popup-title { margin-bottom: 6px; }
  #kaii-popup-cards { min-height: 0; overflow-y: auto; }
  #kaii-popup-cards .battle-card { width: 65px; height: 91px; }
  #result-overlay { gap: 12px; padding: 10px; overflow-y: auto; }
  #result-text { font-size: 30px; }
  #win-streak { font-size: 16px; }
  #result-shop-img { width: auto; max-width: 60vw; max-height: 24dvh; }
  #result-shop-text { font-size: 11px; }
}

/* ブラウザのバーで高さが減っても、季節札と怪異札を重ねた場を収める。 */
@media (orientation: landscape) and (max-height: 310px) {
  body {
    --landscape-field-card-width: clamp(10px, calc((100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 166px) / 4.6), 34px);
  }
}

/* 高さの少ない横画面でも、手札超過の案内を上半分に収める。 */
@media (orientation: landscape) and (max-height: 280px) {
  #hand-overflow-buttons { display: flex; align-items: center; gap: 12px; }
}

/* 狭い縦画面に戻した場合も、魂選択の見出しが画面外へ出ないようにする。 */
@media (orientation: portrait) and (max-width: 280px) {
  #soul-absorb-select { gap: 4px; }
  #soul-absorb-select-warning { padding: 8px 10px; }
  #soul-absorb-select-warning .soul-lethal-message { margin: 4px 0 6px; }
  #soul-absorb-select-warning .soul-lethal-stats { padding-top: 6px; }
}
