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

html {
    min-height: 100%;
    background: #03050b;
    overscroll-behavior-y: none;
}

/* Touch optimization: faster tap response */
a, button, [role="button"] {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

/* Prevent zoom on input focus for iOS */
.input-field, input, textarea, select {
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
}

/* Restore native controls for checkbox/radio so they stay visible */
input[type="checkbox"] {
    -webkit-appearance: checkbox;
    appearance: auto;
}

input[type="radio"] {
    -webkit-appearance: radio;
    appearance: auto;
}

/* Improved touch scrolling on mobile */
.scrollable, [data-scrollable] {
    overflow-x: auto;
}

body {
    font-family: Inter, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    overflow: hidden;
    color: #f4f7ff;
    background: radial-gradient(circle at 20% 30%, #0a0f1e, #03050b);
    background-color: #03050b;
    overscroll-behavior-y: none;
    /* Safe area support for notched devices (iPhone X+) */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#canvas-container {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 18% 22%, rgba(71, 219, 232, 0.18), transparent 38%),
        radial-gradient(circle at 82% 20%, rgba(255, 180, 89, 0.16), transparent 36%),
        radial-gradient(circle at 50% 88%, rgba(132, 157, 255, 0.12), transparent 32%),
        #03050b;
}

#canvas-container::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(2px);
}

#canvas-container::before {
    width: 320px;
    height: 320px;
    top: -80px;
    right: -60px;
    background: radial-gradient(circle, rgba(80, 229, 240, 0.24), rgba(80, 229, 240, 0));
}

#canvas-container::after {
    width: 260px;
    height: 260px;
    left: -70px;
    bottom: -90px;
    background: radial-gradient(circle, rgba(255, 176, 97, 0.24), rgba(255, 176, 97, 0));
}

.app-wrapper {
    position: relative;
    z-index: 10;
    width: 100vw;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.glass-card {
    background: rgba(15, 25, 45, 0.58);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-radius: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    will-change: box-shadow;
    box-shadow: 0 25px 45px rgba(0, 0, 0, 0.35), 0 0 0 0.5px rgba(255, 255, 255, 0.12) inset;
    transition: box-shadow 0.28s ease, border-color 0.28s ease;
}

.glass-card:hover {
    box-shadow: 0 35px 55px rgba(0, 0, 0, 0.45);
    border-color: rgba(255, 195, 106, 0.45);
}

.login-panel {
    width: 410px;
    max-width: 92vw;
    padding: 1.9rem 1.6rem;
    text-align: center;
}

.logo-icon {
    font-size: 2.4rem;
    line-height: 1;
    margin-bottom: 0.55rem;
    background: linear-gradient(135deg, #ffd878, #ffb35b);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.login-header {
    margin-bottom: 1.4rem;
}

.login-header h2 {
    font-weight: 700;
    font-size: 1.9rem;
    background: linear-gradient(120deg, #ffffff, #ffe0a7);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.35rem;
}

.tagline {
    font-size: 0.88rem;
    opacity: 0.9;
    margin-bottom: 0.45rem;
    letter-spacing: 0.4px;
    color: #dbe7ff;
}

.login-note {
    font-size: 0.83rem;
    opacity: 0.78;
    color: #c5d3f3;
}

.input-group {
    margin-bottom: 1.1rem;
    text-align: left;
}

.input-group label {
    font-size: 0.82rem;
    font-weight: 600;
    display: block;
    margin-bottom: 0.42rem;
    color: #deebff;
}

.input-field {
    width: 100%;
    background: rgba(20, 30, 55, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 1.1rem;
    padding: 0.85rem 1.05rem;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    font-weight: 500;
}

.input-field::placeholder {
    color: #9fb2d7;
}

.input-field:focus,
.input-field:focus-visible {
    outline: none !important;
    border-color: rgba(255, 255, 255, 0.38);
    box-shadow: none !important;
    background: rgba(30, 45, 75, 0.85);
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper .input-field {
    padding-right: 68px;
    width: 100%;
}

.toggle-password {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: 1px solid rgba(255, 215, 138, 0.42);
    background: rgba(255, 174, 84, 0.12);
    border-radius: 999px;
    min-width: 52px;
    height: 32px;
    padding: 0 8px;
    color: #ffd988;
    font-weight: 700;
    font-size: 0.70rem;
    cursor: pointer;
    z-index: 6;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    outline: none !important;
    box-shadow: none !important;
    appearance: none;
    -webkit-appearance: none;
}

.toggle-password:hover,
.toggle-password:focus,
.toggle-password:focus-visible,
.toggle-password:active {
    background: rgba(255, 174, 84, 0.22);
    outline: none !important;
    box-shadow: none !important;
}

/* Mobile: consistent password toggle sizing */
@media (max-width: 480px) {
    .password-wrapper {
        align-items: stretch;
    }

    .password-wrapper .input-field {
        padding-right: 62px;
    }

    .toggle-password {
        right: 4px;
        min-width: 48px;
        height: 100%;
        padding: 0 6px;
        font-size: 0.60rem;
        align-items: center;
    }
}

.captcha-wrap {
    margin: 0.55rem 0 0.85rem;
    display: none;
}

.login-btn,
.btn {
    width: 100%;
    background: linear-gradient(95deg, #f0a500, #ff7b2c);
    border: none;
    padding: 0.95rem;
    border-radius: 2rem;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    cursor: pointer;
    transition: filter 0.2s;
    margin-top: 0.35rem;
    letter-spacing: 0.04em;
}

.login-btn:hover,
.btn:hover {
    filter: brightness(1.06);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    transform: none !important;
}

.alert {
    padding: 12px 14px;
    margin-bottom: 12px;
    border-radius: 12px;
    display: none;
    font-weight: 600;
    border: 1px solid transparent;
    text-align: left;
    font-size: 0.88rem;
}

.alert-error {
    background: rgba(220, 53, 69, 0.16);
    color: #ffd5db;
    border-color: rgba(220, 53, 69, 0.35);
}

.alert-success {
    background: rgba(40, 167, 69, 0.16);
    color: #d6f5dd;
    border-color: rgba(40, 167, 69, 0.35);
}

.alert-info {
    background: rgba(23, 162, 184, 0.16);
    color: #d3f2f7;
    border-color: rgba(23, 162, 184, 0.35);
}

.auth-links {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 1rem;
    font-size: 0.82rem;
    flex-wrap: wrap;
}

.auth-links a {
    color: #ffd873;
    text-decoration: none;
    display: block;
}

.auth-links a:hover {
    color: #ffb86b;
    text-decoration: underline;
}

/* Style for Install App button when appended to auth-links */
.auth-links .btn,
.login-footer .btn {
    flex: 1 1 48%;
    padding: 0.7rem 1rem;
    margin-top: 0;
    font-size: 0.8rem;
}

.legal-note {
    margin-top: 1rem;
    font-size: 0.74rem;
    opacity: 0.67;
    color: #c7d3f1;
}

/* Ensure there's room for the fixed footer so the card doesn't sit too close */
.app-wrapper {
    padding-bottom: 72px; /* reserve space for fixed footer on small screens */
}

/* Desktop view: increase padding for larger screens */
@media (min-width: 769px) {
    .app-wrapper {
        padding-bottom: 100px;
    }
}
/* Desktop view: keep footer below the card instead of overlaying it */
@media (min-width: 769px) {
    .app-wrapper {
        padding-bottom: 24px;
    }
}

.auth-footer {
    position: static;
    text-align: center;
    font-size: 0.76rem;
    color: rgba(213, 224, 248, 0.65);
    z-index: 1000;
    padding: 0 14px;
    background: transparent !important;
    border-top: none !important;
    margin-top: 0 !important;
}

.footer-content {
    width: 100%;
    max-width: 100vw;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.footer-content p {
    margin: 0;
}

/* Separate legal block and tagline so they can be spaced independently */
.footer-legal p {
    margin: 0;
    padding: 2px 0 4px 0;
    font-weight: 600;
}

.footer-tagline p {
    margin: 0;
    padding: 0;
    opacity: 0.85;
    font-size: 0.72rem;
}

.app-badge {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 20;
    background: rgba(255, 193, 110, 0.12);
    border: 1px solid rgba(255, 193, 110, 0.4);
    color: #ffd988;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 0.74rem;
    font-weight: 700;
    display: none;
}

.shake {
    animation: shake 0.45s ease-in-out;
}

@keyframes shake {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.35); }
}

/* Stability hard-lock: disable non-essential container motion */
#canvas-container::before,
#canvas-container::after,
.login-panel {
    animation: none !important;
}

@media (max-width: 520px) {
    .login-panel {
        padding: 1.8rem 1.2rem;
        border-radius: 1.4rem;
    }
}

/* Mobile responsiveness: containers, fonts, touch targets */
@media (max-width: 480px) {
    .glass-card {
        padding: 0.8rem;
        border-radius: 1rem;
        max-width: 100vw;
    }

    .login-panel {
        width: 100%;
        max-width: 95vw;
        padding: 1.2rem 1rem;
        margin: auto;
    }

    .login-header h2 {
        font-size: 1.4rem;
        margin-bottom: 0.5rem;
    }

    .tagline {
        font-size: 0.8rem;
        margin-bottom: 1.2rem;
    }

    .input-group label {
        font-size: 0.85rem;
        margin-bottom: 0.3rem;
    }

    .input-field {
        padding: 0.7rem 0.8rem;
        font-size: 16px;
        border-radius: 0.6rem;
        width: 100%;
    }

    .password-wrapper .input-field {
        padding-right: 70px;
    }

    .toggle-password {
        min-width: 45px;
        height: 26px;
        font-size: 0.62rem;
        right: 8px;
    }

    .login-btn,
    .btn {
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        border-radius: 1.5rem;
    }

    .btn:disabled {
        min-height: 44px;
    }

    .auth-links {
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
        font-size: 0.75rem;
    }

    .auth-links a {
        display: block;
        padding: 0.5rem 0;
    }

    .legal-note {
        font-size: 0.65rem;
        line-height: 1.3;
        margin-top: 0.8rem;
    }

    .captcha-wrap {
        margin: 0.4rem 0 0.8rem;
        transform: scale(0.95);
        transform-origin: left top;
    }

    .alert {
        padding: 0.8rem;
        font-size: 0.8rem;
        border-radius: 0.6rem;
        margin-bottom: 0.8rem;
    }

    /* Ensure no horizontal scrolling */
    body {
        overflow-x: hidden;
        background-color: #03050b;
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }

    #canvas-container {
        overflow: hidden;
        position: absolute;
        min-height: 100%;
        height: 100%;
        background-color: #03050b;
    }

    .app-wrapper,
    .glass-card {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

/* On small screens, avoid the fixed footer overlaying auth cards */


@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
