:root {
  --bg-dark: #090e0b;
  --panel-bg: #141c16;
  --panel-border: rgba(212, 175, 55, 0.25);
  --gold-primary: #d4af37;
  --gold-light: #f3e5ab;
  --gold-glow: rgba(212, 175, 55, 0.4);
  --text-gold: #e2d8b5;

  --accent-red: #e63946;
  --accent-blue: #457b9d;
  --accent-green: #2a9d8f;

  --card-width: 72px;
  --card-height: 104px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

body {
  font-family: 'Cinzel', 'Georgia', 'Helvetica Neue', Arial, sans-serif;
  background: url('../images/pctitle.png') center/cover no-repeat;
  color: var(--text-gold);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

@media (max-width: 768px) {
  body {
    background-image: url('../images/pctitle.png');
  }
}

/* 🌳 背景全画面キャンバス */
#firefly-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  pointer-events: none;
  z-index: 0;
}

/* 🎵 BGMトグルボタン */
.settings-toggle-btn {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 999;
  width: 34px;
  height: 34px;
  padding: 0 !important;
  background: rgba(30, 41, 59, 0.9) !important;
  border: 1.5px solid #64748b !important;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.85) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.settings-toggle-btn:hover {
  transform: scale(1.08);
  border-color: #94a3b8 !important;
}
.settings-modal-content {
  background: linear-gradient(160deg, #18221b 0%, #0c140f 100%);
  border: 1.5px solid var(--gold-primary);
  border-radius: 16px;
  padding: 1.2rem;
  width: 88%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.95);
}
.settings-modal-header h2 {
  font-size: 1.1rem;
  color: var(--gold-primary);
  text-align: center;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 6px;
}
.settings-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  text-align: left;
}
.settings-item label {
  font-size: 0.78rem;
  color: var(--gold-light);
  font-weight: bold;
}
.settings-select {
  width: 100%;
  padding: 6px 8px;
  background: #0b100c;
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: #fff;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
}
.settings-item input[type="range"] {
  width: 100%;
  accent-color: var(--gold-primary);
  cursor: pointer;
}

/* 汎用ボタン / 入力フォーム */
button {
  background: linear-gradient(180deg, #e6c875 0%, #b8860b 100%);
  color: #0d120e;
  border: 1px solid #ffe89c;
  padding: 11px 16px;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

button:active { transform: scale(0.98); }
button:disabled {
  background: #3a423b;
  color: #687069;
  border-color: #2a302a;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: linear-gradient(180deg, #3a423b 0%, #202621 100%) !important;
  color: var(--text-gold) !important;
  border-color: rgba(212, 175, 55, 0.3) !important;
}

input[type="text"] {
  width: 100%;
  padding: 10px;
  margin: 6px 0;
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  background: #0b100c;
  color: #fff;
  text-align: center;
  font-size: 0.95rem;
  outline: none;
}

/* モーダル共通ベース */
#action-modal, #result-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.action-modal-content, .result-content {
  background: linear-gradient(145deg, #18241b, #0c120d);
  border: 2px solid var(--gold-primary);
  border-radius: 14px;
  padding: 1.2rem;
  width: 85%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.9);
}

.action-modal-title { font-size: 1rem; font-weight: bold; color: var(--gold-light); margin-bottom: 1rem; }
.action-modal-buttons { display: flex; flex-direction: column; gap: 10px; }

/* 🔍 カード拡大プレビュー モーダル */
.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.preview-modal-content {
  background: linear-gradient(145deg, #18241b, #0c120d);
  border: 2px solid var(--gold-primary);
  border-radius: 16px;
  padding: 1.2rem;
  width: 85%;
  max-width: 290px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-modal-content .card {
  transform: scale(1.6) !important;
  margin: 35px 0 40px 0 !important;
  box-shadow: 0 8px 20px rgba(0,0,0,0.9) !important;
  pointer-events: none;
}

.preview-card-desc {
  font-size: 0.85rem;
  color: var(--gold-light);
  background: rgba(0,0,0,0.6);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  width: 100%;
  line-height: 1.3;
}

/* 🪙 3D コインフリップ モーダル */
.coin-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.coin-container {
  width: 120px;
  height: 120px;
  perspective: 1000px;
  -webkit-perspective: 1000px;
  margin-bottom: 2rem;
}

.coin-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 1.5s cubic-bezier(0.15, 0.85, 0.35, 1.2);
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 2px;
  border: 4px solid #ffd700;
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.8), inset 0 0 15px rgba(255, 255, 255, 0.5);
}

.coin-front {
  background: linear-gradient(135deg, #ffe89c, #b8860b);
  color: #1c1003;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}

.coin-back {
  background: linear-gradient(135deg, #457b9d, #1d3557);
  color: #f1faee;
  border-color: #a8dede;
  box-shadow: 0 0 25px rgba(69, 123, 157, 0.8), inset 0 0 15px rgba(255, 255, 255, 0.4);
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

.coin-result-text {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 0 12px var(--gold-primary), 0 2px 4px #000;
  letter-spacing: 2px;
  text-align: center;
  padding: 0 1rem;
}

/* 💥 属性別VFXエフェクト */
.vfx-container {
  position: fixed;
  pointer-events: none;
  z-index: 100000;
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

.vfx-slash {
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, transparent 40%, #ff0000 46%, #ffea00 54%, transparent 60%);
  filter: drop-shadow(0 0 15px #ff0000);
  -webkit-filter: drop-shadow(0 0 15px #ff0000);
  animation: slashAnim 0.38s ease-out forwards;
  -webkit-animation: slashAnim 0.38s ease-out forwards;
}

@keyframes slashAnim {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(-35deg); opacity: 0; }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.3) rotate(0deg); }
  100% { transform: translate(-50%, -50%) scale(1.7) rotate(20deg); opacity: 0; }
}

.vfx-ripple {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 4px solid #38bdf8;
  box-shadow: 0 0 25px #0284c7, inset 0 0 15px #38bdf8;
  animation: rippleAnim 0.48s ease-out forwards;
  -webkit-animation: rippleAnim 0.48s ease-out forwards;
}

@keyframes rippleAnim {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.3); opacity: 0; border-width: 1px; }
}

.vfx-vortex {
  width: 95px;
  height: 95px;
  border-radius: 50%;
  border-top: 6px solid #34d399;
  border-right: 6px solid #059669;
  border-bottom: 2px solid transparent;
  filter: drop-shadow(0 0 12px #10b981);
  -webkit-filter: drop-shadow(0 0 12px #10b981);
  animation: vortexAnim 0.42s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
  -webkit-animation: vortexAnim 0.42s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes vortexAnim {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(0deg); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.9) rotate(540deg); opacity: 0; }
}

/* 💥 CRITICAL / ダメージ ポップアップ */
.critical-popup {
  position: fixed;
  transform: translate(-50%, -50%);
  color: #ffe600;
  font-family: 'Cinzel', 'Georgia', sans-serif;
  font-size: 1.8rem;
  font-weight: 900;
  text-shadow: 0 0 8px #ff0000, 0 0 18px #ffea00, 0 2px 4px #000;
  z-index: 100001;
  pointer-events: none;
  animation: criticalPopupAnim 0.9s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes criticalPopupAnim {
  0% { opacity: 0; transform: translate(-50%, 0%) scale(0.3) rotate(-10deg); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.5) rotate(0deg); }
  70% { opacity: 1; transform: translate(-50%, -80%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(0.8); }
}

.damage-popup {
  position: fixed;
  transform: translate(-50%, -50%);
  color: #ff2a2a;
  font-family: 'Cinzel', sans-serif;
  font-size: 1.6rem;
  font-weight: 900;
  text-shadow: 0 0 6px #000, 0 0 14px #ff0000;
  z-index: 100000;
  pointer-events: none;
  animation: damagePopupAnim 0.85s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes damagePopupAnim {
  0% { opacity: 0; transform: translate(-50%, -10%) scale(0.4); }
  25% { opacity: 1; transform: translate(-50%, -60%) scale(1.4); }
  70% { opacity: 1; transform: translate(-50%, -85%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(0.7); }
}

.screen-impact-shake {
  animation: impactShakeAnim 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
}

@keyframes impactShakeAnim {
  10%, 90% { transform: translate3d(-2px, 2px, 0); }
  20%, 80% { transform: translate3d(4px, -3px, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 5px, 0); filter: brightness(1.8) drop-shadow(0 0 15px #ffd700); }
  40%, 60% { transform: translate3d(6px, -4px, 0); }
}

.summon-shockwave {
  position: fixed;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--gold-primary);
  box-shadow: 0 0 30px var(--gold-glow), inset 0 0 20px #ff2a2a;
  z-index: 900;
  pointer-events: none;
  animation: shockwaveAnim 0.65s ease-out forwards;
}

@keyframes shockwaveAnim {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; border-width: 8px; }
  100% { transform: translate(-50%, -50%) scale(9); opacity: 0; border-width: 1px; }
}

.shatter-particle {
  position: fixed;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  z-index: 99999;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(230, 57, 70, 0.9);
  animation: particleFlyAnim 0.65s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes particleFlyAnim {
  0% { opacity: 1; transform: translate(0, 0) scale(1.3) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0.1) rotate(var(--rot)); }
}
/* ================= =================================
   🔥🌊🍃 コスト6以上：最上級召喚（天動説演出）VFX
===================================================== */

/* 全画面オーバーレイ */
/* ===================================================
   🔥🌊🍃 コスト6以上：最上級召喚 (演出・グラフィック全振り)
===================================================== */

/* 全画面オーバーレイ */
.legend-summon-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: legendOverlayAnim 1.6s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

@keyframes legendOverlayAnim {
  0% { opacity: 0; }
  15% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* 💥 中央から広がる光線バースト */
.legend-light-burst {
  position: absolute;
  width: 100vmax;
  height: 100vmax;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    var(--burst-color) 15deg,
    transparent 30deg,
    var(--burst-color) 45deg,
    transparent 60deg,
    var(--burst-color) 90deg,
    transparent 120deg,
    var(--burst-color) 180deg,
    transparent 240deg,
    var(--burst-color) 300deg,
    transparent 360deg
  );
  opacity: 0.6;
  animation: burstSpin 1.6s linear forwards;
}

@keyframes burstSpin {
  0% { transform: scale(0.2) rotate(0deg); opacity: 0.8; }
  50% { transform: scale(1.5) rotate(90deg); opacity: 0.6; }
  100% { transform: scale(2.5) rotate(180deg); opacity: 0; }
}

/* ⭕ 巨大衝撃波リング */
.legend-shockwave-ring {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 8px solid var(--burst-color);
  box-shadow: 0 0 40px var(--burst-color), inset 0 0 30px #fff;
  animation: ringExpand 1.2s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes ringExpand {
  0% { transform: scale(0.1); opacity: 1; border-width: 12px; }
  100% { transform: scale(12); opacity: 0; border-width: 1px; }
}

/* --- 🔥 赤属性：紅蓮のマグマ ＆ 火柱 ＆ 炎光 --- */
.legend-bg-red {
  background: radial-gradient(circle, rgba(185, 28, 28, 0.9) 0%, rgba(69, 10, 10, 0.98) 100%);
  --burst-color: #ff4500;
}
.lava-pillar {
  position: absolute;
  bottom: -50px;
  width: 120vw;
  height: 90vh;
  background: linear-gradient(180deg, transparent 0%, rgba(255, 68, 0, 0.85) 40%, rgba(255, 215, 0, 0.95) 100%);
  filter: blur(6px);
  animation: lavaRise 1.4s ease-out forwards;
}
@keyframes lavaRise {
  0% { transform: translateY(100%); opacity: 0; }
  25% { transform: translateY(0%); opacity: 1; }
  100% { transform: translateY(-15%); opacity: 0; }
}

/* --- 🌊 青属性：深海渦 ＆ 巨大水柱 ＆ 蒼光 --- */
.legend-bg-blue {
  background: radial-gradient(circle, rgba(14, 116, 144, 0.9) 0%, rgba(8, 47, 73, 0.98) 100%);
  --burst-color: #38bdf8;
}
.water-spout {
  position: absolute;
  width: 280px;
  height: 120vh;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.7), rgba(255, 255, 255, 0.95), rgba(56, 189, 248, 0.7), transparent);
  border-radius: 50%;
  filter: blur(4px);
  animation: waterSpoutSpin 1.4s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}
@keyframes waterSpoutSpin {
  0% { transform: scaleX(0.2) rotate(0deg); opacity: 0; }
  35% { transform: scaleX(2) rotate(180deg); opacity: 0.95; }
  100% { transform: scaleX(3.5) rotate(360deg); opacity: 0; }
}

/* --- 🍃 緑属性：古代樹 ＆ 黄金胞子 ＆ 翠光 --- */
.legend-bg-green {
  background: radial-gradient(circle, rgba(15, 118, 110, 0.9) 0%, rgba(4, 47, 38, 0.98) 100%);
  --burst-color: #34d399;
}
.spore-particle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fde047;
  border-radius: 50%;
  box-shadow: 0 0 14px #34d399, 0 0 24px #fde047;
  animation: sporeFly 1.5s ease-out forwards;
}
@keyframes sporeFly {
  0% { transform: translate(0, 100vh) scale(0.2); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: translate(var(--tx), -20vh) scale(2.5); opacity: 0; }
}