:root {
    --bg: #12100f;
    --bg-warm: #211b17;
    --panel: rgba(16, 14, 13, 0.92);
    --panel-soft: rgba(31, 27, 24, 0.82);
    --panel-field: rgba(255, 250, 242, 0.06);
    --line: rgba(229, 199, 160, 0.23);
    --line-strong: rgba(229, 199, 160, 0.46);
    --gold: #e6c295;
    --gold-deep: #c99967;
    --text: #fffaf2;
    --muted: #b9b0a6;
    --dim: #81786f;
    --sea: #9fc5c3;
    --green: #9ed7aa;
    --red: #e8a191;
    --violet: #8e879f;
    --ink: #17110d;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    position: relative;
    color: var(--text);
    font-family: "Manrope", Arial, sans-serif;
    background: #060807;
    user-select: none;
}

body::before {
    content: "";
    position: fixed;
    inset: -2px;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(105deg, rgba(18, 16, 15, 0.34), rgba(31, 27, 24, 0.2) 46%, rgba(10, 9, 9, 0.64)),
        url('bg_village.jpg') center center / 100% 100% no-repeat;
    /* CEF off-screen rendering does not reliably capture GPU-promoted filtered
       pseudo-elements. Keep this layer in the normal paint tree. */
}

button,
input {
    font: inherit;
}

button {
    letter-spacing: 0;
}

.auth-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(620px, 1fr) minmax(400px, 468px);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    isolation: isolate;
}

.auth-shell::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(255, 250, 242, 0.035) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255, 250, 242, 0.028) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: linear-gradient(to bottom, transparent, #000 10%, #000 88%, transparent);
    z-index: -1;
    display: none; /* Тимчасово вимкнено на прохання */
}

.scene-panel {
    position: relative;
    min-width: 0;
    overflow: hidden;
    padding: 38px 48px;
}

.ambient-grid,
.horizon-glow,
.sand-trace,
.stage-light,
.stand-shadow {
    position: absolute;
    pointer-events: none;
    display: none;
}

.ambient-grid {
    inset: 0;
    background:
        linear-gradient(120deg, transparent 0 37%, rgba(230, 194, 149, 0.05) 37% 38%, transparent 38% 100%),
        linear-gradient(70deg, transparent 0 58%, rgba(159, 197, 195, 0.045) 58% 59%, transparent 59% 100%);
    opacity: 0.9;
}

.horizon-glow {
    left: 2%;
    right: 3%;
    bottom: 19%;
    height: 30%;
    background:
        radial-gradient(ellipse at 29% 68%, rgba(230, 194, 149, 0.34), transparent 42%),
        radial-gradient(ellipse at 57% 52%, rgba(159, 197, 195, 0.14), transparent 38%),
        linear-gradient(90deg, transparent, rgba(230, 194, 149, 0.1), transparent);
    filter: blur(18px);
}

.sand-trace {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(230, 194, 149, 0.28), transparent);
}

.trace-a {
    left: 5%;
    right: 14%;
    top: 19%;
}

.trace-b {
    left: 18%;
    right: 5%;
    bottom: 23%;
}

.brand-mark {
    position: relative;
    z-index: 2;
    max-width: 620px;
}

.brand-kicker {
    display: block;
    color: var(--sea);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.brand-mark h1 {
    margin: 10px 0 10px;
    color: var(--text);
    font-size: clamp(36px, 4.2vw, 58px);
    line-height: 0.98;
    letter-spacing: 0;
}

.brand-mark p {
    margin: 0;
    max-width: 390px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.scene-stats {
    position: absolute;
    z-index: 2;
    left: 48px;
    bottom: 44px;
    display: flex;
    gap: 10px;
}

.scene-stats span {
    padding: 7px 10px;
    color: rgba(255, 250, 242, 0.78);
    background: rgba(255, 250, 242, 0.055);
    border: 1px solid rgba(255, 250, 242, 0.08);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.character-stage {
    position: absolute;
    z-index: 2;
    left: auto;
    right: clamp(110px, 12vw, 230px);
    bottom: 5vh;
    width: min(470px, 34vw);
    height: min(635px, 72vh);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stage-arch {
    position: absolute;
    inset: 5% 7% 18%;
    background:
        linear-gradient(180deg, rgba(255, 250, 242, 0.07), rgba(255, 250, 242, 0.015)),
        linear-gradient(90deg, rgba(159, 197, 195, 0.08), transparent 28% 72%, rgba(230, 194, 149, 0.1));
    border: 1px solid rgba(230, 194, 149, 0.24);
    box-shadow:
        inset 0 0 0 1px rgba(255, 250, 242, 0.035),
        inset 0 -90px 90px rgba(0, 0, 0, 0.32),
        0 38px 90px rgba(0, 0, 0, 0.36);
}

.stage-arch::before,
.stage-arch::after {
    content: "";
    position: absolute;
    top: 11%;
    bottom: 11%;
    width: 1px;
    background: linear-gradient(transparent, rgba(230, 194, 149, 0.42), transparent);
}

.stage-arch::before {
    left: 18%;
}

.stage-arch::after {
    right: 18%;
}

.stage-light {
    left: 21%;
    right: 21%;
    top: 24%;
    bottom: 18%;
    background: radial-gradient(ellipse at center, rgba(230, 194, 149, 0.22), transparent 66%);
    filter: blur(20px);
}

.skin-frame {
    position: absolute;
    z-index: 3;
    left: 0;
    right: 0;
    bottom: calc(14% + 32px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 100%;
    height: 70%;
    /* Avoid a separate filtered compositing layer in transparent MCEF OSR. */
}

.skin-model {
    --skin-url: none;
    --skin-pixel: min(10px, 1.18vh);
    position: relative;
    width: calc(var(--skin-pixel) * 16);
    height: calc(var(--skin-pixel) * 32);
    image-rendering: pixelated;
    transform: translateY(0) scale(1.08);
    transform-origin: bottom center;
}

.skin-model-loading .skin-head,
.skin-model-loading .skin-hat {
    background: #5c4638;
}

.skin-model-loading .skin-body,
.skin-model-loading .skin-jacket {
    background: #385a5b;
}

.skin-model-loading .skin-arm,
.skin-model-loading .skin-sleeve {
    background: #8f6b50;
}

.skin-model-loading .skin-leg,
.skin-model-loading .skin-pants {
    background: #343b55;
}

.skin-part {
    position: absolute;
    display: block;
    background-image: var(--skin-url);
    background-size: calc(var(--skin-pixel) * 64) calc(var(--skin-pixel) * 64);
    background-repeat: no-repeat;
    image-rendering: pixelated;
}

.skin-head,
.skin-hat {
    left: calc(var(--skin-pixel) * 4);
    top: 0;
    width: calc(var(--skin-pixel) * 8);
    height: calc(var(--skin-pixel) * 8);
}

.skin-head {
    background-position: calc(var(--skin-pixel) * -8) calc(var(--skin-pixel) * -8);
    z-index: 5;
}

.skin-hat {
    background-position: calc(var(--skin-pixel) * -40) calc(var(--skin-pixel) * -8);
    z-index: 6;
}

.skin-body,
.skin-jacket {
    left: calc(var(--skin-pixel) * 4);
    top: calc(var(--skin-pixel) * 8);
    width: calc(var(--skin-pixel) * 8);
    height: calc(var(--skin-pixel) * 12);
}

.skin-body {
    background-position: calc(var(--skin-pixel) * -20) calc(var(--skin-pixel) * -20);
    z-index: 3;
}

.skin-jacket {
    background-position: calc(var(--skin-pixel) * -20) calc(var(--skin-pixel) * -36);
    z-index: 4;
}

.skin-arm,
.skin-sleeve,
.skin-leg,
.skin-pants {
    width: calc(var(--skin-pixel) * 4);
    height: calc(var(--skin-pixel) * 12);
}

.skin-arm-right,
.skin-sleeve-right {
    left: 0;
    top: calc(var(--skin-pixel) * 8);
}

.skin-arm-left,
.skin-sleeve-left {
    left: calc(var(--skin-pixel) * 12);
    top: calc(var(--skin-pixel) * 8);
}

.skin-arm-right {
    background-position: calc(var(--skin-pixel) * -44) calc(var(--skin-pixel) * -20);
    z-index: 2;
}

.skin-sleeve-right {
    background-position: calc(var(--skin-pixel) * -44) calc(var(--skin-pixel) * -36);
    z-index: 4;
}

.skin-arm-left {
    background-position: calc(var(--skin-pixel) * -36) calc(var(--skin-pixel) * -52);
    z-index: 2;
}

.skin-sleeve-left {
    background-position: calc(var(--skin-pixel) * -52) calc(var(--skin-pixel) * -52);
    z-index: 4;
}

.skin-leg-right,
.skin-pants-right {
    left: calc(var(--skin-pixel) * 4);
    top: calc(var(--skin-pixel) * 20);
}

.skin-leg-left,
.skin-pants-left {
    left: calc(var(--skin-pixel) * 8);
    top: calc(var(--skin-pixel) * 20);
}

.skin-leg-right {
    background-position: calc(var(--skin-pixel) * -4) calc(var(--skin-pixel) * -20);
    z-index: 1;
}

.skin-pants-right {
    background-position: calc(var(--skin-pixel) * -4) calc(var(--skin-pixel) * -36);
    z-index: 3;
}

.skin-leg-left {
    background-position: calc(var(--skin-pixel) * -20) calc(var(--skin-pixel) * -52);
    z-index: 1;
}

.skin-pants-left {
    background-position: calc(var(--skin-pixel) * -4) calc(var(--skin-pixel) * -52);
    z-index: 3;
}

.stand-shadow {
    z-index: 1;
    left: 23%;
    right: 23%;
    bottom: 15%;
    height: 36px;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.62), transparent 70%);
    filter: blur(7px);
}

.stand-base {
    position: absolute;
    z-index: 2;
    left: 17%;
    right: 17%;
    bottom: 14%;
    height: 32px;
    background:
        linear-gradient(180deg, rgba(255, 250, 242, 0.13), transparent),
        linear-gradient(90deg, rgba(230, 194, 149, 0.5), rgba(142, 135, 159, 0.24), rgba(159, 197, 195, 0.28));
    border: 1px solid rgba(255, 250, 242, 0.18);
    box-shadow: 0 20px 42px rgba(0, 0, 0, 0.52);
}

.stand-base span {
    position: absolute;
    left: 11%;
    right: 11%;
    bottom: -13px;
    height: 13px;
    background: rgba(19, 15, 13, 0.86);
    border: 1px solid rgba(230, 194, 149, 0.18);
    border-top: 0;
}

.plate {
    position: absolute;
    z-index: 4;
    left: 12%;
    right: 12%;
    bottom: 1%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 62px;
    padding: 13px 15px;
    background: rgba(14, 12, 11, 0.84);
    border: 1px solid rgba(230, 194, 149, 0.28);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
    /* backdrop-filter is not reliable in CEF off-screen rendering. */
}

.plate span {
    display: block;
    overflow: hidden;
    color: var(--gold);
    font-size: 19px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plate small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.plate strong {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    color: var(--sea);
    background: rgba(159, 197, 195, 0.09);
    border: 1px solid rgba(159, 197, 195, 0.2);
    font-size: 11px;
}

.panel-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 54px 30px 0;
    pointer-events: auto;
}

.panel-wrap::before {
    content: "";
    position: absolute;
    left: -96px;
    top: 0;
    bottom: 0;
    width: 192px;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(12, 10, 9, 0.18) 34%, rgba(12, 10, 9, 0.5) 100%);
    display: none;
}

.auth-panel {
    position: relative;
    width: 100%;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    padding: 26px;
    background:
        linear-gradient(180deg, rgba(255, 250, 242, 0.05), rgba(255, 250, 242, 0)),
        rgba(16, 14, 13, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    box-shadow:
        0 30px 86px rgba(0, 0, 0, 0.65),
        inset 0 1px 0 rgba(255, 250, 242, 0.05);
    animation: slidePanel 420ms ease-out;
}

.auth-panel::before {
    content: "";
    position: absolute;
    left: 28px;
    right: 28px;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), var(--sea), transparent);
    opacity: 0.7;
}

.auth-panel::-webkit-scrollbar {
    width: 6px;
}

.auth-panel::-webkit-scrollbar-thumb {
    background: rgba(230, 194, 149, 0.32);
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.secure-dot {
    width: 12px;
    height: 12px;
    background: var(--green);
    box-shadow: 0 0 0 6px rgba(158, 215, 170, 0.08), 0 0 22px var(--green);
}

.panel-head p {
    margin: 0 0 5px;
    color: var(--sea);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.panel-head h2 {
    margin: 0;
    color: var(--text);
    font-size: 29px;
    line-height: 1;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 22px;
    padding: 4px;
    background: rgba(255, 250, 242, 0.045);
    border: 1px solid rgba(255, 250, 242, 0.075);
}

.tab-btn,
.link-btn,
.ghost-btn,
.submit-btn {
    border: 0;
    cursor: pointer;
}

.tab-btn {
    min-height: 43px;
    color: var(--muted);
    background: transparent;
    font-weight: 800;
    transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tab-btn:hover {
    color: var(--text);
    background: rgba(255, 250, 242, 0.06);
}

.tab-btn.active {
    color: var(--ink) !important;
    background: linear-gradient(135deg, var(--gold), #d8ad7c);
    box-shadow: 0 12px 28px rgba(230, 194, 149, 0.16);
}

.tab-btn:disabled {
    opacity: 1;
}

.auth-form {
    display: none;
    gap: 15px;
}

.auth-form.active {
    display: grid;
}

.appearance-field {
    display: grid;
    gap: 9px;
}

.field-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.field-title span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.field-title small {
    color: rgba(185, 176, 166, 0.7);
    font-size: 11px;
}

.appearance-actions {
    display: grid;
    grid-template-columns: 1fr 150px;
    gap: 8px;
}

.upload-btn {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    color: var(--gold);
    background: rgba(230, 194, 149, 0.055);
    border: 1px solid rgba(230, 194, 149, 0.22);
    cursor: pointer;
    overflow: hidden;
}

.upload-btn input {
    display: none;
}

.upload-btn span {
    overflow: hidden;
    color: var(--gold);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 3px;
    background: rgba(255, 250, 242, 0.045);
    border: 1px solid rgba(255, 250, 242, 0.075);
}

.model-choice label {
    display: block;
}

.model-choice input {
    display: none;
}

.model-choice span {
    display: grid;
    place-items: center;
    min-height: 36px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.model-choice input:checked + span {
    color: var(--ink);
    background: var(--gold);
}

label {
    display: grid;
    gap: 7px;
}

label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

label small {
    color: rgba(185, 176, 166, 0.82);
    font-size: 11px;
    line-height: 1.35;
}

input {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    color: var(--text);
    background: var(--panel-field);
    border: 1px solid rgba(255, 250, 242, 0.12);
    border-radius: 2px;
    outline: 0;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:hover {
    border-color: rgba(255, 250, 242, 0.2);
}

input:focus {
    background: rgba(255, 250, 242, 0.082);
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(230, 194, 149, 0.12);
}

input::placeholder {
    color: rgba(185, 176, 166, 0.58);
}

input:read-only {
    color: var(--muted);
    background: rgba(255, 250, 242, 0.035);
}

.password-field {
    display: grid;
    grid-template-columns: 1fr 92px;
    overflow: hidden;
    background: var(--panel-field);
    border: 1px solid rgba(255, 250, 242, 0.12);
    border-radius: 2px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.password-field:focus-within {
    background: rgba(255, 250, 242, 0.082);
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(230, 194, 149, 0.12);
}

.password-field input {
    border: 0;
    background: transparent;
    box-shadow: none;
}

.ghost-btn {
    color: var(--gold);
    background: rgba(230, 194, 149, 0.055);
    border-left: 1px solid rgba(255, 250, 242, 0.1);
    font-size: 12px;
    font-weight: 800;
}

.ghost-btn:hover {
    color: var(--text);
    background: rgba(230, 194, 149, 0.12);
}

.row-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.check-line {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.check-line input {
    position: relative;
    width: 17px;
    min-width: 17px;
    height: 17px;
    min-height: 17px;
    padding: 0;
    appearance: none;
    background: rgba(255, 250, 242, 0.08);
    border: 1px solid rgba(255, 250, 242, 0.22);
}

.check-line input:checked {
    background: var(--gold);
    border-color: var(--gold);
}

.check-line input:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid var(--ink);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.check-line span {
    color: var(--muted);
    font-weight: 600;
    line-height: 1.35;
}

.terms-line {
    align-items: flex-start;
}

.link-btn {
    padding: 0;
    color: var(--gold);
    background: transparent;
    font-weight: 800;
}

.link-btn:hover {
    color: var(--text);
}

.link-btn.back {
    justify-self: start;
}

.recovery-copy h3 {
    margin: 0 0 8px;
    font-size: 23px;
}

.recovery-copy p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.alert {
    display: none;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: 2px;
    font-size: 13px;
    line-height: 1.38;
}

.alert.error {
    color: var(--red);
    background: rgba(232, 161, 145, 0.12);
    border-color: rgba(232, 161, 145, 0.42);
}

.alert.success {
    color: var(--green);
    background: rgba(158, 215, 170, 0.12);
    border-color: rgba(158, 215, 170, 0.42);
}

.submit-btn {
    position: relative;
    overflow: hidden;
    min-height: 52px;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(255, 250, 242, 0.18), transparent),
        linear-gradient(135deg, var(--gold), var(--gold-deep));
    border: 1px solid rgba(255, 250, 242, 0.18);
    border-radius: 2px;
    font-weight: 900;
    box-shadow: 0 16px 34px rgba(230, 194, 149, 0.18);
    transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.submit-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 0 20%, rgba(255, 250, 242, 0.2) 42%, transparent 62% 100%);
    transform: translateX(-120%);
    transition: transform 380ms ease;
}

.submit-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
    box-shadow: 0 18px 40px rgba(230, 194, 149, 0.25);
}

.submit-btn:hover::after {
    transform: translateX(120%);
}

.submit-btn:disabled {
    cursor: default;
    opacity: 0.62;
    transform: none;
}

.submit-btn.loading span::after {
    content: "...";
}

.success-screen {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(18, 16, 15, 0.9);
}

.success-screen.active {
    display: flex;
}

.success-card {
    width: min(420px, calc(100vw - 48px));
    padding: 36px;
    text-align: center;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.success-ring {
    width: 66px;
    height: 66px;
    margin: 0 auto 18px;
    border: 4px solid var(--green);
    box-shadow: inset 0 0 20px rgba(158, 215, 170, 0.18), 0 0 30px rgba(158, 215, 170, 0.16);
}

.success-card h2 {
    margin: 0 0 8px;
    color: var(--gold);
}

.success-card p {
    margin: 0;
    color: var(--muted);
}

@keyframes slidePanel {
    from {
        opacity: 0;
        transform: translateX(28px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 1100px) {
    .auth-shell {
        grid-template-columns: minmax(420px, 1fr) minmax(388px, 438px);
    }

    .scene-panel {
        padding: 36px;
    }

    .scene-stats {
        left: 36px;
    }

    .character-stage {
        right: 6%;
        width: min(420px, 42vw);
    }
}

@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .scene-panel {
        display: none;
    }

    .panel-wrap {
        padding: 24px;
    }

    .panel-wrap::before {
        display: none;
    }
}
