@layer components {
  .cos-av {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: var(--cos-size, 96px);
    height: var(--cos-size, 96px);
    flex: none;
  }

  .cos-av__photo {
    position: absolute;
    z-index: 2;
    inset: 4%;
    display: grid;
    place-items: center;
    border-radius: 18%;
    overflow: hidden;
    background:
      radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 50%),
      radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--accent) 42%, #2a1a4d), #120a24 82%);
    box-shadow: inset 0 0 0 2px rgba(255, 222, 150, 0.28), 0 6px 16px rgba(0, 0, 0, 0.5);
  }

  .cos-av[data-fit='ring'] .cos-av__photo {
    inset: 9%;
    border-radius: 13%;
  }

  .cos-av[data-fit='image'] .cos-av__photo {
    inset: 15%;
    border-radius: 6%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
  }

  .cos-av__photo img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .cos-av__letter {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: calc(var(--cos-size, 96px) * 0.4);
    font-weight: 900;
    color: transparent;
    background: var(--gold-text);
    -webkit-background-clip: text;
    background-clip: text;
    filter: drop-shadow(0 3px 0 rgba(42, 21, 0, 0.9));
  }

  .cos-av__ring {
    position: absolute;
    z-index: 1;
    inset: 0;
    padding: 7%;
    border-radius: 18%;
    overflow: hidden;
    pointer-events: none;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: xor;
  }

  .cos-av__ring i {
    position: absolute;
    inset: -30%;
    display: block;
  }

  .cos-av__ring[data-frame='neon'] {
    mask: none;
    background: none;
    box-shadow:
      inset 0 0 0 3px #5de9ff,
      0 0 14px rgba(93, 233, 255, 0.85),
      inset 0 0 12px rgba(93, 233, 255, 0.6);
    animation: cos-pulse 2.2s ease-in-out infinite;
  }

  .cos-av__ring[data-frame='blood'] {
    mask: none;
    background: none;
    box-shadow:
      inset 0 0 0 3px #e0182d,
      0 0 16px rgba(224, 24, 45, 0.8),
      inset 0 0 14px rgba(120, 0, 10, 0.9);
    animation: cos-pulse 1.6s ease-in-out infinite;
  }

  .cos-av__ring[data-frame='ice'] i,
  .cos-av__ring[data-frame='frost'] i {
    background: conic-gradient(#eafcff, #8fd6ff, #d8f4ff, #6cc0ff, #eafcff);
    animation: cos-spin 9s linear infinite;
  }

  .cos-av__ring[data-frame='ice'],
  .cos-av__ring[data-frame='frost'] {
    filter: drop-shadow(0 0 7px rgba(140, 214, 255, 0.75));
  }

  .cos-av__ring[data-frame='gold'] i {
    background: conic-gradient(#fff7d6, #ffe07a, #f6b52c, #a96b08, #fff1b8, #fff7d6);
    animation: cos-spin 7s linear infinite;
  }

  .cos-av__ring[data-frame='gold'] {
    filter: drop-shadow(0 0 7px rgba(255, 200, 70, 0.75));
  }

  .cos-av__ring[data-frame='rainbow'] i {
    background: conic-gradient(#ff3d6e, #ffd23f, #5ee06a, #5de9ff, #b28bff, #ff3d6e);
    animation: cos-spin 4.5s linear infinite;
  }

  .cos-av__ring[data-frame='rainbow'] {
    filter: drop-shadow(0 0 8px rgba(255, 120, 200, 0.65));
  }

  .cos-av__ring[data-frame='pumpkin'] i {
    background: conic-gradient(#ff7a1a, #ffbe3a, #ff4f00, #ff7a1a);
    animation: cos-spin 6s linear infinite;
  }

  .cos-av__ring[data-frame='pumpkin'] {
    filter: drop-shadow(0 0 8px rgba(255, 122, 26, 0.8));
  }

  .cos-av__ring[data-frame='haunted'] i {
    background: conic-gradient(#7cff4f, #3a1163, #a06bff, #0d3b16, #7cff4f);
    animation: cos-spin 5s linear infinite;
  }

  .cos-av__ring[data-frame='haunted'] {
    filter: drop-shadow(0 0 9px rgba(124, 255, 79, 0.55));
  }

  .cos-av__ring[data-frame='candycane'] i {
    background: repeating-conic-gradient(#fff 0 10deg, #e8263c 10deg 20deg);
    animation: cos-spin 8s linear infinite;
  }

  .cos-av__ring[data-frame='candycane'] {
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
  }

  .cos-av__frame {
    position: absolute;
    z-index: 3;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: fill;
    pointer-events: none;
  }

  .cos-av__fx {
    position: absolute;
    z-index: 4;
    inset: -6%;
    overflow: hidden;
    pointer-events: none;
  }

  .cos-av__mote {
    position: absolute;
    left: 50%;
    top: 50%;
    font-size: calc(var(--cos-size, 96px) * 0.15);
    line-height: 1;
    font-style: normal;
    transform-origin: 50% 50%;
    animation: cos-orbit 5.4s linear infinite;
    animation-delay: calc(var(--i) * -0.9s);
  }

  .cos-av__level {
    position: absolute;
    z-index: 5;
    right: -2%;
    bottom: -2%;
    min-width: calc(var(--cos-size, 96px) * 0.32);
    padding: 1px 5px 2px;
    border-radius: 99px;
    font-size: calc(var(--cos-size, 96px) * 0.18);
    font-weight: 900;
    text-align: center;
    color: #2a1500;
    background: linear-gradient(180deg, #fff4c4, #f0a91d);
    box-shadow: 0 0 0 2px #2a1500, 0 3px 8px rgba(0, 0, 0, 0.5);
  }

  .cos-name {
    font-weight: 900;
    color: var(--cos-name, var(--text));
  }

  .cos-name[data-tint] {
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
  }

  .cos-name[data-tint='rainbow'] {
    background-image: linear-gradient(100deg, #ff5a6e, #ffd23f, #5ee06a, #5de9ff, #b28bff, #ff5a6e);
    background-size: 300% 100%;
    animation: cos-slide 5s linear infinite;
  }

  .cos-name[data-tint='halloween'] {
    background-image: linear-gradient(100deg, #ff7a1a, #ffbe3a, #a06bff, #ff7a1a);
    background-size: 240% 100%;
    animation: cos-slide 6s linear infinite;
  }

  .cos-name[data-tint='frost'] {
    background-image: linear-gradient(100deg, #ffffff, #8fd6ff, #d8f4ff, #ffffff);
    background-size: 240% 100%;
    animation: cos-slide 6s linear infinite;
  }

  .cos-name[data-tint='candycane'] {
    background-image: repeating-linear-gradient(115deg, #ff4f66 0 10px, #fff 10px 20px);
    background-size: 200% 100%;
    animation: cos-slide 7s linear infinite;
  }

  .cos-badge {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
  }

  .cos-shelf {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }

  .cos-shelf__slot {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 0 0 1px rgba(255, 212, 74, 0.28);
  }

  .cos-shelf__slot img {
    width: 26px;
    height: 26px;
    object-fit: contain;
  }

  .cos-pv {
    display: grid;
    place-items: center;
    width: 110px;
    height: 100px;
  }

  .cos-pv img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.5));
  }

  .cos-pv--wide img {
    width: 110px;
    height: 68px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 0 0 2px rgba(255, 212, 74, 0.35), 0 8px 16px rgba(0, 0, 0, 0.5);
  }

  .cos-pv--avatar img {
    width: 92px;
    height: 92px;
    border-radius: 16%;
    object-fit: cover;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
  }

  .cos-pv--badge img {
    width: 74px;
    height: 74px;
  }

  .cos-pv--color {
    border-radius: 18px;
    background: radial-gradient(70% 70% at 50% 35%, rgba(255, 255, 255, 0.1), transparent 70%);
  }

  .cos-pv--color b {
    font-size: 46px;
    letter-spacing: 0.02em;
  }

  .cos-pv--frame .cos-av {
    --cos-size: 88px;
  }

  .cos-pv--effect {
    position: relative;
    --cos-size: 66px;
  }

  .cos-pv--effect i {
    position: absolute;
    left: 50%;
    top: 50%;
    font-size: 26px;
    font-style: normal;
    animation: cos-orbit 4.6s linear infinite;
    animation-delay: calc(var(--i) * -1.5s);
  }

  .cos-banner {
    position: relative;
    isolation: isolate;
    height: 132px;
    overflow: hidden;
    border-radius: 20px 20px 0 0;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 34%, #2c1a4d), color-mix(in srgb, var(--deep) 55%, #0c0619));
  }

  .cos-banner__img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .cos-banner__empty {
    position: absolute;
    inset: 0;
    background:
      radial-gradient(90% 120% at 50% 0%, rgba(255, 212, 74, 0.25), transparent 65%),
      radial-gradient(60% 100% at 92% 100%, color-mix(in srgb, var(--accent-2) 30%, transparent), transparent 70%),
      radial-gradient(circle, rgba(255, 255, 255, 0.4) 0 1px, rgba(255, 255, 255, 0) 1.6px) 0 0 / 34px 34px,
      radial-gradient(circle, rgba(255, 255, 255, 0.22) 0 1px, rgba(255, 255, 255, 0) 1.6px) 17px 17px / 34px 34px,
      repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.05) 0 14px, rgba(255, 255, 255, 0) 14px 28px);
  }
}

@layer fx {
  @keyframes cos-spin {
    to {
      rotate: 360deg;
    }
  }

  @keyframes cos-slide {
    to {
      background-position: 300% 50%;
    }
  }

  @keyframes cos-pulse {
    0%,
    100% {
      opacity: 1;
    }

    50% {
      opacity: 0.55;
    }
  }

  @keyframes cos-orbit {
    from {
      transform: rotate(0deg) translateX(calc(var(--cos-size, 96px) * 0.55)) rotate(0deg) scale(0.85);
    }

    50% {
      transform: rotate(180deg) translateX(calc(var(--cos-size, 96px) * 0.55)) rotate(-180deg) scale(1.1);
    }

    to {
      transform: rotate(360deg) translateX(calc(var(--cos-size, 96px) * 0.55)) rotate(-360deg) scale(0.85);
    }
  }
}

@layer state {
  [data-motion='reduced'] .cos-av__ring,
  [data-motion='reduced'] .cos-av__mote,
  [data-motion='reduced'] .cos-name,
  [data-motion='reduced'] .cos-pv--effect i {
    animation: none;
  }
}
