/*
 * The points game's avatar (game/avatar.js): the member's initial, a still picture, or an animated
 * avatar - the port of Resources/Skins/animated_preview/avatars.css, which the owner approved.
 *
 * Every rule is scoped under .game-ava (or the pause class), so nothing else on the display changes.
 * Sizes are in em: .game-ava sets font-size to 1% of its size (--s, set by avatar.js in vmin), so
 * 100em is the avatar's full width at any size. Only transform and opacity are animated.
 *
 * Markup of an animated avatar (avatar.js):
 *   .game-ava.ava-anim.ava-world-<w>.ava-mode-<frame|pop>[.ava-light]   --s, --d (phase), --img
 *     .ava-aura                      behind the photo: halo, rays, magic circle
 *     .ava-disc                      the round photo window
 *       .game-ava-letter             the initial, under the picture
 *       img.ava-photo                the photo (in "pop": the background, character painted out)
 *       .ava-mid > i*                particles between background and character ("pop" only)
 *       .ava-fx                      over the photo: scanlines, sweeps, glitch slices
 *     .ava-ring                      the animated rim
 *     .ava-front > i*, svg           particles and ornaments over the rim, may leave the circle
 *     .ava-pop > img.ava-cut         the character alone, over everything ("pop" only)
 * .ava-light (below 60 panel px, the roster rows): no aura, particles, ornaments or overlays; only the
 * rim turns. Keyframes are prefixed game-ava- so they never meet the display's own.
 */

/* ------------------------------------------------------------------------------- every avatar */

.game-ava {
    --s: 6vmin;
    --d: 0;
    position: relative;
    flex: none;
    display: inline-block;
    vertical-align: middle;
    width: var(--s);
    height: var(--s);
    font-size: calc(var(--s) / 100);
    line-height: 1;
    font-style: normal;
}

.game-ava *,
.game-ava *::before,
.game-ava *::after {
    box-sizing: border-box;
}

/* No picture (none worn, still loading, or failed): the member's initial on a soft disc. */
.game-ava.game-ava-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    font-size: calc(var(--s) * 0.46);
    font-weight: 800;
    color: var(--text, #f2f4f7);
}

/* The initial under a picture: shows until the picture covers it, and again if it fails. */
.game-ava .game-ava-letter {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 46em;
    font-weight: 800;
    color: var(--text, #f2f4f7);
}

/* A picture not filled yet (or taken away after an error) shows nothing, not a broken-image mark. */
.game-ava img:not([src]) {
    visibility: hidden;
}

.game-ava img {
    user-select: none;
    -webkit-user-drag: none;
}

/* A still avatar: a round picture. */
.game-ava.ava-still {
    overflow: hidden;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.game-ava.ava-still .game-ava-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Pixel-art avatars stay crisp when enlarged. */
.game-ava.pixelated img {
    image-rendering: pixelated;
}

/* Pauses every CSS animation under an element (avatar.js setAvatarMotion): avatars, the skin's
   keyframes, anything the caller hides or stills. */
.game-motion-off,
.game-motion-off::before,
.game-motion-off::after,
.game-motion-off *,
.game-motion-off *::before,
.game-motion-off *::after {
    animation-play-state: paused !important;
}

/* An animated avatar draws its own round photo and rim, and its glow and a popping head may leave
   the round box: the roster's and the card's avatar slots step aside for it (as in the preview). */
.chores-avatar:has(> .game-ava.ava-anim),
.kid-avatar:has(> .game-ava.ava-anim) {
    overflow: visible;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

/* ------------------------------------------------------------------------ the animated avatar */

.game-ava.ava-anim {
    display: block;
    isolation: isolate;
    /* World accents; each world below overrides them. */
    --c1: #5b9dd9;
    --c2: #f2f4f7;
    --glow: rgba(91, 157, 217, 0.55);
}

.game-ava .ava-aura,
.game-ava .ava-ring,
.game-ava .ava-front {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.game-ava .ava-aura {
    z-index: 0;
}

.game-ava .ava-disc {
    position: absolute;
    inset: 9em;
    z-index: 1;
    border-radius: 50%;
    overflow: hidden;
    background: #1a2130;
    /* Keeps overflow:hidden clipping round while children are transformed (Chromium/WebView). */
    -webkit-mask-image: -webkit-radial-gradient(white, black);
}

/* The world's own backdrop: behind avatars that come without a background, and the whole
   background in "pop" when the character has no background layer of its own. */
.game-ava .ava-disc::before {
    content: "";
    position: absolute;
    inset: -12%;
    background: var(--backdrop, #1a2130);
}

.game-ava .ava-disc .game-ava-letter {
    font-size: 38em;
}

.game-ava .ava-ring {
    z-index: 2;
}

.game-ava .ava-front {
    z-index: 3;
}

.game-ava .ava-photo,
.game-ava .ava-cut {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-ava .ava-mid,
.game-ava .ava-fx {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.game-ava .ava-mid {
    z-index: 1;
}

.game-ava .ava-cut {
    transform-origin: 50% 100%;
}

.game-ava .ava-fx {
    z-index: 3;
}

.game-ava i {
    position: absolute;
    display: block;
    font-style: normal;
}

.game-ava svg {
    position: absolute;
    display: block;
    overflow: visible;
    /* The display is RTL; text on a circular path only lays out left-to-right in Chromium. */
    direction: ltr;
}

/* Frame: the photo breathes (a slow, small zoom-and-drift), the world frame plays around it. */
.game-ava.ava-mode-frame .ava-photo {
    animation: game-ava-breathe 16s ease-in-out infinite alternate;
    animation-delay: calc(var(--d) * -16s);
}

.game-ava.ava-mode-frame .ava-mid {
    display: none;
}

@keyframes game-ava-breathe {
    0% { transform: scale(1.03) translate(0, 0); }
    50% { transform: scale(1.08) translate(-1.2%, -1%); }
    100% { transform: scale(1.05) translate(1.2%, 0.6%); }
}

/* Pop: the background drifts one way, the character (.ava-pop) the other way and slightly breathes,
   so the character seems to stand in front of its picture. */
.game-ava.ava-mode-pop .ava-photo,
.game-ava.ava-mode-pop .ava-disc::before {
    animation: game-ava-pop-back 9s ease-in-out infinite alternate;
    animation-delay: calc(var(--d) * -9s);
}

/* The pop-out layer: the character cut from a window --pop-k times the avatar's size, its bottom
   edge on the photo's bottom edge. The mask keeps the lower half inside the round photo; above the
   photo's middle a soft dome, a little wider than the photo and closing before the layer's top,
   lets the head, hair or hat rise over the rim without hard edges. A "-pop" layer (from the
   original, with room above the head) uses 1.18; an avatar's own "-cut" layer (.from-cut) is simply
   enlarged from the bottom (1.1) so the head still clears the rim. */
.game-ava .ava-pop {
    --pop-k: 1.18;
    position: absolute;
    z-index: 4;
    display: none;
    left: calc(50% - 41em * var(--pop-k));
    bottom: 9em;
    width: calc(82em * var(--pop-k));
    height: calc(82em * var(--pop-k));
    pointer-events: none;
    -webkit-mask-image: radial-gradient(circle 41em at 50% calc(100% - 41em), #000 40.5em, transparent 41em), radial-gradient(ellipse 44em 92% at 50% 100%, #000 88%, transparent 100%);
    -webkit-mask-size: 100% 100%, 100% calc(100% - 41em);
    -webkit-mask-position: 0 0, 50% 0;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-composite: source-over;
    mask-image: radial-gradient(circle 41em at 50% calc(100% - 41em), #000 40.5em, transparent 41em), radial-gradient(ellipse 44em 92% at 50% 100%, #000 88%, transparent 100%);
    mask-size: 100% 100%, 100% calc(100% - 41em);
    mask-position: 0 0, 50% 0;
    mask-repeat: no-repeat;
    mask-composite: add;
}

.game-ava .ava-pop.from-cut {
    --pop-k: 1.1;
}

.game-ava.ava-mode-pop.ava-has-pop .ava-pop {
    display: block;
}

.game-ava .ava-pop .ava-cut {
    animation: game-ava-pop-front 9s ease-in-out infinite alternate;
    animation-delay: calc(var(--d) * -9s);
}

/* No background layer of its own: the drifting world backdrop stands in for it. */
.game-ava.ava-mode-pop.ava-no-back .ava-photo {
    display: none;
}

/* The character is in: the initial seen through a missing background goes. */
.game-ava.ava-loaded .game-ava-letter {
    display: none;
}

@keyframes game-ava-pop-front {
    0% { transform: scale(1.06) translateX(-1.6%) rotate(-0.6deg); }
    100% { transform: scale(1.1) translateX(1.6%) rotate(0.6deg); }
}

@keyframes game-ava-pop-back {
    0% { transform: scale(1.22) translateX(3%); }
    100% { transform: scale(1.18) translateX(-3%); }
}

/* Shared particle motions: rise (steam, embers, motes) and twinkle (sparkles). Each particle sets
   --x (left, %), --y (top, %), --t (duration, s), --p (phase 0..1), --z (size, em). */
.game-ava i.rise {
    left: var(--x);
    bottom: -6%;
    width: var(--z);
    height: var(--z);
    margin-left: calc(var(--z) / -2);
    border-radius: 50%;
    opacity: 0;
    animation: game-ava-rise calc(var(--t) * 1s) linear infinite;
    animation-delay: calc(var(--p) * var(--t) * -1s);
}

@keyframes game-ava-rise {
    0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
    15% { opacity: 1; }
    60% { opacity: 0.8; }
    100% { transform: translate(var(--dx, 0em), -95em) scale(1.25); opacity: 0; }
}

.game-ava i.twinkle {
    left: var(--x);
    top: var(--y);
    width: var(--z);
    height: var(--z);
    margin: calc(var(--z) / -2) 0 0 calc(var(--z) / -2);
    opacity: 0;
    animation: game-ava-twinkle calc(var(--t) * 1s) ease-in-out infinite;
    animation-delay: calc(var(--p) * var(--t) * -1s);
}

@keyframes game-ava-twinkle {
    0%, 100% { transform: scale(0.2) rotate(0deg); opacity: 0; }
    45% { transform: scale(1) rotate(45deg); opacity: 1; }
    60% { transform: scale(0.7) rotate(60deg); opacity: 0.7; }
}

/* A rim shared by most worlds: a ring drawn with a radial mask over a (rotating) conic gradient. */
.game-ava .ava-ring::before {
    content: "";
    position: absolute;
    inset: 7em;
    border-radius: 50%;
    background: var(--ring-paint, conic-gradient(var(--c1), var(--c2), var(--c1)));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--ring-w, 3.6em)), #000 calc(100% - var(--ring-w, 3.6em) + 0.5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - var(--ring-w, 3.6em)), #000 calc(100% - var(--ring-w, 3.6em) + 0.5px));
    animation: game-ava-spin var(--ring-spin, 10s) linear infinite;
}

@keyframes game-ava-spin {
    to { transform: rotate(360deg); }
}

@keyframes game-ava-spin-back {
    to { transform: rotate(-360deg); }
}

/* A soft glow that pulses behind the photo. */
.game-ava .ava-aura::before {
    content: "";
    position: absolute;
    inset: 4em;
    border-radius: 50%;
    background: radial-gradient(circle, var(--glow) 40%, transparent 70%);
    animation: game-ava-pulse 4s ease-in-out infinite;
    animation-delay: calc(var(--d) * -4s);
}

@keyframes game-ava-pulse {
    0%, 100% { transform: scale(0.92); opacity: 0.55; }
    50% { transform: scale(1.04); opacity: 1; }
}

/* ---------------------------------------------------------------------------------------------
 * The Avengers: a red-gold rim, the six Infinity Stones orbiting, a "snap" flash every few seconds.
 * ------------------------------------------------------------------------------------------- */

.game-ava.ava-world-mcu {
    --backdrop: radial-gradient(circle at 30% 22%, rgba(242, 193, 78, 0.35), transparent 45%), radial-gradient(circle at 75% 80%, #6b1020, transparent 60%), #160c24;
    --c1: #c8102e;
    --c2: #f2c14e;
    --glow: rgba(242, 193, 78, 0.55);
    --ring-paint: conic-gradient(#7a0d1c, #c8102e, #f2c14e, #fff3c4, #f2c14e, #c8102e, #7a0d1c, #c8102e, #f2c14e, #7a0d1c);
    --ring-spin: 7s;
}

.game-ava.ava-world-mcu .ava-front .stones {
    inset: 0;
    animation: game-ava-spin 14s linear infinite;
    animation-delay: calc(var(--d) * -14s);
}

.game-ava.ava-world-mcu .ava-front .stone {
    width: 7em;
    height: 7em;
    margin: -3.5em 0 0 -3.5em;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff 0 12%, var(--sc) 45%, color-mix(in srgb, var(--sc) 55%, #000) 100%);
    box-shadow: 0 0 2.5em 0.8em var(--sc);
    animation: game-ava-stone 2.8s ease-in-out infinite alternate;
    animation-delay: calc(var(--i) * -0.45s);
}

@keyframes game-ava-stone {
    from { transform: scale(0.75); filter: brightness(0.85); }
    to { transform: scale(1.1); filter: brightness(1.3); }
}

/* The snap: a bright ring that expands from the rim and fades. */
.game-ava.ava-world-mcu .ava-ring::after {
    content: "";
    position: absolute;
    inset: 8em;
    border-radius: 50%;
    border: 1.6em solid #fff3c4;
    box-shadow: 0 0 4em #f2c14e, inset 0 0 4em #f2c14e;
    opacity: 0;
    animation: game-ava-snap 6s ease-out infinite;
    animation-delay: calc(var(--d) * -6s);
}

@keyframes game-ava-snap {
    0%, 82% { transform: scale(1); opacity: 0; }
    84% { opacity: 0.95; }
    100% { transform: scale(1.22); opacity: 0; }
}

/* A metallic shine sliding across the photo. */
.game-ava.ava-world-mcu .ava-fx::before {
    content: "";
    position: absolute;
    inset: -20%;
    background: linear-gradient(115deg, transparent 42%, rgba(255, 243, 196, 0.38) 50%, transparent 58%);
    transform: translateX(-70%);
    animation: game-ava-sweep 6s ease-in-out infinite;
    animation-delay: calc(var(--d) * -6s);
}

@keyframes game-ava-sweep {
    0%, 55% { transform: translateX(-70%); }
    85%, 100% { transform: translateX(70%); }
}

.game-ava.ava-world-mcu i.rise {
    background: radial-gradient(circle, #fff3c4 0 25%, rgba(242, 193, 78, 0.8) 45%, transparent 70%);
}

/* ---------------------------------------------------------------------------------------------
 * Attack on Titan: titan steam rising, a leather rim with a blade glint running round it, a slow
 * red heat at the bottom.
 * ------------------------------------------------------------------------------------------- */

.game-ava.ava-world-aot {
    --backdrop: linear-gradient(180deg, #9fb7c6 0%, #d8c9a8 58%, #6d5a43 100%);
    --c1: #3e5b45;
    --c2: #e8dcc0;
    --glow: rgba(255, 110, 40, 0.5);
    --ring-paint: conic-gradient(from 0deg, #2b3d2f 0deg, #3e5b45 300deg, #dfe6ea 330deg, #ffffff 340deg, #3e5b45 360deg);
    --ring-spin: 3.6s;
    --ring-w: 3.2em;
}

.game-ava.ava-world-aot .ava-aura::before {
    inset: 30em 10em 0;
    background: radial-gradient(ellipse at 50% 80%, var(--glow) 0 30%, transparent 70%);
}

.game-ava.ava-world-aot .ava-ring::after {
    content: "";
    position: absolute;
    inset: 11em;
    border-radius: 50%;
    border: 0.9em solid rgba(232, 220, 192, 0.55);
}

.game-ava.ava-world-aot i.rise {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.55) 0 18%, rgba(255, 255, 255, 0.16) 45%, transparent 68%);
    animation-name: game-ava-steam;
}

@keyframes game-ava-steam {
    0% { transform: translate(0, 0) scale(0.5); opacity: 0; }
    20% { opacity: 0.8; }
    100% { transform: translate(var(--dx, 0em), -50em) scale(2); opacity: 0; }
}

/* ---------------------------------------------------------------------------------------------
 * Arcane: a hextech rim of glowing blue cells, blue crystal motes, a purple shimmer wisp.
 * ------------------------------------------------------------------------------------------- */

.game-ava.ava-world-arcane {
    --backdrop: radial-gradient(circle at 50% 30%, rgba(63, 208, 255, 0.35), transparent 50%), linear-gradient(180deg, #1b3a4a 0%, #0c1a24 60%, #2a1036 100%);
    --c1: #3fd0ff;
    --c2: #c33cff;
    --glow: rgba(63, 208, 255, 0.5);
    --ring-paint: repeating-conic-gradient(from 0deg, #3fd0ff 0 9deg, #0b4a66 9deg 12deg);
    --ring-spin: 18s;
    --ring-w: 3.4em;
}

.game-ava.ava-world-arcane .ava-ring::before {
    filter: drop-shadow(0 0 1.2em #3fd0ff);
}

.game-ava.ava-world-arcane .ava-ring::after {
    content: "";
    position: absolute;
    inset: 3em;
    border-radius: 50%;
    border: 0.7em solid #d6a84b;
    border-color: #d6a84b transparent #d6a84b transparent;
    animation: game-ava-spin-back 12s linear infinite;
}

.game-ava.ava-world-arcane i.rise {
    border-radius: 0.6em;
    background: linear-gradient(135deg, #e9fbff, #3fd0ff 55%, #0b6fa0);
    box-shadow: 0 0 1.6em #3fd0ff;
    transform-origin: center;
    animation-name: game-ava-mote;
}

@keyframes game-ava-mote {
    0% { transform: translate(0, 0) rotate(45deg) scale(0.4); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translate(var(--dx, 0em), -90em) rotate(225deg) scale(0.9); opacity: 0; }
}

.game-ava.ava-world-arcane .ava-fx::before {
    content: "";
    position: absolute;
    width: 70%;
    height: 45%;
    left: -10%;
    bottom: -12%;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(195, 60, 255, 0.55), rgba(255, 60, 170, 0.18) 45%, transparent 70%);
    mix-blend-mode: screen;
    animation: game-ava-wisp 11s ease-in-out infinite alternate;
    animation-delay: calc(var(--d) * -11s);
}

@keyframes game-ava-wisp {
    from { transform: translate(0, 0) scale(0.9); opacity: 0.5; }
    to { transform: translate(55%, -18%) scale(1.25); opacity: 1; }
}

/* ---------------------------------------------------------------------------------------------
 * The Lord of the Rings: a gold band whose runes glow like the heated Ring, rising embers, a warm
 * firelight flicker.
 * ------------------------------------------------------------------------------------------- */

.game-ava.ava-world-lotr {
    --backdrop: radial-gradient(circle at 50% 100%, #7a4a14, transparent 65%), radial-gradient(circle at 50% 20%, #3b3a2e, #15110a 75%);
    --c1: #d4a537;
    --c2: #fff0b3;
    --glow: rgba(255, 122, 26, 0.45);
    --ring-paint: conic-gradient(#4a3008, #8a6414, #d4a537, #8a6414, #4a3008, #8a6414, #d4a537, #8a6414, #4a3008);
    --ring-spin: 20s;
    --ring-w: 5.4em;
}

.game-ava.ava-world-lotr .ava-front .runes {
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 0 0.6em #ff5a00) drop-shadow(0 0 1.4em #ff5a00);
    animation: game-ava-spin 40s linear infinite;
    animation-delay: calc(var(--d) * -40s);
}

.game-ava.ava-world-lotr .ava-front .runes text {
    font-size: 5.2px;
    letter-spacing: 1.05px;
    font-weight: 700;
    fill: #ffd27a;
    font-family: "Segoe UI Historic", "Noto Sans Runic", "Segoe UI Symbol", serif;
    animation: game-ava-heat 5s ease-in-out infinite;
    animation-delay: calc(var(--d) * -5s);
}

@keyframes game-ava-heat {
    0%, 100% { opacity: 0.25; fill: #ff9a3a; }
    50% { opacity: 1; fill: #fff6d0; }
}

.game-ava.ava-world-lotr i.rise {
    background: radial-gradient(circle, #fff0b3 0 20%, #ff7a1a 45%, transparent 70%);
    animation-name: game-ava-ember;
}

@keyframes game-ava-ember {
    0% { transform: translate(0, 0) scale(0.8); opacity: 0; }
    10% { opacity: 1; }
    40% { transform: translate(calc(var(--dx, 0em) * -0.6), -38em) scale(1); opacity: 0.9; }
    100% { transform: translate(var(--dx, 0em), -92em) scale(0.3); opacity: 0; }
}

.game-ava.ava-world-lotr .ava-fx::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 110%, rgba(255, 122, 26, 0.38), transparent 60%);
    mix-blend-mode: screen;
    animation: game-ava-flicker 2.3s steps(1, end) infinite;
    animation-delay: calc(var(--d) * -2.3s);
}

@keyframes game-ava-flicker {
    0% { opacity: 0.6; }
    20% { opacity: 0.85; }
    35% { opacity: 0.5; }
    55% { opacity: 1; }
    70% { opacity: 0.7; }
    85% { opacity: 0.9; }
}

/* ---------------------------------------------------------------------------------------------
 * Cyberpunk: Edgerunners: a flickering neon rim with HUD ticks, scanlines, and a short RGB glitch
 * every few seconds.
 * ------------------------------------------------------------------------------------------- */

.game-ava.ava-world-edgerunners {
    --backdrop: radial-gradient(circle at 80% 20%, rgba(255, 42, 109, 0.55), transparent 45%), linear-gradient(160deg, #2a0a3a, #0a0f2a 55%, #003a44);
    --c1: #f3e600;
    --c2: #00f0ff;
    --glow: rgba(243, 230, 0, 0.4);
    --ring-paint: conic-gradient(#f3e600 0 70deg, transparent 70deg 90deg, #00f0ff 90deg 200deg, transparent 200deg 215deg, #ff2a6d 215deg 300deg, transparent 300deg 315deg, #f3e600 315deg);
    --ring-spin: 6s;
    --ring-w: 2.6em;
}

.game-ava.ava-world-edgerunners .ava-ring::before {
    filter: drop-shadow(0 0 1em #00f0ff);
    animation: game-ava-spin 6s linear infinite, game-ava-neon 3.1s steps(1, end) infinite;
}

@keyframes game-ava-neon {
    0%, 100% { opacity: 1; }
    8% { opacity: 0.35; }
    10% { opacity: 1; }
    62% { opacity: 0.6; }
    64% { opacity: 1; }
}

/* HUD ticks turning the other way. */
.game-ava.ava-world-edgerunners .ava-ring::after {
    content: "";
    position: absolute;
    inset: 2.5em;
    border-radius: 50%;
    background: repeating-conic-gradient(rgba(0, 240, 255, 0.85) 0 2deg, transparent 2deg 15deg);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2em), #000 calc(100% - 2em + 0.5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 2em), #000 calc(100% - 2em + 0.5px));
    animation: game-ava-spin-back 16s linear infinite;
}

.game-ava.ava-world-edgerunners .ava-fx::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.16) 0 0.5em, transparent 0.5em 1.8em);
    mix-blend-mode: multiply;
}

/* The glitch: two copies of the picture (--img) shifted sideways in thin slices, cyan and magenta.
   Without --img (the picture not in yet) they draw nothing. */
.game-ava.ava-world-edgerunners .ava-fx::after,
.game-ava.ava-world-edgerunners .ava-fx .glitch {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--img, none) center / cover no-repeat;
    opacity: 0;
    mix-blend-mode: screen;
    animation: game-ava-glitch-a 4.2s steps(1, end) infinite;
    animation-delay: calc(var(--d) * -4.2s);
}

.game-ava.ava-world-edgerunners .ava-fx::after {
    filter: sepia(1) saturate(6) hue-rotate(140deg);
}

.game-ava.ava-world-edgerunners .ava-fx .glitch {
    filter: sepia(1) saturate(6) hue-rotate(280deg);
    animation-name: game-ava-glitch-b;
}

@keyframes game-ava-glitch-a {
    0%, 86%, 100% { opacity: 0; transform: none; clip-path: inset(0 0 0 0); }
    87% { opacity: 0.85; transform: translateX(4em); clip-path: inset(18% 0 62% 0); }
    89% { opacity: 0.85; transform: translateX(-5em); clip-path: inset(55% 0 25% 0); }
    91% { opacity: 0.85; transform: translateX(3em); clip-path: inset(72% 0 8% 0); }
    93% { opacity: 0; }
}

@keyframes game-ava-glitch-b {
    0%, 86%, 100% { opacity: 0; transform: none; clip-path: inset(0 0 0 0); }
    87% { opacity: 0.8; transform: translateX(-4em); clip-path: inset(30% 0 48% 0); }
    90% { opacity: 0.8; transform: translateX(5em); clip-path: inset(8% 0 80% 0); }
    92% { opacity: 0.8; transform: translateX(-2em); clip-path: inset(62% 0 20% 0); }
    94% { opacity: 0; }
}

.game-ava.ava-world-edgerunners i.rise {
    width: 0.8em;
    height: calc(var(--z) * 1.6);
    border-radius: 0.3em;
    background: linear-gradient(180deg, transparent, #00f0ff);
    box-shadow: 0 0 1em #00f0ff;
}

/* ---------------------------------------------------------------------------------------------
 * Invincible: comic speed rays behind, a bold yellow-and-blue inked rim that punches outward, a
 * halftone shade over the photo's edge.
 * ------------------------------------------------------------------------------------------- */

.game-ava.ava-world-invincible {
    --backdrop: radial-gradient(circle, rgba(255, 255, 255, 0.35) 0.8em, transparent 1em) 0 0 / 5em 5em, radial-gradient(circle at 50% 40%, #8cc8ff, #1e5bd8 75%);
    --c1: #ffd200;
    --c2: #1e5bd8;
    --glow: rgba(255, 210, 0, 0.35);
    --ring-paint: conic-gradient(#ffd200 0 180deg, #1e5bd8 180deg 360deg);
    --ring-spin: 30s;
    --ring-w: 4.2em;
}

.game-ava.ava-world-invincible .ava-aura::after {
    content: "";
    position: absolute;
    inset: -2em;
    border-radius: 50%;
    background: repeating-conic-gradient(rgba(255, 255, 255, 0.9) 0 3deg, transparent 3deg 11deg, rgba(255, 210, 0, 0.85) 11deg 13deg, transparent 13deg 20deg);
    -webkit-mask: radial-gradient(circle, transparent 38%, #000 52%, transparent 72%);
    mask: radial-gradient(circle, transparent 38%, #000 52%, transparent 72%);
    animation: game-ava-rays 1.4s linear infinite;
}

@keyframes game-ava-rays {
    0% { transform: rotate(0deg) scale(0.96); opacity: 0.7; }
    50% { transform: rotate(4deg) scale(1.02); opacity: 1; }
    100% { transform: rotate(8deg) scale(0.96); opacity: 0.7; }
}

.game-ava.ava-world-invincible .ava-ring::before {
    box-shadow: inset 0 0 0 1em #0b0d12;
    animation: game-ava-spin 30s linear infinite, game-ava-punch 5s cubic-bezier(0.3, 1.8, 0.5, 1) infinite;
}

.game-ava.ava-world-invincible .ava-disc {
    animation: game-ava-punch 5s cubic-bezier(0.3, 1.8, 0.5, 1) infinite;
    animation-delay: calc(var(--d) * -5s);
}

@keyframes game-ava-punch {
    0%, 78%, 100% { scale: 1; }
    84% { scale: 1.07; }
    90% { scale: 0.98; }
}

.game-ava.ava-world-invincible .ava-fx::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(11, 13, 18, 0.55) 0.9em, transparent 1.1em) 0 0 / 4em 4em;
    -webkit-mask: radial-gradient(circle, transparent 52%, #000 78%);
    mask: radial-gradient(circle, transparent 52%, #000 78%);
}

/* In "pop", Invincible's characters fly: a bigger up-down float. */
.game-ava.ava-world-invincible .ava-pop .ava-cut {
    animation-name: game-ava-fly;
    animation-duration: 3.2s;
    animation-delay: calc(var(--d) * -3.2s);
}

@keyframes game-ava-fly {
    0% { transform: scale(1.06) translateY(1.5%); }
    100% { transform: scale(1.06) translateY(-4%); }
}

.game-ava.ava-world-invincible i.rise {
    width: 0.9em;
    height: calc(var(--z) * 2.4);
    border-radius: 0.4em;
    background: rgba(255, 255, 255, 0.85);
    animation-duration: calc(var(--t) * 0.35s);
}

/* ---------------------------------------------------------------------------------------------
 * The Legend of Vox Machina: a magic circle turning behind, twinkling sparkles, and a d20 that
 * rolls now and then and lands on 20.
 * ------------------------------------------------------------------------------------------- */

.game-ava.ava-world-voxmachina {
    --backdrop: radial-gradient(circle at 50% 30%, #5b3590, #160c2a 72%);
    --c1: #9b5cff;
    --c2: #2de2c9;
    --glow: rgba(155, 92, 255, 0.5);
    --ring-paint: conic-gradient(#2de2c9, #9b5cff, #f0c75e, #9b5cff, #2de2c9);
    --ring-spin: 9s;
    --ring-w: 2.8em;
}

.game-ava.ava-world-voxmachina .ava-aura .sigil {
    inset: 0;
    width: 100%;
    height: 100%;
    animation: game-ava-spin 24s linear infinite;
    filter: drop-shadow(0 0 0.8em #2de2c9);
}

.game-ava.ava-world-voxmachina .ava-aura .sigil-inner {
    animation: game-ava-spin-back 16s linear infinite;
    transform-origin: 50px 50px;
}

.game-ava.ava-world-voxmachina i.twinkle {
    background: #fff;
    clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
    filter: drop-shadow(0 0 0.6em #2de2c9);
}

.game-ava.ava-world-voxmachina i.twinkle:nth-child(3n) {
    background: #f0c75e;
}

.game-ava.ava-world-voxmachina .ava-front .d20 {
    width: 26em;
    height: 26em;
    left: -2em;
    bottom: -2em;
    animation: game-ava-d20 8s cubic-bezier(0.2, 0.7, 0.2, 1) infinite;
    animation-delay: calc(var(--d) * -8s);
    filter: drop-shadow(0 0.6em 0.8em rgba(0, 0, 0, 0.5));
}

.game-ava.ava-world-voxmachina .ava-front .d20 text {
    font-family: "Segoe UI", sans-serif;
}

@keyframes game-ava-d20 {
    0%, 70% { transform: rotate(0deg) scale(1); }
    72% { transform: rotate(-30deg) scale(0.85) translateY(-8em); }
    82% { transform: rotate(720deg) scale(1.05); }
    86% { transform: rotate(720deg) scale(1.22); }
    92%, 100% { transform: rotate(720deg) scale(1); }
}

.game-ava.ava-world-voxmachina .ava-front .d20 .d20-glow {
    filter: blur(2px);
    animation: game-ava-d20-glow 8s ease-out infinite;
    animation-delay: calc(var(--d) * -8s);
}

@keyframes game-ava-d20-glow {
    0%, 82%, 100% { opacity: 0; }
    86% { opacity: 1; }
}

/* ---------------------------------------------------------------------------------------------
 * Andor: an Imperial hologram - fine scanlines, a scan bar sweeping down, flicker - inside a
 * segmented targeting rim with four brackets.
 * ------------------------------------------------------------------------------------------- */

.game-ava.ava-world-andor {
    --backdrop: radial-gradient(circle at 50% 35%, rgba(111, 211, 255, 0.18), transparent 60%), linear-gradient(180deg, #2b3440, #0f141b);
    --c1: #6fd3ff;
    --c2: #e8742a;
    --glow: rgba(111, 211, 255, 0.35);
    --ring-paint: repeating-conic-gradient(rgba(111, 211, 255, 0.9) 0 26deg, transparent 26deg 30deg);
    --ring-spin: 40s;
    --ring-w: 1.6em;
}

.game-ava.ava-world-andor .ava-ring::after {
    content: "";
    position: absolute;
    inset: 1.5em;
    background:
        linear-gradient(#e8742a, #e8742a) 0 0 / 12em 1em no-repeat,
        linear-gradient(#e8742a, #e8742a) 0 0 / 1em 12em no-repeat,
        linear-gradient(#e8742a, #e8742a) 100% 0 / 12em 1em no-repeat,
        linear-gradient(#e8742a, #e8742a) 100% 0 / 1em 12em no-repeat,
        linear-gradient(#e8742a, #e8742a) 0 100% / 12em 1em no-repeat,
        linear-gradient(#e8742a, #e8742a) 0 100% / 1em 12em no-repeat,
        linear-gradient(#e8742a, #e8742a) 100% 100% / 12em 1em no-repeat,
        linear-gradient(#e8742a, #e8742a) 100% 100% / 1em 12em no-repeat;
    animation: game-ava-lock 7s ease-in-out infinite;
    animation-delay: calc(var(--d) * -7s);
}

/* Close in first, turn while small, open again: the corners never leave the avatar's box. */
@keyframes game-ava-lock {
    0%, 60%, 100% { transform: rotate(0deg) scale(1); opacity: 0.85; }
    64% { transform: rotate(0deg) scale(0.7); opacity: 1; }
    76% { transform: rotate(90deg) scale(0.7); opacity: 1; }
    80% { transform: rotate(90deg) scale(1); opacity: 0.85; }
}

.game-ava.ava-world-andor .ava-fx::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(180deg, rgba(111, 211, 255, 0.16) 0 0.5em, transparent 0.5em 1.4em),
        linear-gradient(180deg, rgba(111, 211, 255, 0.12), rgba(111, 211, 255, 0.04));
    mix-blend-mode: screen;
    animation: game-ava-holo 5s steps(1, end) infinite;
    animation-delay: calc(var(--d) * -5s);
}

@keyframes game-ava-holo {
    0%, 100% { opacity: 1; }
    40% { opacity: 0.55; }
    42% { opacity: 1; }
    43% { opacity: 0.4; }
    45% { opacity: 1; }
}

.game-ava.ava-world-andor .ava-fx::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 14%;
    background: linear-gradient(180deg, transparent, rgba(160, 230, 255, 0.55) 60%, rgba(255, 255, 255, 0.85) 62%, transparent 66%);
    mix-blend-mode: screen;
    animation: game-ava-scan 4s linear infinite;
    animation-delay: calc(var(--d) * -4s);
}

@keyframes game-ava-scan {
    0% { transform: translateY(-110%); }
    70%, 100% { transform: translateY(760%); }
}

.game-ava.ava-world-andor i.rise {
    width: 0.7em;
    height: 0.7em;
    border-radius: 0;
    background: #6fd3ff;
    box-shadow: 0 0 0.8em #6fd3ff;
}

/* ---------------------------------------------------------------------------------------------
 * The light version (roster rows, below 60 panel px): eight of them sit on screen all day on a
 * mid-range panel. Only the rim turns (a transform); the aura, the particles, the ornaments, the
 * overlays and the world's second rim are not drawn, and nothing else moves. Last in the file so it
 * wins over the world rules of the same weight above.
 * ------------------------------------------------------------------------------------------- */

.game-ava.ava-light .ava-aura,
.game-ava.ava-light .ava-front,
.game-ava.ava-light .ava-mid,
.game-ava.ava-light .ava-fx,
.game-ava.ava-light .ava-ring::after {
    display: none;
}

.game-ava.ava-light .ava-ring::before {
    filter: none;
    animation: game-ava-spin var(--ring-spin, 10s) linear infinite;
}

.game-ava.ava-light .ava-disc,
.game-ava.ava-light .ava-disc::before,
.game-ava.ava-light .ava-photo {
    animation: none;
}

/* The pop-out stands still at the middle of its usual drift. */
.game-ava.ava-light.ava-mode-pop .ava-photo,
.game-ava.ava-light.ava-mode-pop .ava-disc::before {
    transform: scale(1.2);
}

.game-ava.ava-light .ava-pop .ava-cut {
    animation: none;
    transform: scale(1.08);
}
