/* ==========================================
   SHADOWS IN THE DECK - ORGANIZED CSS
   Complete style.css - CLEANED & SECTIONED
   
   TABLE OF CONTENTS:
   1. Base Styles & Reset - Line 20
   3. Responsive Scaling System - 41
   3. HUD & Resource Display - Line 103
   4. Layout Containers & Log System - Line 374
   5. Atmospheric Effects & Mist - Line 507
   6. Overlays & Game Screens - Line 746
   7. Card System & Animations - Line 1403
   8. Map System & Game Elements - Line 1922
   9. Buttons, Legend & Tooltips - Line 2019
   10. Tutorial & Interactive Elements - Line 2130
   11. Mobile Responsive - Line 2220
   12. Keyframe Animations - Line 2437
   ========================================== */

/* ==========================================
   1. BASE STYLES & RESET
   ========================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body, html {
  height: 100%;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 18px;
  color: #fff;
  position: relative;
  background: #333;
  overflow-x: hidden;
}

/* ==========================================
   2. RESPONSIVE SCALING SYSTEM
   ========================================== */

#game {
  /* Your existing styles stay the same */
  max-width: 1000px; 
  margin: auto; 
  position: relative; 
  z-index: 2;
  backdrop-filter: blur(1px);
  padding: 20px;
  
  /* NEW: Scaling setup */
  transform-origin: top center; /* Scale from top-center point */
  transition: transform 0.3s ease; /* Smooth scaling when resizing */
}

/* Scale up progressively for larger screens */
/* Much more conservative scaling */
@media (min-width: 1200px) {
  #game { 
    transform: scale(1.05); /* Just 5% bigger */
  }
}

@media (min-width: 1400px) {
  #game { 
    transform: scale(1.1); /* 10% bigger */
  }
}

@media (min-width: 1600px) {
  #game { 
    transform: scale(1.15); /* 15% bigger */
  }
}

@media (min-width: 1920px) {
  #game { 
    transform: scale(1.25); /* 25% bigger on huge screens */
  }
}

/* 
Optional: Manual size controls for testing 
#game.size-small { transform: scale(0.9); }
#game.size-normal { transform: scale(1.0); }
#game.size-large { transform: scale(1.3); }
#game.size-huge { transform: scale(1.7); }
*/


h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.8rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  margin: 20px 0 10px 0;
}

/* ==========================================
   2. HUD & RESOURCE DISPLAY
   ========================================== */
:root {
  --hud-pulse-speed: 3s;
  --hud-hover-speed: 0.4s;
  --hud-glow-intensity: 0.6;
  --hud-animation-subtle: 0.02;
}

#hud {
  margin: 15px;
  font-weight: bold;
  padding: 20px 30px;
  border-radius: 12px;
  text-align: center;
  font-size: 1.3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  
  background: 
    linear-gradient(135deg, rgba(20, 20, 40, 0.95) 0%, rgba(10, 10, 30, 0.9) 100%),
    radial-gradient(circle at 20% 50%, rgba(138, 43, 226, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(100, 150, 255, 0.08) 0%, transparent 50%);
  
  border: 2px solid transparent;
  background-clip: padding-box;
  box-shadow: 
    inset 0 0 0 1px rgba(138, 43, 226, 0.4),
    inset 0 0 0 3px rgba(100, 150, 255, 0.2),
    0 0 20px rgba(138, 43, 226, 0.3),
    0 4px 20px rgba(0, 0, 0, 0.4);
  
  backdrop-filter: blur(15px);
  position: relative;
  overflow: visible;
}

#hud::before,
#hud::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(138, 43, 226, 0.6);
  pointer-events: none;
}

#hud::before {
  top: -2px;
  left: -2px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 8px;
}

#hud::after {
  bottom: -2px;
  right: -2px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 8px;
}

.hud-info {
  flex: 1;
  min-width: 350px;
  display: flex;
  align-items: center;
  gap: 25px;
  font-family: 'Cormorant Garamond', serif;
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  border: 1px solid rgba(138, 43, 226, 0.3);
  transition: all var(--hud-hover-speed) ease;
  position: relative;
  cursor: help;
}

.resource-item:hover {
  background: rgba(138, 43, 226, 0.1);
  border-color: rgba(138, 43, 226, 0.5);
  transform: scale(calc(1 + var(--hud-animation-subtle)));
}

.resource-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 0 4px currentColor);
  transition: all var(--hud-hover-speed) ease;
  
  /* NEW: Setup for background images */
  width: 24px;
  height: 24px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: inline-block;
}

/* Replace emoji icons with custom images */
.resource-icon.orb-icon { 
  background-image: url('images/icons/focus-icon-48.png');
  color: transparent; /* Hide any fallback emoji */
}

.resource-icon.fragment-icon { 
  background-image: url('images/icons/fragment-icon-48.png');
  color: transparent;
}

.resource-icon.cruxflare-icon { 
  background-image: url('images/icons/crux-icon-48.png');
  color: transparent;
  font-size: 1.4rem; /* Keep same size */
}

.resource-item.cruxflare-display {
  min-height: 40px; /* Match other containers */
  max-height: 40px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
}

.resource-value {
  font-size: 1.2rem;
  font-weight: 700;
  text-shadow: 0 0 8px currentColor;
  min-width: 20px;
  text-align: center;
}

.resource-value.orb-count { color: #FFD700; }
.resource-value.fragment-count { color: #00FFFF; }
.resource-value.cruxflare-count { color: #8A2BE2; }

.hud-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hud-button {
  background: linear-gradient(135deg, rgba(138, 43, 226, 0.3) 0%, rgba(100, 30, 180, 0.2) 100%);
  border: 1px solid rgba(138, 43, 226, 0.6);
  color: rgba(222, 184, 135, 0.9);
  padding: 12px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--hud-hover-speed) ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  backdrop-filter: blur(5px);
  font-family: 'Source Sans Pro', sans-serif;
  position: relative;
  overflow: hidden;
}

.hud-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(222, 184, 135, 0.1), transparent);
  transition: left var(--hud-hover-speed) ease;
}

.hud-button:hover {
  background: linear-gradient(135deg, rgba(138, 43, 226, 0.5) 0%, rgba(100, 30, 180, 0.4) 100%);
  border-color: rgba(222, 184, 135, 0.8);
  transform: translateY(-1px) scale(calc(1 + var(--hud-animation-subtle)));
  box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
}

.hud-button:hover::before {
  left: 100%;
}

.hud-button.active {
  background: linear-gradient(135deg, rgba(222, 184, 135, 0.3) 0%, rgba(200, 160, 100, 0.2) 100%);
  border-color: rgba(222, 184, 135, 0.8);
  color: #fff;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.5) 0%, rgba(20, 20, 40, 0.3) 100%);
  padding: 10px 15px;
  border-radius: 8px;
  border: 1px solid rgba(138, 43, 226, 0.4);
  backdrop-filter: blur(10px);
}

.volume-slider {
  width: 90px;
  height: 6px;
  background: linear-gradient(to right, 
    rgba(138, 43, 226, 0.3) 0%, 
    rgba(138, 43, 226, 0.6) 50%, 
    rgba(138, 43, 226, 0.3) 100%);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  transition: all var(--hud-hover-speed) ease;
}

.volume-slider:hover {
  background: linear-gradient(to right, 
    rgba(138, 43, 226, 0.5) 0%, 
    rgba(138, 43, 226, 0.8) 50%, 
    rgba(138, 43, 226, 0.5) 100%);
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: radial-gradient(circle, rgba(222, 184, 135, 0.9) 0%, rgba(200, 160, 100, 0.8) 100%);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 
    0 0 8px rgba(222, 184, 135, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(222, 184, 135, 0.3);
  transition: all var(--hud-hover-speed) ease;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 
    0 0 12px rgba(222, 184, 135, 0.7),
    0 3px 6px rgba(0, 0, 0, 0.4);
}

.volume-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: radial-gradient(circle, rgba(222, 184, 135, 0.9) 0%, rgba(200, 160, 100, 0.8) 100%);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(222, 184, 135, 0.3);
  box-shadow: 
    0 0 8px rgba(222, 184, 135, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all var(--hud-hover-speed) ease;
}

.volume-icon {
  font-size: 1rem;
  color: rgba(222, 184, 135, 0.8);
  filter: drop-shadow(0 0 4px rgba(222, 184, 135, 0.3));
}

/* ==========================================
   3. LAYOUT CONTAINERS & LOG SYSTEM
   ========================================== */

/* ========== STABLE LAYOUT CONTAINERS ========== */
.button-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  height: 80px;
}

#end-turn-btn, #restart-btn { 
  position: static;
  transform: none;
}

.map-container {
  min-height: 100px;
  max-height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px auto;
  max-width: 800px;
  padding: 10px;
}

#map { 
  display: flex; 
  justify-content: center; 
  flex-wrap: wrap;
  gap: 5px;
  width: 100%;
  margin: 0;
}

#log {
  background: rgba(0, 0, 0, 0.6);
  padding: 20px 30px;
  min-height: 80px; /* Changed from fixed height to min-height */
  margin: 15px;
  border-radius: 12px;
  backdrop-filter: blur(15px);
  border: 2px solid rgba(222, 184, 135, 0.4);
  text-align: center;
  font-size: 1.5rem;
  width: calc(100% - 30px);
  max-width: none;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  
  /* Allow text wrapping on mobile */
  white-space: normal; /* Changed from nowrap */
  overflow: visible; /* Changed from hidden */
  text-overflow: clip; /* Changed from ellipsis */
  
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

/* Desktop keeps single line */
@media (min-width: 769px) {
  #log {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 80px; /* Fixed height on desktop */
  }
}

#log.cruxflare-log {
  background: rgba(138, 43, 226, 0.4) !important;
  border: 3px solid rgba(138, 43, 226, 0.9) !important;
  box-shadow: 
    0 0 20px rgba(138, 43, 226, 0.6),
    0 4px 15px rgba(0, 0, 0, 0.5) !important;
  color: rgba(255, 255, 255, 0.95) !important;
  animation: cruxflare-pulse 2s ease-in-out !important;
  font-weight: 600 !important;
  text-shadow: 0 0 8px rgba(138, 43, 226, 0.8) !important;
  
  height: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-section {
  margin: 20px 0;
}

.section-header {
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0 10px 0;
}

/* ========== UPDATED LAYOUT FOR BOTH HAND AND MARKET ========== */
#player-hand {
  position: relative;
  top: 0;
  left: 0;
  min-height: 190px;
  display: flex !important;
  justify-content: center !important; 
  align-items: flex-end !important;
  margin: 25px 0 !important;
  flex-wrap: nowrap !important;
  overflow: visible !important;
  transition: all 0.5s ease;
}

#market {
  position: relative;
  top: 0;
  left: 0;
  min-height: 240px;
  display: flex !important;
  justify-content: center !important; 
  align-items: flex-start !important;
  margin: 25px 0 !important;
  flex-wrap: nowrap !important;
  overflow: visible !important;
  transition: all 0.5s ease;
}

/* ==========================================
   4. ATMOSPHERIC EFFECTS & MIST
   ========================================== */

/* ========== ATMOSPHERIC EFFECTS ========== */
.mist-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.mist-layer::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(circle at 10% 20%, rgba(255,255,255,0.03) 0%, transparent 25%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.02) 0%, transparent 25%),
    radial-gradient(circle at 40% 40%, rgba(255,255,255,0.04) 0%, transparent 25%),
    radial-gradient(circle at 90% 10%, rgba(255,255,255,0.02) 0%, transparent 25%),
    radial-gradient(circle at 30% 70%, rgba(255,255,255,0.03) 0%, transparent 25%);
  animation: mistDrift1 45s ease-in-out infinite;
  opacity: 0.9;
}

.mist-layer::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(circle at 70% 30%, rgba(255,255,255,0.02) 0%, transparent 30%),
    radial-gradient(circle at 20% 60%, rgba(255,255,255,0.03) 0%, transparent 30%),
    radial-gradient(circle at 60% 90%, rgba(255,255,255,0.02) 0%, transparent 30%),
    radial-gradient(circle at 90% 50%, rgba(255,255,255,0.025) 0%, transparent 30%);
  animation: mistDrift2 60s ease-in-out infinite reverse;
  opacity: 0.7;
}

.mist-tendrils {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  background: 
    linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.01) 35%, transparent 40%),
    linear-gradient(-45deg, transparent 60%, rgba(255,255,255,0.015) 65%, transparent 70%),
    linear-gradient(90deg, transparent 20%, rgba(255,255,255,0.008) 25%, transparent 30%);
  animation: tendrilFlow 35s linear infinite;
  opacity: 1.0;
}

/* Warning mode - purple mist */
body.warning-mode .mist-layer::before {
  background: 
    radial-gradient(circle at 10% 20%, rgba(138,43,226,0.08) 0%, transparent 25%),
    radial-gradient(circle at 80% 80%, rgba(120,30,180,0.06) 0%, transparent 25%),
    radial-gradient(circle at 40% 40%, rgba(160,60,220,0.10) 0%, transparent 25%),
    radial-gradient(circle at 90% 10%, rgba(100,20,150,0.05) 0%, transparent 25%),
    radial-gradient(circle at 30% 70%, rgba(140,50,200,0.07) 0%, transparent 25%);
  animation-duration: 30s;
  opacity: 0.9;
}

body.warning-mode .mist-layer::after {
  background: 
    radial-gradient(circle at 70% 30%, rgba(120,20,170,0.05) 0%, transparent 30%),
    radial-gradient(circle at 20% 60%, rgba(140,40,190,0.07) 0%, transparent 30%),
    radial-gradient(circle at 60% 90%, rgba(100,15,140,0.04) 0%, transparent 30%),
    radial-gradient(circle at 90% 50%, rgba(150,50,210,0.06) 0%, transparent 30%);
  animation-duration: 40s;
  opacity: 0.7;
}

body.warning-mode .mist-tendrils {
  background: 
    linear-gradient(45deg, transparent 30%, rgba(138,43,226,0.025) 35%, transparent 40%),
    linear-gradient(-45deg, transparent 60%, rgba(120,30,180,0.03) 65%, transparent 70%),
    linear-gradient(90deg, transparent 20%, rgba(140,40,200,0.02) 25%, transparent 30%);
  animation-duration: 25s;
}

/* Danger mode - red mist */
body.danger-mode .mist-layer::before {
  background: 
    radial-gradient(circle at 10% 20%, rgba(255,100,100,0.08) 0%, transparent 25%),
    radial-gradient(circle at 80% 80%, rgba(200,50,50,0.06) 0%, transparent 25%),
    radial-gradient(circle at 40% 40%, rgba(255,80,80,0.10) 0%, transparent 25%),
    radial-gradient(circle at 90% 10%, rgba(180,40,40,0.05) 0%, transparent 25%),
    radial-gradient(circle at 30% 70%, rgba(255,60,60,0.08) 0%, transparent 25%);
  animation-duration: 15s;
  opacity: 1;
}

body.danger-mode .mist-layer::after {
  background: 
    radial-gradient(circle at 70% 30%, rgba(200,30,30,0.06) 0%, transparent 30%),
    radial-gradient(circle at 20% 60%, rgba(255,40,40,0.08) 0%, transparent 30%),
    radial-gradient(circle at 60% 90%, rgba(180,20,20,0.05) 0%, transparent 30%),
    radial-gradient(circle at 90% 50%, rgba(255,50,50,0.07) 0%, transparent 30%);
  animation-duration: 20s;
  opacity: 0.9;
}

body.danger-mode .mist-tendrils {
  background: 
    linear-gradient(45deg, transparent 30%, rgba(255,50,50,0.03) 35%, transparent 40%),
    linear-gradient(-45deg, transparent 60%, rgba(200,30,30,0.035) 65%, transparent 70%),
    linear-gradient(90deg, transparent 20%, rgba(255,40,40,0.025) 25%, transparent 30%);
  animation-duration: 12s;
}

/* HUD state changes */
body.warning-mode #hud {
  box-shadow: 
    inset 0 0 0 1px rgba(138, 43, 226, 0.6),
    inset 0 0 0 3px rgba(100, 150, 255, 0.3),
    0 0 25px rgba(138, 43, 226, calc(var(--hud-glow-intensity) * 0.8)),
    0 4px 20px rgba(0, 0, 0, 0.4);
}

body.danger-mode #hud {
  box-shadow: 
    inset 0 0 0 1px rgba(255, 100, 100, 0.7),
    inset 0 0 0 3px rgba(255, 150, 150, 0.4),
    0 0 30px rgba(255, 100, 100, var(--hud-glow-intensity)),
    0 4px 20px rgba(0, 0, 0, 0.5);
}

body.danger-mode #hud::before,
body.danger-mode #hud::after {
  border-color: rgba(255, 100, 100, 0.8);
}

/* Cruxflare warning/danger states */
.cruxflare-warning .resource-value.cruxflare-count {
  animation: gentle-pulse var(--hud-pulse-speed) infinite;
}

.cruxflare-danger .resource-value.cruxflare-count {
  color: #FF6464 !important;
  animation: gentle-pulse calc(var(--hud-pulse-speed) * 0.7) infinite;
}

/* ==========================================
   MIST OVERLAY BACKGROUND SYSTEM
   ========================================== */

/* ========== NEW: MIST OVERLAY BACKGROUND LAYER ========== */
/* This layer sits behind all existing mist effects */
.mist-overlay-layer {
  position: fixed;
  /* Expand beyond viewport to prevent edge showing */
  top: -100px;
  left: -100px;
  width: calc(100% + 200px);
  height: calc(100% + 200px);
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  
  /* Default: mist-overlay.png for game start */
  background-image: url('images/mist-overlay.png');
  background-repeat: repeat;
  background-size: auto;
  background-position: 0 0;
  
  /* Default animation - slow drift */
  animation: mistOverlayDrift 60s ease-in-out infinite;
  opacity: 0.55; /* Keep your current opacity setting */
  
  /* Smooth transitions when switching backgrounds */
  transition: background-image 2s ease-in-out, animation-duration 1s ease-in-out;
}

/* ========== PHASE-BASED BACKGROUND SWITCHING ========== */
/* Warning mode (≤9 Cruxflare) - switch to mist-overlay2.png */
body.warning-mode .mist-overlay-layer {
  background-image: url('images/mist-overlay2.png');
  animation-duration: 45s; /* Slightly faster drift */
}

/* Danger mode (≤3 Cruxflare or Final Darkness) - keep overlay2, speed up */
body.danger-mode .mist-overlay-layer {
  background-image: url('images/mist-overlay2.png');
  animation-duration: 25s; /* Much faster "rolling clouds" effect */
}

/* ========== MIST OVERLAY ANIMATIONS ========== */
/* Subtle drift animation for the background images */
@keyframes mistOverlayDrift {
  0%, 100% { 
    background-position: 0 0;
    transform: scale(1);
  }
  25% { 
    background-position: -50px -30px;
    transform: scale(1.02);
  }
  50% { 
    background-position: 30px -60px;
    transform: scale(0.98);
  }
  75% { 
    background-position: -20px -40px;
    transform: scale(1.01);
  }
}

/* ========== OPACITY ADJUSTMENTS FOR EXISTING MIST ========== */
/* Reduce opacity of existing mist layers so overlay images show through */
.mist-layer::before {
  /* Reduce from opacity: 0.9 to 0.6 */
  opacity: 0.4;
}

.mist-layer::after {
  /* Reduce from opacity: 0.7 to 0.4 */
  opacity: 0.2;
}

.mist-tendrils {
  /* Reduce from opacity: 1.0 to 0.7 */
  opacity: 0.5;
}

/* ==========================================
   5. OVERLAYS & GAME SCREENS
   ========================================== */

/* ========== FLOATING PARTICLES ========== */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  animation: float 25s infinite linear;
  opacity: 0;
}

.particle.golden {
  background: radial-gradient(circle, rgba(222, 184, 135, 0.6) 0%, rgba(222, 184, 135, 0.1) 70%, transparent 100%);
  box-shadow: 0 0 4px rgba(222, 184, 135, 0.4);
}

.particle.purple {
  background: radial-gradient(circle, rgba(138, 43, 226, 0.5) 0%, rgba(138, 43, 226, 0.1) 70%, transparent 100%);
  box-shadow: 0 0 4px rgba(138, 43, 226, 0.3);
}

.particle.silver {
  background: radial-gradient(circle, rgba(192, 192, 192, 0.4) 0%, rgba(192, 192, 192, 0.1) 70%, transparent 100%);
  box-shadow: 0 0 3px rgba(192, 192, 192, 0.2);
}



/* ========== CRUXFLARE OVERLAY SYSTEM ========== */

/* Overlay backdrop - similar to game over screen */
.cruxflare-overlay-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cruxflare-overlay-backdrop.show {
  opacity: 1;
}

/* Main overlay container */
.cruxflare-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
}

.cruxflare-overlay.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* The card itself - matching your mockup */
.cruxflare-card {
  width: 220px;
  height: 360px;
  background: linear-gradient(135deg, 
    rgba(25, 15, 45, 0.98) 0%, 
    rgba(15, 10, 35, 0.95) 30%,
    rgba(20, 15, 40, 0.98) 70%,
    rgba(10, 5, 30, 0.95) 100%);
  border: 3px solid rgba(138, 43, 226, 0.8);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 
    0 0 25px rgba(138, 43, 226, 0.6),
    0 8px 32px rgba(0, 0, 0, 0.8);
  position: relative;
  overflow: hidden;
}

/* Mystical corner accents like the HUD */
.cruxflare-card::before,
.cruxflare-card::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(138, 43, 226, 0.8);
  pointer-events: none;
}

.cruxflare-card::before {
  top: 8px;
  left: 8px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 8px;
}

.cruxflare-card::after {
  bottom: 8px;
  right: 8px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 8px;
}

/* Header text "Cruxflare Event" */
.cruxflare-header {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.9rem;
  color: rgba(138, 43, 226, 0.9);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 400;
}

/* Event name title - using Cormorant Garamond like in your mockup */
.cruxflare-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.8rem;
  color: rgba(222, 184, 135, 0.95);
  margin-bottom: 15px;
  font-weight: 500;
  text-shadow: 0 0 8px rgba(222, 184, 135, 0.4);
}

/* Icon from iconCardList.md */
.cruxflare-icon {
  font-size: 3.5rem;
  margin: 20px 0;
  filter: drop-shadow(0 0 10px rgba(138, 43, 226, 0.6));
}

/* Effect description at bottom */
.cruxflare-effect {
  margin-top: auto;
  padding: 12px 16px;
  background: rgba(33, 33, 33, 0.7);
  border-radius: 8px;
  border: 1px solid rgba(138, 43, 226, 0.4);
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.2;
  width: 100%;
  box-sizing: border-box;
}


/* Dismiss hint text */
.cruxflare-dismiss-hint {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
  pointer-events: none;
}

/* Tutorial Popup Styles */
.tutorial-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(3px);
}

.tutorial-popup-content {
  background: linear-gradient(135deg, 
    rgba(25, 15, 45, 0.98) 0%, 
    rgba(15, 10, 35, 0.95) 30%,
    rgba(20, 15, 40, 0.98) 70%,
    rgba(10, 5, 30, 0.95) 100%);
  border: 3px solid rgba(138, 43, 226, 0.8);
  border-radius: 16px;
  padding: 30px;
  max-width: 500px;
  text-align: center;
  color: #fff;
  box-shadow: 
    0 0 25px rgba(138, 43, 226, 0.6),
    0 8px 32px rgba(0, 0, 0, 0.8);
  font-family: 'Source Sans Pro', sans-serif;
  position: relative;
}

.tutorial-popup-content::before,
.tutorial-popup-content::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(138, 43, 226, 0.8);
  pointer-events: none;
}

.tutorial-popup-content::before {
  top: 8px;
  left: 8px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 8px;
}

.tutorial-popup-content::after {
  bottom: 8px;
  right: 8px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 8px;
}

.tutorial-popup-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  color: rgba(222, 184, 135, 0.95);
  margin-bottom: 20px;
  text-shadow: 0 0 8px rgba(222, 184, 135, 0.4);
}

.tutorial-goal {
  font-size: 1.3rem;
  color: rgba(222, 184, 135, 0.9);
  margin-bottom: 25px;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  border: 1px solid rgba(222, 184, 135, 0.3);
}

.tutorial-steps {
  text-align: left;
  margin: 20px 0;
  line-height: 1.6;
}

.tutorial-step {
  display: flex;
  align-items: center;
  margin: 12px 0;
  font-size: 1.1rem;
}

.tutorial-step-number {
  background: rgba(138, 43, 226, 0.8);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-right: 12px;
  flex-shrink: 0;
}

.tutorial-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 25px;
}

.tutorial-btn {
  padding: 12px 24px;
  border: 1px solid rgba(222, 184, 135, 0.6);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
  color: rgba(222, 184, 135, 0.9);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Source Sans Pro', sans-serif;
  text-decoration: none;
  display: inline-block;
}

.tutorial-btn:hover {
  background: rgba(222, 184, 135, 0.1);
  border-color: rgba(222, 184, 135, 0.8);
  transform: translateY(-2px);
}

.tutorial-btn.tutorial-primary {
  background: linear-gradient(135deg, rgba(138, 43, 226, 0.3) 0%, rgba(100, 30, 180, 0.2) 100%);
  border-color: rgba(138, 43, 226, 0.6);
}

.tutorial-btn.tutorial-primary:hover {
  background: linear-gradient(135deg, rgba(138, 43, 226, 0.5) 0%, rgba(100, 30, 180, 0.4) 100%);
}

/* ========== ENHANCED WIN/LOSE POPUP STYLES ==========
   Add these styles to your style.css file (replace existing game-over styles) */

/* ========== VICTORY SCREEN (WIN) ========== */
.victory-screen {
  pointer-events: auto;
 background: 
  linear-gradient(135deg, 
    rgba(222, 184, 135, 0.3) 0%,    /* Dimming overlay on top */
    rgba(138, 43, 226, 0.6) 30%, 
    rgba(100, 150, 255, 0.7) 70%, 
    rgba(222, 184, 135, 0.9) 100%),
  url('images/victory-background.png'); /* Image behind */
background-size: 100%;
background-position: center;
background-repeat: no-repeat;
  backdrop-filter: blur(15px);
  padding: 40px;
  border-radius: 16px;
  border: 3px solid rgba(222, 184, 135, 0.9);
  text-align: center;
  box-shadow: 
    0 0 30px rgba(222, 184, 135, 0.5),
    inset 0 0 30px rgba(222, 184, 135, 0.1),
    0 20px 40px rgba(0, 0, 0, 0.3);
  animation: victory-appear 0.8s ease-out;
  position: relative;
  z-index: 10001;
  overflow: visible;
}

.victory-screen .game-over-title {
  color: rgba(222, 184, 135, 0.95);
  text-shadow: 
    0 0 10px rgba(222, 184, 135, 0.6),
    0 0 20px rgba(222, 184, 135, 0.3);
  animation: victory-glow 2s ease-in-out infinite alternate;
}

.victory-screen .game-over-score {
  color: rgba(222, 184, 135, 0.9);
}

.victory-screen .game-over-flavor {
  color: rgba(255, 255, 255, 0.85);
}

/* ========== DEFEAT SCREEN (LOSE) ========== */
.defeat-screen {
  pointer-events: auto;
  background: 
  linear-gradient(135deg, 
    rgba(25, 15, 45, 0.3) 0%, 
    rgba(60, 20, 80, 0.6) 30%, 
    rgba(80, 30, 100, 0.7) 70%, 
    rgba(15, 10, 35, 0.9) 100%),
  url('images/defeat-background.png'); /* Image behind */
background-size: 100%;
background-position: center;
background-repeat: no-repeat;
  backdrop-filter: blur(20px);
  padding: 40px;
  border-radius: 16px;
  border: 3px solid rgba(138, 43, 226, 0.7);
  text-align: center;
  box-shadow: 
    0 0 25px rgba(138, 43, 226, 0.4),
    inset 0 0 40px rgba(0, 0, 0, 0.4),
    0 20px 40px rgba(0, 0, 0, 0.8);
  animation: defeat-appear 0.8s ease-out;
  position: relative;
  z-index: 10001;
  overflow: visible;
}

.defeat-screen .game-over-title {
  color: rgba(138, 43, 226, 0.9);
  text-shadow: 
    0 0 8px rgba(138, 43, 226, 0.5),
    0 0 16px rgba(138, 43, 226, 0.2);
  animation: defeat-pulse 3s ease-in-out infinite;
}

.defeat-screen .game-over-score {
  color: rgba(200, 150, 255, 0.8);
}

.defeat-screen .game-over-flavor {
  color: rgba(255, 255, 255, 0.7);
}

/* ========== GAME OVER SCREENS ========== */
#game-over-container {
  padding: 0; /* Remove any padding */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  width: 90%;
  max-width: 600px;
  border-radius: 16px; /* Match the popup's border-radius */
  overflow: hidden; /* Clip any content that extends beyond the rounded corners */
  pointer-events: none;
}

.game-over-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
}

.game-over-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.5rem;
  margin-bottom: 15px;
}

.game-over-score {
  font-size: 1.3rem;
  margin-bottom: 10px;
}

.game-over-flavor {
  font-style: italic;
  margin-bottom: 20px;
  line-height: 1.4;
}

/* ========== PARTICLE CONTAINER ========== */
.particle-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10002;
  overflow: hidden;
}

/* ========== WIN PARTICLES (EXPANDING STARBURST) ========== */
.win-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, 
    rgba(222, 184, 135, 1) 0%, 
    rgba(222, 184, 135, 0.8) 50%, 
    transparent 100%);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: win-expand 2s ease-out var(--delay, 0s) infinite;
  box-shadow: 
    0 0 6px rgba(222, 184, 135, 0.8),
    0 0 12px rgba(222, 184, 135, 0.4);
}

.win-particle:nth-child(3n) {
  background: radial-gradient(circle, 
    rgba(255, 255, 255, 1) 0%, 
    rgba(255, 255, 255, 0.6) 50%, 
    transparent 100%);
  box-shadow: 
    0 0 8px rgba(255, 255, 255, 0.8),
    0 0 16px rgba(255, 255, 255, 0.3);
}

.win-particle:nth-child(5n) {
  background: radial-gradient(circle, 
    rgba(100, 150, 255, 1) 0%, 
    rgba(100, 150, 255, 0.8) 50%, 
    transparent 100%);
  box-shadow: 
    0 0 6px rgba(100, 150, 255, 0.8),
    0 0 12px rgba(100, 150, 255, 0.4);
}

/* ========== LOSE PARTICLES (CONTRACTING VACUUM) ========== */
.lose-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: radial-gradient(circle, 
    rgba(138, 43, 226, 1) 0%, 
    rgba(138, 43, 226, 0.6) 50%, 
    transparent 100%);
  border-radius: 50%;
  top: var(--start-y, 50%);
  left: var(--start-x, 50%);
  animation: lose-contract 2.5s ease-in var(--delay, 0s) infinite;
  box-shadow: 
    0 0 4px rgba(138, 43, 226, 0.7),
    0 0 8px rgba(138, 43, 226, 0.3);
}

.lose-particle:nth-child(3n) {
  background: radial-gradient(circle, 
    rgba(80, 20, 120, 1) 0%, 
    rgba(80, 20, 120, 0.8) 50%, 
    transparent 100%);
  box-shadow: 
    0 0 4px rgba(80, 20, 120, 0.8),
    0 0 8px rgba(80, 20, 120, 0.4);
}

.lose-particle:nth-child(4n) {
  background: radial-gradient(circle, 
    rgba(60, 60, 60, 1) 0%, 
    rgba(60, 60, 60, 0.6) 50%, 
    transparent 100%);
  box-shadow: 
    0 0 3px rgba(60, 60, 60, 0.6),
    0 0 6px rgba(60, 60, 60, 0.2);
}

/* ========== PARTICLE ANIMATIONS ========== */
@keyframes win-expand {
  0% { 
    transform: translate(-50%, -50%) rotate(var(--angle, 0deg)) translateX(0px) scale(0);
    opacity: 0;
  }
  10% { 
    opacity: 1;
    transform: translate(-50%, -50%) rotate(var(--angle, 0deg)) translateX(20px) scale(0.5);
  }
  50% { 
    opacity: 1;
    transform: translate(-50%, -50%) rotate(var(--angle, 0deg)) translateX(calc(var(--distance, 400px) * 0.7)) scale(1);
  }
  100% { 
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--angle, 0deg)) translateX(var(--distance, 400px)) scale(0.2);
  }
}

@keyframes lose-contract {
  0% { 
    transform: scale(1);
    opacity: 0.8;
  }
  20% { 
    opacity: 1;
  }
  80% { 
    transform: scale(0.8);
    opacity: 0.6;
  }
  100% { 
    transform: scale(0) translate(calc(50vw - var(--start-x, 50%)), calc(50vh - var(--start-y, 50%)));
    opacity: 0;
  }
}

/* ========== SCREEN APPEARANCE ANIMATIONS ========== */
@keyframes victory-appear {
  0% {
    opacity: 0;
    transform: scale(0.7) translateY(30px);
    box-shadow: 0 0 0 rgba(222, 184, 135, 0);
  }
  50% {
    transform: scale(1.05) translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    box-shadow: 
      0 0 30px rgba(222, 184, 135, 0.5),
      inset 0 0 30px rgba(222, 184, 135, 0.1),
      0 20px 40px rgba(0, 0, 0, 0.3);
  }
}

@keyframes defeat-appear {
  0% {
    opacity: 0;
    transform: scale(1.2) translateY(-20px);
    box-shadow: 0 0 0 rgba(138, 43, 226, 0);
  }
  50% {
    transform: scale(0.95) translateY(5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    box-shadow: 
      0 0 25px rgba(138, 43, 226, 0.4),
      inset 0 0 40px rgba(0, 0, 0, 0.4),
      0 20px 40px rgba(0, 0, 0, 0.8);
  }
}

@keyframes victory-glow {
  0% {
    text-shadow: 
      0 0 10px rgba(222, 184, 135, 0.6),
      0 0 20px rgba(222, 184, 135, 0.3);
  }
  100% {
    text-shadow: 
      0 0 15px rgba(222, 184, 135, 0.9),
      0 0 30px rgba(222, 184, 135, 0.5),
      0 0 45px rgba(222, 184, 135, 0.2);
  }
}

@keyframes defeat-pulse {
  0%, 100% {
    text-shadow: 
      0 0 8px rgba(138, 43, 226, 0.5),
      0 0 16px rgba(138, 43, 226, 0.2);
  }
  50% {
    text-shadow: 
      0 0 12px rgba(138, 43, 226, 0.7),
      0 0 24px rgba(138, 43, 226, 0.4),
      0 0 36px rgba(138, 43, 226, 0.1);
  }
}

/* ========== MOBILE RESPONSIVENESS ========== */
@media (max-width: 768px) {
  .victory-screen, .defeat-screen {
    /*padding: 30px 20px;
    margin: 20px;*/
  }
  
  .win-particle, .lose-particle {
    width: 3px;
    height: 3px;
  }
  
  .particle-container.win-particles .win-particle {
    animation-duration: 1.5s;
  }
  
  .particle-container.lose-particles .lose-particle {
    animation-duration: 2s;
  }
}

/* ========== SECTION HEADERS ========== */
.section-header {
  display: none;
}

.section-header.show {
  display: block;
}

.section-header.hidden {
  display: none;
}

/* ==========================================
   6. CARD SYSTEM & ANIMATIONS
   ========================================== */

/* ========== CARD SYSTEM ========== */
.card-flip {
  width: 120px;
  height: 170px;
  margin: 4px;
  position: relative;
  cursor: pointer;
  transition: all 0.4s ease;
  z-index: 1;
}

/* ========== HAND CARD SYSTEM (UNCHANGED) ========== */
#player-hand .card-flip {
  margin-left: -30px;
  transform-origin: bottom center;
  transition: all 0.4s ease;
}

#player-hand .card-flip:first-child { margin-left: 4px; }
#player-hand .card-flip:nth-child(1) { transform: rotate(-8deg); }
#player-hand .card-flip:nth-child(2) { transform: rotate(-4deg); }
#player-hand .card-flip:nth-child(3) { transform: rotate(0deg); }
#player-hand .card-flip:nth-child(4) { transform: rotate(4deg); }
#player-hand .card-flip:nth-child(5) { transform: rotate(8deg); }
#player-hand .card-flip:nth-child(6) { transform: rotate(10deg); }

#player-hand:hover .card-flip { margin-left: -20px; z-index: 2; }
#player-hand .card-flip:hover {
  transform: rotate(0deg) translateY(-15px) scale(1.03) !important;
  z-index: 10 !important;
  margin-left: 15px;
  margin-right: 15px;
}

#player-hand .card-flip.card-played {
  opacity: 1.0;              
  filter: grayscale(0.5) brightness(0.7);  /* Darker but not transparent */
  pointer-events: none;
  z-index: 0;
}

/* ========== NEW MARKET CARD OVERLAPPING SYSTEM ========== */
#market .card-flip {
  margin-left: -25px;
  transform-origin: center center;
  transition: all 0.4s ease;
  z-index: 1;
}

#market .card-flip:first-child { 
  margin-left: 4px; 
}

/* No rotation for market cards - keep them horizontal */
#market .card-flip:nth-child(1) { transform: rotate(0deg); }
#market .card-flip:nth-child(2) { transform: rotate(0deg); }
#market .card-flip:nth-child(3) { transform: rotate(0deg); }
#market .card-flip:nth-child(4) { transform: rotate(0deg); }
#market .card-flip:nth-child(5) { transform: rotate(0deg); }

/* Container hover - cards spread out */
#market:hover .card-flip { 
  margin-left: -15px; 
  z-index: 2; 
}

/* Individual card hover - lift and scale without rotation */
#market .card-flip:hover {
  transform: rotate(0deg) translateY(-12px) scale(1.05) !important;
  z-index: 10 !important;
  margin-left: 12px;
  margin-right: 12px;
}

/* Purchased cards stay in place but dimmed */
#market .card-flip.market-bought {
  opacity: 1.0;              /* Changed from 0.7 to 1.0 */
  filter: grayscale(0.5) brightness(0.7);  /* Dimmed but not transparent */
  z-index: 0;
}

/* Enhanced market card hover glow */
#market .card-flip:hover .card-front {
  border-color: rgba(222, 184, 135, 0.8);
  box-shadow: 
    0 5px 15px rgba(222, 184, 135, 0.3),
    0 0 20px rgba(222, 184, 135, 0.2);
}

/* ========== CARD VISUAL STYLES (SHARED) ========== */
.card-flip-inner {
  position: relative;
  background: rgba(33, 44, 99, 1.0);  /* Solid dark backdrop */
  width: 100%;
  height: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  transition: opacity 0.3s ease;
}

.card-front {
  background: linear-gradient(135deg, 
    rgba(25, 25, 45, 0.98) 0%, 
    rgba(15, 15, 35, 0.95) 30%,
    rgba(20, 20, 40, 0.98) 70%,
    rgba(10, 10, 30, 0.95) 100%);
  border: 2px solid rgba(138, 43, 226, 0.4);
  color: #f5f5f5;
  opacity: 1;
  z-index: 2;
  text-align: center !important;
  padding: 10px 8px;
  box-sizing: border-box;
  word-wrap: break-word;
  
  /* Setup for background images */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}



.card-front > div:first-child {
  text-align: center !important;
  display: block !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: 0 5px !important;
  box-sizing: border-box !important;
  line-height: 1.1 !important;
}

.card-front div {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
}

.card-front:hover {
  border-color: rgba(222, 184, 135, 0.8);
  box-shadow: 0 5px 15px rgba(222, 184, 135, 0.3);
}

/* ==========================================
   CARD BACKGROUND SYSTEM - CLEAN VERSION
   Replace the entire card background section with this
   ========================================== */

/* ========== BASE CARD BACKGROUNDS ========== */
/* Focus Cards - Golden Orb Background */
[data-card-name*="Focus"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.2) 0%, 
      rgba(15, 15, 35, 0.4) 30%,
      rgba(20, 20, 40, 0.6) 70%,
      rgba(10, 10, 30, 0.8) 100%),
    url('images/cards/focus-card-120.png');
}

/* Move Cards - Footprints Background */
[data-card-name*="Move"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.2) 0%, 
      rgba(15, 15, 35, 0.4) 30%,
      rgba(20, 20, 40, 0.6) 70%,
      rgba(10, 10, 30, 0.8) 100%),
    url('images/cards/move-card-120.png');
}

/* ========== DEAD/SHADOW CARDS ========== */
[data-card-name*="Shadow (dead)"] .card-front,
[data-card-name*="dead"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(43, 54, 109, .2) 0%,    /* Lighter version of your blue */
      rgba(23, 34, 89, .4) 30%,    /* Darker version */
      rgba(38, 49, 104, .6) 70%,   /* Medium version */
      rgba(18, 29, 84, .8) 100%),  /* Darkest version */
    url('images/cards/dead-card-120.png');
  
  border-color: rgba(80, 40, 80, 0.8) !important;
  color: rgba(255, 255, 255, 0.7) !important;
}

/* Make dead cards look more ominous */
[data-card-name*="Shadow (dead)"] .card-front:hover,
[data-card-name*="dead"] .card-front:hover {
  border-color: rgba(120, 60, 120, 0.9) !important;
  box-shadow: 0 5px 15px rgba(80, 40, 80, 0.4) !important;
}

/* ========== DEFENSIVE CARDS ========== */
/* Shadow Blocker - Protective barrier theme */
[data-card-name*="Shadow Blocker"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/shadow-blocker-card-120.png');
}

/* Spirit Guide - Mystical protection theme */
[data-card-name*="Spirit Guide"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/spirit-guide-card-120.png');
}

/* ========== MYSTICAL/VISION CARDS ========== */
/* Dream Sight - Foresight/crystal ball theme */
[data-card-name*="Dream Sight"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/dream-sight-card-120.png');
}

/* Dream Echo - Time manipulation/replay theme */
[data-card-name*="Dream Echo"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/dream-echo-card-120.png');
}

/* Ethereal Leap - Teleportation/void travel theme */
[data-card-name*="Ethereal Leap"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/ethereal-leap-card-120.png');
}

/* ========== SAFE MOVEMENT CARDS ========== */
/* Swift Step - Quick evasion theme */
[data-card-name*="Swift Step"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/swift-step-card-120.png');
}

/* Void Step - Void walking theme */
[data-card-name*="Void Step"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/void-step-card-120.png');
}

/* Shadow Walk - Shadow manipulation theme */
[data-card-name*="Shadow Walk"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/shadow-walk-card-120.png');
}

/* ========== RESOURCE/TREASURE CARDS ========== */
/* Lucky Find - Treasure hunting theme */
[data-card-name*="Lucky Find"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/lucky-find-card-120.png');
}

/* Coin Burst - Energy explosion theme */
[data-card-name*="Coin Burst"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/coin-burst-card-120.png');
}

/* Essence Tap - Energy siphoning theme */
[data-card-name*="Essence Tap"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/essence-tap-card-120.png');
}

/* ========== SPECIAL CARDS ========== */
/* Fragment 2pts - Enhanced fragment theme */
[data-card-name*="Fragment 2pts"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/fragment-2pts-card-120.png');
}

/* Mist Walker - Mystical travel theme */
[data-card-name*="Mist Walker"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/mist-walker-card-120.png');
}

/* ========== ADVANCED MOVEMENT CARDS ========== */
/* Astral Drift - Cosmic travel theme */
[data-card-name*="Astral Drift"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/astral-drift-card-120.png');
}

/* Phantom Step - Ghostly movement theme */
[data-card-name*="Phantom Step"] .card-front {
  background-image: 
    linear-gradient(135deg, 
      rgba(25, 25, 45, 0.45) 0%, 
      rgba(15, 15, 35, 0.40) 30%,
      rgba(20, 20, 40, 0.45) 70%,
      rgba(10, 10, 30, 0.40) 100%),
    url('images/cards/phantom-step-card-120.png');
}


.card-back {
  background: linear-gradient(135deg, 
    rgba(43, 54, 109, 1) 0%,    /* Lighter version of your blue */
    rgba(23, 34, 89, 1) 30%,    /* Darker version */
    rgba(38, 49, 104, 1) 70%,   /* Medium version */
    rgba(18, 29, 84, 1) 100%);  /* Darkest version */
  border: 2px solid rgba(138, 43, 226, 0.6);
  color: transparent;
  opacity: 0;
  z-index: 1;
  position: relative;
}

.card-back::after {
  content: '✧';
  position: absolute;
  font-size: 2.2em;
  color: rgba(138, 43, 226, 0.8);
  text-shadow: 0 0 15px rgba(138, 43, 226, 0.8);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: gentle-glow 3s ease-in-out infinite alternate;
}

.card-flip-inner.played .card-front {
  opacity: 0;
  z-index: 1;
}

.card-flip-inner.played .card-back {
  opacity: 1;
  z-index: 2;
}

.cost {
  font-size: 0.95em;
  color: rgba(222, 184, 135, 0.95);
  font-weight: bold;
  margin-top: 8px;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  border: 1px solid rgba(222, 184, 135, 0.4);
}

.card-flip.market-bought .card-flip-inner {
  animation: simple-market-flip 0.3s ease-in-out forwards;
}

.card-flip.market-bought .card-front {
  opacity: 0;
}

.card-flip.market-bought .card-back {
  opacity: 1;
}

.card-flip.new-card {
  animation: cardAppear 0.6s ease forwards;
}

/* ========== PHASE SYSTEM ENLARGED CARDS ========== */
.cards-enlarged .card-flip {
  width: 156px;
  height: 221px;
}

.cards-enlarged .card-flip .card-front,
.cards-enlarged .card-flip .card-back {
  font-size: 1.4em;
}

/* Enlarged hand cards */
.cards-enlarged#player-hand .card-flip {
  margin-left: -45px;
}

.cards-enlarged#player-hand:hover .card-flip {
  margin-left: -25px;
}

/* Enlarged market cards */
.cards-enlarged#market .card-flip {
  margin-left: -35px;
}

.cards-enlarged#market:hover .card-flip {
  margin-left: -20px;
}

.cards-enlarged#market .card-flip:hover {
  margin-left: 15px;
  margin-right: 15px;
  transform: rotate(0deg) translateY(-15px) scale(1.05) !important;
}

.cards-enlarged {
  min-height: 240px;
  padding: 15px 0;
  margin: 15px 0;
  gap: 12px;
  justify-content: center;
  align-items: flex-start;
}

/* Phase visibility controls */
.phase-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-20px);
  transition: all 0.5s ease;
  pointer-events: none;
}

.phase-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: all 0.5s ease;
  pointer-events: auto;
}

#market.phase-hidden,
#player-hand.phase-hidden {
  display: none !important;
}

#market.phase-visible,
#player-hand.phase-visible {
  display: flex !important;
}

/* ==========================================
   7. MAP SYSTEM & GAME ELEMENTS
   ========================================== */

/* ========== MAP SYSTEM ========== */
.node { 
  width: 40px; 
  height: 40px; 
  border-radius: 50%; 
  background: rgba(192, 192, 192, 0.3);
  border: 2px solid rgba(192, 192, 192, 0.6);
  margin: 5px; 
  position: relative;
  cursor: help;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
}

.node:hover {
  border-color: rgba(222, 184, 135, 0.8);
  background: rgba(192, 192, 192, 0.4);
}

.node.encounter-active {
  animation: encounterBlast 1.2s ease-in-out !important;
  z-index: 1000 !important;
  position: relative !important;
  transform-origin: center !important;
}

.node.encounter-active::before {
  content: '' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: 0 !important;
  height: 0 !important;
  border-radius: 50% !important;
  background: rgba(255, 0, 255, 0.5) !important;
  transform: translate(-50%, -50%) !important;
  animation: massiveRipple 1.2s ease-out !important;
  pointer-events: none !important;
  z-index: 999 !important;
}

/* Updated Dream Map icons with custom images */
.player { 
  position: absolute; 
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  
  /* Custom image setup */
  width: 32px;
  height: 32px;
  background-image: url('images/icons/player-icon-48.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 0 8px rgba(0, 255, 255, 0.8));
}

.fragment { 
  position: absolute; 
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  
  /* Custom image setup */
  width: 32px;
  height: 32px;
  background-image: url('images/icons/fragment-icon-48.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 0 6px rgba(222, 184, 135, 0.8));
}

.encounter { 
  position: absolute; 
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  
  /* Custom image setup */
  width: 32px;
  height: 32px;
  background-image: url('images/icons/encounter-icon-48.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 0 6px rgba(138, 43, 226, 0.7));
}

/* ==========================================
   8. BUTTONS, LEGEND & TOOLTIPS
   ========================================== */

/* ========== BUTTONS ========== */
#restart-btn, #end-turn-btn { 
  margin: 15px 5px; 
  padding: 18px 36px; 
  border: 1px solid rgba(222, 184, 135, 0.8); 
  border-radius: 8px; 
  background: rgba(0, 0, 0, 0.4); 
  color: rgba(222, 184, 135, 0.9); 
  font-weight: bold; 
  font-size: 1.2rem; 
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  font-family: 'Source Sans Pro', sans-serif;
  display: block;
  margin-left: auto;
  margin-right: auto;
  min-width: 140px;
}

#restart-btn:hover, #end-turn-btn:hover { 
  background: rgba(50, 50, 70, 0.6);
  border-color: rgba(222, 184, 135, 0.8);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(222, 184, 135, 0.2);
}

/* ========== LEGEND ========== */
#legend {
  background: rgba(0, 0, 0, 0.4);
  padding: 10px;
  border-radius: 8px;
  margin: 25px auto 15px auto;
  max-width: 800px;
  font-size: 1.1em;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(138, 43, 226, 0.3);
  text-align: center;
}

.legend-item {
  display: inline-block;
  margin: 0 15px;
}

.legend-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

/* ========== TOOLTIPS ========== */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 0.9em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
  border: 1px solid rgba(138, 43, 226, 0.5);
}

.tooltip:hover::after {
  opacity: 1;
}

.resource-item::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--hud-hover-speed);
  z-index: 1000;
  border: 1px solid rgba(138, 43, 226, 0.5);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.resource-item:hover::after {
  opacity: 1;
}

/* ==========================================
   9. TUTORIAL & INTERACTIVE ELEMENTS
   ========================================== */

/* ========== TUTORIAL STYLES ========== */
#tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.tutorial-content {
  text-align: center;
  color: white;
  max-width: 600px;
  padding: 20px;
}

.tutorial-text {
  font-size: 1.6rem;
  margin-bottom: 20px;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.tutorial-text.fade-in {
  opacity: 1;
}

.tutorial-overlay-text {
  position: fixed;
  background: rgba(222, 184, 135, 0.9);
  color: #000;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 1.1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.tutorial-overlay-text.tutorial-overlay-visible {
  opacity: 1;
}

.tutorial-skip {
  background: rgba(138, 43, 226, 0.3);
  border: 1px solid rgba(138, 43, 226, 0.6);
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tutorial-skip:hover {
  background: rgba(138, 43, 226, 0.5);
}

.tutorial-highlight {
  position: relative;
  z-index: 9999;
  border: 3px solid rgba(222, 184, 135, 0.8) !important;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.tutorial-glow {
  box-shadow: 0 0 20px rgba(222, 184, 135, 0.6) !important;
}

.tutorial-pulse {
  animation: tutorial-pulse 1s infinite;
}

.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* ==========================================
   10. MOBILE RESPONSIVE
   ========================================== */

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 768px) {
  /* ========== COMPACT GAME LAYOUT ========== */
  #game { 
    padding: 8px; /* Reduced from 20px */
  }
  
  body, html { 
    font-size: 16px; 
  }

  /* ========== ULTRA-COMPACT HUD ========== */
  #hud {
    flex-direction: column;
    gap: 8px; /* Reduced from 20px */
    margin: 8px; /* Reduced from 15px */
    padding: 12px 16px; /* Reduced from 20px 30px */
    font-size: 1rem; /* Reduced from 1.3rem */
  }
  
  .hud-info {
    min-width: auto;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px; /* Reduced from 25px */
    font-size: 0.9rem;
  }
  
  .resource-item {
    padding: 4px 8px; /* Reduced from 8px 12px */
    font-size: 0.85rem;
    min-height: 32px; /* Reduced from 40px */
    max-height: 32px;
  }
  
  .resource-icon {
    font-size: 1.1rem; /* Reduced from 1.4rem */
    width: 20px; /* Custom icon sizing for mobile */
    height: 20px;
  }

  /* Mobile map icon sizing */
  .player {
    width: 16px;
    height: 16px;
  }
  
  .fragment, .encounter {
    width: 12px;
    height: 12px;
  }
  
  .resource-value {
    font-size: 1rem; /* Reduced from 1.2rem */
    min-width: 16px; /* Reduced from 20px */
  }

  /* ========== MICRO MUSIC CONTROLS ========== */
  .hud-controls {
    gap: 8px;
    align-items: center;
    justify-content: center;
    width: 100%;
  }
  
  .hud-button {
    padding: 6px 10px; /* Much smaller */
    font-size: 0.8rem; /* Smaller text */
    gap: 4px;
    min-width: auto;
  }
  
  .volume-control {
    padding: 6px 10px; /* Reduced from 10px 15px */
    gap: 6px;
  }
  
  .volume-slider {
    width: 60px; /* Reduced from 120px */
  }

  /* ========== COMPACT LOG SYSTEM ========== */
  #log {
    min-height: 50px; /* Reduced from 80px */
    max-height: 80px; /* Allow expansion */
    font-size: 1.1rem; /* Reduced from 1.5rem */
    padding: 10px 15px; /* Reduced from 20px 30px */
    margin: 8px; /* Reduced from 15px */
    line-height: 1.3; /* Better for wrapping */
    
    /* Enable text wrapping on mobile */
    white-space: normal;
    overflow: visible;
    word-break: break-word;
  }

  /* ========== COMPACT MAP CONTAINER WITH BREATHING ROOM ========== */
  .map-container {
    min-height: 120px; /* Reduced from 150px */
    max-height: 120px;
    padding: 8px; /* Increased for better spacing */
    margin: 20px auto; /* Increased for separation from HUD and log */
  }

  /* ========== COMPACT SECTION HEADERS ========== */
  h2, .section-header {
    font-size: 1.4rem; /* Reduced from 1.8rem */
    margin: 12px 0 6px 0; /* Reduced margins */
  }

  /* ========== COMPACT CARD AREAS ========== */
  #market, #player-hand {
    min-height: 140px; /* Reduced from 160px */
    margin: 15px 0; /* Reduced from 25px 0 */
  }
  
  .button-container {
    height: 60px; /* Reduced from 70px */
    margin: 12px 0; /* Reduced from 20px 0 */
  }

  /* ========== COMPACT BUTTONS ========== */
  #restart-btn, #end-turn-btn { 
    padding: 12px 24px; /* Reduced from 18px 36px */
    font-size: 1rem; /* Reduced from 1.2rem */
    margin: 8px 4px; /* Reduced from 15px 5px */
    min-width: 120px; /* Reduced from 140px */
  }

  /* ========== GAME SECTIONS SPACING ========== */
  .game-section {
    margin: 12px 0; /* Reduced from 20px 0 */
  }

  /* ========== EXISTING CARD RULES (keeping your working styles) ========== */
  /* Hand cards mobile */
  #player-hand .card-flip { margin-left: -20px; }
  #player-hand:hover .card-flip { margin-left: -12px; }
  #player-hand .card-flip:hover {
    margin-left: 8px;
    margin-right: 8px;
    transform: rotate(0deg) translateY(-8px) scale(1.02) !important;
  }

  /* Market cards mobile */
  #market .card-flip { 
    margin-left: -30px; /* Tighter overlap on mobile */
  }
  
  #market:hover .card-flip { 
    margin-left: -20px; 
  }
  
  #market .card-flip:hover {
    margin-left: 8px;
    margin-right: 8px;
    transform: rotate(0deg) translateY(-8px) scale(1.03) !important;
  }

  .card-flip { width: 85px; height: 120px; }
  .card-front, .card-back { font-size: 0.9em; }

  .cards-enlarged .card-flip {
    width: 85px;
    height: 120px;
  }
  
  .cards-enlarged .card-flip .card-front,
  .cards-enlarged .card-flip .card-back {
    font-size: 0.9em;
  }
  
  .cards-enlarged .card-flip .cost {
    font-size: 0.8em;
  }
  
  .cards-enlarged {
    min-height: 140px; /* Reduced from 160px */
    gap: 6px; /* Reduced from 8px */
    padding: 10px 0; /* Reduced from 15px 0 */
    margin: 10px 0; /* Reduced from 15px 0 */
  }

  .cards-enlarged#market .card-flip {
    margin-left: -35px;
  }
  
  .cards-enlarged#market:hover .card-flip {
    margin-left: -25px;
  }

  /* ========== COMPACT OVERLAYS ========== */
  .cruxflare-card {
    width: 160px; /* Reduced from 180px */
    height: 240px; /* Reduced from 260px */
    padding: 12px; /* Reduced from 15px */
  }
  
  .cruxflare-title {
    font-size: 1.1rem; /* Down from 1.3rem */
    line-height: 1.1; /* Tighter spacing for 2-line titles */
    margin-bottom: 12px; /* Slightly less margin */
  }
  
  .cruxflare-icon {
    font-size: 2.4rem; /* Reduced from 2.8rem */
    margin: 12px 0; /* Reduced from 15px 0 */
  }
  
  .cruxflare-effect {
    margin-top: auto;
    margin-bottom: 25px;  /* <-- ADD THIS LINE */
    font-size: 0.8rem; /* Reduced from 0.9rem */
    padding: 8px 10px; /* Reduced from 10px 12px */
  }
}

/* ==========================================
   11. KEYFRAME ANIMATIONS
   ========================================== */

/* ========== KEYFRAME ANIMATIONS ========== */
@keyframes mistDrift1 {
  0%, 100% { 
    transform: translate(0, 0) rotate(0deg) scale(1); 
  }
  25% { 
    transform: translate(-30px, -20px) rotate(1deg) scale(1.05); 
  }
  50% { 
    transform: translate(20px, -40px) rotate(-1deg) scale(0.95); 
  }
  75% { 
    transform: translate(-10px, -30px) rotate(0.5deg) scale(1.02); 
  }
}

@keyframes mistDrift2 {
  0%, 100% { 
    transform: translate(0, 0) rotate(0deg) scale(1); 
  }
  33% { 
    transform: translate(25px, -15px) rotate(-0.8deg) scale(1.03); 
  }
  66% { 
    transform: translate(-15px, -35px) rotate(0.8deg) scale(0.97); 
  }
}

@keyframes tendrilFlow {
  0% { 
    transform: translateX(0) translateY(0) skewX(0deg); 
  }
  25% { 
    transform: translateX(-20px) translateY(-10px) skewX(1deg); 
  }
  50% { 
    transform: translateX(15px) translateY(-20px) skewX(-1deg); 
  }
  75% { 
    transform: translateX(-10px) translateY(-15px) skewX(0.5deg); 
  }
  100% { 
    transform: translateX(0) translateY(0) skewX(0deg); 
  }
}

@keyframes float {
  0% { 
    transform: translateY(100vh) translateX(0) rotate(0deg) scale(0.5); 
    opacity: 0; 
  }
  5% { 
    opacity: 0.8;
    transform: translateY(95vh) translateX(10px) rotate(18deg) scale(0.8);
  }
  50% {
    transform: translateY(50vh) translateX(var(--drift, 50px)) rotate(180deg) scale(1);
    opacity: 0.6;
  }
  95% { 
    opacity: 0.4; 
  }
  100% { 
    transform: translateY(-10vh) translateX(calc(var(--drift, 50px) * 2)) rotate(360deg) scale(0.3); 
    opacity: 0; 
  }
}

@keyframes gentle-pulse {
  0%, 100% { 
    opacity: 1; 
    text-shadow: 0 0 8px currentColor;
  }
  50% { 
    opacity: 0.8; 
    text-shadow: 0 0 12px currentColor, 0 0 20px currentColor;
  }
}

@keyframes gentle-glow {
  0% { text-shadow: 0 0 10px rgba(138, 43, 226, 0.6); }
  100% { text-shadow: 0 0 20px rgba(138, 43, 226, 1); }
}

@keyframes cruxflare-pulse {
  0% { 
    transform: scale(1);
    border-color: rgba(138, 43, 226, 0.9);
    box-shadow: 
      0 0 20px rgba(138, 43, 226, 0.6),
      0 4px 15px rgba(0, 0, 0, 0.5);
  }
  50% { 
    transform: scale(1.02);
    border-color: rgba(160, 60, 255, 1);
    box-shadow: 
      0 0 30px rgba(160, 60, 255, 0.8),
      0 6px 20px rgba(0, 0, 0, 0.6);
  }
  100% { 
    transform: scale(1);
    border-color: rgba(138, 43, 226, 0.9);
    box-shadow: 
      0 0 20px rgba(138, 43, 226, 0.6),
      0 4px 15px rgba(0, 0, 0, 0.5);
  }
}

@keyframes encounterBlast {
  0% { 
    transform: scale(1);
    background: rgba(192, 192, 192, 0.3);
    border: 2px solid rgba(192, 192, 192, 0.6);
    box-shadow: 0 0 0 rgba(255, 0, 255, 0);
  }
  
  25% { 
    transform: scale(2);
    background: rgba(255, 0, 255, 1);
    border: 4px solid rgba(255, 0, 255, 1);
    box-shadow: 0 0 40px rgba(255, 0, 255, 1);
  }
  
  50% { 
    transform: scale(2.5);
    background: rgba(255, 100, 255, 1);
    border: 6px solid rgba(255, 100, 255, 1);
    box-shadow: 0 0 60px rgba(255, 100, 255, 1);
  }
  
  75% { 
    transform: scale(1.8);
    background: rgba(255, 0, 255, 0.8);
    border: 4px solid rgba(255, 0, 255, 0.8);
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.8);
  }
  
  100% { 
    transform: scale(1);
    background: rgba(192, 192, 192, 0.3);
    border: 2px solid rgba(192, 192, 192, 0.6);
    box-shadow: 0 0 0 rgba(255, 0, 255, 0);
  }
}

@keyframes massiveRipple {
  0% {
    width: 0;
    height: 0;
    opacity: 1;
    background: rgba(255, 0, 255, 0.8);
  }
  50% {
    width: 200px;
    height: 200px;
    opacity: 0.5;
    background: rgba(255, 100, 255, 0.6);
  }
  100% {
    width: 300px;
    height: 300px;
    opacity: 0;
    background: rgba(255, 0, 255, 0);
  }
}

@keyframes simple-market-flip {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes cardAppear {
  0% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes game-over-appear {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes tutorial-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes pulse-warning {
  0%   { 
    border-color: rgba(138, 43, 226, 0.3); 
    box-shadow: 0 0 5px rgba(138, 43, 226, 0.2);
  }
  50%  { 
    border-color: rgba(138, 43, 226, 0.8); 
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.5);
  }
  100% { 
    border-color: rgba(138, 43, 226, 0.3);
    box-shadow: 0 0 5px rgba(138, 43, 226, 0.2);
  }
}

@keyframes pulse-danger {
  0%   { 
    border-color: rgba(255, 100, 100, 0.4); 
    background: rgba(0, 0, 0, 0.4); 
    box-shadow: 0 0 5px rgba(255, 100, 100, 0.3);
  }
  50%  { 
    border-color: rgba(255, 100, 100, 0.9); 
    background: rgba(255, 100, 100, 0.1); 
    box-shadow: 0 0 20px rgba(255, 100, 100, 0.6);
  }
  100% { 
    border-color: rgba(255, 100, 100, 0.4); 
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 5px rgba(255, 100, 100, 0.3);
  }
}
