:root {
    --accent: #00d2ff;
    --accent-soft: rgba(0, 210, 255, 0.10);
    --accent-glow: rgba(0, 210, 255, 0.18);
    --bg: #010102;
    --surface: #0a0a0f;
    --surface-raised: #101017;
    --field: rgba(255, 255, 255, 0.035);
    --border: rgba(255, 255, 255, 0.075);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #ffffff;
    --muted: rgba(255, 255, 255, 0.48);
    --muted-soft: rgba(255, 255, 255, 0.30);
    --error: #ff4757;
    --warning: #ffa502;
    --success: #2ecc71;
    --radius: 16px;
}

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

html {
    min-width: 320px;
    background: var(--bg);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    color: var(--text);
    background: var(--bg);
    font-family: 'Montserrat', sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(0, 210, 255, 0.38);
    outline-offset: 3px;
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background:
        radial-gradient(circle at 72% 24%, rgba(0, 210, 255, 0.075), transparent 32%),
        linear-gradient(to right, rgba(255,255,255,0.014) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.014) 1px, transparent 1px);
    background-size: auto, 50px 50px, 50px 50px;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,.7) 55%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,.7) 55%, transparent 100%);
}

.portal-layout {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(360px, 0.86fr) minmax(520px, 1.14fr);
    opacity: 0;
    transition: opacity .45s ease;
}

.portal-layout.ready {
    opacity: 1;
}

/* Left: project context, intentionally quiet */
.portal-left {
    position: sticky;
    top: 0;
    min-width: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(34px, 5vw, 76px);
    overflow: hidden;
    border-right: 1px solid var(--border);
    background:
        radial-gradient(circle at 68% 38%, rgba(0,210,255,0.08), transparent 34%),
        linear-gradient(145deg, rgba(255,255,255,0.018), transparent 36%);
}

.portal-left::before {
    content: '';
    position: absolute;
    width: min(36vw, 520px);
    aspect-ratio: 1;
    right: -22%;
    top: 16%;
    z-index: -1;
    border: 1px solid rgba(0,210,255,0.10);
    border-radius: 50%;
    box-shadow:
        0 0 0 64px rgba(0,210,255,0.012),
        0 0 0 128px rgba(255,255,255,0.006);
}

.portal-left-header,
.portal-left-footer,
.portal-left-bottom,
.lore-content {
    position: relative;
    z-index: 1;
}

.portal-left-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.back-home,
.mobile-back {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    text-decoration: none;
    text-transform: uppercase;
    transition: color .2s ease, transform .2s ease;
}

.back-home:hover,
.mobile-back:hover {
    color: #fff;
}

.back-home:hover {
    transform: translateX(-3px);
}

.back-home svg,
.mobile-back svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.lore-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0 !important;
    padding: 8px 13px;
    color: var(--accent);
    border: 1px solid rgba(0,210,255,0.18);
    border-radius: 999px;
    background: rgba(0,210,255,0.035);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.lore-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}

.portal-left-bottom {
    width: min(100%, 650px);
}

.lore-title {
    margin-bottom: 24px;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: clamp(56px, 6.4vw, 96px);
    font-weight: 800;
    line-height: .9;
    letter-spacing: -.065em;
}

.lore-title::after {
    content: '.';
    color: var(--accent);
}

.lore-desc {
    max-width: 540px;
    margin-bottom: 42px;
    color: var(--muted);
    font-size: clamp(14px, 1.2vw, 17px);
    font-weight: 500;
    line-height: 1.75;
}

.lore-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.l-stat-box {
    min-width: 0 !important;
    padding: 17px 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(24,24,31,.62), rgba(10,10,15,.72));
}

.l-stat-box:nth-child(3) {
    grid-column: 1 / -1;
}

.stat-feature-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-feature-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    color: var(--accent);
    border: 1px solid rgba(0,210,255,.12);
    border-radius: 10px;
    background: rgba(0,210,255,.045);
}

.stat-feature-icon svg {
    width: 19px;
    height: 19px;
    fill: currentColor;
}

.stat-feature-label {
    margin-bottom: 4px;
}

.stat-feature-text {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
}

.l-val {
    margin-bottom: 4px;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 800;
}

.l-lbl {
    color: var(--muted-soft);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.portal-left-footer {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 20px !important;
    margin-top: 36px !important;
    padding-top: 22px !important;
    border-top: 1px solid var(--border) !important;
}

.portal-left-footer a:hover {
    color: var(--accent) !important;
}

.footer-copy {
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    font-size: 10px;
    font-weight: 600;
}

.footer-links a {
    color: var(--muted);
    text-decoration: none;
    transition: color .2s ease;
}

/* Right: content-sized forms, no fixed square */
.portal-right {
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(72px, 10vh, 116px) clamp(32px, 7vw, 104px);
    background: rgba(4,4,7,.34);
}

.forms-wrapper {
    position: relative;
    width: min(100%, 460px);
    margin: auto 0;
}

.forms-wrapper::before {
    content: 'FANTASYRP / ACCOUNT';
    display: block;
    margin-bottom: 38px;
    color: var(--muted-soft);
    font-family: monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .16em;
}

.forms-wrapper::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 0;
    width: 42px;
    height: 1px;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}

.mobile-back {
    display: none;
}

.form-layer {
    position: static;
    width: 100%;
    height: auto;
    display: none;
    flex-direction: column;
    justify-content: flex-start;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
}

.form-layer.active {
    display: flex;
    animation: form-enter .32s ease both;
}

@keyframes form-enter {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.anim-item,
.form-layer.active .anim-item {
    opacity: 1;
    transform: none;
    transition: none;
}

.brand-form::before {
    content: 'ЭТЕРНИЯ · ЕДИНЫЙ ПРОФИЛЬ';
    display: block;
    margin-bottom: 11px;
    color: var(--accent);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .16em;
}

.brand-form h2 {
    margin-bottom: 36px;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: clamp(34px, 3.5vw, 46px);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.04em;
}

.center-text {
    margin: -18px 0 30px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.65;
}

.center-text-compact {
    margin-bottom: 20px;
}

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

.input-group-compact {
    margin-bottom: 12px;
}

.input-relative {
    position: relative;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.input-group input {
    width: 100%;
    min-height: 56px;
    padding: 15px 18px;
    color: #fff !important;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--field);
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.input-group input::placeholder {
    color: rgba(255,255,255,.24);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255,255,255,.05);
    box-shadow: 0 0 0 4px rgba(0,210,255,.065);
}

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

.eye-toggle {
    position: absolute;
    top: 50%;
    right: 14px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--muted);
    border: 0;
    border-radius: 9px;
    background: transparent;
    cursor: pointer;
    transform: translateY(-50%);
}

.eye-toggle:hover {
    color: var(--accent);
    background: rgba(255,255,255,.04);
}

.eye-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.caps-warning {
    position: absolute;
    top: 50%;
    right: 52px;
    color: var(--warning);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%);
}

.caps-warning.visible {
    opacity: 1;
}

.remember-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin: 2px 0 24px;
}

.check-group {
    position: relative;
    display: inline-flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 24px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.remember-row .check-group {
    align-items: center;
    margin-bottom: 0;
}

/* The native checkbox remains functional but never appears twice. */
.check-group > input[type='checkbox'] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.check-box {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--field);
    transition: background .2s ease, border-color .2s ease;
}

.check-box svg {
    width: 12px;
    height: 12px;
    fill: #000;
    opacity: 0;
    transform: scale(.6);
    transition: opacity .2s ease, transform .2s ease;
}

.check-group.active .check-box,
.check-group:has(input:checked) .check-box {
    border-color: var(--accent);
    background: var(--accent);
}

.check-group.active .check-box svg,
.check-group:has(input:checked) .check-box svg {
    opacity: 1;
    transform: scale(1);
}

.check-group:focus-within .check-box {
    outline: 3px solid rgba(0,210,255,.25);
    outline-offset: 2px;
}

.check-label,
.text-link {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.55;
}

.text-link,
.form-footer a {
    cursor: pointer;
    transition: color .2s ease;
}

.text-link:hover,
.form-footer a:hover {
    color: #fff;
}

.form-link-muted {
    color: var(--muted) !important;
}

.check-label a,
.form-footer a {
    color: var(--accent);
    text-decoration: none;
}

.turnstile-wrapper {
    min-height: 65px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 2px 0 22px;
    overflow: hidden;
}

.btn-primary {
    position: relative;
    width: 100%;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 20px;
    color: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--field);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform .2s ease, background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.btn-primary.accent {
    color: #000;
    border-color: var(--accent);
    background: var(--accent);
}

.btn-primary:hover {
    color: #000;
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 12px 32px var(--accent-glow);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    opacity: .65;
    cursor: wait;
    transform: none;
}

.btn-primary.is-loading::after {
    content: '';
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

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

.btn-secondary {
    margin-top: 10px;
    color: var(--muted);
    border-color: transparent;
    background: transparent;
}

.btn-secondary:hover {
    color: #fff;
    border-color: var(--border);
    background: rgba(255,255,255,.035);
    box-shadow: none;
    transform: none;
}

.form-footer {
    margin-top: 26px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.code-inputs {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 28px;
}

.code-inputs input {
    width: 100%;
    min-width: 0;
    height: 58px;
    padding: 0;
    color: #fff !important;
    border: 1px solid var(--border);
    border-bottom: 2px solid rgba(0,210,255,.65);
    border-radius: 10px;
    background: var(--field) !important;
    font-family: 'Outfit', sans-serif;
    font-size: 23px;
    font-weight: 800;
    text-align: center;
}

.code-inputs input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0,210,255,.065);
}

.pass-strength {
    width: 100%;
    height: 3px;
    display: none;
    margin: -8px 0 20px;
    overflow: hidden;
    border-radius: 3px;
    background: rgba(255,255,255,.06);
}

.pass-strength-fill {
    width: 0;
    height: 100%;
    transition: width .25s ease;
}

#toast-box {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000000;
    width: min(360px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.magic-msg {
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px 17px;
    color: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    background: rgba(10,10,15,.96);
    box-shadow: 0 20px 50px rgba(0,0,0,.65);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.55;
    animation: toast-in .35s ease both;
}

.magic-msg svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: currentColor;
}

.magic-msg.error { border-left-color: var(--error); }
.magic-msg.error svg { color: var(--error); }
.magic-msg.success { border-left-color: var(--success); }
.magic-msg.success svg { color: var(--success); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUpToast {
    to { opacity: 0; transform: translateY(-8px); }
}

@media (max-width: 1050px) {
    .portal-layout {
        display: block;
    }

    .portal-left {
        display: none;
    }

    .portal-right {
        min-height: 100dvh;
        padding: 30px clamp(20px, 7vw, 64px) 56px;
        background:
            radial-gradient(circle at 82% 5%, rgba(0,210,255,.075), transparent 28%),
            transparent;
    }

    .forms-wrapper {
        width: min(100%, 480px);
        margin: 0 auto;
    }

    .mobile-back {
        display: inline-flex;
        margin-bottom: 54px;
    }
}

@media (max-width: 520px) {
    .portal-right {
        padding: calc(22px + env(safe-area-inset-top)) 17px calc(36px + env(safe-area-inset-bottom));
    }

    .forms-wrapper::before {
        margin-bottom: 30px;
    }

    .mobile-back {
        margin-bottom: 42px;
    }

    .brand-form h2 {
        margin-bottom: 30px;
        font-size: 34px;
    }

    .remember-row {
        align-items: flex-start;
        gap: 14px;
    }

    .check-label,
    .text-link {
        font-size: 11px;
    }

    .turnstile-wrapper {
        justify-content: center;
        margin-left: -8px;
        margin-right: -8px;
    }

    .code-inputs {
        gap: 5px;
    }

    .code-inputs input {
        height: 54px;
        font-size: 20px;
    }

    #toast-box {
        top: calc(14px + env(safe-area-inset-top));
        right: 16px;
        left: 16px;
        width: auto;
    }
}

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