body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    padding: clamp(24px, 5vw, 56px) 16px 48px;
    color: #1c1c1c;
    background: #f6f6f4;
}

h1 {
    text-align: center;
    margin: 0 0 clamp(24px, 4vw, 36px);
    font-size: clamp(30px, 5vw, 44px);
    line-height: 1.1;
}

.virus-list {
    width: min(100%, 760px);
    margin: 0 auto;
    display: grid;
    gap: 8px;
}

.virus-item {
    padding: 2px 0;
}

.virus-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 4px 8px 4px 0;
}

.virus-name {
    flex: 1;
    min-width: 0;
    color: #1717a5;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.arrow {
    flex: 0 0 40px;
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    background: #f0f0ed;
    cursor: pointer;
    color: #333;
    font-size: 13px;
    transition: background-color 150ms ease;
}

.arrow:hover {
    background: #e4e4df;
}

.arrow:focus-visible,
.virus-name:focus-visible {
    outline: 3px solid #77a7ff;
    outline-offset: 2px;
}

.dropdown {
    display: none;
    padding: 0 52px 14px 0;
}

.dropdown.open {
    display: grid;
    justify-items: start;
    gap: 12px;
}

.desc {
    margin: 0;
    max-width: 65ch;
    line-height: 1.55;
}

.img-pulse {
    display: inline-block;
    animation: pulse 1.5s ease-in-out infinite;
}

.img-rotate {
    animation: sway 2s ease-in-out infinite, rgbGlow 3s linear infinite;
}

.virus-img {
    display: block;
    width: min(200px, 100%);
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
}

.chaos-rope {
    --pull-distance: 0px;
    position: fixed;
    top: 0;
    right: 28px;
    z-index: 1000;
    width: 38px;
    height: 185px;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.chaos-rope.pulling {
    cursor: grabbing;
}

.chaos-rope-line {
    position: absolute;
    top: 0;
    left: 18px;
    width: 3px;
    height: calc(112px + var(--pull-distance));
    background: repeating-linear-gradient(135deg, #c79a62 0 5px, #75451e 5px 9px);
    box-shadow: 1px 0 2px rgb(0 0 0 / 45%);
    transition: height 120ms ease-out;
}

.chaos-rope-handle {
    position: absolute;
    top: calc(101px + var(--pull-distance));
    left: 3px;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 3px solid #75451e;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffe36d, #d4750e 68%, #6b2504);
    box-shadow: 0 3px 5px rgb(0 0 0 / 45%);
    color: #fff4b0;
    font-size: 18px;
    transition: top 120ms ease-out;
}

.chaos-rope.activated {
    pointer-events: none;
    animation: chaosRope 160ms linear infinite;
}

body.chaos-active {
    overflow: hidden;
    background: linear-gradient(130deg, #f00, #0f0, #00f, #f0f, #ff0, #0ff, #f00);
    background-size: 500% 500%;
    animation: rgbBackground 420ms linear infinite;
}

body.chaos-active .img-pulse,
body.chaos-active .img-rotate {
    animation: none;
    transform: none;
}

/* Карточки больше не нужны, когда их содержимое разлетается по экрану. */
body.chaos-active .virus-item {
    visibility: hidden;
}

body.chaos-active .chaos-flyer {
    position: fixed;
    top: var(--chaos-y);
    left: var(--chaos-x);
    z-index: 50;
    margin: 0;
    max-width: min(260px, 62vw);
    color: #f00;
    line-height: 1.15;
    text-align: center;
    text-decoration-thickness: 2px;
    visibility: visible;
    will-change: transform, color, filter;
    animation:
        chaosMotion var(--chaos-motion-duration) linear var(--chaos-motion-delay) infinite alternate,
        rgbText 290ms linear var(--chaos-color-delay) infinite;
}

body.chaos-active .virus-img.chaos-flyer {
    max-width: min(200px, 45vw);
    max-height: min(200px, 38vh);
    object-fit: contain;
    animation:
        chaosMotion var(--chaos-motion-duration) linear var(--chaos-motion-delay) infinite alternate,
        rgbImage 240ms linear var(--chaos-color-delay) infinite;
}

@keyframes chaosMotion {
    0% {
        transform: translate3d(0, 0, 0) rotate(var(--chaos-rotate-start)) scale(1);
    }
    38% {
        transform: translate3d(var(--chaos-x-one), var(--chaos-y-one), 0) rotate(var(--chaos-rotate-one)) scale(1.16);
    }
    72% {
        transform: translate3d(var(--chaos-x-two), var(--chaos-y-two), 0) rotate(var(--chaos-rotate-two)) scale(0.82);
    }
    100% {
        transform: translate3d(0, 0, 0) rotate(var(--chaos-rotate-start)) scale(1.06);
    }
}

@keyframes rgbBackground {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

@keyframes rgbText {
    0% { color: #f00; text-shadow: 2px 2px 0 #0ff, -2px -2px 0 #00f; }
    33% { color: #0f0; text-shadow: 2px 2px 0 #f0f, -2px -2px 0 #f00; }
    66% { color: #00f; text-shadow: 2px 2px 0 #ff0, -2px -2px 0 #0f0; }
    100% { color: #f00; text-shadow: 2px 2px 0 #0ff, -2px -2px 0 #00f; }
}

@keyframes rgbImage {
    0% { filter: hue-rotate(0deg) saturate(2) drop-shadow(0 0 8px #f00); }
    33% { filter: hue-rotate(120deg) saturate(2.4) drop-shadow(0 0 12px #0f0); }
    66% { filter: hue-rotate(240deg) saturate(2.2) drop-shadow(0 0 15px #00f); }
    100% { filter: hue-rotate(360deg) saturate(2) drop-shadow(0 0 8px #f00); }
}

@keyframes chaosRope {
    0%, 100% { transform: translateX(-2px) rotate(-3deg); }
    50% { transform: translateX(2px) rotate(3deg); }
}

@media (max-width: 600px) {
    body {
        padding: 22px 12px 36px;
    }

    .virus-list {
        width: calc(100% - 52px);
        margin-left: 0;
        margin-right: auto;
        gap: 9px;
    }

    .virus-row {
        gap: 8px;
        min-height: 48px;
        padding-left: 0;
    }

    .arrow {
        flex-basis: 38px;
        min-height: 38px;
    }

    .dropdown {
        padding: 0 46px 14px 0;
    }

    .chaos-rope {
        right: 14px;
    }

    body.chaos-active .chaos-flyer {
        max-width: 72vw;
        font-size: clamp(14px, 4.5vw, 24px);
    }

    body.chaos-active .virus-img.chaos-flyer {
        max-width: 44vw;
        max-height: 31vh;
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes sway {
    0%, 100% { transform: rotate(-20deg); }
    50% { transform: rotate(20deg); }
}

@keyframes rgbGlow {
    0%   { filter: drop-shadow(0 0 6px #ff0000); }
    33%  { filter: drop-shadow(0 0 12px #00ff00); }
    66%  { filter: drop-shadow(0 0 18px #0088ff); }
    100% { filter: drop-shadow(0 0 6px #ff0000); }
}
