/* ── Card Base ── */
.card {
  position: relative; width: 160px; height: 220px;
  border-radius: 14px; overflow: hidden;
  cursor: pointer; transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s ease;
  flex-shrink: 0;
}
.card:hover { transform: translateY(-6px) scale(1.04); }
.card-inner { width: 100%; height: 100%; position: relative; border-radius: 14px; overflow: hidden; }

/* ── Tier Borders via pseudo-element wrapper ── */
.card::before {
  content: ''; position: absolute; inset: -2px;
  border-radius: 16px; z-index: 0; transition: opacity 0.3s;
}
.card-inner { position: relative; z-index: 1; }

/* ── SSS: Rainbow conic spinning border ── */
.card.tier-SSS::before {
  background: conic-gradient(from 0deg, #ffd700, #ff6b6b, #a855f7, #00d2d3, #38ef7d, #ffd700);
  animation: spinBorder 3s linear infinite;
}
.card.tier-SSS { box-shadow: 0 0 30px rgba(255,215,0,0.6), 0 0 60px rgba(168,85,247,0.3); }
.card.tier-SSS:hover { box-shadow: 0 0 50px rgba(255,215,0,0.9), 0 0 90px rgba(168,85,247,0.5); }

/* ── SS: Pulse purple ── */
.card.tier-SS::before { background: #a855f7; animation: pulseBorder 2s ease-in-out infinite; }
.card.tier-SS { box-shadow: 0 0 20px rgba(168,85,247,0.6); }
.card.tier-SS:hover { box-shadow: 0 0 40px rgba(168,85,247,0.9); }

/* ── S: Flame shimmer ── */
.card.tier-S::before {
  background: linear-gradient(45deg, #ef4444, #f97316, #ef4444, #dc2626);
  background-size: 200% 200%;
  animation: shimmerBorder 2s ease infinite;
}
.card.tier-S { box-shadow: 0 0 18px rgba(239,68,68,0.6); }
.card.tier-S:hover { box-shadow: 0 0 35px rgba(239,68,68,0.9); }

/* ── A: Orange glow pulse ── */
.card.tier-A::before { background: #f97316; animation: pulseBorderA 2.5s ease-in-out infinite; }
.card.tier-A { box-shadow: 0 0 14px rgba(249,115,22,0.5); }

/* ── B: Blue metallic ── */
.card.tier-B::before {
  background: linear-gradient(45deg, #3b82f6, #60a5fa, #3b82f6);
  background-size: 200% 200%;
  animation: shimmerBorder 3s ease infinite;
}
.card.tier-B { box-shadow: 0 0 10px rgba(59,130,246,0.4); }

/* ── C: Green subtle ── */
.card.tier-C::before { background: #22c55e; }
.card.tier-C { box-shadow: 0 0 6px rgba(34,197,94,0.3); }

/* ── D: Grey minimal ── */
.card.tier-D::before { background: #374151; }
.card.tier-D { box-shadow: 0 0 4px rgba(0,0,0,0.5); }

/* ── Card Body ── */
.card-body {
  position: absolute; inset: 2px;
  border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column;
}

/* ── Card Backgrounds by element ── */
.card-body.elem-fire   { background: linear-gradient(160deg, #1a0a05 0%, #2d1008 40%, #1a0a05 100%); }
.card-body.elem-fire::after   { background: repeating-linear-gradient(45deg, rgba(239,68,68,0.05) 0px, rgba(239,68,68,0.05) 1px, transparent 1px, transparent 8px); }
.card-body.elem-water  { background: linear-gradient(160deg, #050d1a 0%, #082040 40%, #050d1a 100%); }
.card-body.elem-water::after  { background: repeating-linear-gradient(0deg, rgba(14,165,233,0.06) 0px, rgba(14,165,233,0.06) 1px, transparent 1px, transparent 10px); }
.card-body.elem-earth  { background: linear-gradient(160deg, #0a0f05 0%, #18280a 40%, #0a0f05 100%); }
.card-body.elem-earth::after  { background: radial-gradient(circle 2px at 15% 30%, rgba(132,204,22,0.12) 50%, transparent 50%), radial-gradient(circle 2px at 55% 70%, rgba(132,204,22,0.08) 50%, transparent 50%); background-size: 20px 20px; }
.card-body.elem-wind   { background: linear-gradient(160deg, #050f12 0%, #0a2030 40%, #050f12 100%); }
.card-body.elem-wind::after   { background: repeating-conic-gradient(rgba(103,232,249,0.04) 0deg 1deg, transparent 1deg 10deg); }
.card-body.elem-light  { background: linear-gradient(160deg, #14100a 0%, #2a2000 40%, #14100a 100%); }
.card-body.elem-light::after  { background: radial-gradient(ellipse at 50% 40%, rgba(251,191,36,0.12) 0%, transparent 70%); }
.card-body.elem-dark   { background: linear-gradient(160deg, #080510 0%, #180528 40%, #080510 100%); }
.card-body.elem-dark::after   { background: repeating-linear-gradient(-45deg, rgba(139,92,246,0.05) 0px, rgba(139,92,246,0.05) 1px, transparent 1px, transparent 8px), repeating-linear-gradient(45deg, rgba(139,92,246,0.03) 0px, rgba(139,92,246,0.03) 1px, transparent 1px, transparent 8px); }
.card-body::after { content: ''; position: absolute; inset: 0; pointer-events: none; }

/* ── Card Header Row ── */
.card-header-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 8px 10px 4px;
  position: relative; z-index: 2;
}
.tier-badge {
  font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 0.75rem;
  padding: 2px 7px; border-radius: 6px; letter-spacing: 0.04em;
}
.tier-badge.tier-SSS { background: linear-gradient(135deg, #ffd700, #a855f7); color: #000; }
.tier-badge.tier-SS  { background: #a855f7; color: #fff; }
.tier-badge.tier-S   { background: #ef4444; color: #fff; }
.tier-badge.tier-A   { background: #f97316; color: #fff; }
.tier-badge.tier-B   { background: #3b82f6; color: #fff; }
.tier-badge.tier-C   { background: #22c55e; color: #fff; }
.tier-badge.tier-D   { background: #374151; color: #9ca3af; }

.elem-icon { font-size: 0.95rem; }

/* ── Card Art Area ── */
.card-art {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 3rem; position: relative; z-index: 2;
  text-shadow: 0 4px 12px rgba(0,0,0,0.6);
  filter: drop-shadow(0 0 8px currentColor);
  animation: floatArt 3s ease-in-out infinite;
}
.card.tier-SSS .card-art { animation: floatArtSSS 2s ease-in-out infinite; }

.card-name {
  text-align: center; font-family: 'Outfit', sans-serif; font-weight: 700;
  font-size: 0.72rem; padding: 0 8px; margin-bottom: 4px;
  position: relative; z-index: 2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* ── Stat Bars ── */
.card-stats {
  padding: 4px 10px 8px; position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
}
.stat-row { display: flex; align-items: center; gap: 4px; }
.stat-label { font-size: 0.58rem; color: rgba(255,255,255,0.5); font-family: 'JetBrains Mono', monospace; width: 22px; flex-shrink: 0; }
.stat-bar-bg { flex: 1; height: 3px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.stat-bar-fill.hp  { background: linear-gradient(90deg, #22c55e, #4ade80); }
.stat-bar-fill.atk { background: linear-gradient(90deg, #ef4444, #f97316); }
.stat-bar-fill.def { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.stat-bar-fill.spd { background: linear-gradient(90deg, #a855f7, #c084fc); }

/* ── Stars ── */
.card-stars { text-align: center; font-size: 0.7rem; color: var(--gold); letter-spacing: 1px; padding-bottom: 6px; position: relative; z-index: 2; min-height: 16px; }

/* ── NEW Badge ── */
.new-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--gold); color: #1a1400;
  font-size: 0.62rem; font-weight: 800;
  padding: 2px 6px; border-radius: 6px;
  animation: newBadgePulse 1s ease infinite;
  z-index: 10;
}
@keyframes newBadgePulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ── Role Icon Corner ── */
.role-corner {
  position: absolute; bottom: 26px; right: 8px;
  font-size: 0.8rem; opacity: 0.7; z-index: 3;
}

/* ── Animations ── */
@keyframes spinBorder { to { transform: rotate(360deg); } }
@keyframes pulseBorder {
  0%,100% { opacity: 1; box-shadow: 0 0 20px rgba(168,85,247,0.8); }
  50% { opacity: 0.7; box-shadow: 0 0 40px rgba(168,85,247,1); }
}
@keyframes pulseBorderA {
  0%,100% { opacity: 1; }
  50% { opacity: 0.6; }
}
@keyframes shimmerBorder {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes floatArt {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes floatArtSSS {
  0%,100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 12px gold); }
  50% { transform: translateY(-8px) scale(1.05); filter: drop-shadow(0 0 24px gold); }
}

/* ── Card Grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  justify-items: center;
}

/* ── Inventory Filters ── */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center;
}
.filter-chip {
  padding: 5px 12px; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 0.8rem; font-family: 'Inter', sans-serif;
  transition: var(--transition);
}
.filter-chip:hover, .filter-chip.active { border-color: var(--accent); color: white; background: rgba(124,92,231,0.15); }
.filter-chip.tier-SSS.active { border-color: #ffd700; background: rgba(255,215,0,0.1); color: #ffd700; }
.filter-chip.tier-SS.active  { border-color: #a855f7; color: #a855f7; }
.filter-chip.tier-S.active   { border-color: #ef4444; color: #ef4444; }
.filter-chip.tier-A.active   { border-color: #f97316; color: #f97316; }
.filter-chip.tier-B.active   { border-color: #3b82f6; color: #3b82f6; }
.filter-chip.tier-C.active   { border-color: #22c55e; color: #22c55e; }
.filter-chip.tier-D.active   { border-color: #6b7280; color: #6b7280; }
