.avatar-wrapper {
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #4b5563;
  flex-shrink: 0;
}
.avatar-wrapper.avatar-sm { width: 48px; height: 48px; padding: 3px; }
.avatar-wrapper.avatar-md { width: 76px; height: 76px; padding: 3.5px; }

.avatar-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  background: var(--bg-main);
  display: block;
  position: relative;
  z-index: 2;
}

.lvl-badge {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  border: 2px solid currentColor;
  font-size: 0.75rem;
  font-weight: 800;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  z-index: 7;
}
.avatar-sm .lvl-badge { font-size: 0.65rem; min-width: 18px; height: 16px; bottom: -4px; border-width: 1.5px; }

.frame-lvl-1 { background: linear-gradient(135deg, #6b7280, #9ca3af); color: #9ca3af; }
.frame-lvl-2 { background: linear-gradient(135deg, #92400e, #d97706, #b45309); box-shadow: 0 0 12px rgba(217, 119, 6, 0.35); color: #f59e0b; }
.frame-lvl-3 { background: linear-gradient(135deg, #94a3b8, #f8fafc, #64748b); box-shadow: 0 0 14px rgba(226, 232, 240, 0.45); color: #e2e8f0; }
.frame-lvl-4 { background: linear-gradient(135deg, #b45309, #fde047, #eab308, #fef08a); box-shadow: 0 0 18px rgba(250, 204, 21, 0.55); color: #fde047; }
.frame-lvl-5 {
  background: linear-gradient(135deg, #00f0ff, #7c5cff, #ff4d8d, #00f0ff);
  background-size: 200% 200%;
  animation: neonShift 3s linear infinite;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.65);
  color: #00f0ff;
}
.portrait-fx-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 1.35rem;
  z-index: 8;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
  animation: fxFloat 2.2s ease-in-out infinite alternate;
}
.avatar-sm .portrait-fx-badge { font-size: 0.95rem; top: -5px; right: -5px; }
.avatar-md .portrait-fx-badge { font-size: 1.15rem; top: -6px; right: -6px; }

.fx-sparkle::after,
.fx-frost::after,
.fx-crown::after,
.fx-halo::after,
.fx-orbit::after,
.fx-aurora::after,
.fx-plasma::after,
.fx-phoenix::after,
.fx-dragon::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
}

.fx-sparkle::after {
  border: 2px dotted #facc15;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.55);
  animation: spinRing 9s linear infinite;
}

.fx-frost::after {
  border: 2px dashed #38bdf8;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.7);
  animation: spinRing 8s linear infinite reverse;
}

.fx-crown::after {
  border: 2.5px solid #f59e0b;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.75);
}

.fx-halo::after {
  inset: -7px;
  border: 3px solid #fde047;
  box-shadow: 0 0 22px rgba(250, 204, 21, 0.95), 0 0 36px rgba(245, 158, 11, 0.55);
  animation: haloPulse 1.6s ease-in-out infinite alternate;
}

.fx-orbit::after {
  inset: -7px;
  border: 2.5px solid transparent;
  border-top-color: #00f0ff;
  border-bottom-color: #ec4899;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.8), 0 0 28px rgba(236, 72, 153, 0.5);
  animation: spinRing 2.2s linear infinite;
}
.fx-aurora::after {
  inset: -7px;
  border: 3px dashed #22d3ee;
  box-shadow: 0 0 22px rgba(6, 182, 212, 0.85), 0 0 36px rgba(168, 85, 247, 0.7);
  animation: spinRing 3.6s linear infinite, auroraGlow 2.4s ease-in-out infinite alternate;
}

.fx-plasma::after {
  inset: -8px;
  border: 3px solid transparent;
  border-top-color: #00f0ff;
  border-right-color: #ff00aa;
  border-bottom-color: #7c5cff;
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.9), 0 0 38px rgba(255, 0, 170, 0.75);
  animation: spinRing 1.4s linear infinite;
}

.fx-phoenix::after {
  inset: -8px;
  border: 3px dashed #fb923c;
  box-shadow: 0 0 26px rgba(249, 115, 22, 0.95), 0 0 42px rgba(239, 68, 68, 0.8);
  animation: spinRing 3s linear infinite, firePulse 1.1s ease-in-out infinite alternate;
}

.fx-dragon .portrait-fx-badge {
  font-size: 1.75rem;
  top: -13px;
  right: -13px;
  filter: drop-shadow(0 0 12px rgba(250, 204, 21, 0.95)) drop-shadow(0 0 20px rgba(239, 68, 68, 0.9));
}
.fx-dragon::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #dc2626, #f97316, #fde047, #ec4899, #dc2626);
  animation: spinRing 2.2s linear infinite;
  z-index: 1;
}
.fx-dragon::after {
  inset: -10px;
  border: 3px double #fde047;
  box-shadow: 0 0 30px rgba(239, 68, 68, 1), 0 0 48px rgba(250, 204, 21, 0.85);
  animation: spinRing 4s linear infinite reverse, firePulse 0.9s ease-in-out infinite alternate;
}
.avatar-sm .fx-dragon .portrait-fx-badge { font-size: 1.1rem; top: -6px; right: -6px; }

@keyframes neonShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes spinRing {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes firePulse {
  from { box-shadow: 0 0 18px rgba(239, 68, 68, 0.75), 0 0 30px rgba(249, 115, 22, 0.6); }
  to { box-shadow: 0 0 32px rgba(250, 204, 21, 1), 0 0 52px rgba(239, 68, 68, 0.95); }
}
@keyframes auroraGlow {
  from { border-color: #22d3ee; }
  to { border-color: #e879f9; }
}
@keyframes haloPulse {
  from { transform: scale(0.98); opacity: 0.8; }
  to { transform: scale(1.05); opacity: 1; }
}
@keyframes fxFloat {
  from { transform: translateY(0px) scale(1); }
  to { transform: translateY(-4px) scale(1.14); }
}
