:root {
    color-scheme: dark;
    --auth-gold: #f0c95e;
    --auth-gold-bright: #ffe18a;
    --auth-gold-muted: #a98b47;
    --auth-bg: #070604;
    --auth-panel: rgba(17, 14, 10, 0.94);
    --auth-panel-border: rgba(240, 201, 94, 0.24);
    --auth-field: rgba(5, 5, 5, 0.9);
    --auth-text: #f7f3e8;
    --auth-muted: #b9b1a2;
    --auth-danger: #ff7777;
    --auth-success: #7ddf8a;
    --auth-content-width: 420px;
    --legal-author-color: #f2d37f;
    --legal-link-color: #d4af57;
    --legal-link-hover-color: #ffd978;
    --legal-baddy-base-color: #d4a017;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 0;
    min-height: 100%;
    background: var(--auth-bg);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    --mobile-safe-vw: 100vw;
    --mobile-safe-vh: 100dvh;
    --mobile-safe-vh-base: 100dvh;
}

body {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    overflow-x: clip;
    overflow-y: auto;
    background: #050505;
    color: var(--auth-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        linear-gradient(180deg, rgba(3, 3, 3, 0.42), rgba(3, 3, 3, 0.76)),
        url('../icons/background1.png') center / cover no-repeat;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 18%, rgba(240, 201, 94, 0.11), transparent 35rem),
        linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 30%, transparent 70%, rgba(0, 0, 0, 0.22));
}

button,
input {
    font: inherit;
}

button,
a,
input,
select {
    -webkit-tap-highlight-color: transparent;
}

:focus-visible {
    outline: 3px solid rgba(255, 225, 138, 0.8);
    outline-offset: 3px;
}

.auth-home-link {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
    z-index: 30;
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border: 1px solid rgba(240, 201, 94, 0.2);
    border-radius: 14px;
    background: rgba(8, 7, 5, 0.68);
    color: var(--auth-gold);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.26);
    text-decoration: none;
    backdrop-filter: blur(10px);
    transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.auth-home-link:hover {
    background: rgba(30, 24, 13, 0.9);
    color: var(--auth-gold-bright);
    transform: translateY(-1px);
}

.auth-home-link:active {
    transform: scale(0.96);
}

.auth-home-link svg {
    display: block;
    width: 25px;
    height: 25px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.auth-home-icon-body {
    fill: #080704;
}

.auth-stage {
    display: contents;
}

.app-title {
    grid-row: 1;
    justify-self: center;
    margin: clamp(24px, 5vh, 54px) 72px 8px;
    color: var(--auth-gold);
    font-size: clamp(48px, 7vw, 84px);
    font-weight: 900;
    letter-spacing: 0.035em;
    line-height: 0.95;
    text-align: center;
    text-shadow: 4px 5px 0 #000, 0 12px 34px rgba(0, 0, 0, 0.48);
    text-transform: uppercase;
    -webkit-text-stroke: 3px #000;
}

.auth-main {
    grid-row: 2;
    align-self: center;
    justify-self: stretch;
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px max(18px, env(safe-area-inset-right)) 28px max(18px, env(safe-area-inset-left));
}

.login-container {
    display: flex;
    width: min(100%, var(--auth-content-width));
    min-width: 0;
    flex-direction: column;
    gap: 17px;
    margin: 0;
    padding: 30px;
    border: 1px solid var(--auth-panel-border);
    border-radius: 20px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 42%),
        var(--auth-panel);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.035);
    backdrop-filter: blur(14px);
}

.login-container h2 {
    margin: 0 0 3px;
    color: #fff;
    font-size: 25px;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1.2;
    text-align: center;
}

.input-group {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
}

.input-group label {
    color: var(--auth-muted);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.04em;
}

.input-group input:not([type="checkbox"]) {
    display: block;
    width: 100%;
    min-width: 0;
    height: 48px;
    padding: 0 14px;
    border: 1px solid rgba(240, 201, 94, 0.15);
    border-radius: 10px;
    background: var(--auth-field);
    color: #fff;
    caret-color: var(--auth-gold-bright);
    font-size: 16px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.input-group input:not([type="checkbox"]):hover {
    border-color: rgba(240, 201, 94, 0.28);
}

.input-group input:not([type="checkbox"]):focus {
    outline: none;
    border-color: rgba(255, 225, 138, 0.72);
    background: #080704;
    box-shadow: 0 0 0 3px rgba(240, 201, 94, 0.11);
}

.remember-row {
    display: flex;
    min-height: 26px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.remember-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    margin: 0;
    accent-color: var(--auth-gold);
}

.remember-row label {
    margin: 0;
    cursor: pointer;
    font-size: 13px;
    letter-spacing: 0;
}

.password-input-shell {
    position: relative;
    display: flex;
    width: 100%;
    align-items: center;
}

.password-input-shell input {
    padding-right: 50px !important;
}

.password-visibility-toggle {
    position: absolute;
    top: 50%;
    right: 9px;
    display: grid;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    place-items: center;
    transform: translateY(-50%);
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #9d8b63;
    cursor: pointer;
}

.password-visibility-toggle:hover,
.password-visibility-toggle:focus-visible {
    color: var(--auth-gold-bright);
}

.password-visibility-icon {
    display: block;
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.password-visibility-toggle .icon-eye,
.password-input-shell.is-password-visible .password-visibility-toggle .icon-eye-off {
    display: none;
}

.password-visibility-toggle .icon-eye-off,
.password-input-shell.is-password-visible .password-visibility-toggle .icon-eye {
    display: block;
}

.btn {
    min-height: 48px;
    padding: 11px 16px;
    border: 1px solid rgba(240, 201, 94, 0.24);
    border-radius: 10px;
    background: #211b11;
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.btn.btn-primary {
    border-color: #d3aa46;
    background: linear-gradient(180deg, #deb84f, #ae8730);
    color: #171006;
    text-shadow: 0 1px rgba(255, 255, 255, 0.18);
}

.btn:hover {
    border-color: var(--auth-gold-bright);
    transform: translateY(-1px);
}

.btn.btn-primary:hover {
    background: linear-gradient(180deg, #f1cc66, #c99e39);
}

.btn:active {
    transform: scale(0.985);
}

.btn.is-clicking,
.alternative-actions a.is-clicking {
    animation: auth-click-pulse 180ms ease-out;
}

@keyframes auth-click-pulse {
    50% { transform: scale(0.97); }
}

.alternative-actions {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 12px;
    color: #716a5f;
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
}

.alternative-actions a {
    color: #c6a65a;
    font-weight: 750;
    text-decoration: none;
}

.alternative-actions a:hover {
    color: var(--auth-gold-bright);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.error-message {
    min-height: 18px;
    margin: -2px 0 0;
    color: var(--auth-danger);
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
    overflow-wrap: anywhere;
}

.auth-message-success {
    color: var(--auth-success);
}

.verification-container {
    position: relative;
}

.verification-heading {
    margin-bottom: 6px !important;
}

.verification-message {
    margin: 0;
    color: var(--auth-muted);
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}

.auth-lang-select {
    display: none;
}

.auth-lang-shell {
    width: min(100%, var(--auth-content-width));
    min-width: 0;
    margin: 0;
}

.auth-lang-dropdown {
    position: relative;
    z-index: 6;
    width: 100%;
}

.auth-lang-dropdown.open {
    z-index: 80;
}

.auth-lang-button {
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid rgba(240, 201, 94, 0.16);
    border-radius: 9px;
    background: rgba(10, 9, 7, 0.9);
    color: #d7d0c2;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.auth-lang-button:hover,
.auth-lang-button[aria-expanded="true"] {
    border-color: rgba(240, 201, 94, 0.4);
    color: #fff;
}

.auth-lang-menu {
    position: absolute;
    top: auto;
    right: 0;
    bottom: calc(100% + 6px);
    left: 0;
    display: none;
    max-height: min(240px, 40vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(240, 201, 94, 0.26);
    border-radius: 10px;
    background: #0b0a08;
    box-shadow: 0 16px 35px rgba(0, 0, 0, 0.55);
}

.auth-lang-dropdown.open .auth-lang-menu {
    display: block;
}

.auth-lang-option {
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: transparent;
    color: #ddd7ca;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.auth-lang-option:last-child {
    border-bottom: 0;
}

.auth-lang-option:hover {
    background: rgba(240, 201, 94, 0.1);
    color: #fff;
}

.auth-footer {
    position: relative;
    grid-row: 3;
    align-self: end;
    width: 100%;
    margin: 0;
    padding: 12px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    overflow: hidden;
    border-top: 1px solid rgba(240, 201, 94, 0.3);
    background: rgba(9, 7, 3, 0.88);
    text-align: center;
    backdrop-filter: blur(12px);
}

.auth-footer .benchmark-footer-inner {
    position: relative;
    z-index: 1;
    width: min(100%, 980px);
    min-width: 0;
    margin: 0 auto;
}

.legal-footer-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 4px;
}

.legal-baddy-icon {
    display: block;
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.auth-footer .legal-footer-text {
    margin: 0 0 3px;
    color: #fff;
    font-size: 11px;
    font-weight: 650;
}

.auth-footer .legal-author {
    color: var(--legal-author-color);
}

.auth-footer .legal-footer-disclaimer {
    max-width: 850px;
    margin: 0 auto 6px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 9px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.auth-footer .legal-footer-links {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 9px;
    padding-top: 6px;
    border-top: 1px solid rgba(212, 175, 87, 0.16);
    font-size: 10px;
}

.auth-footer .legal-footer-links a {
    color: var(--legal-link-color);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer .legal-footer-links a:hover {
    color: var(--legal-link-hover-color);
    text-decoration: underline;
}

.auth-footer .legal-divider {
    color: var(--legal-link-color);
    opacity: 0.45;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px #080704 inset !important;
    box-shadow: 0 0 0 1000px #080704 inset !important;
    -webkit-text-fill-color: #fff !important;
    caret-color: #fff !important;
}

@media (max-width: 640px) {
    html {
        height: 100%;
        overflow: hidden;
        overscroll-behavior: none;
    }

    body {
        height: 100%;
        grid-template-rows: minmax(0, 1fr) auto;
        min-height: 100svh;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: hidden;
        overscroll-behavior: none;
    }

    .auth-stage {
        grid-row: 1;
        display: grid;
        grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 0;
    }

    .auth-home-link {
        top: max(10px, env(safe-area-inset-top));
        left: max(10px, env(safe-area-inset-left));
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .auth-home-link svg {
        width: 22px;
        height: 22px;
    }

    .app-title {
        grid-row: 1;
        align-self: center;
        justify-self: center;
        width: calc(100% - 24px);
        max-width: calc(100vw - 24px);
        min-width: 0;
        margin: max(10px, env(safe-area-inset-top)) 0 8px;
        font-size: clamp(24px, 10vw, 54px);
        letter-spacing: 0.025em;
        line-height: 1;
        text-shadow: 3px 3px 0 #000;
        white-space: nowrap;
        -webkit-text-stroke: 1.5px #000;
    }

    .auth-main {
        display: contents;
    }

    .login-container {
        grid-row: 2;
        grid-column: 1;
        align-self: center;
        justify-self: center;
        width: min(calc(100% - 24px), var(--auth-content-width));
        max-width: 100%;
        min-width: 0;
        gap: 13px;
        padding: 20px 16px;
        border-radius: 16px;
    }

    .login-container h2 {
        font-size: 22px;
    }

    .input-group input:not([type="checkbox"]) {
        height: 46px;
        font-size: 16px;
    }

    .btn {
        min-height: 46px;
    }

    .alternative-actions {
        gap: 6px 9px;
        font-size: 12px;
    }

    .auth-lang-button,
    .auth-lang-option {
        font-size: 16px;
    }

    .auth-lang-shell {
        grid-row: 3;
        grid-column: 1;
        align-self: start;
        justify-self: center;
        width: min(calc(100% - 24px), var(--auth-content-width));
        max-width: 100%;
        margin: 8px 0 0;
    }

    .auth-footer {
        grid-row: 2;
        padding-top: 8px;
        padding-bottom: max(7px, env(safe-area-inset-bottom));
    }

    .legal-baddy-icon {
        width: 30px;
        height: 30px;
    }

    .auth-footer .legal-footer-text {
        font-size: 9px;
    }

    .auth-footer .legal-footer-disclaimer {
        margin-bottom: 4px;
        font-size: 7px;
        line-height: 1.25;
    }

    .auth-footer .legal-footer-links {
        gap: 4px 7px;
        padding-top: 4px;
        font-size: 9px;
    }

    .auth-footer .legal-divider {
        display: none;
    }
}

@media (max-height: 680px) and (min-width: 641px) {
    .app-title {
        margin-top: 18px;
        font-size: 48px;
    }

    .auth-main {
        padding-top: 12px;
        padding-bottom: 18px;
    }

    .login-container {
        gap: 12px;
        padding: 20px 26px;
    }

    .legal-baddy-icon {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 640px) and (max-height: 720px) {
    .auth-stage {
        grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
    }

    .app-title {
        margin-top: max(5px, env(safe-area-inset-top));
        margin-bottom: 4px;
        font-size: clamp(24px, 9vw, 48px);
    }

    .auth-main {
        gap: 5px;
        padding: 0 9px 7px;
    }

    .login-container {
        gap: 9px;
        padding: 14px;
        border-radius: 14px;
    }

    .login-container h2 {
        margin-bottom: 0;
        font-size: 20px;
    }

    .input-group {
        gap: 4px;
    }

    .input-group label {
        font-size: 11px;
    }

    .input-group input:not([type="checkbox"]) {
        height: 40px;
    }

    .remember-row {
        min-height: 22px;
    }

    .btn {
        min-height: 40px;
        padding: 7px 12px;
    }

    .error-message {
        min-height: 10px;
        font-size: 10px;
        line-height: 1.2;
    }

    .auth-lang-button,
    .auth-lang-option {
        min-height: 34px;
        padding-top: 5px;
        padding-bottom: 5px;
    }

    .auth-footer {
        padding-top: 5px;
        padding-bottom: max(4px, env(safe-area-inset-bottom));
    }

    .legal-footer-icon-wrap {
        margin-bottom: 1px;
    }

    .legal-baddy-icon {
        width: 24px;
        height: 24px;
    }

    .auth-footer .legal-footer-text {
        margin-bottom: 1px;
        font-size: 8px;
    }

    .auth-footer .legal-footer-disclaimer {
        margin-bottom: 2px;
        font-size: 6.5px;
        line-height: 1.15;
    }

    .auth-footer .legal-footer-links {
        gap: 3px 6px;
        padding-top: 2px;
        font-size: 8px;
    }
}

@media (max-width: 640px) and (max-height: 560px) {
    .auth-stage {
        grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
    }

    .app-title {
        margin-top: max(2px, env(safe-area-inset-top));
        margin-bottom: 2px;
        font-size: clamp(22px, 8.5vw, 42px);
    }

    .auth-main {
        gap: 4px;
        padding-right: 7px;
        padding-bottom: 3px;
        padding-left: 7px;
    }

    .login-container {
        gap: 7px;
        padding: 10px 12px;
    }

    .input-group input:not([type="checkbox"]) {
        height: 36px;
    }

    .btn {
        min-height: 36px;
        padding-top: 5px;
        padding-bottom: 5px;
    }

    .auth-lang-button,
    .auth-lang-option {
        min-height: 30px;
        padding-top: 3px;
        padding-bottom: 3px;
    }

    .auth-footer {
        padding-top: 3px;
        padding-bottom: max(3px, env(safe-area-inset-bottom));
    }

    .legal-baddy-icon {
        width: 20px;
        height: 20px;
    }

    .auth-footer .legal-footer-disclaimer {
        margin-bottom: 1px;
        font-size: 6px;
    }

    .auth-footer .legal-footer-links {
        padding-top: 1px;
        font-size: 7px;
    }
}

@media (max-width: 370px) {
    .app-title {
        margin-right: 0;
        margin-left: 0;
    }

    .auth-main {
        padding-right: 8px;
        padding-left: 8px;
    }

    .login-container {
        padding: 17px 13px;
    }
}

html.mobile-viewport-guard,
html.mobile-viewport-guard body {
    width: 100%;
    max-width: 100%;
    min-height: 100svh;
    min-height: 100dvh;
}

html.mobile-viewport-guard body.mobile-keyboard-open {
    min-height: 100dvh;
}

html.mobile-viewport-guard body.auth-lang-menu-open {
    overflow-y: auto;
}

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