@property --auth-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

body.is-auth {
    background: var(--navy-950);
    color: #fff;
}

body.is-auth::before {
    display: none;
}

.auth {
    --tilt-x: 0deg;
    --tilt-y: 0deg;
    --mx: 50%;
    --my: 50%;
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 72px 16px 56px;
    overflow: hidden;
    isolation: isolate;
    background:
        radial-gradient(circle at 50% 0%, #17386d 0%, transparent 55%),
        linear-gradient(180deg, #060f23, #0a1630 60%, #050b1a);
}

.auth__canvas,
.auth__aurora,
.auth__grid {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.auth__canvas {
    width: 100%;
    height: 100%;
}

.auth__aurora {
    background:
        radial-gradient(40% 35% at 20% 25%, rgba(42, 100, 183, 0.38), transparent 70%),
        radial-gradient(35% 30% at 80% 70%, rgba(186, 155, 73, 0.26), transparent 70%),
        radial-gradient(30% 30% at 60% 15%, rgba(88, 101, 242, 0.22), transparent 70%);
    filter: blur(30px);
    animation: auth-aurora 18s ease-in-out infinite alternate;
}

.auth__grid {
    background:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0%, transparent 65%);
    -webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0%, transparent 65%);
}

@keyframes auth-aurora {
    0% { transform: translate3d(-3%, -2%, 0) scale(1); }
    100% { transform: translate3d(3%, 3%, 0) scale(1.12); }
}

.auth__back {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 2;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
}

.auth__back:hover,
.auth__back:focus-visible {
    background: rgba(255, 255, 255, 0.14);
    transform: translateX(-3px);
}

.auth__card {
    position: relative;
    width: min(460px, 100%);
    padding: 44px 36px 32px;
    border-radius: 28px;
    text-align: center;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03)),
        rgba(8, 18, 40, 0.72);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    box-shadow:
        0 40px 100px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    transform: perspective(1100px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
    transition: transform 0.25s ease-out;
    overflow: hidden;
}

.auth__edge {
    position: absolute;
    inset: 0;
    padding: 1.5px;
    border-radius: inherit;
    background: conic-gradient(from var(--auth-angle), transparent 0deg, var(--gold-400) 60deg, transparent 130deg, var(--blue-600) 220deg, transparent 300deg);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    animation: auth-spin 6s linear infinite;
    pointer-events: none;
}

@keyframes auth-spin {
    to { --auth-angle: 360deg; }
}

.auth__scan {
    position: absolute;
    left: 0;
    right: 0;
    top: -30%;
    height: 30%;
    background: linear-gradient(180deg, transparent, rgba(214, 187, 116, 0.09), transparent);
    animation: auth-scan 7s ease-in-out infinite;
    pointer-events: none;
}

@keyframes auth-scan {
    0% { transform: translateY(0); opacity: 0; }
    15%, 85% { opacity: 1; }
    100% { transform: translateY(520%); opacity: 0; }
}

.auth__seal {
    position: relative;
    width: 132px;
    height: 132px;
    margin: 0 auto 26px;
    transform: translate3d(calc(var(--tilt-y) * -1.2), calc(var(--tilt-x) * 1.2), 0);
    transition: transform 0.25s ease-out;
}

.auth__seal img {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.5));
    animation: auth-float 5s ease-in-out infinite;
}

@keyframes auth-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.auth__ring {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.auth__ring--outer {
    inset: -16px;
    border: 1.5px dashed rgba(214, 187, 116, 0.55);
    animation: auth-rotate 28s linear infinite;
}

.auth__ring--inner {
    inset: -6px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--gold-400);
    border-right-color: transparent;
    animation: auth-rotate 7s linear infinite reverse;
}

.auth__glow {
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(214, 187, 116, 0.35), transparent 68%);
    animation: auth-pulse 3.2s ease-in-out infinite;
    z-index: 0;
}

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

@keyframes auth-pulse {
    0%, 100% { opacity: 0.55; transform: scale(0.92); }
    50% { opacity: 1; transform: scale(1.08); }
}

.auth__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    color: var(--gold-200);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.auth__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3ddc84;
    box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.6);
    animation: auth-blink 1.8s ease-out infinite;
}

@keyframes auth-blink {
    0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.6); }
    100% { box-shadow: 0 0 0 10px rgba(61, 220, 132, 0); }
}

.auth__title {
    margin: 0;
    font-family: "Merriweather", Georgia, serif;
    font-size: clamp(1.9rem, 6vw, 2.5rem);
    line-height: 1.1;
    background: linear-gradient(90deg, #fff 20%, var(--gold-200) 50%, #fff 80%);
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: auth-sheen 6s linear infinite;
}

@keyframes auth-sheen {
    to { background-position: -220% center; }
}

.auth__typed {
    min-height: 3em;
    margin: 14px 0 26px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.95rem;
    line-height: 1.6;
}

.auth__typed.is-typing::after {
    content: "▍";
    margin-left: 2px;
    color: var(--gold-400);
    animation: auth-caret 0.8s steps(1) infinite;
}

@keyframes auth-caret {
    50% { opacity: 0; }
}

.auth__alert {
    display: grid;
    gap: 4px;
    margin: 0 0 20px;
    padding: 14px 16px;
    border-radius: 14px;
    text-align: left;
    font-size: 0.88rem;
    line-height: 1.5;
}

.auth__alert strong {
    font-size: 0.95rem;
}

.auth__alert--error {
    border: 1px solid rgba(255, 99, 99, 0.45);
    background: rgba(255, 70, 70, 0.12);
    color: #ffd0d0;
}

.auth__alert--ok {
    border: 1px solid rgba(61, 220, 132, 0.45);
    background: rgba(61, 220, 132, 0.1);
    color: #c9f7dc;
}

.auth__card.has-error {
    animation: auth-shake 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97) 0.9s both;
}

@keyframes auth-shake {
    10%, 90% { translate: -2px 0; }
    20%, 80% { translate: 4px 0; }
    30%, 50%, 70% { translate: -7px 0; }
    40%, 60% { translate: 7px 0; }
}

.auth__discord {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 18px 22px;
    border-radius: 16px;
    overflow: hidden;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    background: linear-gradient(135deg, #5865f2, #4752c4);
    box-shadow: 0 14px 34px rgba(88, 101, 242, 0.45);
    transition: transform 0.15s ease-out, box-shadow 0.25s ease, filter 0.25s ease;
    will-change: transform;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.auth__discord:hover,
.auth__discord:focus-visible {
    box-shadow: 0 20px 48px rgba(88, 101, 242, 0.65);
    filter: brightness(1.08);
    outline: none;
}

.auth__discord:focus-visible {
    outline: 2px solid var(--gold-400);
    outline-offset: 3px;
}

.auth__discord-shine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 40%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: skewX(-20deg);
    animation: auth-shine 3.6s ease-in-out infinite;
}

@keyframes auth-shine {
    0%, 55% { left: -60%; }
    100% { left: 130%; }
}

.auth__discord-arrow {
    transition: transform 0.25s ease;
}

.auth__discord:hover .auth__discord-arrow {
    transform: translateX(6px);
}

.auth__discord.is-disabled {
    background: linear-gradient(135deg, #3d4466, #2e3452);
    box-shadow: none;
    opacity: 0.7;
    cursor: not-allowed;
}

.auth__discord.is-disabled .auth__discord-shine {
    display: none;
}

.auth__discord.is-loading {
    pointer-events: none;
    filter: saturate(0.85);
}

.auth__discord.is-loading .auth__discord-arrow {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    font-size: 0;
    animation: auth-rotate 0.8s linear infinite;
}

.auth__ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    transform: scale(0);
    animation: auth-ripple 0.7s ease-out forwards;
    pointer-events: none;
}

@keyframes auth-ripple {
    to { transform: scale(1); opacity: 0; }
}

.auth__notice {
    margin: 14px 0 0;
    color: var(--gold-200);
    font-size: 0.82rem;
}

.auth__loader {
    margin-top: 20px;
    text-align: left;
}

.auth__loader[hidden] {
    display: none;
}

.auth__steps {
    display: grid;
    gap: 10px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.auth__steps li {
    position: relative;
    padding-left: 30px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.88rem;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.4s ease, transform 0.4s ease, color 0.3s ease;
}

.auth__steps li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1px;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.auth__steps li.is-active,
.auth__steps li.is-done {
    opacity: 1;
    transform: none;
}

.auth__steps li.is-active {
    color: #fff;
}

.auth__steps li.is-active::before {
    border-color: var(--gold-400);
    border-top-color: transparent;
    animation: auth-rotate 0.8s linear infinite;
}

.auth__steps li.is-done {
    color: #c9f7dc;
}

.auth__steps li.is-done::before {
    border-color: #3ddc84;
    background: #3ddc84 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23062' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / 12px no-repeat;
}

.auth__progress {
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.auth__progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--blue-600), var(--gold-400));
    transition: width 0.6s ease;
}

.auth__meta {
    display: grid;
    gap: 10px;
    margin: 26px 0 0;
    padding: 22px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    list-style: none;
    text-align: left;
}

.auth__meta li {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.82rem;
}

.auth__meta svg {
    flex-shrink: 0;
    color: var(--gold-400);
}

.auth__legal {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 18px;
    margin: 0;
    padding: 0 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.74rem;
    letter-spacing: 0.04em;
}

.auth__clock {
    display: block;
    margin-bottom: 4px;
    color: var(--gold-400);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.12em;
}

[data-anim] {
    opacity: 0;
}

.auth.is-ready [data-anim],
.auth.is-reduced [data-anim] {
    opacity: 1;
}

@media (max-width: 520px) {
    .auth {
        padding: 84px 14px 80px;
    }

    .auth__card {
        padding: 36px 22px 26px;
        border-radius: 24px;
    }

    .auth__back {
        top: 16px;
        left: 16px;
    }
}

@media (max-height: 760px) and (min-width: 521px) {
    .auth {
        padding-top: 84px;
        padding-bottom: 90px;
    }
}

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