html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none;
}

html {
    height: 100vh;
    height: 100svh;
    height: 100dvh;
}

body {
    box-sizing: border-box;
    display: grid;
    place-items: center;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    padding:
        env(safe-area-inset-top, 0px)
        env(safe-area-inset-right, 0px)
        env(safe-area-inset-bottom, 0px)
        env(safe-area-inset-left, 0px);
    background-color: #87ceeb;
    touch-action: none;
}

body.auth-open {
    background-color: #071426;
}

canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    background-color: #87ceeb;
    box-shadow:
        inset 0 0 0 4px black,
        0 0 20px rgba(0, 0, 0, 0.4);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body.auth-open canvas {
    visibility: hidden;
}

#auth-screen {
    position: fixed;
    z-index: 2;
    inset: 0 auto auto 0;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    padding:
        max(16px, env(safe-area-inset-top, 0px))
        max(16px, env(safe-area-inset-right, 0px))
        max(16px, env(safe-area-inset-bottom, 0px))
        max(16px, env(safe-area-inset-left, 0px));
    background:
        radial-gradient(ellipse at 50% 20%, rgba(55, 137, 218, 0.2), transparent 65%),
        linear-gradient(145deg, #071426, #102e52 52%, #0a1b32);
    touch-action: pan-y;
}

#auth-screen[hidden],
#auth-online-id-field[hidden] {
    display: none;
}

.auth-panel {
    box-sizing: border-box;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 16px;
    width: min(100%, 440px);
    margin: auto 0;
    padding: clamp(20px, 5vw, 32px);
    border: 1px solid rgba(122, 184, 244, 0.65);
    border-radius: 24px;
    background: linear-gradient(160deg, #142f52, #0d2340 54%, #09182d);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), 0 0 24px rgba(50, 146, 255, 0.22);
    color: #f6faff;
    font-family: Arial, sans-serif;
}

.auth-panel[hidden] {
    display: none;
}

.auth-panel h1 {
    margin: 0;
    color: #f6faff;
    font-size: clamp(26px, 7vw, 36px);
    font-weight: 900;
    line-height: 1.15;
    text-align: center;
    text-shadow: 0 0 16px rgba(91, 176, 255, 0.7);
    overflow-wrap: anywhere;
}

.auth-subtitle {
    margin: -8px 0 0;
    color: #ffd66b;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-align: center;
}

.auth-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
}

.auth-field > span {
    color: #dcebfa;
    font-size: 15px;
    font-weight: 600;
}

.auth-field input {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 50px;
    padding: 12px 14px;
    border: 1px solid rgba(105, 153, 196, 0.65);
    border-radius: 12px;
    outline: none;
    background: linear-gradient(180deg, #0b223b, #081a2f);
    color: white;
    font: 16px Arial, sans-serif;
}

.auth-field input::placeholder {
    color: #91a9c0;
    opacity: 1;
}

.auth-field input:focus {
    border-color: #65c2ff;
    box-shadow: 0 0 0 3px rgba(71, 177, 255, 0.2);
}

.auth-field small {
    color: #d9f4ff;
    font-size: 13px;
}

.auth-password-control {
    position: relative;
    min-width: 0;
}

.auth-password-control input {
    padding-right: 82px;
}

.auth-password-toggle {
    position: absolute;
    top: 50%;
    right: 7px;
    min-width: 64px;
    min-height: 36px;
    transform: translateY(-50%);
    border: 1px solid rgba(121, 185, 238, 0.42);
    border-radius: 9px;
    background: #173a5a;
    color: white;
    font-weight: 700;
    touch-action: manipulation;
}

.auth-message {
    margin: 0;
    color: #ffd700;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    overflow-wrap: anywhere;
}

.auth-message-error {
    color: #ff9b9b;
}

.auth-message-success {
    color: #9be7b1;
}

.auth-verification-copy,
.auth-verification-email {
    margin: 0;
    color: #dcebfa;
    font-size: 15px;
    line-height: 1.5;
    text-align: center;
    overflow-wrap: anywhere;
}

.auth-verification-email strong {
    color: #ffd66b;
    overflow-wrap: anywhere;
}

.auth-loading {
    margin: 0;
    color: #ffd66b;
    font-size: 14px;
    text-align: center;
}

.auth-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    border: 2px solid rgba(255, 214, 107, 0.35);
    border-top-color: #ffd66b;
    border-radius: 50%;
    vertical-align: -2px;
    animation: auth-spin 0.8s linear infinite;
}

@keyframes auth-spin {
    to {
        transform: rotate(360deg);
    }
}

.auth-button {
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border: 1px solid rgba(121, 185, 238, 0.48);
    border-radius: 14px;
    background: linear-gradient(180deg, #153d65, #102b49);
    color: #f6faff;
    font: 700 15px Arial, sans-serif;
    touch-action: manipulation;
}

.auth-google-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-google-button[hidden] {
    display: none;
}

.auth-google-button svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.auth-primary {
    border-color: #65c2ff;
    background: linear-gradient(180deg, #328ee6, #1766b3);
}

.auth-button:disabled {
    opacity: 0.6;
}