/* ==========================================================================
   TAVERN WAIFU TCG — BATTLE ARENA & DECK STYLING
   ========================================================================== */

/* Element Themes */
:root {
  --tcg-chaos: #ef4444;
  --tcg-chaos-glow: rgba(239, 68, 68, 0.45);
  --tcg-order: #fbbf24;
  --tcg-order-glow: rgba(251, 191, 36, 0.45);
  --tcg-life: #10b981;
  --tcg-life-glow: rgba(16, 185, 129, 0.45);
  --tcg-death: #a855f7;
  --tcg-death-glow: rgba(168, 85, 247, 0.45);
  --tcg-arcane: #06b6d4;
  --tcg-arcane-glow: rgba(6, 182, 212, 0.45);

  --tcg-bg-glass: rgba(18, 12, 8, 0.88);
  --tcg-border-gold: rgba(212, 163, 89, 0.35);
}

/* Container */
.tcg-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 580px;
  background: radial-gradient(circle at center top, #28170c 0%, #110905 100%);
  color: #f3f4f6;
  font-family: inherit;
  user-select: none;
  overflow-y: auto;
  position: relative;
  box-sizing: border-box;
  padding: 12px;
  gap: 12px;
  font-size: 11px;
}

/* Sub-Tab Navigation Bar — single row; direct children split the width evenly */
.tcg-nav-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 0px;
}

/*
 * Unified "chip" sizing shared by every element that lives in the nav bar.
 * flex: 1 1 0 makes the 4 nav buttons (or the 2 in-battle chips) divide the
 * available width into equal parts at any screen size.
 */
.tcg-nav-btn,
.tcg-compendium-btn,
.tcg-in-battle-indicator,
.tcg-retreat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
  gap: 6px;
  height: 34px;
  margin: 0px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.tcg-nav-btn,
.tcg-compendium-btn {
  background: rgba(45, 27, 15, 0.6);
  border-color: rgba(212, 163, 89, 0.25);
  color: #e5e7eb;


      background-image: url('../assets/ui/marroon.webp');
      background-size: cover;      /* Scales image to cover entire button */
  background-position: center; /* Centers the image */
  background-repeat: no-repeat;/* Prevents tiling */
  
  /* Optional sizing & resets */
  border: none;
  height: 50px;
  border-radius: 0;
  box-shadow: none;
  background-size: 100% 100%;
}

.tcg-compendium-btn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.tcg-nav-btn:hover,
.tcg-compendium-btn:hover {
  transform: translateY(-1px);
}

.tcg-nav-btn.active {
  color: #fff;
  filter: contrast(1.1);
}

.tcg-in-battle-indicator {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
  cursor: default;
}

.tcg-in-battle-indicator b {
  color: #ffffff;
  font-weight: 800;
}

.tcg-retreat-btn {
  background: rgba(45, 27, 15, 0.7);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.tcg-retreat-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
  color: #ffffff;
  transform: translateY(-1px);
}



/* Power Wheel Overlay Popover */
.tcg-wheel-popover {
  display: none;
  position: absolute;
  top: 68px;
  right: 16px;
  z-index: 1000;
  background: rgba(18, 10, 6, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid #fbbf24;
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(251, 191, 36, 0.2);
  width: 280px;
  animation: tcgFadeIn 0.2s ease-out forwards;
}

.tcg-wheel-popover.open {
  display: block;
}

.tcg-wheel-title {
  font-size: 14px;
  font-weight: 800;
  color: #fbbf24;
  margin-bottom: 8px;
  text-align: center;
  letter-spacing: 0.5px;
}

.tcg-wheel-cycle {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}

.tcg-wheel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

.tcg-wheel-row .advantage {
  color: #10b981;
  font-weight: 700;
}

/* ==========================================================================
   BATTLE ARENA (SINGLE-ROW LAYOUT)
   ========================================================================== */
.tcg-arena-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  position: relative;
}

/* Turn Banner / Arena HUD */
.tcg-arena-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: rgba(20, 12, 8, 0.85);
  border: 1px solid var(--tcg-border-gold);
  border-radius: 12px;
  padding: 6px 10px;
}

.tcg-turn-indicator {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

/* Auto-battle pill (inside the arena HUD, no extra container) */
.tcg-auto-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 10, 6, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 14px;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  cursor: pointer;
}

.tcg-auto-toggle .tcg-auto-state {
  color: #94a3b8;
}

.tcg-auto-toggle.on {
  border-color: #4ade80;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.tcg-auto-toggle.on .tcg-auto-state {
  color: #bbf7d0;
}

.tcg-turn-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.tcg-turn-badge.player-turn {
  background: #15803d;
  color: #bbf7d0;
  border: 1px solid #4ade80;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.tcg-turn-badge.opponent-turn {
  background: #991b1b;
  color: #fecaca;
  border: 1px solid #f87171;
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.3);
}

.tcg-turn-instructions {
  font-size: 13px;
  color: #e2e8f0;
  font-weight: 600;
}

.tcg-round-counter {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}

/* Team Rows */
.tcg-team-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 200px;
  padding: 4px;
  background: rgba(14, 8, 5, 0.6);
  border-radius: 16px;
  position: relative;
}

.tcg-team-label {
  position: absolute;
  top: -9px;
  left: 18px;
  background: #1f140e;
  border: 1px solid var(--tcg-border-gold);
  color: #d1d5db;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Center Arena Divider */
.tcg-arena-mid {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 48px;
}

.tcg-vs-crest {
  background: radial-gradient(circle, #78350f 0%, #291206 100%);
  border: 2px solid #fbbf24;
  color: #fef08a;
  font-size: 13px;
  font-weight: 900;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.3);
}

/* Ultimate Action Bar */
.tcg-ultimate-dock {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(18, 10, 6, 0.95);
  border: 2px solid #ef4444;
  border-radius: 30px;
  padding: 6px 18px;
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.5), 0 4px 15px rgba(0, 0, 0, 0.8);
  animation: ultimatePulse 1.2s infinite alternate ease-in-out;
  z-index: 50;
}

.tcg-ultimate-dock.order-theme {
  border-color: #fbbf24;
  box-shadow: 0 0 25px rgba(251, 191, 36, 0.5), 0 4px 15px rgba(0, 0, 0, 0.8);
}

.tcg-ultimate-dock.life-theme {
  border-color: #10b981;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.5), 0 4px 15px rgba(0, 0, 0, 0.8);
}

.tcg-ultimate-dock.death-theme {
  border-color: #8b5cf6;
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.5), 0 4px 15px rgba(0, 0, 0, 0.8);
}

.tcg-ultimate-dock.arcane-theme {
  border-color: #06b6d4;
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.5), 0 4px 15px rgba(0, 0, 0, 0.8);
}

.tcg-ultimate-btn {
  /* PAUSED (mana/ultimate feature not ready): hidden even if some code path renders it. */
  display: none;
  background: linear-gradient(135deg, #b91c1c 0%, #ea580c 100%);
  border: 1px solid #fca5a5;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  padding: 8px 18px;
  border-radius: 20px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  align-items: center;
  gap: 8px;
}

.tcg-ultimate-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.15);
}

/* ==========================================================================
   TCG COMBAT CARD COMPONENT
   ========================================================================== */
.tcg-card {
  width: 155px;
  height: 225px;
  background: #1c130d;
  border-radius: 12px;
  border: 2px solid rgba(212, 163, 89, 0.3);
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s, border-color 0.2s;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
}

.tcg-card:hover {
  border-color: rgba(251, 191, 36, 0.7);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.8), 0 0 15px rgba(251, 191, 36, 0.2);
}

/* Element Borders */
.tcg-card.type-chaos {
  border-color: rgba(239, 68, 68, 0.4);
}

.tcg-card.type-order {
  border-color: rgba(251, 191, 36, 0.4);
}

.tcg-card.type-life {
  border-color: rgba(16, 185, 129, 0.4);
}

.tcg-card.type-death {
  border-color: rgba(168, 85, 247, 0.4);
}

.tcg-card.type-arcane {
  border-color: rgba(6, 182, 212, 0.4);
}

/* Selection state for player attacker */
.tcg-card.selected-attacker {
  transform: translateY(-8px) scale(1.04);
  border-color: #fbbf24 !important;
  z-index: 10;
}

/* Acted / Exhausted Card */
.tcg-card.acted {
  filter: grayscale(0.55) brightness(0.75);
  cursor: default;
  /* No !important here on purpose: an !important transform would outrank the
     hitShake keyframe animation in the CSS cascade and freeze the card, so a
     waifu being hit during the opponent's turn (while already "acted") would
     never shake. A normal transform still overrides .selected-attacker via
     source order while letting the hit animation play. */
  transform: none;
}

/* Defeated Card */
.tcg-card.defeated {
  filter: grayscale(0.9) brightness(0.4);
  pointer-events: none;
  opacity: 0.55;
  border-style: dashed;
}

.tcg-card.defeated .tcg-card-skull {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  color: #ef4444;
  text-shadow: 0 0 15px rgba(0, 0, 0, 0.9);
  z-index: 5;
}

/* Card Header */
.tcg-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: rgba(10, 6, 4, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
}

/* Shared tavern level shown on TCG cards (backend archetypes stay invisible) */
.tcg-card-lv-badge {
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.5px;
  color: #fde68a;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.55);
  padding-left: 6px;
  flex-shrink: 0;
}

.tcg-card-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
  color: #f3f4f6;
}

.tcg-element-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
}

.tcg-element-pill.pill-chaos {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.tcg-element-pill.pill-light,
.tcg-element-pill.pill-order {
  background: rgba(251, 191, 36, 0.2);
  color: #fde047;
}

.tcg-element-pill.pill-life {
  background: rgba(16, 185, 129, 0.2);
  color: #86efac;
}

.tcg-element-pill.pill-death {
  background: rgba(168, 85, 247, 0.2);
  color: #d8b4fe;
}

.tcg-element-pill.pill-arcane {
  background: rgba(6, 182, 212, 0.2);
  color: #67e8f9;
}

/* Card Image Frame */
.tcg-card-art-box {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  background-color: #0f0a07;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.tcg-card.type-chaos .tcg-card-art-box,
.tcg-card-art-box.type-chaos {
  background-image: url('../assets/ui/chaos.jpg');
}

.tcg-card.type-order .tcg-card-art-box,
.tcg-card-art-box.type-order {
  background-image: url('../assets/ui/order.jpg');
}

.tcg-card.type-life .tcg-card-art-box,
.tcg-card-art-box.type-life {
  background-image: url('../assets/ui/life.jpg');
}

.tcg-card.type-death .tcg-card-art-box,
.tcg-card-art-box.type-death {
  background-image: url('../assets/ui/death.jpg');
}

.tcg-card.type-arcane .tcg-card-art-box,
.tcg-card-art-box.type-arcane {
  background-image: url('../assets/ui/arcane.jpg');
}

.tcg-card-art-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.3s;
}

.tcg-card:hover .tcg-card-art-img {
  transform: scale(1.05);
}

/* Floor Badge on Player Cards */
.tcg-card-floor-tag {
  position: absolute;
  bottom: 4px;
  left: 6px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fbbf24;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
}

/* Divine Barrier Overlay Badge */
.tcg-barrier-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(251, 191, 36, 0.9);
  color: #1a0f05;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
  z-index: 4;
}

/* Matchup Hover Indicator on Enemy Cards */
.tcg-target-indicator {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.5px;
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  animation: indicatorBounce 0.4s ease-out;
}

.tcg-target-indicator.strong {
  background: #15803d;
  color: #dcfce7;
}

.tcg-target-indicator.normal {
  background: #334155;
  color: #f1f5f9;
}

.tcg-target-indicator.weak {
  background: #991b1b;
  color: #fee2e2;
}

/* Card Stats Footer */
.tcg-card-footer {
  padding: 6px 8px;
  background: rgba(14, 8, 5, 0.92);
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Nature row (element pill + matchup indicator) inside the footer */
.nature-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 18px;
}

.nature-row .tcg-target-indicator {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  animation: none;
  font-size: 10px;
  padding: 1px 6px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.tcg-inline-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
}

.tcg-hp-inline {
  color: #f87171;
  min-width: 22px;
  text-align: left;
}

.tcg-stat-spacer {
  flex: 1;
}

.tcg-atk-inline {
  min-width: 42px;
  text-align: right;
}

.tcg-mana-inline {
  /* PAUSED (mana/ultimate feature not ready): hidden even if some code path renders it. */
  display: none;
  align-items: center;
  margin-left: 6px;
}

/* HP Bar */
.tcg-hp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #f87171;
}

.tcg-hp-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
}

.tcg-hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #22c55e 100%);
  border-radius: 3px;
  transition: width 0.3s ease-out;
}

/* Inline HP Bar for Arena */
.tcg-hp-bar-inline {
  position: relative;
  width: 90%;
  height: 14px;
  background: #4a4a4a;
  border-radius: 3px;
  overflow: hidden;
  margin-left: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tcg-hp-bar-inline .tcg-hp-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #ef4444;
}

.tcg-hp-bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

/* ATK & Mana Row */
.tcg-stat-subrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
}

.tcg-atk-label {
  font-size: 11px;
  font-weight: 800;
  color: #fbbf24;
}

/* Mana Crystals */
.tcg-mana-crystals {
  display: flex;
  gap: 3px;
}

.tcg-mana-crystal {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.2s;
}

.tcg-mana-crystal.filled {
  background: #38bdf8;
  border-color: #bae6fd;
  box-shadow: 0 0 6px #38bdf8;
}

.tcg-mana-crystal.max-full {
  background: #fbbf24;
  border-color: #fef08a;
  box-shadow: 0 0 8px #fbbf24;
  animation: crystalFlash 1s infinite alternate;
}

/* ==========================================================================
   ANIMATIONS & FLOATING COMBAT TEXT
   ========================================================================== */
.tcg-floating-text {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: 20px;
  pointer-events: none;
  z-index: 100;
  animation: floatDamage 0.9s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.tcg-floating-text.damage {
  color: #ef4444;
}

.tcg-floating-text.strong-damage {
  color: #f59e0b;
  font-size: 24px;
}

.tcg-floating-text.heal {
  color: #22c55e;
  font-size: 22px;
}

.tcg-floating-text.absorbed {
  color: #60a5fa;
  font-size: 16px;
}

/* Card Attacks and Hit Recoil */
.anim-lunge-up {
  animation: lungeUp 0.35s ease-in-out;
  z-index: 25;
}

.anim-lunge-down {
  animation: lungeDown 0.35s ease-in-out;
  z-index: 25;
}

.anim-hit-shake {
  animation: hitShake 0.35s ease-in-out;
}

.anim-screen-shake {
  animation: screenShake 0.45s ease-in-out;
}

/* Sprite-sheet particle FX played on top of a struck card.
   Frame art, count and animation are driven per-affinity by ui/combatFx.js
   (Web Animations API), so this base class only handles placement. */
.tcg-combat-fx {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-repeat: no-repeat;
  background-position: 0 0;
  pointer-events: none;
  z-index: 120;
}

@keyframes lungeUp {
  0% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-28px) scale(1.06);
  }

  100% {
    transform: translateY(0);
  }
}

@keyframes lungeDown {
  0% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(28px) scale(1.06);
  }

  100% {
    transform: translateY(0);
  }
}

@keyframes hitShake {

  0%,
  100% {
    transform: translate(0, 0);
  }

  20% {
    transform: translate(-6px, 4px) rotate(-3deg);
  }

  40% {
    transform: translate(6px, -4px) rotate(3deg);
  }

  60% {
    transform: translate(-4px, 2px);
  }

  80% {
    transform: translate(3px, -2px);
  }
}

@keyframes screenShake {

  0%,
  100% {
    transform: translate(0, 0);
  }

  25% {
    transform: translate(-5px, 5px);
  }

  50% {
    transform: translate(5px, -5px);
  }

  75% {
    transform: translate(-3px, 3px);
  }
}

@keyframes floatDamage {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.6);
  }

  30% {
    opacity: 1;
    transform: translate(-50%, -24px) scale(1.2);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50px) scale(1);
  }
}

@keyframes indicatorBounce {
  0% {
    transform: translateX(-50%) scale(0.5);
    opacity: 0;
  }

  100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

@keyframes ultimatePulse {
  0% {
    transform: scale(1);
  }

  100% {
    transform: scale(1.04);
  }
}

@keyframes crystalFlash {
  0% {
    filter: brightness(1);
  }

  100% {
    filter: brightness(1.6);
  }
}

@keyframes tcgFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   CHAPTERS / STAGE SELECT VIEW
   ========================================================================== */
.tcg-stages-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.tcg-chapter-header {
  font-size: 18px;
  font-weight: 800;
  color: #fbbf24;
  border-bottom: 2px solid rgba(251, 191, 36, 0.2);
  padding-bottom: 6px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tcg-stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.tcg-stage-card {
  background: rgba(22, 14, 9, 0.85);
  border: 1px solid var(--tcg-border-gold);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.tcg-stage-card:hover {
  border-color: #fbbf24;
  background: rgba(32, 19, 12, 0.95);
}

.tcg-stage-card.cleared {
  border-color: rgba(34, 197, 94, 0.4);
}

.tcg-clear-badge {
  position: absolute;
  top: 10px;
  right: -24px;
  background: #16a34a;
  color: #f0fdf4;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 26px;
  transform: rotate(45deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.5px;
}

.tcg-stage-title-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tcg-stage-name {
  font-size: 15px;
  font-weight: 800;
  color: #f3f4f6;
}

.tcg-stage-desc {
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.4;
}

.tcg-stage-enemies {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.tcg-enemy-preview-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #0f0a07;
}

.tcg-stage-rewards-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
}

.tcg-stage-reward-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}

.tcg-brawl-btn {
  background: linear-gradient(135deg, #b45309 0%, #78350f 100%);
  border: 1px solid #fbbf24;
  color: #fef08a;
  font-weight: 800;
  font-size: 13px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.tcg-brawl-btn:hover {
  background: linear-gradient(135deg, #d97706 0%, #92400e 100%);
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.3);
}

/* ==========================================================================
   DECK BUILDER VIEW
   ========================================================================== */
.tcg-deck-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.tcg-deck-slots-box {
  background: rgba(20, 12, 8, 0.85);
  border: 1px solid var(--tcg-border-gold);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tcg-deck-slots-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tcg-deck-slots-title {
  font-size: 15px;
  font-weight: 800;
  color: #fbbf24;
}

.tcg-deck-slots-grid {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.tcg-slot-card-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.tcg-slot-badge {
  font-size: 11px;
  font-weight: 800;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 2px 10px;
  border-radius: 12px;
}

.tcg-slot-remove-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.tcg-slot-remove-btn:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: #ef4444;
  color: #ffffff;
  transform: translateY(-1px);
}

.tcg-deck-slot-empty {
  width: 155px;
  height: 225px;
  border: 2px dashed rgba(212, 163, 89, 0.4);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #9ca3af;
  font-size: 12px;
  background: rgba(14, 8, 5, 0.4);
}

/* Roster Selector Drawer */
.tcg-roster-box {
  background: rgba(16, 10, 6, 0.9);
  border: 1px solid var(--tcg-border-gold);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tcg-roster-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tcg-roster-title {
  font-size: 15px;
  font-weight: 800;
  color: #f3f4f6;
}

.tcg-roster-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.tcg-roster-card-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.tcg-roster-card-wrap:hover {
  transform: translateY(-4px);
  border-color: rgba(251, 191, 36, 0.7);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.8), 0 0 15px rgba(251, 191, 36, 0.2);
}

.tcg-roster-assign-btn {
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: #fbbf24;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 6px;
  cursor: pointer;
  width: 155px;
  box-sizing: border-box;
  text-align: center;
  transition: all 0.2s ease;
}

.tcg-roster-assign-btn:hover {
  background: #fbbf24;
  color: #1a0f05;
  border-color: #fbbf24;
}

/* ==========================================================================
   VICTORY / DEFEAT MODAL OVERLAY
   ========================================================================== */
.tcg-result-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.tcg-result-modal-content {
  background: radial-gradient(circle at center, #26170d 0%, #110804 100%);
  border: 2px solid #fbbf24;
  border-radius: 18px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 0 35px rgba(251, 191, 36, 0.4), 0 20px 40px rgba(0, 0, 0, 0.9);
  animation: tcgFadeIn 0.3s ease-out;
  text-align: center;
}

.tcg-result-modal-content.defeat-state {
  border-color: #ef4444;
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.4), 0 20px 40px rgba(0, 0, 0, 0.9);
}

.tcg-result-crest {
  font-size: 48px;
}

.tcg-result-title {
  font-size: 24px;
  font-weight: 900;
  color: #fbbf24;
  letter-spacing: 1px;
}

.tcg-result-title.defeat {
  color: #ef4444;
}

.tcg-result-rewards {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 18px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Free victory level-up banner (borderless gradient band) */
.tcg-result-levelup-banner {
  width: 100%;
  padding: 10px 18px;
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.28), rgba(251, 191, 36, 0.12) 55%, rgba(180, 83, 9, 0.25));
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tcg-result-levelup-header {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fbbf24;
  text-transform: uppercase;
}

.tcg-result-levelup-line {
  font-size: 13px;
  font-weight: 700;
  color: #fde68a;
  animation: tcgFadeIn 0.4s ease-out;
}

.tcg-reward-line {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 800;
}

.tcg-modal-action-btn {
  background: linear-gradient(135deg, #b45309 0%, #78350f 100%);
  border: 1px solid #fbbf24;
  color: #fef08a;
  font-size: 14px;
  font-weight: 900;
  padding: 10px 24px;
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
}

.tcg-modal-action-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}