.has-gengar-ability-rage { container: gengar-rage / inline-size; }
.has-gengar-ability-rage::before { content: none; }

.gengar-ability-rage {
    --rage-ink: #14100e;
    --rage-edge: color-mix(in srgb, var(--rage-glow) 43%, transparent);
    --rage-text: color-mix(in srgb, var(--rage-glow) 54%, #fff5f1);
    --rage-frenzy: #f7a3b7;
    --rage-exhaust: #aed1e2;
    display: grid;
    gap: 12px;
    min-width: 0;
    padding: clamp(12px, 2.4cqw, 20px);
    border: 1px solid var(--rage-edge);
    border-radius: 14px;
    background:
        radial-gradient(ellipse at 22% 0%, color-mix(in srgb, var(--rage-vein) 15%, transparent), transparent 63%),
        linear-gradient(146deg, color-mix(in srgb, var(--rage-stone) 82%, #12130e), var(--rage-ink) 70%);
    box-shadow: inset 0 0 0 3px #06050963, 0 10px 25px #02071050;
}
.gengar-ability-rage[data-gengar-theme=rem] {
    --rage-ink: #0e0a19;
    --rage-frenzy: #e2a4ff;
    --rage-exhaust: #b9cfdf;
    background:
        radial-gradient(ellipse at 13% 0%, color-mix(in srgb, var(--rage-vein) 65%, transparent), transparent 75%),
        linear-gradient(146deg, #221832, var(--rage-ink) 65%);
}

.gengar-ability-rage__header, .gengar-ability-rage__stage {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 10px;
}
.gengar-ability-rage__header {
    justify-content: space-between;
    color: var(--rage-text);
    font-size: .8em;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.gengar-ability-rage__actual, .gengar-ability-rage__stage > span {
    padding: 2px 8px;
    border: 1px solid var(--rage-edge);
    border-radius: 999px;
    background: #06060996;
    color: var(--rage-text);
    font-size: .71em;
    font-weight: 750;
    letter-spacing: .05em;
    line-height: 1.4;
    text-transform: uppercase;
}
.gengar-ability-rage__progress { display: grid; gap: 5px; color: #e4e2e6; font-size: .79em; }
.gengar-ability-rage__progress progress:not([hidden]) {
    appearance: none;
    display: block;
    overflow: hidden;
    width: 100%;
    height: 5px;
    border: 0;
    border-radius: 999px;
    background: #09070bc0;
    accent-color: var(--rage-glow);
}
.gengar-ability-rage__progress progress::-webkit-progress-bar { background: #09070bc0; }
.gengar-ability-rage__progress progress::-webkit-progress-value { background: linear-gradient(90deg, var(--rage-vein), var(--rage-glow)); }
.gengar-ability-rage__progress progress::-moz-progress-bar { background: linear-gradient(90deg, var(--rage-vein), var(--rage-glow)); }

.gengar-ability-rage__selector { display: grid; gap: 8px; min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.gengar-ability-rage__levels { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(4px, 1.1cqw, 9px); }
.gengar-ability-rage__phases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(4px, 1.1cqw, 9px); }
.gengar-ability-rage__node { position: relative; min-width: 0; cursor: pointer; }
.gengar-ability-rage__node > input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.gengar-ability-rage__choice {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 1px;
    min-height: 65px;
    box-sizing: border-box;
    padding: 4px 2px 7px;
    border: 1px solid color-mix(in srgb, var(--rage-glow) 27%, #1f1a22);
    border-radius: 7px;
    background:
        linear-gradient(126deg, transparent 36%, color-mix(in srgb, var(--rage-glow) 7%, transparent) 37% 39%, transparent 40%),
        linear-gradient(154deg, color-mix(in srgb, var(--rage-stone) 43%, #211b24), #100c14 72%);
    color: #e3e0e5;
    line-height: 1.16;
    text-align: center;
    transition: box-shadow .16s ease, border-color .16s ease;
}
.gengar-ability-rage__choice img { width: min(100%, 35px); height: 31px; object-fit: contain; opacity: .48; }
.gengar-ability-rage__levels .gengar-ability-rage__choice { position: relative; isolation: isolate; overflow: hidden; }
.gengar-ability-rage__levels .gengar-ability-rage__choice::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 0;
    background: linear-gradient(128deg, transparent 8%, var(--rage-glow) 45%, var(--rage-vein) 62%, transparent 85%);
    clip-path: polygon(15% 100%, 30% 66%, 24% 67%, 38% 44%, 52% 40%, 57% 19%, 72% 0, 60% 20%,
        54% 44%, 39% 47%, 28% 63%, 34% 62%, 18% 100%);
    opacity: .18;
    pointer-events: none;
}
.gengar-ability-rage__levels .has-reached-rage .gengar-ability-rage__choice::before { opacity: .55; }
.gengar-ability-rage__node.has-reached-rage img,
.gengar-ability-rage__node > input:checked + .gengar-ability-rage__choice img { opacity: 1; }
.gengar-ability-rage__node.has-reached-rage img { filter: drop-shadow(0 0 5px color-mix(in srgb, var(--rage-vein) 67%, transparent)); }
.gengar-ability-rage__node.has-current-rage::after {
    content: '';
    position: absolute;
    inset: auto 28% 4px;
    height: 2px;
    background: var(--rage-glow);
    box-shadow: 0 0 7px var(--rage-glow);
}
.gengar-ability-rage__node:hover > span, .gengar-ability-rage__node > input:checked + span {
    border-color: var(--rage-glow);
    box-shadow: inset 0 0 18px color-mix(in srgb, var(--rage-vein) 29%, transparent);
    color: #fffcff;
}
.gengar-ability-rage__node > input:focus-visible + span { outline: 2px solid var(--rage-glow); outline-offset: 2px; }
.gengar-ability-rage__phases .gengar-ability-rage__node[data-rage-stage=frenzy] { --rage-glow: var(--rage-frenzy); }
.gengar-ability-rage__phases .gengar-ability-rage__node[data-rage-stage=exhaust] { --rage-glow: var(--rage-exhaust); }
.gengar-ability-rage__phases .gengar-ability-rage__choice {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: center;
    justify-items: start;
    align-items: center;
    gap: 2px 8px;
    min-height: 54px;
    padding: 6px 8px 8px;
    background: linear-gradient(115deg, color-mix(in srgb, var(--rage-glow) 19%, #17101c), #0d0c13 65%);
    color: var(--rage-glow);
    text-align: left;
}
.gengar-ability-rage__phases img { grid-row: 1 / span 2; width: 34px; height: 34px; opacity: .9; border-radius: 5px; }
.gengar-ability-rage__phases b { font-size: .8em; }
.gengar-ability-rage__phases small { color: #d8d2df; font-size: .66em; }

.gengar-ability-rage__readout {
    position: relative;
    display: grid;
    grid-template: 'heading fist' auto 'passive fist' auto 'effect fist' auto / minmax(0, 1fr) min(18cqw, 128px);
    align-content: start;
    align-items: center;
    gap: 8px 6px;
    min-height: 120px;
    padding: clamp(9px, 2cqw, 16px);
    border: 1px solid var(--rage-edge);
    border-radius: 9px;
    background: radial-gradient(ellipse at 90% 38%, color-mix(in srgb, var(--rage-vein) 17%, transparent), transparent 63%), #08070cd9;
}
.gengar-ability-rage[data-viewed-rage=frenzy] .gengar-ability-rage__readout { border-color: color-mix(in srgb, var(--rage-frenzy) 62%, transparent); }
.gengar-ability-rage[data-viewed-rage=exhaust] .gengar-ability-rage__readout { border-color: color-mix(in srgb, var(--rage-exhaust) 62%, transparent); }
.gengar-ability-rage__fist {
    grid-area: fist;
    width: 100%;
    max-height: 130px;
    object-fit: contain;
    filter: drop-shadow(0 0 9px color-mix(in srgb, var(--rage-vein) 46%, transparent));
}
.gengar-ability-rage[data-viewed-rage=exhaust] .gengar-ability-rage__fist { filter: saturate(.35) brightness(.75); }
.gengar-ability-rage__stage { grid-area: heading; color: #fffbf0; line-height: 1.2; }
.gengar-ability-rage__stage > span { font-size: .64em; }
.gengar-ability-rage__passive:not([hidden]) { grid-area: passive; display: flex; flex-wrap: wrap; gap: 4px; }
.gengar-ability-rage__passive > span {
    padding: 2px 6px;
    border: 1px solid color-mix(in srgb, var(--rage-glow) 24%, transparent);
    border-radius: 4px;
    background: #0d0b16a8;
    color: #efeae7;
    font-size: .67em;
    line-height: 1.4;
}
.gengar-ability-rage__effect { grid-area: effect; color: #e2e7ef; font-size: .88em; line-height: 1.5; }
.gengar-ability-rage__baseline { margin-top: 6px; color: #c7c4ca; font-size: .9em; }
.gengar-ability-rage__baseline strong { color: var(--rage-glow); }

@container gengar-rage (max-width: 420px) {
    .gengar-ability-rage__phases img { width: 26px; height: 26px; }
    .gengar-ability-rage__phases .gengar-ability-rage__choice { gap: 2px 5px; padding-inline: 6px; }
    .gengar-ability-rage__readout { grid-template: 'heading fist' auto 'passive passive' auto 'effect effect' auto / minmax(0, 1fr) 48px; }
}
@container gengar-rage (max-width: 300px) {
    .gengar-ability-rage__phases .gengar-ability-rage__choice { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
    .gengar-ability-rage__phases img { grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .gengar-ability-rage__choice { transition: none; }
}
