/* ==========================================================================
   Tome  Premium Trading Card CSS (v4)
   Collectible card with hero image, stat rings, element theming, rarity FX,
   holographic foils, element textures, sparkle particles, noise overlay,
   edge gilding, card back, graded slab, 3D flip reveal.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Custom Properties & Defaults
   -------------------------------------------------------------------------- */

:root {
  --card-bg: #12141a;
  --card-text: #e4e8f0;
  --card-text-muted: #888e9e;
  --card-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;

  /* Element defaults (overridden per .element-*) */
  --element-primary: #888;
  --element-secondary: #aaa;
  --element-glow: rgba(136, 136, 136, 0.3);
  --element-texture: none;
  --element-ring-shadow: none;
}

/* --------------------------------------------------------------------------
   1. Element Types
   -------------------------------------------------------------------------- */

.card.element-fire {
  --element-primary: #FF6B35;
  --element-secondary: #FF9A5C;
  --element-glow: rgba(255, 107, 53, 0.4);
  --element-ring-shadow: 0 0 8px rgba(255, 107, 53, 0.5);
}

.card.element-water {
  --element-primary: #3B82F6;
  --element-secondary: #60A5FA;
  --element-glow: rgba(59, 130, 246, 0.4);
  --element-ring-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.card.element-earth {
  --element-primary: #92713F;
  --element-secondary: #B8956A;
  --element-glow: rgba(146, 113, 63, 0.4);
  --element-ring-shadow: 0 0 8px rgba(146, 113, 63, 0.5);
}

.card.element-air {
  --element-primary: #A3E4D7;
  --element-secondary: #D5F5E3;
  --element-glow: rgba(163, 228, 215, 0.35);
  --element-ring-shadow: 0 0 8px rgba(163, 228, 215, 0.4);
}

.card.element-electric {
  --element-primary: #FFD700;
  --element-secondary: #FFF176;
  --element-glow: rgba(255, 215, 0, 0.45);
  --element-ring-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.card.element-shadow {
  --element-primary: #6B21A8;
  --element-secondary: #9333EA;
  --element-glow: rgba(107, 33, 168, 0.45);
  --element-ring-shadow: 0 0 8px rgba(107, 33, 168, 0.5);
}

.card.element-light {
  --element-primary: #FFF8DC;
  --element-secondary: #FFFAED;
  --element-glow: rgba(255, 248, 220, 0.35);
  --element-ring-shadow: 0 0 8px rgba(255, 248, 220, 0.4);
}

.card.element-void {
  --element-primary: #4a0080;
  --element-secondary: #7c3aed;
  --element-glow: rgba(74, 0, 128, 0.5);
  --element-ring-shadow: 0 0 8px rgba(74, 0, 128, 0.5);
}

/* --------------------------------------------------------------------------
   1b. Element Textures (overlaid on card art)
   -------------------------------------------------------------------------- */

.card-element-texture {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s;
}

.card.element-fire .card-element-texture {
  background:
    radial-gradient(2px 2px at 20% 30%, rgba(255, 120, 30, 0.6), transparent),
    radial-gradient(2px 2px at 60% 20%, rgba(255, 80, 0, 0.5), transparent),
    radial-gradient(1px 1px at 80% 60%, rgba(255, 160, 50, 0.4), transparent),
    radial-gradient(2px 2px at 40% 70%, rgba(255, 100, 20, 0.5), transparent),
    radial-gradient(1px 1px at 10% 80%, rgba(255, 140, 40, 0.3), transparent);
  animation: fire-flicker 2s ease-in-out infinite alternate;
  opacity: 0.7;
}

@keyframes fire-flicker {
  0% { opacity: 0.5; filter: brightness(1); }
  50% { opacity: 0.8; filter: brightness(1.2); }
  100% { opacity: 0.6; filter: brightness(0.9); }
}

.card.element-water .card-element-texture {
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 8px,
      rgba(59, 130, 246, 0.04) 8px,
      rgba(59, 130, 246, 0.04) 10px
    );
  animation: water-ripple 4s ease-in-out infinite;
  opacity: 0.6;
}

@keyframes water-ripple {
  0%, 100% { background-position: 0 0; }
  50% { background-position: 0 12px; }
}

.card.element-earth .card-element-texture {
  background:
    radial-gradient(3px 3px at 15% 25%, rgba(146, 113, 63, 0.3), transparent),
    radial-gradient(2px 2px at 45% 55%, rgba(120, 90, 40, 0.25), transparent),
    radial-gradient(4px 4px at 75% 35%, rgba(160, 130, 70, 0.2), transparent),
    radial-gradient(2px 2px at 30% 80%, rgba(140, 110, 50, 0.25), transparent);
  opacity: 0.5;
}

.card.element-air .card-element-texture {
  background:
    linear-gradient(135deg, transparent 40%, rgba(163, 228, 215, 0.06) 50%, transparent 60%);
  background-size: 200% 200%;
  animation: air-sweep 5s ease-in-out infinite;
  opacity: 0.7;
}

@keyframes air-sweep {
  0% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}

.card.element-electric .card-element-texture {
  background:
    linear-gradient(87deg, transparent 48%, rgba(255, 215, 0, 0.15) 49%, rgba(255, 215, 0, 0.15) 50%, transparent 51%),
    linear-gradient(263deg, transparent 48%, rgba(255, 240, 100, 0.1) 49%, rgba(255, 240, 100, 0.1) 50%, transparent 51%);
  animation: electric-crackle 0.8s steps(2) infinite;
  opacity: 0.6;
}

@keyframes electric-crackle {
  0% { opacity: 0.6; }
  25% { opacity: 0.2; }
  50% { opacity: 0.7; }
  75% { opacity: 0.3; }
  100% { opacity: 0.6; }
}

.card.element-shadow .card-element-texture {
  background:
    radial-gradient(ellipse at 30% 50%, rgba(0, 0, 0, 0.3), transparent 60%),
    radial-gradient(ellipse at 70% 30%, rgba(107, 33, 168, 0.15), transparent 50%);
  animation: shadow-drift 6s ease-in-out infinite alternate;
  opacity: 0.7;
}

@keyframes shadow-drift {
  0% { background-position: 0% 0%; filter: brightness(0.9); }
  100% { background-position: 20% 10%; filter: brightness(1.1); }
}

.card.element-light .card-element-texture {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 248, 220, 0.15), transparent 60%);
  animation: light-pulse 3s ease-in-out infinite alternate;
  opacity: 0.6;
}

@keyframes light-pulse {
  0% { opacity: 0.4; }
  100% { opacity: 0.8; }
}

.card.element-void .card-element-texture {
  background:
    radial-gradient(circle at 50% 50%, rgba(74, 0, 128, 0.2), transparent 50%),
    radial-gradient(circle at 20% 80%, rgba(124, 58, 237, 0.1), transparent 40%);
  animation: void-warp 4s ease-in-out infinite alternate;
  opacity: 0.7;
}

@keyframes void-warp {
  0% { transform: scale(1); filter: hue-rotate(0deg); }
  100% { transform: scale(1.05); filter: hue-rotate(20deg); }
}

/* --------------------------------------------------------------------------
   2. Card Shell
   -------------------------------------------------------------------------- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  color: var(--card-text);
  font-family: var(--card-font);
  border-radius: 16px;
  border: 2px solid var(--element-primary);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 20px var(--element-glow);
  overflow: hidden;
  container-type: inline-size;
  opacity: 1;
  /* 3D tilt support */
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
  transform-style: preserve-3d;
  will-change: transform;
  cursor: grab;
  /* Shine position vars (set by JS) */
  --shine-x: 50%;
  --shine-y: 50%;
  --shine-opacity: 0;
}

/* Cursor-following spotlight */
.card-shine {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  border-radius: inherit;
  opacity: var(--shine-opacity);
  transition: opacity 0.3s ease;
  background: radial-gradient(
    circle at var(--shine-x) var(--shine-y),
    rgba(255, 255, 255, 0.35) 0%,
    rgba(255, 255, 255, 0.12) 25%,
    transparent 55%
  );
  mix-blend-mode: soft-light;
}

/* Noise / grain texture overlay */
.card-noise {
  position: absolute;
  inset: 0;
  z-index: 14;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0.06;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

/* Subtle inner edge highlight */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 10;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* --------------------------------------------------------------------------
   2b. Edge Gilding
   -------------------------------------------------------------------------- */

.card-gilding {
  position: absolute;
  inset: -1px;
  border-radius: calc(16px + 1px);
  pointer-events: none;
  z-index: -1;
}

/* Common: no gilding */
.card.rarity-common .card-gilding { display: none; }

/* Uncommon: subtle silver edge */
.card.rarity-uncommon .card-gilding {
  box-shadow: 0 0 3px rgba(176, 184, 200, 0.3);
}

/* Rare: gold edge */
.card.rarity-rare .card-gilding {
  box-shadow:
    0 0 4px rgba(212, 168, 67, 0.4),
    0 0 8px rgba(212, 168, 67, 0.2);
}

/* Epic: purple/indigo edge */
.card.rarity-epic .card-gilding {
  box-shadow:
    0 0 6px rgba(99, 102, 241, 0.5),
    0 0 12px rgba(139, 92, 246, 0.3);
}

/* Legendary: rainbow edge */
.card.rarity-legendary .card-gilding {
  background: conic-gradient(from var(--gilding-angle, 0deg),
    #ff6b6b, #ffd93d, #6bcb77, #4d96ff, #9b59b6, #ff6b6b
  );
  filter: blur(3px);
  opacity: 0.6;
  animation: gilding-rotate 4s linear infinite;
}

@property --gilding-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes gilding-rotate {
  to { --gilding-angle: 360deg; }
}

/* --------------------------------------------------------------------------
   3. Card Art (Image Area)
   -------------------------------------------------------------------------- */

.card-art {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.card-art img {
  display: block;
  width: 100%;
  height: 240px;
  object-fit: cover;
  object-position: center 30%;
}

/* Radial vignette */
.card-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(
    ellipse 70% 60% at 50% 40%,
    transparent 40%,
    rgba(0, 0, 0, 0.5) 100%
  );
}

/* Bottom gradient */
.card-gradient {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(18, 20, 26, 0.3) 30%,
    rgba(18, 20, 26, 0.7) 60%,
    #12141a 100%
  );
}

/* --------------------------------------------------------------------------
   4. Badges (float on image)
   -------------------------------------------------------------------------- */

.card-badges {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 5;
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  pointer-events: auto;
  white-space: nowrap;
}

.badge-icon {
  font-size: 0.7rem;
  line-height: 1;
}

.badge-element {
  color: var(--element-secondary);
}

.badge-rarity {
  color: #d4d4d4;
}

/* --------------------------------------------------------------------------
   5. Title Bar (overlays gradient zone)
   -------------------------------------------------------------------------- */

.card-title-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 20px 14px;
  z-index: 3;
}

.card-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.card-subtitle {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.3;
}

/* --------------------------------------------------------------------------
   6. Card Body
   -------------------------------------------------------------------------- */

.card-body {
  display: flex;
  flex-direction: column;
  padding: 0 20px 16px;
}

/* --------------------------------------------------------------------------
   7. Stat Rings (4-across grid) with element personality
   -------------------------------------------------------------------------- */

.card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 0;
}

.stat-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Animatable percentage property for stat ring fill */
@property --ring-fill {
  syntax: '<percentage>';
  initial-value: 0%;
  inherits: false;
}

/* The ring container */
.stat-ring {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  --ring-fill: calc(var(--pct) * 1%);
  background: conic-gradient(
    var(--element-primary) var(--ring-fill),
    rgba(255, 255, 255, 0.08) var(--ring-fill)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--element-ring-shadow);
  transition: box-shadow 0.3s;
}

/* SVG ring: hidden in normal mode (CSS conic-gradient is better) */
.stat-ring-svg {
  display: none;
}

/* Animate ring fill from 0% on card entrance */
.card-enter .stat-ring {
  animation: ring-fill-in 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
}

/* Stagger each stat ring */
.card-enter .stat-cell:nth-child(2) .stat-ring { animation-delay: 0.4s; }
.card-enter .stat-cell:nth-child(3) .stat-ring { animation-delay: 0.5s; }
.card-enter .stat-cell:nth-child(4) .stat-ring { animation-delay: 0.6s; }

@keyframes ring-fill-in {
  from { --ring-fill: 0%; }
  to   { --ring-fill: calc(var(--pct) * 1%); }
}

/* Inner circle */
.stat-ring::before {
  content: '';
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--card-bg);
}

/* Element-specific ring glow on high stats */
.card.element-fire .stat-ring { filter: drop-shadow(0 0 3px rgba(255, 107, 53, 0.2)); }
.card.element-water .stat-ring { filter: drop-shadow(0 0 3px rgba(59, 130, 246, 0.2)); }
.card.element-electric .stat-ring { filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.2)); }
.card.element-shadow .stat-ring { filter: drop-shadow(0 0 3px rgba(107, 33, 168, 0.2)); }
.card.element-void .stat-ring { filter: drop-shadow(0 0 3px rgba(124, 58, 237, 0.2)); }

/* Stat value text */
.stat-val {
  position: relative;
  z-index: 1;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

/* Stat label below ring */
.stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--card-text-muted);
  text-align: center;
  line-height: 1.2;
}

/* --------------------------------------------------------------------------
   8. Description
   -------------------------------------------------------------------------- */

.card-desc {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #b0b8c8;
  margin-top: 12px;
}

/* --------------------------------------------------------------------------
   9. Card Bottom (flavor text + tags)
   -------------------------------------------------------------------------- */

.card-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 12px;
  margin-top: 12px;
}

.card-flavor {
  font-size: 0.75rem;
  font-style: italic;
  color: #888;
  line-height: 1.4;
  margin: 0 0 8px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  color: #888;
}

/* ==========================================================================
   10. Rarity Tiers
   ========================================================================== */

/* --- Common: paper texture, minimal border -------------------------------- */
.card.rarity-common {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Paper grain for common cards */
.card.rarity-common .card-noise {
  opacity: 0.1;
  mix-blend-mode: overlay;
}

.card.rarity-common .badge-rarity { color: #999; }

/* --- Uncommon: silver tint ------------------------------------------------ */
.card.rarity-uncommon {
  border-color: var(--element-primary);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 12px var(--element-glow);
}

.card.rarity-uncommon .badge-rarity { color: #b0b8c8; }

/* --- Rare: gold border + shimmer sweep ------------------------------------ */
.card.rarity-rare {
  border-color: #d4a843;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 16px rgba(212, 168, 67, 0.25),
    0 0 40px rgba(212, 168, 67, 0.1);
}

.card.rarity-rare .badge-rarity { color: #d4a843; }

/* Gold shimmer sweep */
.card.rarity-rare::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 11;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(212, 168, 67, 0.07) 44%,
    rgba(212, 168, 67, 0.14) 50%,
    rgba(212, 168, 67, 0.07) 56%,
    transparent 60%
  );
  background-size: 250% 100%;
  animation: shimmer-sweep 4s ease-in-out infinite;
}

@keyframes shimmer-sweep {
  0%   { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}

/* Refractor lines on rare+ */
.card-refractor {
  position: absolute;
  inset: 0;
  z-index: 13;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0;
  mix-blend-mode: color-dodge;
}

.card.rarity-rare .card-refractor {
  opacity: 0.04;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.08) 3px,
    rgba(255, 255, 255, 0.08) 5px
  );
  animation: refractor-shift 6s linear infinite;
}

.card.rarity-epic .card-refractor {
  opacity: 0.06;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 2px,
    rgba(200, 180, 255, 0.1) 2px,
    rgba(200, 180, 255, 0.1) 4px
  );
  animation: refractor-shift 4s linear infinite;
}

.card.rarity-legendary .card-refractor {
  opacity: 0.08;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.12) 2px,
    rgba(255, 255, 255, 0.12) 4px
  );
  animation: refractor-shift 3s linear infinite;
}

@keyframes refractor-shift {
  from { background-position: 0 0; }
  to { background-position: 40px 40px; }
}

/* --- Epic: purple border + glow + pulse ---------------------------------- */
.card.rarity-epic {
  border-color: #6366f1;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 24px rgba(99, 102, 241, 0.35),
    0 0 48px rgba(139, 92, 246, 0.15);
  animation: epic-border-pulse 3s ease-in-out infinite;
}

.card.rarity-epic .badge-rarity { color: #818cf8; }

@keyframes epic-border-pulse {
  0%, 100% {
    border-color: #6366f1;
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.5),
      0 2px 8px rgba(0, 0, 0, 0.3),
      0 0 24px rgba(99, 102, 241, 0.35),
      0 0 48px rgba(139, 92, 246, 0.15);
  }
  50% {
    border-color: #818cf8;
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.5),
      0 2px 8px rgba(0, 0, 0, 0.3),
      0 0 32px rgba(99, 102, 241, 0.5),
      0 0 64px rgba(139, 92, 246, 0.25);
  }
}

/* --- Legendary: animated rainbow border + strong glow + foil ------------- */
.card.rarity-legendary {
  border: 3px solid transparent;
  background-clip: padding-box;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 28px rgba(255, 200, 50, 0.35),
    0 0 64px rgba(255, 150, 50, 0.18);
  animation: legendary-glow-pulse 3s ease-in-out infinite;
}

.card.rarity-legendary .badge-rarity {
  color: #ffd700;
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
}

@keyframes legendary-glow-pulse {
  0%, 100% {
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.5),
      0 0 28px rgba(255, 200, 50, 0.35),
      0 0 64px rgba(255, 150, 50, 0.18);
  }
  50% {
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.5),
      0 0 36px rgba(255, 200, 50, 0.55),
      0 0 80px rgba(255, 150, 50, 0.3);
  }
}

/* Holographic rainbow border via rotating gradient + mask */
.card.rarity-legendary::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: calc(16px + 3px);
  padding: 3px;
  background: linear-gradient(
    var(--legendary-angle, 0deg),
    #ff6b6b,
    #ffd93d,
    #6bcb77,
    #4d96ff,
    #9b59b6,
    #ff6b6b
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  z-index: 11;
  pointer-events: none;
  animation: legendary-border-rotate 4s linear infinite;
}

@property --legendary-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes legendary-border-rotate {
  to { --legendary-angle: 360deg; }
}

/* Fallback for browsers without @property */
@supports not (background: paint(something)) {
  @keyframes legendary-border-rotate {
    0%   { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
  }
}

/* --------------------------------------------------------------------------
   10b. Holographic Foil (Rare+ cards)
   -------------------------------------------------------------------------- */

.card-foil {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 12;
  pointer-events: none;
  opacity: 0;
}

/* Rare: subtle gold foil */
.card.rarity-rare .card-foil {
  opacity: 0.12;
  mix-blend-mode: color-dodge;
  background: linear-gradient(
    var(--foil-angle, 135deg),
    rgba(212, 168, 67, 0.3) 0%,
    rgba(255, 215, 0, 0.15) 25%,
    transparent 50%,
    rgba(212, 168, 67, 0.2) 75%,
    rgba(255, 200, 50, 0.3) 100%
  );
  animation: foil-shift 6s ease-in-out infinite alternate;
}

/* Epic: purple/blue foil */
.card.rarity-epic .card-foil {
  opacity: 0.18;
  mix-blend-mode: color-dodge;
  background: linear-gradient(
    var(--foil-angle, 135deg),
    rgba(99, 102, 241, 0.3) 0%,
    rgba(139, 92, 246, 0.2) 25%,
    transparent 45%,
    rgba(99, 102, 241, 0.15) 65%,
    rgba(168, 85, 247, 0.3) 100%
  );
  animation: foil-shift 5s ease-in-out infinite alternate;
}

/* Legendary: full rainbow holo foil */
.card.rarity-legendary .card-foil {
  opacity: 0.25;
  mix-blend-mode: color-dodge;
  background:
    repeating-linear-gradient(
      115deg,
      transparent 0px,
      transparent 2px,
      rgba(255, 255, 255, 0.15) 2px,
      rgba(255, 255, 255, 0.15) 4px
    ),
    repeating-linear-gradient(
      65deg,
      transparent 0px,
      transparent 3px,
      rgba(200, 180, 255, 0.1) 3px,
      rgba(200, 180, 255, 0.1) 5px
    ),
    linear-gradient(
      var(--foil-angle, 135deg),
      rgba(255, 80, 80, 0.25) 0%,
      rgba(255, 200, 50, 0.2) 17%,
      rgba(80, 255, 80, 0.2) 33%,
      rgba(80, 200, 255, 0.2) 50%,
      rgba(150, 80, 255, 0.25) 67%,
      rgba(255, 100, 200, 0.2) 83%,
      rgba(255, 80, 80, 0.25) 100%
    );
  animation: foil-shift 4s ease-in-out infinite alternate, foil-hue 8s linear infinite;
}

@property --foil-angle {
  syntax: '<angle>';
  initial-value: 135deg;
  inherits: false;
}

@keyframes foil-shift {
  0% { --foil-angle: 115deg; }
  100% { --foil-angle: 155deg; }
}

@keyframes foil-hue {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* --------------------------------------------------------------------------
   10c. Sparkle Particles (Legendary only)
   -------------------------------------------------------------------------- */

.card-sparkles {
  position: absolute;
  inset: 0;
  z-index: 16;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
}

.sparkle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.6);
  animation: sparkle-float linear infinite;
  opacity: 0;
}

.sparkle:nth-child(1) { left: 10%; top: 20%; animation-duration: 3s; animation-delay: 0s; }
.sparkle:nth-child(2) { left: 30%; top: 60%; animation-duration: 4s; animation-delay: 0.5s; }
.sparkle:nth-child(3) { left: 50%; top: 15%; animation-duration: 3.5s; animation-delay: 1s; }
.sparkle:nth-child(4) { left: 70%; top: 45%; animation-duration: 4.5s; animation-delay: 1.5s; }
.sparkle:nth-child(5) { left: 85%; top: 75%; animation-duration: 3s; animation-delay: 2s; }
.sparkle:nth-child(6) { left: 20%; top: 85%; animation-duration: 5s; animation-delay: 0.8s; }
.sparkle:nth-child(7) { left: 60%; top: 30%; animation-duration: 3.8s; animation-delay: 2.5s; }
.sparkle:nth-child(8) { left: 90%; top: 10%; animation-duration: 4.2s; animation-delay: 1.2s; }

@keyframes sparkle-float {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  15% { opacity: 1; transform: translateY(-5px) scale(1); }
  50% { opacity: 0.6; transform: translateY(-15px) scale(0.8); }
  85% { opacity: 1; transform: translateY(-25px) scale(1); }
  100% { opacity: 0; transform: translateY(-35px) scale(0.3); }
}

/* Only show sparkles on legendary */
.card:not(.rarity-legendary) .card-sparkles { display: none; }

/* ==========================================================================
   11. Card Flip Reveal (3D)
   ========================================================================== */

.card-flip-container {
  perspective: 1200px;
  width: 100%;
  max-width: 380px;
}

.card-flip-inner {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-flip-inner.flipped {
  transform: rotateY(180deg);
}

.card-flip-inner .card {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Card Back */
.card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: rotateY(180deg);
  border-radius: 16px;
  overflow: hidden;
  background: var(--card-bg);
  border: 2px solid rgba(201, 168, 76, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  /* Ornate pattern background */
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(201, 168, 76, 0.03) 10px,
      rgba(201, 168, 76, 0.03) 20px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 10px,
      rgba(201, 168, 76, 0.03) 10px,
      rgba(201, 168, 76, 0.03) 20px
    ),
    radial-gradient(ellipse at center, rgba(201, 168, 76, 0.06), transparent 70%);
}

.card-back-logo {
  font-family: 'Cinzel', serif;
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #c9a84c, #a07830);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-back-sub {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(201, 168, 76, 0.4);
}

.card-back-emblem {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid rgba(201, 168, 76, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: rgba(201, 168, 76, 0.3);
  margin-bottom: 0.5rem;
  background: radial-gradient(circle, rgba(201, 168, 76, 0.05), transparent);
}

/* ==========================================================================
   11b. Entrance Animation
   ========================================================================== */

.card-enter {
  animation: card-fade-in-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes card-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   12. Graded Slab Mode
   ========================================================================== */

.slab-container {
  position: relative;
  padding: 40px 12px 16px;
  border-radius: 14px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.03) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.2),
    0 8px 32px rgba(0, 0, 0, 0.4);
  /* Plastic sheen */
  overflow: hidden;
}

/* Plastic shine sweep */
.slab-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.06) 45%,
    rgba(255, 255, 255, 0.02) 55%,
    transparent 70%
  );
  transform: translateX(-100%);
  animation: slab-shine 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 20;
}

@keyframes slab-shine {
  0%, 80% { transform: translateX(-100%) rotate(45deg); }
  100% { transform: translateX(100%) rotate(45deg); }
}

/* Grade label at top */
.slab-label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.7);
  z-index: 21;
}

.slab-grade {
  font-size: 0.85rem;
  font-weight: 900;
  color: #c9a84c;
}

.slab-serial {
  font-family: 'Inter', monospace;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.08em;
}

/* ==========================================================================
   13. Export Mode
   ========================================================================== */

.card.export-mode {
  width: 380px;
  max-width: none;
  border-radius: 16px;
  box-shadow: none !important;
  animation: none !important;
}

.card.export-mode *,
.card.export-mode *::before,
.card.export-mode *::after {
  animation: none !important;
  transition: none !important;
}

/* Remove backdrop-filter for export (not rasterizable) */
.card.export-mode .badge {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(0, 0, 0, 0.55);
}

/* Hide dynamic overlays */
.card.export-mode .card-shine,
.card.export-mode .card-foil,
.card.export-mode .card-sparkles,
.card.export-mode .card-refractor,
.card.export-mode .card-element-texture,
.card.export-mode .card-gilding {
  display: none;
}

/* Keep noise for texture in export */
.card.export-mode .card-noise {
  animation: none !important;
}

/* Reset 3D transforms */
.card.export-mode {
  transform: none !important;
  perspective: none;
}

/* Stat rings: use SVG ring in export (html2canvas can't render conic-gradient) */
.card.export-mode .stat-ring {
  background: none;
  box-shadow: none;
  filter: none;
}

.card.export-mode .stat-ring-svg {
  display: block;
  position: absolute;
  inset: 0;
}

.card.export-mode .stat-ring::before {
  /* Keep the inner circle background */
  background: var(--card-bg);
}

/* Legendary art foil overlay */
.card.export-mode.rarity-legendary > .card-art::after {
  display: none;
}

/* Legendary rainbow border pseudo */
.card.export-mode.rarity-legendary::after {
  display: none;
}

/* ==========================================================================
   13b. Seasonal Card Accents
   Subtle seasonal treatments based on card creation date.
   Applied via .season-{name} class alongside element/rarity classes.
   ========================================================================== */

/* -- Season Custom Properties -- */
.card.season-spring {
  --season-tint: rgba(255, 183, 197, 0.35);
  --season-glow: rgba(255, 160, 180, 0.15);
}

.card.season-summer {
  --season-tint: rgba(255, 200, 80, 0.35);
  --season-glow: rgba(255, 180, 50, 0.12);
}

.card.season-fall {
  --season-tint: rgba(210, 140, 50, 0.35);
  --season-glow: rgba(200, 130, 40, 0.15);
}

.card.season-winter {
  --season-tint: rgba(160, 200, 240, 0.35);
  --season-glow: rgba(130, 180, 230, 0.12);
}

/* -- Seasonal Border Tint (layered on top of existing border) -- */
.card.season-spring {
  border-color: var(--element-primary);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 20px var(--element-glow),
    0 0 28px var(--season-glow);
}

.card.season-summer {
  border-color: var(--element-primary);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 20px var(--element-glow),
    0 0 28px var(--season-glow);
}

.card.season-fall {
  border-color: var(--element-primary);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 20px var(--element-glow),
    0 0 28px var(--season-glow);
}

.card.season-winter {
  border-color: var(--element-primary);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 20px var(--element-glow),
    0 0 28px var(--season-glow);
}

/* -- Spring: Cherry blossom petals at corners -- */
.card-season-petals {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
  display: none;
}

.card.season-spring .card-season-petals { display: block; }

.card-season-petals::before,
.card-season-petals::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50% 0 50% 50%;
  background: rgba(255, 183, 197, 0.4);
  filter: blur(0.5px);
}

.card-season-petals::before {
  top: 8px;
  right: 10px;
  transform: rotate(25deg);
  animation: petal-drift-1 6s ease-in-out infinite alternate;
}

.card-season-petals::after {
  bottom: 12px;
  left: 8px;
  width: 5px;
  height: 5px;
  transform: rotate(-15deg);
  animation: petal-drift-2 7s ease-in-out infinite alternate;
}

@keyframes petal-drift-1 {
  0% { transform: rotate(25deg) translateY(0); opacity: 0.5; }
  100% { transform: rotate(40deg) translateY(3px); opacity: 0.3; }
}

@keyframes petal-drift-2 {
  0% { transform: rotate(-15deg) translateX(0); opacity: 0.4; }
  100% { transform: rotate(-25deg) translateX(2px); opacity: 0.25; }
}

/* -- Summer: Heat shimmer on card art -- */
.card-season-shimmer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
  display: none;
}

.card.season-summer .card-season-shimmer { display: block; }

.card.season-summer .card-season-shimmer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    0deg,
    transparent 0%,
    rgba(255, 200, 80, 0.02) 20%,
    transparent 40%,
    rgba(255, 200, 80, 0.03) 60%,
    transparent 80%,
    rgba(255, 200, 80, 0.02) 100%
  );
  animation: heat-shimmer 4s ease-in-out infinite;
}

@keyframes heat-shimmer {
  0%, 100% { transform: translateY(0) scaleX(1); }
  25% { transform: translateY(-1px) scaleX(1.002); }
  50% { transform: translateY(0) scaleX(0.998); }
  75% { transform: translateY(1px) scaleX(1.001); }
}

/* -- Fall: Leaf shapes at corners -- */
.card-season-leaves {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
  display: none;
}

.card.season-fall .card-season-leaves { display: block; }

.card-season-leaves::before,
.card-season-leaves::after {
  content: '';
  position: absolute;
  width: 7px;
  height: 7px;
  background: rgba(210, 140, 50, 0.35);
  transform: rotate(45deg);
  border-radius: 1px 50% 1px 50%;
}

.card-season-leaves::before {
  top: 10px;
  left: 10px;
  animation: leaf-sway-1 5s ease-in-out infinite alternate;
}

.card-season-leaves::after {
  bottom: 14px;
  right: 10px;
  width: 6px;
  height: 6px;
  background: rgba(190, 110, 30, 0.3);
  animation: leaf-sway-2 6s ease-in-out infinite alternate;
}

@keyframes leaf-sway-1 {
  0% { transform: rotate(45deg) translate(0, 0); opacity: 0.45; }
  100% { transform: rotate(55deg) translate(1px, 2px); opacity: 0.3; }
}

@keyframes leaf-sway-2 {
  0% { transform: rotate(45deg) translate(0, 0); opacity: 0.4; }
  100% { transform: rotate(35deg) translate(-1px, 1px); opacity: 0.25; }
}

/* -- Winter: Frost crystal edges -- */
.card-season-frost {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
  display: none;
}

.card.season-winter .card-season-frost { display: block; }

.card-season-frost::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50px;
  height: 50px;
  background: radial-gradient(
    ellipse at 0% 0%,
    rgba(200, 220, 255, 0.12) 0%,
    transparent 70%
  );
  border-radius: inherit;
}

.card-season-frost::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 50px;
  height: 50px;
  background: radial-gradient(
    ellipse at 100% 100%,
    rgba(200, 220, 255, 0.10) 0%,
    transparent 70%
  );
  border-radius: inherit;
}

/* -- Season Badge (small label on the art area) -- */
.season-badge {
  position: absolute;
  bottom: 8px;
  right: 12px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.5);
  pointer-events: none;
  text-transform: uppercase;
}

.season-badge-icon {
  font-size: 0.6rem;
  line-height: 1;
}

/* -- Rarity overrides: ensure rarity box-shadow still dominates -- */
.card.rarity-rare.season-spring,
.card.rarity-rare.season-summer,
.card.rarity-rare.season-fall,
.card.rarity-rare.season-winter {
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 16px rgba(212, 168, 67, 0.25),
    0 0 40px rgba(212, 168, 67, 0.1),
    0 0 24px var(--season-glow);
}

.card.rarity-epic.season-spring,
.card.rarity-epic.season-summer,
.card.rarity-epic.season-fall,
.card.rarity-epic.season-winter {
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 24px rgba(99, 102, 241, 0.35),
    0 0 48px rgba(139, 92, 246, 0.15),
    0 0 24px var(--season-glow);
}

.card.rarity-legendary.season-spring,
.card.rarity-legendary.season-summer,
.card.rarity-legendary.season-fall,
.card.rarity-legendary.season-winter {
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 28px rgba(255, 200, 50, 0.35),
    0 0 64px rgba(255, 150, 50, 0.18),
    0 0 24px var(--season-glow);
}

/* Hide seasonal overlays in export mode */
.card.export-mode .card-season-petals,
.card.export-mode .card-season-shimmer,
.card.export-mode .card-season-leaves,
.card.export-mode .card-season-frost,
.card.export-mode .season-badge {
  display: none;
}

/* ==========================================================================
   14. Responsive
   ========================================================================== */

/* Container queries for cards inside flex/grid parents */
@container (max-width: 340px) {
  .stat-ring {
    width: 50px;
    height: 50px;
  }

  .stat-ring::before {
    width: 40px;
    height: 40px;
  }

  .stat-val {
    font-size: 0.85rem;
  }

  .card-stats {
    gap: 8px;
    padding: 12px 0;
  }

  .card-body {
    padding: 0 14px 12px;
  }

  .card-title-bar {
    padding: 0 14px 10px;
  }

  .card-name {
    font-size: 1rem;
  }

  .card-badges {
    top: 8px;
    left: 8px;
    right: 8px;
  }

  .badge {
    font-size: 0.6rem;
    padding: 3px 8px;
  }
}

/* Fallback for browsers without container queries */
@media (max-width: 340px) {
  .stat-ring {
    width: 50px;
    height: 50px;
  }

  .stat-ring::before {
    width: 40px;
    height: 40px;
  }

  .stat-val {
    font-size: 0.85rem;
  }

  .card-stats {
    gap: 8px;
    padding: 12px 0;
  }

  .card-body {
    padding: 0 14px 12px;
  }

  .card-title-bar {
    padding: 0 14px 10px;
  }

  .card-name {
    font-size: 1rem;
  }
}

/* ==========================================================================
   15. Print
   ========================================================================== */

/* ==========================================================================
   16. Cosmetic Effects (applied via CSS classes from Ink Shop)
   ========================================================================== */

/* -- Particle Cosmetics -- */

.card.cosmetic-sparkle-gold::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #ffd700 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 60% 15%, #daa520 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 60%, #ffd700 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 35% 80%, #f0c040 0%, transparent 100%),
    radial-gradient(1px 1px at 10% 55%, #ffd700 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 90% 40%, #daa520 0%, transparent 100%);
  animation: cosmetic-sparkle-drift 4s ease-in-out infinite alternate;
  border-radius: inherit;
}

.card.cosmetic-sparkle-prismatic::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 15% 25%, #ff6b6b 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 10%, #ffd93d 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 75% 35%, #6bcb77 0%, transparent 100%),
    radial-gradient(1px 1px at 25% 70%, #4d96ff 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 85% 75%, #9b59b6 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 55%, #ff8c42 0%, transparent 100%);
  animation: cosmetic-sparkle-drift 3s ease-in-out infinite alternate;
  border-radius: inherit;
}

@keyframes cosmetic-sparkle-drift {
  0% { opacity: 0.5; transform: translateY(0); }
  100% { opacity: 1; transform: translateY(-3px); }
}

/* -- Border Cosmetics -- */

.card.cosmetic-border-flame {
  box-shadow:
    0 0 8px rgba(232, 93, 58, 0.5),
    0 0 20px rgba(232, 93, 58, 0.2),
    inset 0 0 8px rgba(232, 93, 58, 0.15);
  animation: cosmetic-flame-pulse 2s ease-in-out infinite;
}

@keyframes cosmetic-flame-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(232,93,58,0.5), 0 0 20px rgba(232,93,58,0.2), inset 0 0 8px rgba(232,93,58,0.15); }
  50% { box-shadow: 0 0 14px rgba(255,107,53,0.7), 0 0 30px rgba(255,154,92,0.3), inset 0 0 12px rgba(255,107,53,0.2); }
}

.card.cosmetic-border-frost {
  box-shadow:
    0 0 10px rgba(168, 216, 234, 0.5),
    0 0 25px rgba(137, 196, 225, 0.2),
    inset 0 0 8px rgba(224, 240, 255, 0.15);
  animation: cosmetic-frost-shimmer 3s ease-in-out infinite;
}

@keyframes cosmetic-frost-shimmer {
  0%, 100% { box-shadow: 0 0 10px rgba(168,216,234,0.5), 0 0 25px rgba(137,196,225,0.2), inset 0 0 8px rgba(224,240,255,0.15); }
  50% { box-shadow: 0 0 16px rgba(200,230,255,0.6), 0 0 35px rgba(168,216,234,0.3), inset 0 0 12px rgba(224,240,255,0.25); }
}

.card.cosmetic-border-vines {
  box-shadow:
    0 0 8px rgba(74, 124, 89, 0.5),
    0 0 20px rgba(123, 198, 126, 0.2),
    inset 0 0 6px rgba(74, 124, 89, 0.15);
  animation: cosmetic-vine-grow 4s ease-in-out infinite;
}

@keyframes cosmetic-vine-grow {
  0%, 100% { box-shadow: 0 0 8px rgba(74,124,89,0.5), 0 0 20px rgba(123,198,126,0.2), inset 0 0 6px rgba(74,124,89,0.15); }
  50% { box-shadow: 0 0 14px rgba(74,124,89,0.6), 0 0 30px rgba(123,198,126,0.35), inset 0 0 10px rgba(74,124,89,0.2); }
}

.card.cosmetic-border-lightning {
  box-shadow:
    0 0 8px rgba(245, 200, 66, 0.5),
    0 0 20px rgba(224, 168, 0, 0.2),
    inset 0 0 6px rgba(245, 200, 66, 0.1);
  animation: cosmetic-lightning-flash 1.5s ease-in-out infinite;
}

@keyframes cosmetic-lightning-flash {
  0%, 90%, 100% { box-shadow: 0 0 8px rgba(245,200,66,0.5), 0 0 20px rgba(224,168,0,0.2), inset 0 0 6px rgba(245,200,66,0.1); }
  93% { box-shadow: 0 0 20px rgba(245,200,66,0.9), 0 0 40px rgba(255,255,200,0.5), inset 0 0 15px rgba(245,200,66,0.3); }
  96% { box-shadow: 0 0 8px rgba(245,200,66,0.5), 0 0 20px rgba(224,168,0,0.2), inset 0 0 6px rgba(245,200,66,0.1); }
}

/* -- Glow Cosmetics -- */

.card.cosmetic-glow-aura {
  box-shadow:
    0 0 15px rgba(255, 255, 255, 0.2),
    0 0 30px rgba(255, 255, 255, 0.1),
    0 0 45px rgba(var(--element-primary-rgb, 136), 0.15);
  animation: cosmetic-aura-breathe 3s ease-in-out infinite;
}

@keyframes cosmetic-aura-breathe {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}

.card.cosmetic-glow-neon {
  box-shadow:
    0 0 5px #0ff,
    0 0 15px rgba(0, 255, 255, 0.4),
    0 0 30px rgba(0, 255, 255, 0.15),
    inset 0 0 5px rgba(0, 255, 255, 0.1);
  animation: cosmetic-neon-pulse 1.8s ease-in-out infinite;
}

@keyframes cosmetic-neon-pulse {
  0%, 100% { box-shadow: 0 0 5px #0ff, 0 0 15px rgba(0,255,255,0.4), 0 0 30px rgba(0,255,255,0.15), inset 0 0 5px rgba(0,255,255,0.1); }
  50% { box-shadow: 0 0 10px #0ff, 0 0 25px rgba(0,255,255,0.6), 0 0 50px rgba(0,255,255,0.25), inset 0 0 10px rgba(0,255,255,0.15); }
}

/* -- Foil Cosmetics -- */

.card.cosmetic-foil-chrome .card-foil {
  opacity: 0.35;
  background: linear-gradient(
    135deg,
    rgba(200, 200, 200, 0.8) 0%,
    rgba(255, 255, 255, 0.9) 25%,
    rgba(180, 180, 180, 0.7) 50%,
    rgba(240, 240, 240, 0.85) 75%,
    rgba(200, 200, 200, 0.8) 100%
  );
  mix-blend-mode: overlay;
}

.card.cosmetic-foil-galaxy .card-foil {
  opacity: 0.3;
  background: linear-gradient(
    135deg,
    rgba(26, 5, 51, 0.8) 0%,
    rgba(45, 27, 105, 0.7) 20%,
    rgba(74, 14, 78, 0.6) 40%,
    rgba(10, 10, 46, 0.8) 60%,
    rgba(100, 40, 150, 0.5) 80%,
    rgba(26, 5, 51, 0.8) 100%
  );
  mix-blend-mode: screen;
  animation: cosmetic-galaxy-shift 8s linear infinite;
}

@keyframes cosmetic-galaxy-shift {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 200%; }
}

.card.cosmetic-foil-galaxy .card-foil {
  background-size: 200% 200%;
}

/* -- Fused Card Treatment -- */

.card.fused-card {
  box-shadow:
    0 0 10px rgba(255, 215, 0, 0.3),
    0 0 25px rgba(255, 215, 0, 0.15),
    inset 0 0 8px rgba(255, 215, 0, 0.1);
}

.card.fused-card .card-gilding {
  opacity: 1;
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.15) 0%,
    rgba(218, 165, 32, 0.1) 50%,
    rgba(255, 215, 0, 0.15) 100%
  );
}

/* Hide cosmetic effects in export mode */
.card.export-mode.cosmetic-sparkle-gold::after,
.card.export-mode.cosmetic-sparkle-prismatic::after {
  display: none;
}

.card.export-mode.cosmetic-border-flame,
.card.export-mode.cosmetic-border-frost,
.card.export-mode.cosmetic-border-vines,
.card.export-mode.cosmetic-border-lightning,
.card.export-mode.cosmetic-glow-aura,
.card.export-mode.cosmetic-glow-neon,
.card.export-mode.cosmetic-foil-chrome,
.card.export-mode.cosmetic-foil-galaxy {
  animation: none;
}

/* ==========================================================================
   17. Print
   ========================================================================== */

@media print {
  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  .card *,
  .card *::before,
  .card *::after {
    animation: none !important;
  }
}
