/* ============================================================
   登录界面 — DESIGN IN MOTION
   浅色编辑风 + 卡片入场动效；不影响登录/注册逻辑
   ============================================================ */

body:has(.auth-container:not(.hidden)) #dynamicBgCanvas,
body:has(.auth-container:not(.hidden)) .game-container,
body:has(.auth-container:not(.hidden)) .game-restore-btn {
    display: none !important;
}

.auth-container {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 0 4vw;
    overflow: hidden;
    background:
        radial-gradient(circle at 16% 10%, #ebeaf0 0%, #d9d8df 42%, #cecdd5 72%, #c8c7cf 100%);
    color: #1a1a1f;
    font-family: "Inter", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

.auth-container * { box-sizing: border-box; }

/* ---------- 背景舞台 ---------- */
.login-stage {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.login-top {
    position: absolute;
    top: 26px;
    left: 4vw;
    right: 4vw;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    height: auto;
    background: none;
    border: 0;
    box-shadow: none;
    pointer-events: none;
    animation: loginTopIn 0.8s cubic-bezier(0.16, 0.84, 0.24, 1) 0.1s both;
}

@keyframes loginTopIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-brand {
    color: #1a1a1f;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.06em;
}

.login-top-right {
    display: flex;
    align-items: center;
    gap: 16px;
    pointer-events: none;
}

.login-top-note {
    color: #5c5c66;
    font-size: 9px;
    letter-spacing: 0.16em;
}

.login-edit-btn {
    pointer-events: auto;
    padding: 8px 14px;
    border: 1px solid rgba(20, 20, 25, 0.28);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.35);
    color: #1a1a1f;
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.login-edit-btn:hover {
    background: #1a1a1f;
    color: #fff;
}

.login-headline {
    position: absolute;
    left: 4vw;
    top: 12.5vh;
    z-index: 2;
    color: #1a1a1f;
    font-family: "Helvetica Neue", "Arial Black", Arial, sans-serif;
    font-size: clamp(54px, 6.6vw, 104px);
    font-weight: 500;
    line-height: 0.8;
    letter-spacing: -0.075em;
    text-transform: uppercase;
}

.login-headline span { display: block; }

.login-headline .line1 {
    animation: loginHeadline 0.95s cubic-bezier(0.16, 0.84, 0.24, 1) 0.1s both;
}

.login-headline .line2 {
    margin-left: clamp(24px, 5vw, 76px);
    color: transparent;
    -webkit-text-stroke: 1px #1a1a1f;
    animation: loginHeadline 0.95s cubic-bezier(0.16, 0.84, 0.24, 1) 0.2s both;
}

@keyframes loginHeadline {
    0% {
        opacity: 0;
        clip-path: inset(0 100% 0 0);
        transform: translateX(-26px);
    }
    100% {
        opacity: 1;
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
    }
}

/* ---------- 卡片网格 ---------- */
.login-cards {
    position: absolute;
    top: 9.5%;
    right: 3.5%;
    bottom: 8%;
    left: 45%;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 1.15vw;
    transform: rotate(-2deg) translate3d(var(--px, 0px), var(--py, 0px), 0);
    transform-origin: 50% 50%;
    transition: transform 0.35s cubic-bezier(0.16, 0.84, 0.24, 1);
}

.login-card {
    position: relative;
    min-width: 0;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 5px;
    background: #f4f4f4;
    box-shadow: 0 18px 40px rgba(35, 35, 45, 0.16);
    transform: rotate(var(--rot, 0deg));
    will-change: transform;
}

.login-card:nth-child(1) { --rot: -4deg; }
.login-card:nth-child(2) { --rot: 2deg; }
.login-card:nth-child(3) { --rot: 3deg; }
.login-card:nth-child(4) { --rot: -2deg; }
.login-card:nth-child(5) { --rot: 4deg; }
.login-card:nth-child(6) { --rot: -3deg; }

.login-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    transition: transform 0.7s cubic-bezier(0.16, 0.84, 0.24, 1);
}

.login-card:hover img { transform: scale(1.03); }

.login-card-replace {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 3;
    padding: 7px 10px;
    border: 0;
    border-radius: 999px;
    background: #1a1a1f;
    color: #fff;
    font-size: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.login-foot {
    position: absolute;
    left: 4vw;
    right: 4vw;
    bottom: 22px;
    z-index: 2;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    color: #55555e;
    font-size: 9px;
    line-height: 1.55;
    letter-spacing: 0.02em;
    animation: loginFootIn 0.8s cubic-bezier(0.16, 0.84, 0.24, 1) 0.75s both;
}

@keyframes loginFootIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-foot span:first-child { max-width: 300px; }
.login-foot span:last-child { letter-spacing: 0.12em; white-space: nowrap; }

/* ---------- 登录表单 ---------- */
.auth-container .auth-box {
    position: absolute;
    left: 4vw;
    top: 36.5vh;
    z-index: 6;
    width: min(360px, 32vw);
    min-width: 320px;
    max-width: 390px;
    max-height: calc(100vh - 34px);
    overflow-y: auto;
    margin: 0;
    padding: 26px 28px 24px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 30px 80px rgba(28, 28, 38, 0.18);
    backdrop-filter: blur(24px) saturate(1.08);
    -webkit-backdrop-filter: blur(24px) saturate(1.08);
    animation: authPanelIn 0.85s cubic-bezier(0.16, 0.84, 0.24, 1) 0.35s both;
}

@keyframes authPanelIn {
    from { opacity: 0; transform: translateY(22px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-container .auth-header {
    margin: 0 0 20px;
    text-align: left;
}

.auth-container .auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 0 0 16px;
    border: 1px solid #1a1a1f;
    border-radius: 50%;
    color: #1a1a1f;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    animation: none;
}

/* 注册 / 找回密码时，左上角 A. 徽标换成返回登录箭头（尺寸位置与徽标完全一致，切换不跳版） */
.auth-container .auth-back {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 0 0 16px;
    padding: 0;
    border: 1px solid #1a1a1f;
    border-radius: 50%;
    background: transparent;
    color: #1a1a1f;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.22s ease, color 0.22s ease, transform 0.22s ease;
}

.auth-container .auth-back svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-container .auth-back:hover {
    background: #1a1a1f;
    color: #fff;
    transform: translateX(-2px);
}

.auth-container .auth-back:active {
    transform: translateX(-2px) scale(0.94);
}

.auth-container .auth-back:focus-visible {
    outline: 2px solid #1a1a1f;
    outline-offset: 3px;
}

.auth-container .auth-box.is-sub .auth-logo { display: none; }
.auth-container .auth-box.is-sub .auth-back { display: flex; }

.auth-container .auth-header h1 {
    margin: 0 0 6px;
    color: #17171c;
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.05em;
    line-height: 1;
    text-transform: uppercase;
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
    -webkit-text-fill-color: currentColor;
}

.auth-container .auth-header p {
    margin: 0;
    color: #5e5e68;
    font-size: 11px;
    line-height: 1.55;
}

.auth-container .auth-form { gap: 13px; }

.auth-container .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-container .form-group label {
    display: block;
    margin: 0;
    color: #4b4b55;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.auth-container .form-group input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid rgba(20, 20, 28, 0.14);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.58);
    color: #17171c;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.auth-container .form-group input:focus {
    border-color: #17171c;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(20, 20, 28, 0.06);
}

.auth-container .form-group input::placeholder { color: #92929c; }

.auth-container .auth-btn {
    width: 100%;
    margin-top: 5px;
    padding: 12px 14px;
    border: 0;
    border-radius: 10px;
    background: #17171c;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.auth-container .auth-btn:hover {
    background: #000;
    transform: translateY(-1px);
    box-shadow: none;
}

.auth-container .login-btn,
.auth-container .register-btn,
.auth-container .reset-btn { background: #17171c; }

.auth-container .forgot-link {
    margin-top: -3px;
    text-align: right;
}

.auth-container .forgot-link a,
.auth-container .auth-switch a {
    color: #1a1a1f;
    font-size: 10px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.auth-container .auth-switch {
    margin-top: 14px;
    color: #62626c;
    font-size: 10px;
    text-align: center;
}

.auth-container .auth-error {
    margin-top: 12px;
    padding: 9px 11px;
    border: 1px solid rgba(180, 40, 40, 0.22);
    border-radius: 8px;
    background: rgba(220, 60, 60, 0.08);
    color: #a52c2c;
    font-size: 11px;
    text-align: center;
}

.auth-container .auth-error.show { display: block; }

.auth-container .forgot-info {
    margin-bottom: 16px;
    text-align: left;
}

.auth-container .forgot-info h3 {
    margin: 0 0 4px;
    color: #17171c;
    font-size: 15px;
    font-weight: 600;
}

.auth-container .forgot-info p {
    margin: 0;
    color: #62626c;
    font-size: 10px;
    line-height: 1.5;
}

/* ---------- 图片与文字编辑 ---------- */
.auth-container [data-login-text] {
    white-space: pre-line;
}

.auth-container.login-editing [data-login-text] {
    outline: 1px dashed rgba(20, 20, 28, 0.35);
    outline-offset: 4px;
    cursor: text;
}

.auth-container.login-editing [data-login-text]:focus {
    outline: 2px solid #17171c;
    background: rgba(255, 255, 255, 0.42);
}

.auth-container.login-editing .login-brand,
.auth-container.login-editing .login-top-note,
.auth-container.login-editing .login-headline span,
.auth-container.login-editing .login-foot span {
    pointer-events: auto;
}

.auth-container.login-editing .login-card {
    outline: 1px dashed rgba(20, 20, 28, 0.5);
    outline-offset: 4px;
    cursor: pointer;
    pointer-events: auto;
}

.auth-container.login-editing .login-card-replace {
    opacity: 1;
    pointer-events: auto;
}

.auth-container.login-editing .login-card.is-drop {
    outline: 2px solid #17171c;
}

.login-editbar {
    position: fixed;
    left: 50%;
    bottom: 22px;
    z-index: 30;
    display: none;
    align-items: center;
    gap: 14px;
    padding: 8px 10px 8px 16px;
    border: 1px solid rgba(20, 20, 28, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 12px 34px rgba(28, 28, 38, 0.16);
    color: #5a5a64;
    font-size: 10px;
    letter-spacing: 0.04em;
    transform: translateX(-50%);
    backdrop-filter: blur(16px);
}

.auth-container.login-editing .login-editbar { display: flex; }

.login-reset {
    padding: 7px 11px;
    border: 1px solid rgba(20, 20, 28, 0.2);
    border-radius: 999px;
    background: transparent;
    color: #2a2a32;
    font-size: 9px;
    cursor: pointer;
}

.login-reset:hover {
    border-color: #a52c2c;
    color: #a52c2c;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
    .auth-container .auth-box {
        width: min(340px, 34vw);
        min-width: 300px;
        padding: 24px;
    }

    .login-cards { left: 47%; }
    .login-headline { font-size: clamp(50px, 6.4vw, 86px); }
}

@media (max-width: 900px) {
    .auth-container {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 80px 18px 32px;
        overflow-y: auto;
    }

    .login-stage { display: contents; }

    .login-top,
    .login-headline,
    .auth-container .auth-box,
    .login-cards,
    .login-foot {
        flex: 0 0 auto;
    }

    .login-top {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        order: 1;
        padding: 0 2px;
    }

    .login-brand { font-size: 19px; }
    .login-top-note { display: none; }
    .login-edit-btn { font-size: 8px; }

    .login-headline {
        position: relative;
        top: auto;
        left: auto;
        order: 2;
        margin: 22px 0 18px;
        font-size: clamp(52px, 15vw, 82px);
        z-index: 2;
    }

    .login-headline .line2 { margin-left: clamp(18px, 8vw, 52px); }

    .auth-container .auth-box {
        position: relative;
        top: auto;
        left: auto;
        order: 3;
        width: 100%;
        max-width: 420px;
        min-width: 0;
        margin: 0 auto 24px;
        max-height: none;
    }

    .login-cards {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        order: 4;
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: none;
        gap: 10px;
        transform: rotate(-1deg);
    }

    .login-card {
        aspect-ratio: 480 / 345;
    }

    .login-foot {
        position: relative;
        left: auto;
        right: auto;
        bottom: auto;
        order: 5;
        flex-direction: column;
        gap: 8px;
        margin: 22px 0 8px;
    }

    .login-foot span:first-child { max-width: 320px; }

    .login-editbar {
        bottom: 14px;
        width: calc(100% - 28px);
        justify-content: space-between;
    }
}

@media (max-width: 520px) {
    .auth-container { padding: 72px 14px 26px; }
    .login-headline { font-size: clamp(46px, 15vw, 68px); }
    .auth-container .auth-box { padding: 22px 20px 20px; border-radius: 18px; }
    .auth-container .auth-header h1 { font-size: 26px; }
    .login-cards { gap: 8px; }
    .login-foot { font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .login-headline .line1,
    .login-headline .line2,
    .auth-container .auth-box { animation: none; }
}
