:root {
    --coal: #080a0a;
    --night: #0b1013;
    --panel: rgba(11, 12, 11, 0.94);
    --panel-deep: rgba(7, 8, 8, 0.98);
    --line: rgba(167, 121, 49, 0.34);
    --line-strong: rgba(207, 157, 66, 0.72);
    --gold: #c9973f;
    --gold-bright: #e1b75f;
    --ivory: #e4d6ba;
    --muted: #9a8e7a;
    --quiet: #6f685d;
    --green: #77a06f;
    --danger: #bd6f62;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-width: 320px;
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--ivory);
    background: var(--coal);
    font-family: "Kurale", Georgia, serif;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.gate {
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    display: grid;
    grid-template-columns: minmax(440px, 1fr) minmax(390px, 520px);
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
    isolation: isolate;
    background: #11171b;
}

.gate__art,
.gate__nav,
.gate__shade {
    position: absolute;
    inset: 0;
    z-index: -2;
}

.gate__art,
.gate__nav {
    background:
        url("/assets/login/login-ostrog-gates-v1.png")
        46% center / cover no-repeat;
    transform: scale(1);
}

.gate__art {
    animation: scene-arrive 1600ms cubic-bezier(.2, .75, .2, 1) both;
}

.gate__nav {
    --rift-x: 34vw;
    --rift-y: 52vh;
    --rift-radius: 0px;
    z-index: -1;
    opacity: 0;
    background-image: url("/assets/login/login-ostrog-navi-v1.png");
    -webkit-mask-image:
        radial-gradient(
            circle var(--rift-radius) at var(--rift-x) var(--rift-y),
            #000 0%,
            #000 48%,
            rgba(0, 0, 0, 0.88) 66%,
            rgba(0, 0, 0, 0.22) 88%,
            transparent 100%
        );
    mask-image:
        radial-gradient(
            circle var(--rift-radius) at var(--rift-x) var(--rift-y),
            #000 0%,
            #000 48%,
            rgba(0, 0, 0, 0.88) 66%,
            rgba(0, 0, 0, 0.22) 88%,
            transparent 100%
        );
    transition: opacity 180ms ease, --rift-radius 180ms ease;
    will-change: opacity, mask-image;
}

.gate.is-rift-visible .gate__nav {
    --rift-radius: 132px;
    opacity: 1;
}

.gate__shade {
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg,
            rgba(4, 7, 9, 0.08) 0%,
            rgba(4, 7, 9, 0.03) 36%,
            rgba(4, 7, 9, 0.42) 59%,
            rgba(4, 7, 9, 0.96) 80%,
            #080a0a 100%),
        linear-gradient(0deg,
            rgba(5, 7, 8, 0.76) 0%,
            transparent 34%,
            rgba(5, 7, 8, 0.25) 100%);
}

.brand {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    position: relative;
    z-index: 1;
    width: min(560px, calc(100% - 96px));
    margin: clamp(34px, 5vw, 76px) 0 0 clamp(30px, 6vw, 100px);
    display: flex;
    flex-direction: column;
    animation: copy-arrive 900ms 280ms ease-out both;
}

.brand__eyebrow,
.auth__kicker,
.one-time {
    color: var(--gold);
    font-family: "Monomakh", Georgia, serif;
    font-size: 11px;
    letter-spacing: 2.1px;
    text-transform: uppercase;
}

.brand__eyebrow {
    display: flex;
    align-items: center;
    gap: 13px;
}

.brand__eyebrow::before {
    content: "";
    width: 34px;
    height: 1px;
    background: var(--gold);
}

.brand__name {
    margin-top: 7px;
    color: #ead39c;
    font-family: "Monomakh", Georgia, serif;
    font-size: clamp(54px, 7vw, 104px);
    line-height: 0.93;
    text-shadow: 0 5px 24px rgba(0, 0, 0, 0.72);
}

.brand__line {
    max-width: 390px;
    margin-top: 15px;
    color: rgba(228, 214, 186, 0.76);
    font-size: clamp(14px, 1.2vw, 18px);
    line-height: 1.5;
    text-shadow: 0 2px 12px #000;
}

.world-note {
    grid-column: 1;
    grid-row: 3;
    align-self: end;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 30px clamp(30px, 6vw, 100px);
    color: rgba(228, 214, 186, 0.62);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-shadow: 0 2px 8px #000;
}

.world-note__ember {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #d79237;
    box-shadow: 0 0 10px #d79237;
}

.auth {
    grid-column: 2;
    grid-row: 1 / 4;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding:
        max(34px, env(safe-area-inset-top))
        clamp(34px, 4.3vw, 68px)
        max(24px, env(safe-area-inset-bottom));
    background:
        linear-gradient(90deg, transparent, rgba(189, 137, 54, 0.035) 18%, transparent 72%),
        var(--panel);
    border-left: 1px solid var(--line);
    box-shadow: -28px 0 70px rgba(0, 0, 0, 0.35);
    animation: auth-arrive 780ms 180ms cubic-bezier(.2, .75, .2, 1) both;
}

.auth::before,
.auth::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    opacity: 0.55;
    background:
        linear-gradient(90deg,
            transparent 0 8%,
            var(--line-strong) 8% 12%,
            transparent 12% 14%,
            var(--line) 14% 86%,
            transparent 86%);
}

.auth::before {
    top: 20px;
}

.auth::after {
    bottom: 18px;
}

.auth__top {
    margin-bottom: 25px;
}

.auth__kicker {
    margin: 0 0 8px;
}

.auth__title {
    margin: 0;
    color: var(--ivory);
    font-family: "Monomakh", Georgia, serif;
    font-size: clamp(30px, 3.1vw, 44px);
    font-weight: 400;
    line-height: 1.04;
    letter-spacing: 0;
}

.auth__lead {
    margin: 12px 0 0;
    max-width: 390px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.panel {
    min-height: 324px;
}

.panel[hidden],
.method[hidden] {
    display: none;
}

.panel.is-entering {
    animation: panel-enter 240ms ease-out both;
}

.method-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 0 0 24px;
    border-bottom: 1px solid var(--line);
}

.method-tab {
    min-height: 43px;
    position: relative;
    padding: 0 4px 10px;
    border: 0;
    color: var(--quiet);
    background: transparent;
    cursor: pointer;
    font-family: "Monomakh", Georgia, serif;
    font-size: 15px;
}

.method-tab::after {
    content: "";
    position: absolute;
    right: 50%;
    bottom: -1px;
    left: 50%;
    height: 2px;
    background: var(--gold);
    transition: left 180ms ease, right 180ms ease;
}

.method-tab:hover {
    color: var(--ivory);
}

.method-tab.is-active {
    color: var(--gold-bright);
}

.method-tab.is-active::after {
    right: 8px;
    left: 8px;
}

.method {
    min-height: 232px;
}

.method.is-entering {
    animation: panel-enter 220ms ease-out both;
}

.method-copy {
    min-height: 102px;
    padding: 18px 19px;
    border-left: 2px solid var(--gold);
    background: rgba(199, 151, 63, 0.055);
}

.method-copy__title {
    margin: 0;
    color: var(--ivory);
    font-family: "Monomakh", Georgia, serif;
    font-size: 20px;
}

.method-copy__text {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.primary-action {
    width: 100%;
    min-height: 52px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px 0 21px;
    border: 1px solid #b58434;
    border-radius: 3px;
    color: #17120a;
    background:
        linear-gradient(180deg, #d2a551, #b98531);
    box-shadow:
        inset 0 1px rgba(255, 238, 184, 0.38),
        0 7px 24px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    font-family: "Monomakh", Georgia, serif;
    font-size: 18px;
    transition: filter 160ms ease, transform 120ms ease, box-shadow 160ms ease;
}

.primary-action:hover:not(:disabled) {
    filter: brightness(1.08);
    box-shadow:
        inset 0 1px rgba(255, 238, 184, 0.48),
        0 8px 30px rgba(160, 104, 29, 0.2);
}

.primary-action:active:not(:disabled) {
    transform: translateY(1px);
}

.primary-action:disabled {
    color: #5c5549;
    border-color: #514834;
    background: #292722;
    box-shadow: none;
    cursor: not-allowed;
}

.primary-action.is-busy .primary-action__arrow {
    animation: busy 800ms linear infinite;
}

.primary-action__arrow {
    font-size: 23px;
    line-height: 1;
}

.quiet-note,
.field-help {
    color: var(--quiet);
    font-size: 11px;
    line-height: 1.45;
}

.tg-login-section {
    min-height: 93px;
}

.tg-login-loading {
    min-height: 52px;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    border: 1px solid var(--line);
    color: var(--muted);
    background: rgba(2, 4, 5, 0.52);
    font-size: 12px;
}

.tg-login-loading.is-visible {
    display: flex;
}

.tg-login-loading__mark {
    width: 13px;
    height: 13px;
    border: 1px solid var(--quiet);
    border-top-color: var(--gold-bright);
    border-radius: 50%;
    animation: telegram-wait 700ms linear infinite;
}

.tg-login-fallback {
    display: block;
    margin-top: 9px;
    color: var(--quiet);
    text-align: center;
    text-decoration: none;
    font-size: 11px;
}

.tg-login-fallback:hover {
    color: var(--gold-bright);
}

.quiet-note {
    margin: 13px 0 0;
    text-align: center;
}

.status-dot {
    width: 5px;
    height: 5px;
    display: inline-block;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px rgba(119, 160, 111, 0.68);
    vertical-align: 1px;
}

.field-label {
    display: block;
    margin-bottom: 7px;
    color: #b5a78d;
    font-size: 11px;
    letter-spacing: 0.05em;
}

.fields {
    display: grid;
    gap: 15px;
}

.field {
    display: block;
}

.field input,
.password-field {
    width: 100%;
}

.field input,
.otp input {
    height: 46px;
    border: 1px solid rgba(167, 121, 49, 0.31);
    border-radius: 2px;
    outline: none;
    color: var(--ivory);
    background: rgba(2, 4, 5, 0.62);
    caret-color: var(--gold-bright);
}

.field input {
    padding: 0 13px;
    font-size: 15px;
}

.field input::placeholder {
    color: #625d54;
}

.field input:focus,
.otp input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(201, 151, 63, 0.09);
}

.password-field {
    position: relative;
    display: block;
}

.password-field input {
    padding-right: 76px;
}

.reveal {
    position: absolute;
    top: 1px;
    right: 1px;
    bottom: 1px;
    padding: 0 12px;
    border: 0;
    color: var(--quiet);
    background: #0b0d0d;
    cursor: pointer;
    font-size: 11px;
}

.reveal:hover {
    color: var(--gold-bright);
}

.otp {
    display: grid;
    grid-template-columns: repeat(3, minmax(38px, 1fr)) 12px repeat(3, minmax(38px, 1fr));
    gap: 7px;
}

.otp input {
    width: 100%;
    min-width: 0;
    padding: 0;
    text-align: center;
    color: var(--gold-bright);
    font-family: "Monomakh", Georgia, serif;
    font-size: 24px;
}

.otp__break {
    position: relative;
}

.otp__break::after {
    content: "";
    width: 7px;
    height: 1px;
    position: absolute;
    top: 50%;
    left: 50%;
    background: var(--quiet);
    transform: translate(-50%, -50%);
}

.field-help {
    margin: 9px 0 0;
}

.form-message {
    min-height: 18px;
    margin: 10px 0 0;
    color: var(--danger);
    font-size: 12px;
}

.form-message:empty {
    min-height: 0;
    margin-top: 0;
}

.otp-input.error,
.field input.error {
    border-color: var(--danger);
    color: #e3a095;
    box-shadow: 0 0 0 2px rgba(189, 111, 98, 0.08);
}

.otp-inputs.shake,
.fields.shake {
    animation: invalid-shake 360ms ease-in-out;
}

.auth-links {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 12px;
    align-items: center;
    margin-top: 22px;
}

.auth-links span {
    width: 1px;
    height: 16px;
    background: var(--line);
}

.auth-links button,
.back,
.copy-action {
    border: 0;
    color: #a89470;
    background: transparent;
    cursor: pointer;
}

.auth-links button {
    padding: 5px 0;
    font-size: 12px;
}

.auth-links button:hover,
.back:hover,
.copy-action:hover {
    color: var(--gold-bright);
}

.back {
    margin: -5px 0 22px;
    padding: 5px 0;
    font-size: 12px;
}

.agreement {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 15px;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    line-height: 1.45;
}

.agreement input {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    margin: 1px 0 0;
    accent-color: var(--gold);
}

.recovery-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin: 2px auto 15px;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    color: var(--gold-bright);
    background: rgba(201, 151, 63, 0.08);
    font-size: 25px;
}

.one-time {
    margin: 0 0 14px;
    text-align: center;
}

.recovery-value {
    padding: 18px 12px;
    border: 1px solid var(--line-strong);
    color: var(--gold-bright);
    background: rgba(2, 4, 5, 0.68);
    text-align: center;
    font-family: "Monomakh", Georgia, serif;
    font-size: clamp(16px, 2vw, 21px);
    letter-spacing: 0.08em;
    user-select: all;
}

.copy-action {
    display: block;
    margin: 10px auto 3px;
    padding: 5px 10px;
    font-size: 12px;
}

.agreement--code {
    margin-top: 20px;
}

.auth__footer {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid rgba(167, 121, 49, 0.18);
    color: #5e594f;
    font-size: 10px;
}

.auth__footer a {
    color: #766e60;
    text-decoration: none;
}

.auth__footer a:hover {
    color: var(--gold);
}

.toast {
    position: fixed;
    z-index: 20;
    bottom: 24px;
    left: 50%;
    max-width: min(420px, calc(100vw - 32px));
    padding: 11px 16px;
    border: 1px solid var(--line-strong);
    color: var(--ivory);
    background: rgba(8, 10, 10, 0.94);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.54);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity 180ms ease, transform 180ms ease;
    font-size: 12px;
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 2px solid var(--gold-bright);
    outline-offset: 3px;
}

@keyframes scene-arrive {
    from { opacity: 0.6; transform: scale(1.07); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes auth-arrive {
    from { opacity: 0; transform: translateX(32px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes copy-arrive {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes panel-enter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes busy {
    50% { opacity: 0.28; transform: translateX(3px); }
}

@keyframes telegram-wait {
    to { transform: rotate(360deg); }
}

@keyframes invalid-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

@media (max-width: 900px) {
    .gate {
        grid-template-columns: minmax(280px, 0.85fr) minmax(370px, 1fr);
    }

    .brand {
        width: calc(100% - 48px);
        margin-left: 30px;
    }

    .world-note {
        margin-left: 30px;
    }

    .auth {
        padding-right: 34px;
        padding-left: 34px;
    }
}

@media (max-width: 680px) {
    .gate {
        min-height: 100dvh;
        display: block;
        overflow: visible;
        padding-top: min(42vh, 390px);
    }

    .gate__art {
        position: fixed;
        height: min(48vh, 430px);
        background-position: 38% center;
        transform: scale(1);
    }

    .gate__nav {
        position: fixed;
        height: min(48vh, 430px);
        background-position: 38% center;
    }

    .gate.is-rift-visible .gate__nav {
        --rift-radius: 104px;
    }

    .gate__shade {
        position: fixed;
        background:
            linear-gradient(0deg, #080a0a 0%, rgba(8, 10, 10, 0.2) 52%, rgba(5, 7, 8, 0.2) 100%),
            linear-gradient(90deg, rgba(5, 7, 8, 0.1), rgba(5, 7, 8, 0.52));
    }

    .brand {
        position: absolute;
        top: 0;
        left: 0;
        width: calc(100% - 40px);
        margin: max(24px, env(safe-area-inset-top)) 20px 0;
    }

    .brand__eyebrow {
        font-size: 9px;
        letter-spacing: 1.6px;
    }

    .brand__name {
        margin-top: 4px;
        font-size: clamp(48px, 16vw, 68px);
    }

    .brand__line {
        max-width: 270px;
        margin-top: 8px;
        font-size: 13px;
    }

    .world-note {
        display: none;
    }

    .auth {
        width: 100%;
        min-height: calc(100dvh - min(42vh, 390px));
        padding:
            29px
            max(22px, env(safe-area-inset-right))
            max(26px, env(safe-area-inset-bottom))
            max(22px, env(safe-area-inset-left));
        border-top: 1px solid var(--line-strong);
        border-left: 0;
        box-shadow: 0 -22px 52px rgba(0, 0, 0, 0.72);
        background:
            linear-gradient(180deg, rgba(9, 10, 10, 0.97), #080a0a 32%),
            var(--panel-deep);
        animation-name: mobile-auth-arrive;
    }

    .auth::before {
        top: 8px;
    }

    .auth::after {
        display: none;
    }

    .auth__top {
        margin-bottom: 20px;
    }

    .auth__title {
        font-size: 34px;
    }

    .auth__lead {
        font-size: 13px;
    }

    .panel {
        min-height: 0;
    }

    .method {
        min-height: 0;
    }

    .auth__footer {
        margin-top: 26px;
    }

    .toast {
        bottom: max(16px, env(safe-area-inset-bottom));
    }

    @keyframes mobile-auth-arrive {
        from { opacity: 0; transform: translateY(30px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

@media (max-width: 390px) {
    .gate {
        padding-top: 38vh;
    }

    .gate__art {
        height: 44vh;
    }

    .brand__line {
        display: none;
    }

    .auth {
        padding-right: 18px;
        padding-left: 18px;
    }

    .method-tab {
        font-size: 14px;
    }

    .otp {
        grid-template-columns: repeat(3, minmax(34px, 1fr)) 8px repeat(3, minmax(34px, 1fr));
        gap: 5px;
    }
}

@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;
    }
}

@property --rift-radius {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
}
