/* ============================================================
   Hand Fan Component - Hearthstone-Style Card Display
   ============================================================ */

/* Fan Container */
.hand-fan-container {
  display: none;
  position: fixed;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  padding: 20px;
  z-index: 2100;
  pointer-events: auto;
}

/* Combat mode - centered over STR window, but biased downward so it doesn't
   occlude enemy intent + STR header controls. */
.hand-fan-container.hand-fan-combat {
  /* Default/fallback position; in STR combat we prefer JS anchoring to
     #str-combat-window for short-viewport safety. */
  top: 70vh;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  max-width: 700px;
}

/* Combat mode (peripheral) - floats above the STR window to reduce occlusion */
.hand-fan-container.hand-fan-combat-peripheral {
  top: 30vh;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50vw;
  min-width: 320px;
  max-width: 700px;
}

/* Contextual mode - bottom of screen */
.hand-fan-container.hand-fan-contextual {
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  max-width: 600px;
  background: rgba(0, 0, 0, 0.95);
  border: 2px solid #1cff9b;
  border-radius: 12px;
  padding: 15px;
  box-shadow: 0 0 30px rgba(28, 255, 155, 0.5);
}

/* Contextual mode overlay dimming */
.hand-fan-container.hand-fan-contextual::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: -1;
  pointer-events: none;
}

/* Fan appear animation */
.hand-fan-container.hand-fan-appear {
  animation: hand-fan-appear 0.3s ease-out;
}

@keyframes hand-fan-appear {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Fan disappear animation */
.hand-fan-container.hand-fan-disappear {
  animation: hand-fan-disappear 0.3s ease-in forwards;
}

@keyframes hand-fan-disappear {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
}

/* Empty message */
.hand-fan-empty {
  color: #999;
  font-size: 18px;
  font-family: 'Courier New', monospace;
  text-align: center;
  padding: 40px;
}

/* ============================================================
   Card Wrapper (for fan transformation)
   ============================================================ */

.hand-card-wrapper {
  position: relative;
  transition: transform 0.2s ease;
  cursor: pointer;
  transform: translateY(var(--fan-ty, 0px)) rotate(var(--fan-rot, 0deg));
}

/* ============================================================
   Hand Card Element
   ============================================================ */

.hand-card {
  width: 120px;
  height: 168px;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
  user-select: none;
  touch-action: none; /* prevent browser scroll/pan — pointer events drive drag on mobile */
  display: flex;
  flex-direction: column;
  will-change: transform;
}

/* ============================================================
   Card Background: Resource Color + Lifecycle Transparency

   Background color = resource spent (from RESOURCE_COLOR_SYSTEM.md)
   Background opacity = one-time (~30%) vs reusable (~50%)

   Default (no resource / inert) = grey #808080
   ============================================================ */

/* CSS custom properties for resource tint (set per card via data-resource) */
.hand-card { --res-r: 128; --res-g: 128; --res-b: 128; } /* default grey */
.hand-card[data-resource="energy"]  { --res-r: 0;   --res-g: 212; --res-b: 255; }
.hand-card[data-resource="ammo"]    { --res-r: 218; --res-g: 112; --res-b: 214; }
.hand-card[data-resource="battery"] { --res-r: 0;   --res-g: 255; --res-b: 166; }
.hand-card[data-resource="fatigue"] { --res-r: 160; --res-g: 82;  --res-b: 45;  }
.hand-card[data-resource="focus"]   { --res-r: 255; --res-g: 249; --res-b: 176; }
.hand-card[data-resource="hp"]      { --res-r: 255; --res-g: 107; --res-b: 157; }
.hand-card[data-resource="currency"]{ --res-r: 255; --res-g: 255; --res-b: 0;   }
.hand-card[data-resource="key_ammo"]{ --res-r: 255; --res-g: 138; --res-b: 61;  }
.hand-card[data-resource="cards"]   { --res-r: 128; --res-g: 0;   --res-b: 128; }

/* One-time use: consumable + exhaust → 30% opacity (translucent) */
.hand-card.hand-card-consumable {
  background: linear-gradient(
    135deg,
    rgba(var(--res-r), var(--res-g), var(--res-b), 0.20) 0%,
    rgba(var(--res-r), var(--res-g), var(--res-b), 0.30) 100%
  );
  backdrop-filter: blur(3px);
  border: 2px solid rgba(var(--res-r), var(--res-g), var(--res-b), 0.25);
}

.hand-card.hand-card-exhaust {
  background: linear-gradient(
    135deg,
    rgba(var(--res-r), var(--res-g), var(--res-b), 0.22) 0%,
    rgba(var(--res-r), var(--res-g), var(--res-b), 0.30) 100%
  );
  backdrop-filter: blur(3px);
  border: 2px solid rgba(var(--res-r), var(--res-g), var(--res-b), 0.28);
}

/* Reusable: power, gated, core → 50% opacity (more solid) */
.hand-card.hand-card-power {
  background: linear-gradient(
    135deg,
    rgba(var(--res-r), var(--res-g), var(--res-b), 0.40) 0%,
    rgba(var(--res-r), var(--res-g), var(--res-b), 0.50) 100%
  );
  backdrop-filter: blur(5px);
  border: 2px solid rgba(var(--res-r), var(--res-g), var(--res-b), 0.40);
}

.hand-card.hand-card-gated {
  background: linear-gradient(
    135deg,
    rgba(var(--res-r), var(--res-g), var(--res-b), 0.38) 0%,
    rgba(var(--res-r), var(--res-g), var(--res-b), 0.48) 100%
  );
  backdrop-filter: blur(5px);
  border: 2px solid rgba(var(--res-r), var(--res-g), var(--res-b), 0.38);
}

.hand-card.hand-card-core {
  background: linear-gradient(
    135deg,
    rgba(var(--res-r), var(--res-g), var(--res-b), 0.42) 0%,
    rgba(var(--res-r), var(--res-g), var(--res-b), 0.52) 100%
  );
  backdrop-filter: blur(6px);
  border: 2px solid rgba(var(--res-r), var(--res-g), var(--res-b), 0.45);
}

/* ============================================================
   BLVCK (ACT-000) — Universal "Nothing" Card
   Greyed joker identity: blacker, more transparent, serif font.
   Per BLVCK_PHILOSOPHY.md — the void card, the struggle card.
   ============================================================ */

.hand-card.hand-card-blvck {
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.82) 0%,
    rgba(15, 15, 15, 0.72) 50%,
    rgba(0, 0, 0, 0.88) 100%
  );
  border: 1px solid rgba(80, 80, 80, 0.30);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6), 0 0 6px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(3px);
}

.hand-card.hand-card-blvck .hand-card-emoji {
  opacity: 0.35;
  filter: grayscale(1) brightness(0.6);
  font-size: 1.8em;
}

.hand-card.hand-card-blvck .hand-card-name {
  font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, 'Times New Roman', serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.45;
  font-size: 10px;
}

.hand-card.hand-card-blvck .hand-card-cost {
  opacity: 0.25;
}

.hand-card.hand-card-blvck .hand-card-effects {
  opacity: 0.30;
}

/* BLVCK overrides the purple underglow — no glow, just void shadow */
.hand-card.hand-card-blvck {
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6), 0 0 6px rgba(0, 0, 0, 0.3);
}

/* When selected, BLVCK gets a dim grey border instead of the bright selection */
.hand-card.hand-card-blvck.hand-card-selected {
  border-color: rgba(120, 120, 120, 0.45);
  box-shadow: 0 0 4px rgba(80, 80, 80, 0.4), 0 0 8px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   Unaffordable Cards — BLVCK-frame treatment
   Cards with costs the player can't afford get the BLVCK void frame
   while preserving their own emoji and name. Visual signal: "you
   can see this card but you can't play it right now."
   ============================================================ */

.hand-card.hand-card-unaffordable {
  background: linear-gradient(
    135deg,
    rgba(5, 5, 5, 0.78) 0%,
    rgba(20, 20, 20, 0.68) 50%,
    rgba(5, 5, 5, 0.82) 100%
  );
  border: 1px solid rgba(80, 80, 80, 0.30);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6), 0 0 6px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(3px);
  pointer-events: auto;
}

.hand-card.hand-card-unaffordable .hand-card-emoji {
  opacity: 0.40;
  filter: grayscale(0.8) brightness(0.65);
}

.hand-card.hand-card-unaffordable .hand-card-name {
  opacity: 0.50;
  color: rgba(140, 140, 140, 0.7);
}

.hand-card.hand-card-unaffordable .hand-card-cost {
  opacity: 0.60;
  color: #DA70D6; /* ammo magenta — resource cost glow to hint WHY it's locked */
}

.hand-card.hand-card-unaffordable .hand-card-effects {
  opacity: 0.30;
}

/* Unaffordable cards suppress purple underglow */
.hand-card.hand-card-unaffordable {
  --card-glow: rgba(0, 0, 0, 0.3);
}

/* ============================================================
   Purple Underglow System
   Default: 2px purple glow on all cards
   Selected: 4px intensified
   Synergy combo: 5px animated gradient (purple + synergy colors)
   ============================================================ */

/* Default 2px purple underglow — applied as box-shadow directly on .hand-card
   (box-shadow is never clipped by overflow:hidden, unlike pseudo-elements) */
.hand-card {
  box-shadow: 0 0 2px rgba(128, 0, 128, 0.35), 0 0 4px rgba(128, 0, 128, 0.2);
}

/* Synergy combo: 5px with animated shifting colors.
   JS sets --synergy-r, --synergy-g, --synergy-b on the card when combo detected */
.hand-card.hand-card-synergy-glow {
  animation: synergy-underglow-pulse 2s ease-in-out infinite, synergy-underglow-shift 2s ease-in-out infinite;
}

@keyframes synergy-underglow-pulse {
  0%, 100% {
    box-shadow:
      0 0 5px rgba(128, 0, 128, 0.5),
      0 0 8px rgba(var(--synergy-r, 128), var(--synergy-g, 0), var(--synergy-b, 128), 0.25),
      0 0 12px rgba(var(--synergy-r, 128), var(--synergy-g, 0), var(--synergy-b, 128), 0.15);
  }
  50% {
    box-shadow:
      0 0 6px rgba(var(--synergy-r, 128), var(--synergy-g, 0), var(--synergy-b, 128), 0.5),
      0 0 10px rgba(128, 0, 128, 0.4),
      0 0 16px rgba(var(--synergy-r, 128), var(--synergy-g, 0), var(--synergy-b, 128), 0.3);
  }
}

@keyframes synergy-underglow-shift {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(15deg); }
}

/* Card hover effect */
.hand-card-wrapper:hover {
  transform: translateY(calc(var(--fan-ty, 0px) - 20px)) rotate(var(--fan-rot, 0deg)) scale(1.05);
  z-index: 200;
}

.hand-card:hover {
  box-shadow: 0 4px 20px rgba(28, 255, 155, 0.5);
}

/* Card insufficient resources state */
.hand-card.card-insufficient-resources {
  filter: grayscale(100%) brightness(0.4);
  cursor: not-allowed;
  opacity: 0.5;
}

/* Card shake animation for unaffordable cards */
@keyframes card-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.hand-card.card-shake {
  animation: card-shake 0.4s ease-in-out;
}

/* Placeholder "blck" card when hand is empty or all cards unaffordable */
.hand-card-placeholder {
  width: 120px;
  height: 168px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.9) 0%, rgba(20, 20, 20, 0.9) 100%);
  border: 2px solid rgba(100, 100, 100, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', monospace;
  color: #666;
  font-size: 24px;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: default;
  user-select: none;
}

/* Card selected state — single merged rule; transform is handled entirely
   by the gentle pulse keyframes so there is no competing static transform.
   Includes 4px purple underglow (intensified from default 2px). */
.hand-card.hand-card-selected {
  border-color: rgba(28, 255, 155, 0.75) !important;
  box-shadow:
    0 0 0 1px rgba(28, 255, 155, 0.25) inset,
    0 0 18px rgba(28, 255, 155, 0.35),
    0 0 4px rgba(128, 0, 128, 0.55),
    0 0 8px rgba(128, 0, 128, 0.3) !important;
  animation: card-selected-pulse 2s ease-in-out infinite;
}

@keyframes card-selected-pulse {
  0%, 100% { transform: translateY(-6px) scale(1.00); }
  50%      { transform: translateY(-6px) scale(1.015); }
}

/* Targeting mode (press-and-hold) — lifts card and changes border */
.hand-card.hand-card-targeting {
  border-color: rgba(255, 235, 59, 0.85) !important;
  box-shadow: 0 0 0 2px rgba(255, 235, 59, 0.22) inset, 0 0 18px rgba(255, 235, 59, 0.25) !important;
  transform: translateY(-14px) scale(1.06);
  z-index: 999;
}

/* Fan collapse + shuffle polish */
.hand-fan-container.hand-fan-collapsing {
  pointer-events: none;
}

.hand-fan-container.hand-fan-shuffle {
  animation: hand-fan-shuffle 220ms ease-in-out;
}

@keyframes hand-fan-shuffle {
  0%   { transform: translateX(0px); }
  25%  { transform: translateX(-6px); }
  55%  { transform: translateX(5px); }
  100% { transform: translateX(0px); }
}

/* Contextual mode selected state (persistent highlight) */
.hand-fan-contextual-mode .hand-card.hand-card-selected {
  border-color: #ffd700 !important;
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.9) !important;
  transform: translateY(-10px) scale(1.05);
  z-index: 999;
  position: relative;
}

.hand-fan-contextual-mode .hand-card.hand-card-selected::before {
  content: '▶';
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 20px;
  color: #ffd700;
  animation: selected-bounce 0.6s ease-in-out infinite;
}

@keyframes selected-bounce {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-5px);
  }
}

/* ============================================================
   Card Frame: Rarity border + purple-synergy gradient glow

   Frame color = quality/rarity
   Glow = purple base (#800080) blending toward rarity color
   Higher rarity → stronger glow
   ============================================================ */

.hand-card[data-quality="cracked"] {
  border-color: #666 !important;
  box-shadow: 0 0 4px rgba(128, 0, 128, 0.1);
}

.hand-card[data-quality="worn"] {
  border-color: #999 !important;
  box-shadow: 0 0 5px rgba(128, 0, 128, 0.15);
}

.hand-card[data-quality="standard"] {
  border-color: #fff !important;
  box-shadow: 0 0 6px rgba(128, 0, 128, 0.2);
}

.hand-card[data-quality="fine"] {
  border-color: #4fc3f7 !important;
  box-shadow: 0 0 8px rgba(79, 195, 247, 0.3), 0 0 16px rgba(128, 0, 128, 0.2);
}

.hand-card[data-quality="superior"] {
  border-color: #ffeb3b !important;
  box-shadow: 0 0 8px rgba(255, 235, 59, 0.3), 0 0 18px rgba(128, 0, 128, 0.25);
}

.hand-card[data-quality="elite"] {
  border-color: #ff9800 !important;
  box-shadow: 0 0 10px rgba(255, 152, 0, 0.35), 0 0 20px rgba(128, 0, 128, 0.3);
}

.hand-card[data-quality="masterwork"] {
  border-color: #ffd700 !important;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.4), 0 0 24px rgba(128, 0, 128, 0.35);
}

.hand-card[data-quality="near_perfect"] {
  border-color: #8bc34a !important;
  box-shadow: 0 0 14px rgba(139, 195, 74, 0.4), 0 0 28px rgba(128, 0, 128, 0.4);
}

.hand-card[data-quality="perfect"] {
  border-color: #9c27b0 !important;
  box-shadow: 0 0 16px rgba(156, 39, 176, 0.5), 0 0 32px rgba(128, 0, 128, 0.5);
  animation: perfect-card-pulse 2s ease-in-out infinite;
}

@keyframes perfect-card-pulse {
  0%, 100% { box-shadow: 0 0 16px rgba(156, 39, 176, 0.5), 0 0 32px rgba(128, 0, 128, 0.5); }
  50% { box-shadow: 0 0 20px rgba(156, 39, 176, 0.7), 0 0 40px rgba(128, 0, 128, 0.6); }
}

/* ============================================================
   Card Content Elements
   ============================================================ */

/* Cost badge (top-left corner) */
.hand-card-cost {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #1cff9b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: #1cff9b;
  font-family: 'Courier New', monospace;
  z-index: 10;
}

/* Card artwork area (80% of card height) */
.hand-card-artwork {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  position: relative;
}

/* Emoji header glow by card type: offensive/defensive/environmental */
.hand-card[data-card-type="attack"] .hand-card-artwork,
.hand-card[data-card-type="offensive"] .hand-card-artwork {
  background: radial-gradient(ellipse at center, rgba(255, 68, 68, 0.25) 0%, rgba(0, 0, 0, 0.2) 70%);
}

.hand-card[data-card-type="defense"] .hand-card-artwork,
.hand-card[data-card-type="defensive"] .hand-card-artwork,
.hand-card[data-card-type="shield"] .hand-card-artwork {
  background: radial-gradient(ellipse at center, rgba(68, 68, 255, 0.25) 0%, rgba(0, 0, 0, 0.2) 70%);
}

.hand-card[data-card-type="environmental"] .hand-card-artwork,
.hand-card[data-card-type="utility"] .hand-card-artwork,
.hand-card[data-card-type="support"] .hand-card-artwork {
  background: radial-gradient(ellipse at center, rgba(255, 170, 0, 0.25) 0%, rgba(0, 0, 0, 0.2) 70%);
}

.hand-card-emoji {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Card name (bottom) */
.hand-card-name {
  background: rgba(0, 0, 0, 0.8);
  color: #1cff9b;
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  padding: 6px 4px;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Effect icons (legacy) */
.hand-card-effects {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}

.hand-card-effect-icon {
  width: 16px;
  height: 16px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #ffaa00;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

/* Passive effect emoji rows — positioned below artwork, above card name */
.hand-card-passives {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 4px;
  min-height: 0;
}

/* Aggressive passives (damage to enemy): red-tinted bar */
.hand-card-passive-row {
  display: flex;
  align-items: center;
  gap: 1px;
  height: 12px;
  overflow: hidden;
}

.hand-card-passive-row.passive-aggressive {
  background: rgba(255, 68, 68, 0.15);
  border-radius: 2px;
}

/* Self-inflicted passives (cost to self): amber-tinted bar */
.hand-card-passive-row.passive-self {
  background: rgba(255, 170, 0, 0.15);
  border-radius: 2px;
}

.hand-card-passive-emoji {
  font-size: 8px;
  line-height: 1;
  opacity: 0.85;
}

/* Selection badge */
.hand-card-selection-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(28, 255, 155, 0.55);
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(28, 255, 155, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  font-family: 'Courier New', monospace;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 20;
}

/* ============================================================
   Card Animations
   ============================================================ */

/* Minimization animation - slide to single transparent card */
.hand-fan-container.hand-fan-minimized {
  animation: hand-fan-minimize 0.4s ease-in forwards;
}

@keyframes hand-fan-minimize {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 0.3;
    transform: translate(-50%, -50%) scale(0.2);
  }
}

/* Minimized state for hand fan */
.hand-fan-container.hand-fan-minimized .hand-card-wrapper {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0) !important;
  opacity: 0.3;
}

.hand-fan-container.hand-fan-minimized .hand-card-wrapper:not(:first-child) {
  display: none;
}

/* Frame incinerator animation for single-use cards */
@keyframes card-incinerator {
  0% {
    opacity: 1;
    filter: brightness(1);
  }
  30% {
    filter: brightness(2) saturate(2);
    box-shadow: 0 0 30px rgba(255, 100, 0, 1);
  }
  60% {
    transform: scale(1.1);
    filter: brightness(3) hue-rotate(30deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(15deg);
    filter: brightness(0) blur(10px);
  }
}

.hand-card.card-incinerating {
  animation: card-incinerator 0.6s ease-out forwards;
}

/* Commit animation - lift selected cards */
.hand-fan-container.hand-fan-commit .hand-card.hand-card-selected {
  animation: card-lift 0.2s ease-out forwards;
}

@keyframes card-lift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-20px) scale(1.05);
  }
}

/* Resolve animation - cards fly to center */
.hand-fan-container.hand-fan-resolve .hand-card-wrapper {
  animation: card-to-center 0.4s ease-in forwards;
}

@keyframes card-to-center {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateY(-50px) rotate(0deg) scale(0.9);
    opacity: 0.8;
  }
  100% {
    transform: translateY(-100px) rotate(0deg) scale(0.3);
    opacity: 0;
  }
}

/* Repopulate animation - cards fade in from center */
.hand-fan-container.hand-fan-repopulate .hand-card-wrapper {
  animation: card-from-center 0.3s ease-out forwards;
  animation-delay: calc(var(--card-index, 0) * 50ms);
}

/* While repopulating, don't allow hover/click interactions to fight transforms */
.hand-fan-container.hand-fan-repopulate .hand-card-wrapper,
.hand-fan-container.hand-fan-repopulate .hand-card,
.hand-fan-container.hand-fan-interaction-lock .hand-card-wrapper,
.hand-fan-container.hand-fan-interaction-lock .hand-card {
  pointer-events: none;
}

@keyframes card-from-center {
  from {
    transform: translateY(-50px) scale(0.5);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* ============================================================
   Card Tooltip
   ============================================================ */

.hand-card-tooltip {
  position: fixed;
  background: rgba(10, 5, 20, 0.75);
  border: 1px solid rgba(128, 0, 128, 0.6);
  border-radius: 6px;
  padding: 8px 12px;
  max-width: 240px;
  z-index: 3000;
  box-shadow: 0 2px 12px rgba(128, 0, 128, 0.25);
  pointer-events: none;
  font-family: 'Courier New', monospace;
  backdrop-filter: blur(6px);
  transform-origin: bottom center;
  /* JS controls display, transform, opacity, transition for unroll/rollback */
}

.tooltip-title {
  font-size: 11px;
  font-weight: bold;
  color: #e0d0ff;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tooltip-description {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.3;
  margin-bottom: 6px;
}

.tooltip-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid rgba(128, 0, 128, 0.3);
  padding-top: 4px;
}

.tooltip-stat {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
}

.tooltip-stat span {
  font-weight: bold;
}

/* Resource cost color in tooltip */
.tooltip-stat.tooltip-resource-cost span {
  /* color set inline via JS from RESOURCE_COLORS */
}

.tooltip-card-id {
  font-size: 9px;
  color: rgba(128, 0, 128, 0.5);
  margin-top: 4px;
  text-align: right;
}

.tooltip-tags {
  font-size: 9px;
  color: rgba(200, 160, 255, 0.7);
  margin-top: 3px;
}

/* ============================================================
   Responsive Design
   ============================================================ */

@media (max-width: 768px) {
  .hand-card {
    width: 100px;
    height: 140px;
  }

  .hand-card-emoji {
    font-size: 40px;
  }

  .hand-card-name {
    font-size: 10px;
    padding: 4px 2px;
  }

  .hand-card-cost {
    width: 20px;
    height: 20px;
    font-size: 12px;
  }

  .hand-fan-container.hand-fan-contextual {
    width: 95vw;
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .hand-card {
    width: 80px;
    height: 112px;
  }

  .hand-card-emoji {
    font-size: 32px;
  }

  .hand-card-name {
    font-size: 9px;
    padding: 3px 2px;
  }

  .hand-card-cost {
    width: 18px;
    height: 18px;
    font-size: 10px;
    top: 2px;
    left: 2px;
  }

  .hand-card-selection-badge {
    width: 24px;
    height: 24px;
    font-size: 14px;
    top: -6px;
    right: -6px;
  }

  .hand-fan-container.hand-fan-contextual {
    bottom: 10px;
    padding: 8px;
  }
}

/* ============================================================
   Drag Ghost Placeholder
   Empty dotted outline that holds a card's position while dragging
   ============================================================ */

.hand-card-drag-placeholder {
  width: 120px;
  height: 168px;
  border: 2px dashed rgba(128, 0, 128, 0.5);
  border-radius: 8px;
  background: rgba(128, 0, 128, 0.06);
  box-sizing: border-box;
  pointer-events: none;
}

/* Collapse animation when card is deployed/incinerated/discarded */
.hand-card-drag-placeholder.placeholder-collapsing {
  animation: placeholder-collapse 0.25s ease-in forwards;
}

@keyframes placeholder-collapse {
  0% { width: 120px; opacity: 1; margin-left: 0; }
  100% { width: 0; opacity: 0; margin-left: -2px; }
}

@media (max-width: 768px) {
  .hand-card-drag-placeholder { width: 100px; height: 140px; }
  @keyframes placeholder-collapse {
    0% { width: 100px; opacity: 1; margin-left: 0; }
    100% { width: 0; opacity: 0; margin-left: -2px; }
  }
}

@media (max-width: 480px) {
  .hand-card-drag-placeholder { width: 80px; height: 112px; }
  @keyframes placeholder-collapse {
    0% { width: 80px; opacity: 1; margin-left: 0; }
    100% { width: 0; opacity: 0; margin-left: -2px; }
  }
}

/* ============================================================
   Accessibility
   ============================================================ */

.hand-card:focus {
  outline: 2px solid #1cff9b;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .hand-card-wrapper,
  .hand-card,
  .hand-fan-container {
    animation: none !important;
    transition: none !important;
  }
}

@media (prefers-contrast: high) {
  .hand-card {
    border-width: 3px !important;
  }

  .hand-card-cost {
    border-width: 3px;
  }
}

/* ============================================================
   TODO: HAND FAN SQUISH - PORTRAIT/LANDSCAPE TRANSITIONS
   ============================================================

   TODO: Add @media (max-width: 480px) and (orientation: landscape)
         rule to switch hand fan from bottom-arc to right-edge
         vertical chip stack. Cards become 60px wide emoji+cost chips.

   TODO: Card breakout from game frame is by-design (position:fixed,
         z:2100) but on portrait mobile the fan should be anchored
         to env(safe-area-inset-bottom) and use max-height: 30vh
         to avoid occluding game grid entirely.

   TODO: Add CSS transition on .hand-fan-container position/transform
         so orientation changes produce smooth card reflow (~200ms)
         instead of instant pop.

   TODO: Investigate using CSS anchor-positioning (when supported)
         to tether fan container to #str-combat-window during combat
         mode, so it moves with the STR window on landscape panels.

   ============================================================ */

/* ============================================================
   CardDragController — tap-target accessibility highlights
   ============================================================ */

.cdc-tap-target-valid {
  outline: 2px dashed rgba(28, 255, 155, 0.6) !important;
  outline-offset: 3px;
  animation: cdc-target-pulse 1.5s ease-in-out infinite;
}

.cdc-tap-target-active {
  outline: 3px solid #1cff9b !important;
  outline-offset: 2px;
  box-shadow: 0 0 12px rgba(28, 255, 155, 0.5);
}

@keyframes cdc-target-pulse {
  0%, 100% { outline-color: rgba(28, 255, 155, 0.6); }
  50% { outline-color: rgba(28, 255, 155, 0.2); }
}
