.missav-legend-popup {
    --missav-legend-bottom: max(14px, env(safe-area-inset-bottom));
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: var(--missav-legend-bottom);
    z-index: 9989;
    width: clamp(208px, 42vw, 300px);
    max-width: calc(100vw - 28px);
    color: #fff;
    line-height: 1.2;
    animation: missav-legend-popup-enter .32s ease-out both;
}
#missav-telegram-invite.missav-tg {
    top: auto !important;
    right: max(14px, env(safe-area-inset-right)) !important;
    bottom: max(14px, env(safe-area-inset-bottom)) !important;
    transition: bottom .34s cubic-bezier(.22, .8, .24, 1) !important;
    animation: missav-legend-telegram-enter .32s ease-out both !important;
}
#missav-telegram-invite.missav-tg.missav-legend-telegram--above {
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--missav-legend-popup-height, 0px) + 12px) !important;
}
#missav-telegram-invite.missav-tg.missav-legend-telegram--lowered {
    bottom: max(14px, env(safe-area-inset-bottom)) !important;
}
.missav-legend-popup[hidden] { display: none !important; }
.missav-legend-popup__card {
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(255, 126, 182, .92);
    border-radius: 18px;
    background: linear-gradient(145deg, #231322, #11131d 58%, #261323);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .60), 0 0 0 4px rgba(255, 43, 116, .18), 0 0 22px rgba(255, 61, 144, .42);
    animation: missav-legend-card-glow 2.7s 1s ease-in-out infinite;
}
.missav-legend-popup__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 34px;
    padding: 0 11px;
    border-bottom: 1px solid rgba(255, 255, 255, .14);
    background: linear-gradient(90deg, #33152f, #1a1727);
    font: 800 10px/1.2 Arial, sans-serif;
    letter-spacing: .045em;
}
.missav-legend-popup__header span::before {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin: 0 6px 0 0;
    border-radius: 50%;
    background: #ff4c90;
    box-shadow: 0 0 0 3px rgba(255, 76, 144, .16);
    content: "";
}
.missav-legend-popup__header em {
    padding: 4px 6px;
    color: #ffc5dd;
    border: 1px solid rgba(255, 178, 211, .36);
    border-radius: 999px;
    font-size: 9px;
    font-style: normal;
}
.missav-legend-popup__art-link {
    display: block;
    color: inherit;
    text-decoration: none;
}
.missav-legend-popup__art-link:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -4px;
}
.missav-legend-popup__art {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    margin: 0;
    border: 0;
    object-fit: contain;
    filter: saturate(1.08) contrast(1.04);
}
.missav-legend-popup__close {
    position: absolute;
    z-index: 2;
    top: 40px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .56);
    border-radius: 50%;
    background: rgba(14, 10, 20, .72);
    font: 24px/1 Arial, sans-serif;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.missav-legend-popup__footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 10px;
    background: #17151e;
}
.missav-legend-popup__copy {
    display: contents;
}
.missav-legend-popup__copy strong,
.missav-legend-popup__copy small { display: block; }
.missav-legend-popup__copy strong {
    min-width: 0;
    flex: 1 1 auto;
    font: 800 12px/1.1 Arial, sans-serif;
    letter-spacing: .02em;
}
.missav-legend-popup__copy small {
    flex: 0 0 100%;
    order: 3;
    margin-top: 0;
    color: #c4b9c4;
    font: 400 9px/1.3 Arial, sans-serif;
    white-space: normal;
}
.missav-legend-popup__actions {
    display: flex;
    flex: 0 0 auto;
    order: 2;
    gap: 6px;
}
.missav-legend-popup__actions button,
.missav-legend-popup__actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid rgba(255, 151, 193, .90);
    border-radius: 9px;
    font: 800 10px/1 Arial, sans-serif;
    cursor: pointer;
    text-decoration: none;
}
.missav-legend-popup__join {
    color: #fff !important;
    min-height: 42px !important;
    padding: 0 13px !important;
    border: 2px solid #fff4fa !important;
    background: linear-gradient(135deg, #ff6cab, #d51059 52%, #8a0b3d);
    box-shadow: 0 5px 14px rgba(229, 36, 105, .58), inset 0 1px 0 rgba(255, 255, 255, .38);
    font-size: 12px !important;
    font-weight: 900 !important;
    letter-spacing: .035em;
    text-shadow: 0 1px 2px #550421, 0 0 5px rgba(75, 0, 28, .88);
    white-space: nowrap;
}
.missav-legend-popup__join:not([aria-disabled="true"]) {
    animation: missav-legend-cta-pulse 2.2s 1.3s ease-in-out infinite;
}
.missav-legend-popup__later {
    color: #f5ddea;
    border-color: rgba(255, 255, 255, .21) !important;
    background: rgba(255, 255, 255, .08);
}
.missav-legend-popup__push {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 8px;
    padding: 8px 10px;
    border-top: 1px solid rgba(255, 255, 255, .12);
    background: linear-gradient(90deg, rgba(69, 22, 60, .96), rgba(26, 20, 38, .96));
}
.missav-legend-popup__push strong,
.missav-legend-popup__push small { display: block; }
.missav-legend-popup__push strong { font: 800 10px/1.2 Arial, sans-serif; }
.missav-legend-popup__push small { margin-top: 2px; color: #d3bfd0; font: 400 8px/1.2 Arial, sans-serif; }
.missav-legend-popup__notify {
    min-height: 30px;
    padding: 0 8px;
    color: #fff;
    border: 1px solid rgba(255, 200, 223, .92);
    border-radius: 8px;
    background: linear-gradient(135deg, #a14af5, #e72c8d);
    font: 800 9px/1 Arial, sans-serif;
    cursor: pointer;
}
.missav-legend-popup__notify:disabled { cursor: wait; opacity: .72; }
.missav-legend-popup__push-status {
    grid-column: 1 / -1;
    margin: 0;
    color: #f5ddea;
    font: 400 8px/1.25 Arial, sans-serif;
}
.missav-legend-popup__push-status:empty { display: none; }
.missav-legend-popup__push-status[data-state="denied"],
.missav-legend-popup__push-status[data-state="error"] { color: #ffc0cd; }
.missav-legend-popup__push-status[data-state="granted"] { color: #a9f8c7; }
.missav-legend-popup__close:hover,
.missav-legend-popup__later:hover { background-color: rgba(255, 255, 255, .14); }
.missav-legend-popup__join:hover,
.missav-legend-popup__notify:hover { filter: brightness(1.1); }
.missav-legend-popup__join:focus-visible,
.missav-legend-popup__later:focus-visible,
.missav-legend-popup__close:focus-visible,
.missav-legend-popup__notify:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
@keyframes missav-legend-popup-enter {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes missav-legend-telegram-enter {
    from { opacity: 0; transform: translateY(-14px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes missav-legend-card-glow {
    0%, 100% { box-shadow: 0 14px 34px rgba(0, 0, 0, .60), 0 0 0 4px rgba(255, 43, 116, .18), 0 0 22px rgba(255, 61, 144, .42); }
    50% { box-shadow: 0 16px 38px rgba(0, 0, 0, .64), 0 0 0 6px rgba(255, 43, 116, .26), 0 0 34px rgba(255, 83, 156, .72); }
}
@keyframes missav-legend-cta-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 5px 12px rgba(229, 36, 105, .36); }
    50% { transform: scale(1.055); box-shadow: 0 7px 18px rgba(255, 71, 144, .68); }
}
@media (max-height: 620px) {
    .missav-legend-popup { width: min(208px, 33vh); }
}
@media (max-width: 600px) {
    .missav-legend-popup {
        left: auto;
        right: max(14px, env(safe-area-inset-right));
        bottom: max(14px, env(safe-area-inset-bottom));
        width: min(208px, 33vh);
        max-width: calc(100vw - 28px);
    }
    .missav-legend-popup__card { border-radius: 18px; }
    .missav-legend-popup__copy strong { flex-basis: 100%; }
    .missav-legend-popup__actions { margin-left: auto; }
    #missav-telegram-invite.missav-tg { right: max(14px, env(safe-area-inset-right)) !important; }
    #missav-telegram-invite.missav-tg.missav-legend-telegram--above {
        bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--missav-legend-popup-height, 0px) + 12px) !important;
    }
    #missav-telegram-invite.missav-tg.missav-legend-telegram--lowered {
        bottom: max(14px, env(safe-area-inset-bottom)) !important;
    }
}
@media (prefers-reduced-motion: reduce) {
    .missav-legend-popup,
    #missav-telegram-invite.missav-tg,
    .missav-legend-popup__card,
    .missav-legend-popup__join { animation: none !important; }
}
