:root {
    --matrix-green: #00e054;
    --matrix-green-bright: #b0ffcc;
    --matrix-green-dim: #003b1a;
    --matrix-cyan: #00e088;
    --bg: #000000;
    --glow-strong: 0 0 8px rgba(0, 224, 84, 0.8), 0 0 20px rgba(0, 224, 84, 0.5), 0 0 40px rgba(0, 224, 84, 0.3);
    --glow-medium: 0 0 6px rgba(0, 224, 84, 0.6), 0 0 15px rgba(0, 224, 84, 0.4);
    --font-matrix: 'Share Tech Mono', 'Courier New', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    --auth-origin-x: 190px;
    --auth-origin-y: 110px;
    --auth-wave-radius: 1200px;
    --auth-wave-diameter: 2400px;
    background: var(--bg);
    overflow: hidden;
    font-family: var(--font-matrix);
    cursor: crosshair;
    user-select: none;
    -webkit-user-select: none;
    height: 100vh;
    width: 100vw;
    position: relative;
}

#matrixCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
    transition: filter 0.65s ease;
    will-change: transform, filter;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(ellipse at center,
            transparent 0%,
            transparent 40%,
            rgba(0, 0, 0, 0.4) 70%,
            rgba(0, 0, 0, 0.85) 100%);
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.15) 3px,
            rgba(0, 0, 0, 0.15) 4px);
    opacity: 0.6;
    mix-blend-mode: multiply;
}

.noise {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    pointer-events: none;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.5'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    animation: noiseShift 0.5s steps(4) infinite;
}

.phase-sweep {
    position: fixed;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-105%);
    background: linear-gradient(to bottom,
            transparent 0%,
            transparent 44%,
            rgba(0, 255, 100, 0.05) 48%,
            rgba(150, 255, 190, 0.42) 50%,
            rgba(0, 255, 100, 0.08) 52%,
            transparent 57%,
            transparent 100%);
    mix-blend-mode: screen;
}

.auth-scene-tint {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    background:
        radial-gradient(circle at var(--auth-origin-x) var(--auth-origin-y), rgba(190, 0, 42, 0.22) 0%, rgba(115, 0, 30, 0.12) 28%, rgba(60, 0, 18, 0.055) 58%, transparent 78%),
        linear-gradient(rgba(75, 0, 18, 0.055), rgba(55, 0, 15, 0.075));
    mix-blend-mode: screen;
    clip-path: circle(0 at var(--auth-origin-x) var(--auth-origin-y));
    transition: opacity 0.9s ease-in-out;
}

body.auth-alert .auth-scene-tint {
    animation: authSceneSpread 2.25s linear both;
}

body.access-granted .auth-scene-tint {
    opacity: 0;
    clip-path: circle(var(--auth-wave-radius) at var(--auth-origin-x) var(--auth-origin-y));
}

@keyframes authSceneSpread {
    0% {
        opacity: 0.18;
        clip-path: circle(0 at var(--auth-origin-x) var(--auth-origin-y));
    }
    8% { opacity: 0.82; }
    100% {
        opacity: 1;
        clip-path: circle(var(--auth-wave-radius) at var(--auth-origin-x) var(--auth-origin-y));
    }
}

.auth-wave-front {
    position: fixed;
    left: var(--auth-origin-x);
    top: var(--auth-origin-y);
    z-index: 4;
    width: 0;
    height: 0;
    pointer-events: none;
    opacity: 0;
    border: 14px solid rgba(255, 35, 78, 0.14);
    border-radius: 47% 53% 49% 51%;
    transform: translate(-50%, -50%);
    box-shadow:
        0 0 28px 14px rgba(255, 20, 65, 0.22),
        0 0 58px 28px rgba(130, 0, 34, 0.15),
        inset 0 0 34px 16px rgba(255, 25, 70, 0.12);
    filter: blur(17px);
    mix-blend-mode: screen;
    will-change: width, height, opacity, transform;
}

.auth-wave-front::before {
    content: '';
    position: absolute;
    inset: -24px;
    border: 10px solid rgba(255, 50, 88, 0.07);
    border-radius: 52% 48% 54% 46%;
    filter: blur(12px);
}

body.auth-alert .auth-wave-front {
    animation: authWaveFront 2.25s linear both;
}

body.access-granted .auth-wave-front {
    animation: none;
    opacity: 0;
}

@keyframes authWaveFront {
    0% {
        width: 0;
        height: 0;
        opacity: 0;
        transform: translate(-50%, -50%) rotate(-2deg);
    }
    7% { opacity: 0.72; }
    72% { opacity: 0.5; }
    100% {
        width: var(--auth-wave-diameter);
        height: var(--auth-wave-diameter);
        opacity: 0;
        transform: translate(-50%, -50%) rotate(4deg);
    }
}

@keyframes noiseShift {
    0% { background-position: 0 0; }
    25% { background-position: 20px -30px; }
    50% { background-position: -15px 25px; }
    75% { background-position: 30px 15px; }
    100% { background-position: 0 0; }
}

.content-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.glitch-wrapper {
    position: relative;
    text-align: center;
    pointer-events: none;
}

.glitch-title {
    font-size: clamp(2.5rem, 7vw, 6.5rem);
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--matrix-green);
    text-shadow: var(--glow-strong);
    position: relative;
    display: inline-block;
    animation: titleFlicker 4s infinite;
    line-height: 1.1;
    transition: color 1.1s ease-in-out, text-shadow 1.1s ease-in-out;
}

.glitch-title::before,
.glitch-title::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.8;
    transition: color 1.1s ease-in-out, text-shadow 1.1s ease-in-out;
}

.glitch-title::before {
    color: #00cc66;
    z-index: -1;
    animation: glitchShiftA 3.5s infinite;
    clip-path: polygon(0 15%, 100% 15%, 100% 35%, 0 35%);
    text-shadow: -1px 0 rgba(0, 180, 80, 0.5), 1px 0 rgba(0, 220, 120, 0.3);
}

.glitch-title::after {
    color: #aa0055;
    z-index: -2;
    animation: glitchShiftB 2.8s infinite;
    clip-path: polygon(0 65%, 100% 65%, 100% 85%, 0 85%);
    text-shadow: 1px 0 rgba(170, 0, 85, 0.4), -1px 0 rgba(0, 220, 140, 0.25);
}

body.auth-title-alert .glitch-title {
    color: #ff315f;
    text-shadow: 0 0 8px rgba(255, 40, 90, 0.9), 0 0 22px rgba(255, 20, 70, 0.58), 0 0 48px rgba(160, 0, 40, 0.38);
    animation: intrusionTitlePulse 1.15s steps(1, end) infinite;
}

body.auth-title-alert .glitch-title::before {
    color: #ff755c;
    text-shadow: -2px 0 rgba(255, 90, 60, 0.65), 2px 0 rgba(255, 0, 70, 0.4);
}

body.auth-title-alert .glitch-title::after {
    color: #720027;
    text-shadow: 2px 0 rgba(255, 0, 70, 0.55), -2px 0 rgba(90, 0, 35, 0.45);
}

@keyframes intrusionTitlePulse {
    0%, 62%, 100% { transform: translate(0, 0); filter: brightness(1); }
    64% { transform: translate(-3px, 1px); filter: brightness(1.4); }
    67% { transform: translate(4px, -1px); filter: brightness(0.78); }
    70% { transform: translate(-1px, 0); filter: brightness(1.2); }
    73% { transform: translate(0, 0); filter: brightness(1); }
}

@keyframes glitchShiftA {
    0%, 87%, 100% { transform: translate(0, 0); clip-path: polygon(0 15%, 100% 15%, 100% 35%, 0 35%); opacity: 0.8; }
    88% { transform: translate(-10px, 2px); clip-path: polygon(0 5%, 100% 5%, 100% 45%, 0 45%); opacity: 0.6; }
    89% { transform: translate(7px, -1px); clip-path: polygon(0 50%, 100% 50%, 100% 70%, 0 70%); opacity: 0.7; }
    90% { transform: translate(-3px, 0); clip-path: polygon(0 30%, 100% 30%, 100% 55%, 0 55%); opacity: 0.5; }
    91% { transform: translate(5px, -3px); clip-path: polygon(0 10%, 100% 10%, 100% 40%, 0 40%); opacity: 0.7; }
    92% { transform: translate(0, 0); clip-path: polygon(0 15%, 100% 15%, 100% 35%, 0 35%); opacity: 0.8; }
}

@keyframes glitchShiftB {
    0%, 83%, 100% { transform: translate(0, 0); clip-path: polygon(0 65%, 100% 65%, 100% 85%, 0 85%); opacity: 0.8; }
    84% { transform: translate(12px, -2px); clip-path: polygon(0 40%, 100% 40%, 100% 75%, 0 75%); opacity: 0.5; }
    85% { transform: translate(-8px, 3px); clip-path: polygon(0 70%, 100% 70%, 100% 95%, 0 95%); opacity: 0.6; }
    86% { transform: translate(4px, -1px); clip-path: polygon(0 55%, 100% 55%, 100% 80%, 0 80%); opacity: 0.7; }
    87% { transform: translate(-5px, 1px); clip-path: polygon(0 20%, 100% 20%, 100% 60%, 0 60%); opacity: 0.5; }
    88% { transform: translate(0, 0); clip-path: polygon(0 65%, 100% 65%, 100% 85%, 0 85%); opacity: 0.8; }
}

@keyframes titleFlicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
    20%, 22%, 24% { opacity: 0.6; }
    55% { opacity: 0.4; }
}

.domain-tag {
    font-size: clamp(1rem, 2.8vw, 2.2rem);
    color: var(--matrix-cyan);
    text-shadow: var(--glow-medium);
    letter-spacing: 0.4em;
    margin-top: 0.5em;
    opacity: 0.85;
    animation: domainPulse 3s ease-in-out infinite;
    font-weight: 300;
    transition: color 1.1s ease-in-out, text-shadow 1.1s ease-in-out;
}

.domain-origin-dot {
    display: inline-block;
    opacity: 1;
    transition: opacity 0.22s ease, text-shadow 0.22s ease;
}

body.boot-origin-blinking .domain-origin-dot {
    animation: domainOriginBlink 0.72s step-end infinite;
}

body.boot-dot-active .domain-origin-dot {
    opacity: 0;
    text-shadow: 0 0 10px rgba(160, 255, 195, 0.5);
}

@keyframes domainOriginBlink {
    0%, 48% {
        opacity: 1;
        transform: scale(1);
        text-shadow: 0 0 5px rgba(130, 255, 190, 0.55);
    }
    49%, 100% {
        opacity: 0.12;
        transform: scale(0.72);
        text-shadow: 0 0 12px rgba(0, 255, 100, 0.9);
    }
}

body.auth-title-alert .domain-tag {
    color: #ff7893;
    text-shadow: 0 0 8px rgba(255, 65, 105, 0.75), 0 0 24px rgba(180, 0, 45, 0.4);
    animation: intrusionDomainPulse 1.15s ease-in-out infinite;
}

@keyframes intrusionDomainPulse {
    0%, 100% { opacity: 0.72; text-shadow: 0 0 6px rgba(255, 65, 105, 0.5), 0 0 16px rgba(160, 0, 40, 0.28); }
    50% { opacity: 1; text-shadow: 0 0 12px rgba(255, 85, 120, 0.9), 0 0 32px rgba(200, 0, 55, 0.52); }
}

.intrusion-alert {
    position: absolute;
    top: calc(100% + 1.15rem);
    left: 50%;
    color: #ff4c72;
    font-size: clamp(0.7rem, 1.5vw, 1rem);
    letter-spacing: 0.22em;
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, 7px);
    text-shadow: 0 0 6px rgba(255, 40, 85, 0.8), 0 0 18px rgba(180, 0, 45, 0.4);
    transition: opacity 0.55s ease 0.35s, transform 0.55s ease 0.35s;
}

.intrusion-alert::before {
    content: '●';
    display: inline-block;
    margin-right: 0.65em;
}

body.auth-title-alert .intrusion-alert {
    opacity: 0.9;
    transform: translate(-50%, 0);
}

body.auth-title-alert .intrusion-alert::before {
    animation: intrusionIndicatorBlink 0.62s step-end infinite;
}

@keyframes intrusionIndicatorBlink {
    0%, 45% { opacity: 1; }
    46%, 100% { opacity: 0.16; }
}

@keyframes domainPulse {
    0%, 100% { opacity: 0.75; text-shadow: 0 0 6px rgba(0, 224, 136, 0.5), 0 0 15px rgba(0, 224, 136, 0.25); }
    50% { opacity: 1; text-shadow: 0 0 12px rgba(0, 224, 136, 0.8), 0 0 30px rgba(0, 224, 136, 0.4), 0 0 60px rgba(0, 224, 136, 0.15); }
}

.status-line {
    position: absolute;
    bottom: 8%;
    font-size: 0.9rem;
    color: rgba(0, 224, 84, 0.6);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    animation: statusBlink 2s infinite;
    pointer-events: none;
    transition: color 0.8s ease, text-shadow 0.8s ease;
}

body.auth-title-alert .status-line {
    color: rgba(255, 70, 105, 0.82);
    text-shadow: 0 0 7px rgba(255, 30, 80, 0.6);
}

@keyframes statusBlink {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Терминальный блок */
.terminal-boot {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 8;
    width: min(340px, calc(100vw - 40px));
    height: 5px;
    pointer-events: none;
}

.terminal-boot::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    background: var(--matrix-green-bright);
    box-shadow: 0 0 5px rgba(0, 255, 100, 1), 0 0 16px rgba(0, 224, 84, 0.7);
    opacity: 0;
}

.terminal-boot::after {
    width: 0;
    height: 2px;
    top: 1px;
    transform: translateX(-50%);
}

.terminal-boot.active::after {
    animation: terminalBootLine 0.18s cubic-bezier(0.1, 0.85, 0.25, 1) both;
}

.terminal-flight-dot {
    position: fixed;
    z-index: 9;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -50%);
    background: var(--matrix-green-bright);
    box-shadow: 0 0 6px rgba(0, 255, 100, 1), 0 0 18px rgba(0, 224, 84, 0.8), 0 0 36px rgba(0, 180, 70, 0.42);
}

.terminal-flight-dot.visible {
    opacity: 1;
}

.terminal-flight-dot.blinking {
    animation: terminalDestinationBlink 0.72s step-end infinite;
}

.flight-glyph {
    position: fixed;
    z-index: 8;
    pointer-events: none;
    color: rgba(195, 255, 215, 1);
    font-family: var(--font-matrix);
    font-size: var(--trail-size, 14px);
    font-weight: 700;
    line-height: 1;
    text-shadow:
        0 0 4px rgba(220, 255, 230, 1),
        0 0 11px rgba(0, 255, 100, 0.95),
        0 0 24px rgba(0, 220, 84, 0.68);
    transform: translate(-50%, -50%) scale(1);
    animation: flightGlyphFade 1.8s ease-out forwards;
    mix-blend-mode: screen;
    will-change: transform, opacity;
}

@keyframes flightGlyphFade {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.12);
    }
    46% { opacity: 0.92; }
    78% { opacity: 0.58; }
    100% {
        opacity: 0;
        transform:
            translate(
                calc(-50% + var(--trail-drift-x, 0px)),
                calc(-50% + var(--trail-drift-y, 8px))
            )
            scale(0.5);
    }
}

.terminal {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 7;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            180deg,
            rgba(90, 255, 140, 0.052) 0,
            rgba(90, 255, 140, 0.052) 1px,
            rgba(0, 0, 0, 0.12) 1px,
            rgba(0, 0, 0, 0.12) 2px,
            transparent 2px,
            transparent 4px
        ),
        rgba(0, 0, 0, 0.58);
    border: 1px solid rgba(0, 224, 84, 0.3);
    border-color: rgba(70, 255, 135, 0.46) rgba(0, 224, 84, 0.22) rgba(0, 224, 84, 0.26) rgba(35, 240, 110, 0.38);
    border-radius: 4px;
    padding: 8px 12px;
    font-family: var(--font-matrix);
    font-size: 0.8rem;
    color: var(--matrix-green);
    text-shadow: 0 0 3px rgba(0, 224, 84, 0.4);
    box-shadow:
        0 0 15px rgba(0, 224, 84, 0.1),
        inset 0 1px 0 rgba(115, 255, 165, 0.07),
        inset 1px 0 0 rgba(55, 255, 130, 0.045);
    width: min(340px, calc(100vw - 40px));
    height: min(190px, calc(100vh - 40px));
    display: flex;
    flex-direction: column;
    white-space: nowrap;
    overflow: hidden;
    transform-origin: top center;
    transition:
        border-color 0.42s ease-out,
        box-shadow 0.55s ease-out;
}

.terminal::before,
.terminal::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 8px;
    pointer-events: none;
    opacity: 0.76;
    filter: drop-shadow(0 0 3px rgba(0, 255, 100, 0.35));
    transition:
        border-color 0.42s ease-out,
        filter 0.55s ease-out;
}

.terminal::before {
    top: 0;
    right: 0;
    border-top: 2px solid rgba(125, 255, 170, 0.7);
    border-right: 2px solid rgba(60, 255, 130, 0.52);
}

.terminal::after {
    bottom: 0;
    left: 0;
    border-bottom: 2px solid rgba(60, 255, 130, 0.54);
    border-left: 2px solid rgba(0, 224, 84, 0.4);
}

.terminal-frame-detail {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
    background:
        linear-gradient(
            180deg,
            transparent 0%,
            rgba(50, 255, 115, 0.025) 38%,
            rgba(145, 255, 180, 0.12) 50%,
            rgba(50, 255, 115, 0.025) 62%,
            transparent 100%
        ) 0 -72px / 100% 72px no-repeat;
    box-shadow: inset 0 0 24px rgba(0, 255, 100, 0.035);
    opacity: 0.88;
    animation: terminalPhosphorSweep 5.8s linear infinite;
    transition: box-shadow 0.55s ease-out;
}

body.auth-alert .terminal {
    border-color:
        rgba(255, 95, 120, 0.78)
        rgba(255, 35, 75, 0.42)
        rgba(255, 25, 68, 0.52)
        rgba(255, 70, 105, 0.68);
    box-shadow:
        0 0 10px rgba(255, 25, 70, 0.3),
        0 0 28px rgba(185, 0, 45, 0.16),
        inset 0 1px 0 rgba(255, 145, 160, 0.14),
        inset 1px 0 0 rgba(255, 45, 85, 0.09);
    animation: terminalAuthBorderPulse 1.4s ease-in-out infinite;
}

body.auth-alert .terminal::before {
    border-top-color: rgba(255, 150, 165, 0.9);
    border-right-color: rgba(255, 55, 90, 0.75);
    filter: drop-shadow(0 0 5px rgba(255, 25, 70, 0.72));
}

body.auth-alert .terminal::after {
    border-bottom-color: rgba(255, 55, 90, 0.78);
    border-left-color: rgba(255, 25, 70, 0.62);
    filter: drop-shadow(0 0 5px rgba(255, 25, 70, 0.68));
}

body.auth-alert .terminal-frame-detail {
    box-shadow: inset 0 0 24px rgba(255, 20, 65, 0.075);
}

body.auth-alert .terminal-frame-detail::before {
    background: linear-gradient(90deg, transparent, rgba(255, 185, 195, 0.96), transparent);
    box-shadow: 0 0 9px rgba(255, 25, 70, 0.8);
}

body.auth-alert .terminal-frame-detail::after {
    background: linear-gradient(180deg, transparent, rgba(255, 115, 140, 0.9), transparent);
    box-shadow: 0 0 8px rgba(255, 25, 70, 0.7);
}

@keyframes terminalAuthBorderPulse {
    0%, 100% {
        box-shadow:
            0 0 10px rgba(255, 25, 70, 0.26),
            0 0 25px rgba(185, 0, 45, 0.13),
            inset 0 1px 0 rgba(255, 145, 160, 0.12),
            inset 1px 0 0 rgba(255, 45, 85, 0.08);
    }
    38% {
        box-shadow:
            0 0 13px rgba(255, 35, 78, 0.42),
            0 0 36px rgba(205, 0, 50, 0.2),
            inset 0 0 12px rgba(255, 35, 75, 0.07);
    }
    58% {
        box-shadow:
            0 0 8px rgba(255, 25, 70, 0.22),
            0 0 22px rgba(185, 0, 45, 0.1),
            inset 0 1px 0 rgba(255, 145, 160, 0.11);
    }
}

.terminal-frame-detail::before,
.terminal-frame-detail::after {
    content: '';
    position: absolute;
    pointer-events: none;
    opacity: 0;
}

.terminal-frame-detail::before {
    top: 0;
    left: -28%;
    width: 26%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(190, 255, 210, 0.95), transparent);
    box-shadow: 0 0 7px rgba(0, 255, 100, 0.65);
    animation: terminalEdgeSweep 6.8s linear infinite;
}

.terminal-frame-detail::after {
    top: -22%;
    right: 0;
    width: 1px;
    height: 20%;
    background: linear-gradient(180deg, transparent, rgba(145, 255, 180, 0.82), transparent);
    box-shadow: 0 0 6px rgba(0, 255, 100, 0.5);
    animation: terminalEdgeDrop 7.6s linear 1.15s infinite;
}

@keyframes terminalEdgeSweep {
    0%, 8% { left: -28%; opacity: 0; }
    10% { opacity: 0.82; }
    28% { left: 102%; opacity: 0.72; }
    30%, 100% { left: 102%; opacity: 0; }
}

@keyframes terminalEdgeDrop {
    0%, 15% { top: -22%; opacity: 0; }
    17% { opacity: 0.68; }
    34% { top: 102%; opacity: 0.58; }
    36%, 100% { top: 102%; opacity: 0; }
}

@keyframes terminalPhosphorSweep {
    0%, 10% { background-position: 0 -72px; }
    74% { background-position: 0 calc(100% + 72px); }
    100% { background-position: 0 calc(100% + 72px); }
}

.terminal.waiting {
    opacity: 0;
    transform: scaleY(0.015);
    filter: brightness(2.6);
}

.terminal.booting {
    animation: terminalPanelOpen 0.3s cubic-bezier(0.2, 0.9, 0.25, 1) 0.18s both;
}

.terminal-output {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    scrollbar-width: none;
}

.terminal-output::-webkit-scrollbar {
    display: none;
}

.terminal-text {
    display: none;
    margin: 0;
    line-height: 1.2;
}

.terminal-text:not(:empty) {
    display: block;
}

.terminal-status-row {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    flex: 0 0 1.2em;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(55, 255, 125, 0.13);
    color: rgba(70, 255, 135, 0.78);
}

.terminal-text.warning {
    color: #ff335f;
    text-shadow: 0 0 4px rgba(255, 30, 80, 0.8), 0 0 12px rgba(255, 0, 60, 0.35);
}

.terminal-text.notice {
    color: #ffc247;
    text-shadow: 0 0 4px rgba(255, 175, 35, 0.7);
}

.terminal-text.success {
    color: var(--matrix-green-bright);
    text-shadow: 0 0 5px rgba(0, 255, 100, 0.9), 0 0 16px rgba(0, 224, 84, 0.45);
}

.terminal-text.phosphor-settle {
    animation: terminalTextAfterglow 0.68s ease-out both;
}

@keyframes terminalTextAfterglow {
    0% { filter: brightness(2.15) drop-shadow(0 0 5px currentColor); }
    24% { filter: brightness(1.55) drop-shadow(0 0 3px currentColor); }
    100% { filter: brightness(1) drop-shadow(0 0 0 transparent); }
}

.terminal.resetting {
    animation: terminalReset 0.3s steps(2, end) both;
}

.terminal-cursor {
    display: inline-block;
    width: 8px;
    height: 1.2em;
    background: var(--matrix-green);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: cursorBlink 0.6s step-end infinite;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes terminalBootLine {
    0% { width: 0; opacity: 1; }
    100% { width: 100%; opacity: 1; }
}

@keyframes terminalDestinationBlink {
    0%, 48% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    49%, 100% { opacity: 0.12; transform: translate(-50%, -50%) scale(0.72); }
}

@keyframes terminalPanelOpen {
    0% { opacity: 0; transform: scaleY(0.015); filter: brightness(2.6); }
    35% { opacity: 1; transform: scaleY(0.08); filter: brightness(2); }
    72% { transform: scaleY(1.04); filter: brightness(1.25); }
    100% { opacity: 1; transform: scaleY(1); filter: brightness(1); }
}

@keyframes terminalReset {
    0% { opacity: 1; transform: translate(0, 0) scaleY(1); filter: brightness(1); }
    35% { opacity: 0.25; transform: translate(5px, 0) scaleY(0.7); filter: brightness(2); }
    55% { opacity: 0.8; transform: translate(-4px, 0) scaleY(0.25); filter: brightness(1.6); }
    100% { opacity: 0; transform: translate(0, 0) scaleY(0.02); filter: brightness(2.5); }
}

/* Блок с бегущими hex-кодами */
.hex-stream {
    margin: 7px 0 5px;
    padding: 6px 8px 7px;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    opacity: 0.94;
    line-height: 1.35;
    display: none;
    flex-direction: column;
    gap: 3px;
    border: 1px solid rgba(0, 255, 100, 0.2);
    border-left: 2px solid rgba(0, 255, 100, 0.65);
    background: linear-gradient(90deg, rgba(0, 90, 35, 0.2), rgba(0, 20, 8, 0.08));
    box-shadow: inset 0 0 14px rgba(0, 255, 100, 0.055), 0 0 10px rgba(0, 220, 84, 0.08);
    animation: hexStreamPulse 1.1s steps(2, end) infinite;
}

.hex-stream.active {
    display: flex;
}

.hex-stream::before {
    content: '// DECRYPT STREAM';
    display: block;
    margin-bottom: 2px;
    color: rgba(175, 255, 205, 0.78);
    font-size: 0.56rem;
    letter-spacing: 0.2em;
    text-shadow: 0 0 5px rgba(0, 255, 100, 0.45);
}

.hex-stream span {
    display: block;
    font-family: var(--font-matrix);
    color: rgba(70, 255, 135, 0.86);
    text-shadow: 0 0 4px rgba(0, 255, 100, 0.32);
}

.hex-stream span:nth-child(even) {
    color: rgba(155, 255, 190, 0.72);
}

@keyframes hexStreamPulse {
    0%, 100% { border-left-color: rgba(0, 255, 100, 0.48); }
    50% { border-left-color: rgba(150, 255, 190, 0.9); }
}

.corner-brackets {
    position: fixed;
    z-index: 6;
    pointer-events: none;
    opacity: 0.4;
}
.corner-brackets::before,
.corner-brackets::after {
    content: '';
    position: absolute;
    width: 36px;
    height: 36px;
    border-color: var(--matrix-green);
    border-style: solid;
    animation: bracketGlow 2s ease-in-out infinite;
}
.corner-tl { top: 20px; left: 20px; }
.corner-tl::before { border-width: 2px 0 0 2px; top: 0; left: 0; }
.corner-tr { top: 20px; right: 20px; }
.corner-tr::before { border-width: 2px 2px 0 0; top: 0; right: 0; }
.corner-bl { bottom: 20px; left: 20px; }
.corner-bl::before { border-width: 0 0 2px 2px; bottom: 0; left: 0; }
.corner-br { bottom: 20px; right: 20px; }
.corner-br::before { border-width: 0 2px 2px 0; bottom: 0; right: 0; }

@keyframes bracketGlow {
    0%, 100% { border-color: rgba(0, 224, 84, 0.4); filter: drop-shadow(0 0 2px rgba(0, 224, 84, 0.25)); }
    50% { border-color: rgba(0, 224, 84, 0.8); filter: drop-shadow(0 0 6px rgba(0, 224, 84, 0.5)); }
}

.access-flash {
    position: fixed;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    opacity: 0;
    background:
        radial-gradient(circle at center, rgba(210, 255, 225, 0.9) 0%, rgba(0, 255, 100, 0.45) 22%, rgba(0, 80, 25, 0.08) 58%, transparent 78%);
    box-shadow: inset 0 0 120px rgba(0, 255, 100, 0.35);
    mix-blend-mode: screen;
}

body.phase-knock #matrixCanvas {
    filter: brightness(0.55) saturate(0.7);
}

body.phase-scan #matrixCanvas {
    filter: brightness(0.85) contrast(1.08);
}

body.phase-scan .phase-sweep {
    opacity: 0.34;
    animation: phaseSweep 2.6s linear infinite;
}

body.phase-bypass #matrixCanvas {
    filter: brightness(1.25) contrast(1.2) saturate(1.2);
}

body.phase-bypass .phase-sweep {
    opacity: 0.52;
    animation: phaseSweep 1.45s linear infinite;
}

body.phase-crack #matrixCanvas {
    filter: brightness(1.42) contrast(1.32) saturate(1.35);
}

body.phase-crack .phase-sweep {
    opacity: 0.7;
    animation: phaseSweep 0.82s linear infinite;
}

body.phase-crack .noise {
    opacity: 0.075;
    animation-duration: 0.16s;
}

body.phase-warning #matrixCanvas {
    filter: brightness(0.72) contrast(1.55) saturate(0.55);
}

body.phase-inject #matrixCanvas {
    filter: brightness(1.18) contrast(1.22) saturate(1.25);
}

body.phase-success #matrixCanvas {
    filter: brightness(0.9) contrast(1.05) saturate(1.08);
}

body.success-hold #matrixCanvas {
    filter: brightness(0.58) contrast(1.08) saturate(0.82);
}

body.success-hold .terminal-cursor {
    animation: none;
    opacity: 1;
}

body.success-hold .terminal {
    animation: terminalSuccessPulse 1.65s ease-out both;
}

body.success-hold .terminal-frame-detail::before {
    animation: terminalSuccessEdge 1.45s cubic-bezier(0.18, 0.72, 0.25, 1) both;
}

body.security-alert .access-flash {
    background:
        radial-gradient(circle at center, rgba(255, 210, 220, 0.7) 0%, rgba(255, 20, 70, 0.34) 24%, rgba(100, 0, 25, 0.08) 60%, transparent 80%);
    box-shadow: inset 0 0 120px rgba(255, 0, 55, 0.3);
    animation: securityAlertFlash 0.9s steps(1, end) both;
}

body.access-granted .access-flash {
    animation: accessFlash 1.15s ease-out both;
}

body.access-granted #matrixCanvas {
    animation: accessCanvasGlitch 1.15s steps(1, end) both;
}

body.access-granted .glitch-wrapper {
    animation: accessTitleGlitch 1.15s steps(1, end) both;
}

@keyframes accessFlash {
    0% { opacity: 0; }
    7% { opacity: 0.9; }
    13% { opacity: 0.12; }
    21% { opacity: 0.68; }
    31% { opacity: 0.08; }
    44% { opacity: 0.32; }
    100% { opacity: 0; }
}

@keyframes securityAlertFlash {
    0%, 100% { opacity: 0; }
    8% { opacity: 0.72; }
    18% { opacity: 0.08; }
    30% { opacity: 0.5; }
    43% { opacity: 0.05; }
    58% { opacity: 0.28; }
}

@keyframes phaseSweep {
    0% { transform: translateY(-105%); }
    100% { transform: translateY(105%); }
}

@keyframes accessCanvasGlitch {
    0%, 100% { transform: translate(0, 0) scale(1); filter: none; }
    7% { transform: translate(-9px, 2px) scale(1.012); filter: brightness(1.9) contrast(1.35); }
    13% { transform: translate(7px, -2px) scale(1.008); filter: brightness(0.8) contrast(1.6); }
    21% { transform: translate(-4px, 1px) scale(1.01); filter: brightness(1.55) contrast(1.25); }
    31% { transform: translate(3px, 0) scale(1.004); filter: brightness(1.1) contrast(1.1); }
}

@keyframes accessTitleGlitch {
    0%, 100% { transform: translate(0, 0) skew(0); }
    7% { transform: translate(11px, -2px) skewX(-7deg); }
    13% { transform: translate(-8px, 2px) skewX(5deg); }
    21% { transform: translate(5px, -1px) skewX(-3deg); }
    31% { transform: translate(-2px, 0) skewX(1deg); }
}

@keyframes terminalSuccessPulse {
    0% {
        box-shadow: 0 0 15px rgba(0, 224, 84, 0.1), inset 0 1px 0 rgba(115, 255, 165, 0.07);
    }
    12% {
        box-shadow: 0 0 8px rgba(180, 255, 205, 0.95), 0 0 34px rgba(0, 255, 100, 0.62), inset 0 0 18px rgba(110, 255, 160, 0.18);
    }
    36% {
        box-shadow: 0 0 22px rgba(0, 255, 100, 0.34), inset 0 0 10px rgba(80, 255, 135, 0.08);
    }
    100% {
        box-shadow: 0 0 15px rgba(0, 224, 84, 0.1), inset 0 1px 0 rgba(115, 255, 165, 0.07);
    }
}

@keyframes terminalSuccessEdge {
    0% { left: -28%; opacity: 0; }
    12% { opacity: 1; }
    62% { left: 102%; opacity: 0.9; }
    100% { left: 102%; opacity: 0; }
}

@media (max-width: 600px) {
    .glitch-title { letter-spacing: 0.06em; }
    .domain-tag { letter-spacing: 0.2em; }
    .corner-brackets::before { width: 22px; height: 22px; }
    .status-line { font-size: 0.65rem; bottom: 5%; }
    .terminal {
        top: 10px;
        left: 10px;
        font-size: 0.65rem;
        width: min(340px, calc(100vw - 20px));
        padding: 5px 8px;
    }
    .terminal-boot {
        top: 10px;
        left: 10px;
        width: min(340px, calc(100vw - 20px));
    }
    .hex-stream {
        padding: 5px 6px;
        font-size: 0.58rem;
        letter-spacing: 0.08em;
    }
}
