:root {
    --matrix-green: #00ff41;
    --matrix-dark-green: #008f11;
    --bg-dark: #050505;
    --glass-bg: rgba(5, 10, 5, 0.6);
    --glass-border: rgba(0, 255, 65, 0.2);
    --text-main: #e0e0e0;
    --text-muted: #889988;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden; /* Prevent scrollbars from canvas */
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Canvas Background */
#matrix-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Login Container */
.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    position: relative;
    z-index: 10;
    perspective: 1000px;
    opacity: 0;
    animation: systemBoot 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) 1.5s forwards;
}

@keyframes systemBoot {
    0% { opacity: 0; transform: translateY(20px) scale(0.98); filter: blur(5px); }
    10% { opacity: 0.5; filter: blur(2px) brightness(1.5); }
    15% { opacity: 0.2; transform: translateY(10px); }
    30% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0) brightness(1); }
    35% { opacity: 0.8; }
    40% { opacity: 1; }
    100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0) brightness(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.glass-panel {
    background: rgba(10, 20, 10, 0.75);
    background-image: radial-gradient(
        circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(0, 255, 65, 0.06) 0%,
        rgba(10, 20, 10, 0.75) 50%
    );
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 255, 65, 0.2);
    border-top: 1px solid rgba(0, 255, 65, 0.4);
    border-left: 1px solid rgba(0, 255, 65, 0.3);
    border-radius: 16px;
    padding: 40px 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6),
                inset 0 0 20px rgba(0, 255, 65, 0.05);
    position: relative;
    overflow: hidden;
    transition: background-image 0.1s ease;
}

.glass-panel:hover {
    box-shadow: 0 12px 40px 0 rgba(0, 255, 65, 0.15), inset 0 0 25px rgba(0, 255, 65, 0.08);
}

/* Language Switcher */
.lang-switcher {
    position: absolute;
    top: 20px;
    right: 25px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 20;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 14px;
}

.lang-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    padding: 0;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    color: #fff;
    text-shadow: 0 0 5px var(--matrix-green);
}

.lang-btn.active {
    color: var(--matrix-green);
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.8);
    font-weight: bold;
}

.lang-divider {
    color: rgba(255, 255, 255, 0.2);
    font-size: 12px;
}

.logo {
    text-align: center;
    margin-bottom: 35px;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 32px;
    color: var(--matrix-green);
    border: 2px solid var(--matrix-green);
    width: 75px;
    height: 75px;
    line-height: 71px;
    border-radius: 12px;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(0, 255, 65, 0.8);
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.3), inset 0 0 10px rgba(0, 255, 65, 0.2);
    transform-style: preserve-3d;
    animation: holoWobble 10.5s linear infinite;
}

@keyframes holoWobble {
    0%   { transform: perspective(600px) rotateX(30deg) rotateY(0deg); box-shadow: 0px 15px 25px rgba(0,255,65,0.5), inset 0px 3px 15px rgba(0,255,65,0.3); }
    25%  { transform: perspective(600px) rotateX(0deg) rotateY(30deg); box-shadow: -15px 0px 25px rgba(0,255,65,0.5), inset -3px 0px 15px rgba(0,255,65,0.3); }
    50%  { transform: perspective(600px) rotateX(-30deg) rotateY(0deg); box-shadow: 0px -15px 25px rgba(0,255,65,0.5), inset 0px -3px 15px rgba(0,255,65,0.3); }
    75%  { transform: perspective(600px) rotateX(0deg) rotateY(-30deg); box-shadow: 15px 0px 25px rgba(0,255,65,0.5), inset 3px 0px 15px rgba(0,255,65,0.3); }
    100% { transform: perspective(600px) rotateX(30deg) rotateY(0deg); box-shadow: 0px 15px 25px rgba(0,255,65,0.5), inset 0px 3px 15px rgba(0,255,65,0.3); }
}

.logo-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    transform-style: preserve-3d;
    animation: holoWobbleInverse 10.5s linear infinite;
}

@keyframes holoWobbleInverse {
    0%   { transform: rotateY(0deg) rotateX(-50deg); }
    25%  { transform: rotateY(-50deg) rotateX(0deg); }
    50%  { transform: rotateY(0deg) rotateX(50deg); }
    75%  { transform: rotateY(50deg) rotateX(0deg); }
    100% { transform: rotateY(0deg) rotateX(-50deg); }
}

.glitch-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transform-style: preserve-3d;
}

.glitch-wrapper.is-glitching {
    animation: randomGlitch 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes randomGlitch {
    0% { transform: translate(0) skewX(0); opacity: 1; filter: none; }
    20% { transform: translate(-4px, 2px) skewX(15deg); opacity: 0.7; filter: drop-shadow(4px 0 0 rgba(255,0,0,0.9)) drop-shadow(-4px 0 0 rgba(0,255,255,0.9)); }
    40% { transform: translate(4px, -2px) skewX(-20deg); opacity: 0.4; filter: drop-shadow(-4px 0 0 rgba(255,0,0,0.9)) drop-shadow(4px 0 0 rgba(0,255,255,0.9)); }
    60% { transform: translate(-2px, 4px) skewX(10deg); opacity: 0.8; filter: drop-shadow(3px 0 0 rgba(255,0,0,0.9)) drop-shadow(-3px 0 0 rgba(0,255,255,0.9)); }
    80% { transform: translate(3px, -3px) skewX(-5deg); opacity: 0.5; filter: drop-shadow(-3px 0 0 rgba(255,0,0,0.9)) drop-shadow(3px 0 0 rgba(0,255,255,0.9)); }
    100% { transform: translate(0) skewX(0); opacity: 1; filter: none; }
}

.icon-layer {
    position: absolute;
    width: 53px;
    height: 53px;
    opacity: 0;
}

.layer-1 { animation: cycle1 16s infinite; }
.layer-2 { animation: cycle2 16s infinite; }
.layer-3 { animation: cycle3 16s infinite; }
.layer-4 { animation: cycle4 16s infinite; }

@keyframes cycle1 {
    0%, 20% { opacity: 1; transform: scale(1) translateZ(25px); filter: drop-shadow(0 0 8px rgba(0,255,65,0.8)); }
    25%, 95% { opacity: 0; transform: scale(0.8) translateZ(0px); filter: drop-shadow(0 0 0px rgba(0,255,65,0)); }
    100% { opacity: 1; transform: scale(1) translateZ(25px); filter: drop-shadow(0 0 8px rgba(0,255,65,0.8)); }
}
@keyframes cycle2 {
    0%, 20% { opacity: 0; transform: scale(0.8) translateZ(0px); filter: drop-shadow(0 0 0px rgba(0,255,65,0)); }
    25%, 45% { opacity: 1; transform: scale(1) translateZ(25px); filter: drop-shadow(0 0 8px rgba(0,255,65,0.8)); }
    50%, 100% { opacity: 0; transform: scale(0.8) translateZ(0px); filter: drop-shadow(0 0 0px rgba(0,255,65,0)); }
}
@keyframes cycle3 {
    0%, 45% { opacity: 0; transform: scale(0.8) translateZ(0px); filter: drop-shadow(0 0 0px rgba(0,255,65,0)); }
    50%, 70% { opacity: 1; transform: scale(1) translateZ(25px); filter: drop-shadow(0 0 8px rgba(0,255,65,0.8)); }
    75%, 100% { opacity: 0; transform: scale(0.8) translateZ(0px); filter: drop-shadow(0 0 0px rgba(0,255,65,0)); }
}
@keyframes cycle4 {
    0%, 70% { opacity: 0; transform: scale(0.8) translateZ(0px); filter: drop-shadow(0 0 0px rgba(0,255,65,0)); }
    75%, 95% { opacity: 1; transform: scale(1) translateZ(25px); filter: drop-shadow(0 0 8px rgba(0,255,65,0.8)); }
    100% { opacity: 0; transform: scale(0.8) translateZ(0px); filter: drop-shadow(0 0 0px rgba(0,255,65,0)); }
}

/* Internal SVG Animations */
.anim-spin {
    transform-origin: 50px 50px;
    animation: spin 4s linear infinite;
}
.anim-pulse {
    animation: pulse 2s ease-in-out infinite alternate;
}
.anim-wave {
    transform-origin: 50px 50px;
    animation: waveOut 2s ease-out infinite;
}
.anim-wave-delay {
    animation-delay: 1s;
}
.anim-float {
    transform-origin: 50px 50px;
    animation: float 3s ease-in-out infinite alternate;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}
@keyframes pulse {
    0% { opacity: 0.3; filter: drop-shadow(0 0 2px rgba(0,255,65,0.5)); }
    100% { opacity: 1; filter: drop-shadow(0 0 10px rgba(0,255,65,1)); }
}
@keyframes waveOut {
    0% { opacity: 1; transform: scale(0.8); }
    100% { opacity: 0; transform: scale(1.3); }
}
@keyframes float {
    0% { transform: translateY(-3px) scale(0.95); }
    100% { transform: translateY(3px) scale(1.05); }
}

.logo h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.input-group {
    position: relative;
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s;
    min-height: 16px;
}

.input-group:focus-within label {
    color: var(--matrix-green);
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
}

.input-group:focus-within label::before {
    content: "[ ";
    color: #fff;
    opacity: 0.6;
}

.input-group:focus-within label::after {
    content: " ]_";
    color: #fff;
    opacity: 0.6;
    animation: blinkCursor 1s step-end infinite;
}

@keyframes blinkCursor {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.6; }
}

.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--matrix-green);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 16px;
    padding: 12px 15px;
    border-radius: 6px;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input::placeholder {
    color: rgba(136, 153, 136, 0.3);
}

.input-group input:focus {
    border-color: transparent;
    background: rgba(0, 20, 0, 0.6);
}

.focus-border {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--matrix-green);
    transition: 0.4s ease;
    box-shadow: 0 0 10px var(--matrix-green);
}

.input-group input:focus ~ .focus-border {
    width: 100%;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 1px solid var(--matrix-green);
    color: var(--matrix-green);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.1);
}

.login-btn span {
    position: relative;
    z-index: 2;
    display: inline-block;
}

.login-btn:hover {
    background: rgba(0, 255, 65, 0.05);
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.2);
    color: #fff;
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.8);
}

.login-btn:hover span {
    animation: textGlitch 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes textGlitch {
    0% { transform: translate(0) skew(0deg); text-shadow: none; }
    20% { transform: translate(-2px, 1px) skew(-10deg); text-shadow: -2px 0 red, 2px 0 blue; }
    40% { transform: translate(2px, -1px) skew(10deg); text-shadow: 2px 0 red, -2px 0 blue; }
    60% { transform: translate(-1px, 2px) skew(-5deg); text-shadow: -1px 0 red, 1px 0 blue; }
    80% { transform: translate(1px, -2px) skew(5deg); text-shadow: 1px 0 red, -1px 0 blue; }
    100% { transform: translate(0) skew(0deg); text-shadow: 0 0 8px rgba(0, 255, 65, 0.8); }
}

.register-link {
    margin-top: 25px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.register-link a {
    color: var(--matrix-green);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.register-link a:hover {
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
}

/* Responsive Design */
@media (max-width: 480px) {
    .login-container {
        padding: 15px;
    }

    .glass-panel {
        padding: 25px 20px;
        border-radius: 12px;
    }

    .logo-icon {
        width: 60px;
        height: 60px;
        line-height: 56px;
    }

    .logo-icon svg {
        width: 41px !important;
        height: 41px !important;
    }

    .logo h1 {
        font-size: 18px !important;
    }

    .input-group input {
        font-size: 14px;
        padding: 10px 12px;
    }

    .login-btn {
        padding: 12px;
        font-size: 14px;
    }
}

body {
    overflow: auto;
    min-height: 100vh;
}

.login-container {
    max-width: 480px;
}

.glass-panel {
    max-height: calc(100vh - 30px);
    overflow-y: auto;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
    margin: -18px auto 24px;
    max-width: 34ch;
    text-align: center;
}

.mode-switcher {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 24px;
}

.mode-btn,
.secondary-btn {
    background: transparent;
    border: 1px solid rgba(0, 255, 65, 0.25);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    padding: 10px 12px;
    transition: all 0.3s ease;
}

.mode-btn:hover,
.mode-btn.active,
.secondary-btn:hover {
    border-color: var(--matrix-green);
    color: var(--matrix-green);
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
}

.auth-view[hidden] {
    display: none;
}

.auth-form {
    animation: fadeIn 0.25s ease;
}

.terms-check {
    align-items: flex-start;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    font-size: 12px;
    gap: 9px;
    line-height: 1.5;
    margin: -4px 0 24px;
}

.terms-check input {
    accent-color: var(--matrix-green);
    flex: 0 0 auto;
    height: 16px;
    margin: 2px 0 0;
    width: 16px;
}

.terms-metadata {
    align-items: center;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 12px;
    gap: 8px;
    line-height: 1.5;
    margin: -4px 0 18px;
}

.terms-metadata strong {
    color: var(--text-main);
}

.terms-metadata a {
    color: var(--matrix-green);
    margin-left: auto;
}

.login-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.terms-check a,
.auth-footer a,
.auth-link {
    color: var(--matrix-green);
}

.message {
    color: var(--matrix-green);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.5;
    min-height: 18px;
    text-align: center;
}

.message.error {
    color: #ff8a8a;
}

.message:empty {
    min-height: 0;
}

.secondary-btn {
    display: block;
    margin: 14px auto 0;
    width: 100%;
}

.account-details {
    border: 1px solid rgba(0, 255, 65, 0.2);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.8;
    margin-bottom: 20px;
    padding: 14px;
}

.account-details strong {
    color: var(--text-main);
    overflow-wrap: anywhere;
}

.auth-footer {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 24px;
    text-align: center;
}

.auth-footer a {
    text-decoration: none;
}

.auth-footer a:hover {
    text-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
}

@media (max-width: 480px) {
    .glass-panel {
        max-height: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }

    .login-container {
        animation: none;
        opacity: 1;
    }
}
