body:has(.auth-modal-overlay.active) {
    overflow: hidden;
    height: 100vh;
}
.auth-modal-overlay {
    height: 100vh;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: hidden;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s, background 0.3s ease, backdrop-filter 0.3s ease;
}

.auth-modal-overlay.active {
    overflow-y: hidden;
    opacity: 1;
    visibility: visible;
    background: rgba(5, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    transition: opacity 0.3s ease, background 0.3s ease, backdrop-filter 0.3s ease;
}

.auth-container {
    width: 100%;
    max-width: 440px;
    perspective: 1000px;
    transform-style: preserve-3d;
    position: relative;
}

.auth-card-wrapper {
    position: relative;
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.2) 0%, rgba(45, 212, 191, 0.2) 50%, rgba(74, 222, 128, 0.2) 100%);
    padding: 2px;
    border-radius: 24px;
    box-shadow: 
        0 0 0 1px rgba(74, 222, 128, 0.1),
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(74, 222, 128, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: auth-border-glow 4s ease infinite;
    transform-style: preserve-3d;
}

@keyframes auth-border-glow {
    0%, 100% { 
        box-shadow: 
            0 0 0 1px rgba(74, 222, 128, 0.1),
            0 20px 60px rgba(0, 0, 0, 0.6),
            0 0 40px rgba(74, 222, 128, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    50% { 
        box-shadow: 
            0 0 0 1px rgba(74, 222, 128, 0.2),
            0 20px 60px rgba(0, 0, 0, 0.6),
            0 0 60px rgba(74, 222, 128, 0.25),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
}

.auth-card {
    background: linear-gradient(180deg, rgba(15, 35, 25, 0.85) 0%, rgba(10, 25, 18, 0.9) 100%);
    border-radius: 22px;
    width: 100%;
    overflow: hidden;
    position: relative;
    opacity: 0;
    transform: scale(0.9) translateY(30px);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.auth-modal-overlay.active .auth-card {
    animation: auth-telegram-spring 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.auth-modal-overlay.closing .auth-card {
    animation: auth-telegram-out 0.3s cubic-bezier(0.32, 0, 0.67, 0) forwards;
}

@keyframes auth-telegram-spring {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(40px);
    }
    60% {
        opacity: 1;
        transform: scale(1.02) translateY(-8px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes auth-telegram-out {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
}

.auth-matrix-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.03;
    pointer-events: none;
    border-radius: 22px;
    overflow: hidden;
}

.auth-face {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-face.front {
    position: relative;
}

.auth-face.back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transform: rotateY(180deg);
}

.auth-container.flip .auth-face.front {
    transform: rotateY(180deg);
}

.auth-container.flip .auth-face.back {
    transform: rotateY(360deg);
}

.auth-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 2px solid var(--accent-green);
    opacity: 0.6;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.auth-corner-tl { top: 15px; left: 15px; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.auth-corner-tr { top: 15px; right: 15px; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.auth-corner-bl { bottom: 15px; left: 15px; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.auth-corner-br { bottom: 15px; right: 15px; border-left: none; border-top: none; border-radius: 0 0 8px 0; }

.auth-card:hover .auth-corner {
    opacity: 1;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

.auth-modal-header {
    padding: 28px 28px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    z-index: 10;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.auth-pixel-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-green);
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.6);
    clip-path: polygon(25% 0%, 75% 0%, 100% 25%, 100% 75%, 75% 100%, 25% 100%, 0% 75%, 0% 25%);
    animation: auth-pulse-glow 3s infinite;
}

@keyframes auth-pulse-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(74, 222, 128, 0.6); }
    50% { box-shadow: 0 0 30px rgba(74, 222, 128, 0.9); }
}

.auth-title-group h2 {
    font-family: 'VT323', monospace;
    font-size: 1.8rem;
    color: var(--accent-green);
    text-shadow: 0 0 15px rgba(74, 222, 128, 0.4);
    letter-spacing: 2px;
}

.auth-title-group p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 0.5px;
}

.auth-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(248, 113, 113, 0.3);
    background: rgba(248, 113, 113, 0.05);
    color: #fca5a5;
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
}

.auth-close:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.6);
    transform: rotate(90deg);
    box-shadow: 0 0 15px rgba(248, 113, 113, 0.3);
}

.auth-terminal {
    margin: 0 28px 20px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-family: 'VT323', monospace;
    background: rgba(74, 222, 128, 0.05);
    border: 1px solid rgba(74, 222, 128, 0.1);
    border-radius: 10px;
    position: relative;
    z-index: 5;
    opacity: 0;
    transform: translateX(-10px);
    backdrop-filter: blur(10px);
}

.auth-modal-overlay.active .auth-terminal {
    animation: auth-slide-in 0.4s ease 0.2s forwards;
}

@keyframes auth-slide-in {
    to { opacity: 1; transform: translateX(0); }
}

.auth-prompt {
    color: var(--accent-teal);
    text-shadow: 0 0 10px rgba(45, 212, 191, 0.3);
}

.auth-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: var(--accent-green);
    animation: auth-blink 1.2s infinite;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

@keyframes auth-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.auth-body {
    padding: 0 28px 20px;
    position: relative;
    z-index: 5;
}

.auth-form-group {
    margin-bottom: 16px;
    position: relative;
    opacity: 0;
    transform: translateY(10px);
}

.auth-modal-overlay.active .auth-form-group {
    animation: auth-fade-up 0.4s ease forwards;
}

.auth-modal-overlay.active .auth-form-group:nth-child(1) { animation-delay: 0.25s; }
.auth-modal-overlay.active .auth-form-group:nth-child(2) { animation-delay: 0.3s; }
.auth-modal-overlay.active .auth-form-group:nth-child(3) { animation-delay: 0.35s; }
.auth-modal-overlay.active .auth-form-group:nth-child(4) { animation-delay: 0.4s; }

@keyframes auth-fade-up {
    to { opacity: 1; transform: translateY(0); }
}

.auth-form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 500;
}

.auth-input-wrap {
    position: relative;
}

.auth-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: all 0.3s ease;
    z-index: 2;
}

.auth-input {
    width: 100%;
    background: rgba(5, 15, 10, 0.6);
    border: 1px solid var(--border-green);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 13px 14px 13px 44px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.auth-input:focus {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1), 0 0 20px rgba(74, 222, 128, 0.15);
    background: rgba(5, 15, 10, 0.8);
}

.auth-input:focus + .auth-input-icon,
.auth-input-wrap:focus-within .auth-input-icon {
    color: var(--accent-green);
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

.auth-input::placeholder {
    color: var(--text-muted);
}

.auth-pass-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    padding: 4px;
}

.auth-pass-toggle:hover {
    color: var(--accent-green);
}

.auth-pass-strength {
    height: 3px;
    background: rgba(74, 222, 128, 0.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.auth-strength-bar {
    height: 100%;
    width: 0;
    transition: all 0.4s ease;
    border-radius: 2px;
}

.auth-strength-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-family: 'VT323', monospace;
}

.auth-checkbox-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    background: rgba(74, 222, 128, 0.03);
    border: 1px solid rgba(74, 222, 128, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.auth-checkbox-group:hover {
    background: rgba(74, 222, 128, 0.06);
    border-color: rgba(74, 222, 128, 0.2);
}

.auth-checkbox {
    width: 20px;
    height: 20px;
    border: 1px solid var(--border-green);
    border-radius: 6px;
    background: rgba(5, 15, 10, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.auth-checkbox.checked {
    background: var(--accent-green);
    border-color: var(--accent-green);
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.5);
}

.auth-checkbox::after {
    content: '✓';
    color: var(--bg-dark);
    font-size: 0.85rem;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s ease;
}

.auth-checkbox.checked::after {
    opacity: 1;
    transform: scale(1);
}

.auth-checkbox-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.auth-checkbox-label a {
    color: var(--accent-green);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

.auth-checkbox-label a:hover {
    border-bottom-color: var(--accent-green);
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.auth-forgot {
    text-align: center;
    margin-top: 16px;
}

.auth-forgot a {
    color: var(--accent-teal);
    font-size: 0.85rem;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s;
}

.auth-forgot a:hover {
    border-bottom-color: var(--accent-teal);
    text-shadow: 0 0 10px rgba(45, 212, 191, 0.3);
}

.auth-footer {
    padding: 0 28px 28px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    z-index: 10;
}

.auth-btn {
    width: 100%;
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid var(--border-green);
    border-radius: 12px;
    color: var(--accent-green);
    padding: 14px 24px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    backdrop-filter: blur(10px);
    font-weight: 500;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px);
}

.auth-modal-overlay.active .auth-btn {
    animation: auth-fade-up 0.4s ease forwards;
}

.auth-modal-overlay.active .auth-btn:nth-of-type(1) { animation-delay: 0.45s; }
.auth-modal-overlay.active .auth-btn:nth-of-type(2) { animation-delay: 0.5s; }

.auth-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(74, 222, 128, 0.2), transparent);
    transition: left 0.5s ease;
}

.auth-btn:hover::before {
    left: 100%;
}

.auth-btn:hover {
    background: rgba(74, 222, 128, 0.15);
    border-color: var(--accent-green);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(74, 222, 128, 0.2);
}

.auth-btn.primary {
    background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-teal) 100%);
    color: var(--bg-dark);
    border: none;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.5px;
}

.auth-btn.primary:hover {
    background: linear-gradient(135deg, var(--accent-hover) 0%, #5ee6d3 100%);
    box-shadow: 0 8px 30px rgba(74, 222, 128, 0.4);
}

.auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 4px 0;
    opacity: 0;
}

.auth-modal-overlay.active .auth-divider {
    animation: auth-fade-in 0.3s ease 0.48s forwards;
}

@keyframes auth-fade-in {
    to { opacity: 1; }
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-green), transparent);
}

.auth-switch {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding-top: 8px;
    opacity: 0;
}

.auth-modal-overlay.active .auth-switch {
    animation: auth-fade-in 0.3s ease 0.52s forwards;
}

.auth-switch button {
    background: none;
    border: none;
    color: var(--accent-green);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.auth-switch button:hover {
    border-bottom-color: var(--accent-green);
    text-shadow: 0 0 15px rgba(74, 222, 128, 0.4);
}

.auth-flip-hint {
    position: absolute;
    top: 50%;
    right: -50px;
    transform: translateY(-50%);
    color: var(--accent-green);
    font-size: 1.2rem;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    font-family: 'VT323', monospace;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
    animation: auth-pulse-hint 2s infinite;
}

@keyframes auth-pulse-hint {
    0%, 100% { opacity: 0.3; transform: translateY(-50%) scale(1); }
    50% { opacity: 0.6; transform: translateY(-50%) scale(1.1); }
}

.auth-container:hover .auth-flip-hint {
    right: -40px;
    opacity: 0.5;
}

.auth-container.flip .auth-flip-hint {
    right: auto;
    left: -50px;
}

.auth-container.flip:hover .auth-flip-hint {
    left: -40px;
}

.auth-form-group.error .auth-input {
    border-color: var(--error-red);
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.1);
}

.auth-form-group.error .auth-input-icon {
    color: var(--error-red);
}

.auth-error-msg {
    color: var(--error-red);
    font-size: 0.8rem;
    margin-top: 6px;
    font-family: 'VT323', monospace;
    display: none;
}

.auth-form-group.error .auth-error-msg {
    display: block;
    animation: auth-shake 0.5s ease;
}

@keyframes auth-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.auth-btn.loading {
    position: relative;
    color: transparent !important;
}

.auth-btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: var(--bg-dark);
    border-radius: 50%;
    animation: auth-spin 0.8s linear infinite;
}

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

@media (max-width: 520px) {
    .auth-modal-overlay {
        padding: 15px;
        align-items: flex-end;
    }

    .auth-container {
        max-width: 100%;
    }

    .auth-card-wrapper {
        border-radius: 20px;
    }

    .auth-card {
        border-radius: 18px;
    }

    .auth-modal-header {
        padding: 24px 24px 16px;
    }

    .auth-terminal {
        margin: 0 24px 16px;
    }

    .auth-body {
        padding: 0 24px 16px;
    }

    .auth-footer {
        padding: 0 24px 24px;
    }

    .auth-flip-hint {
        display: none;
    }
}

@media (min-width: 521px) and (max-height: 700px) {
    .auth-modal-overlay {
        align-items: flex-start;
        padding-top: 40px;
        padding-bottom: 40px;
        overflow-y: auto;
    }
}