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

/* 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;
}

/* 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);
    /* 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%);
}

#canvas-container::before,
#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;
    gap: 20px;
    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);
    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);
}

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

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

.forgot-header {
    margin-bottom: 1.2rem;
}

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

.tagline {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 0.42rem;
    letter-spacing: 0.38px;
    color: #dbe7ff;
}

.forgot-note {
    font-size: 0.8rem;
    opacity: 0.78;
    color: #c5d3f3;
}

.input-group,
.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

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

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

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

.input-field:focus,
.input-field:focus-visible,
.form-group input:focus,
.form-group input: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,
.password-wrapper input {
    width: 100%;
    padding-right: 68px;
}

.toggle-password {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: auto !important;
    max-width: 58px;
    min-height: 0 !important;
    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;
    box-shadow: none;
    -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: comprehensive responsive design for 480px screens */
@media (max-width: 480px) {
    /* Container sizing */
    .glass-card {
        padding: 0.8rem;
        border-radius: 1rem;
        max-width: 100vw;
    }

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


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

    /* Form elements */
    .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 {
        align-items: stretch;
    }

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

    .toggle-password {
        right: 8px;
        width: auto !important;
        max-width: 50px;
        min-width: 45px;
        min-height: 0 !important;
        height: 26px;
        padding: 0 6px;
        font-size: 0.62rem;
        align-items: center;
    }

    /* Buttons - 44px minimum touch target */
    .forgot-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;
    }

    /* Links and text */
    .auth-links,
    .forgot-footer {
        gap: 8px;
        font-size: 0.75rem;
    }

    .auth-links a,
    .forgot-footer a {
        padding: 0.4rem 0;
    }

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

    /* Prevent horizontal scrolling */
    body {
        overflow-x: hidden;
    }

    #canvas-container {
        overflow: hidden;
    }
}

.forgot-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;
}

.forgot-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.86rem;
}

.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,
.forgot-footer {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 0.95rem;
    font-size: 0.81rem;
    flex-wrap: wrap;
}

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

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

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

.auth-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 10px;
    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-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.footer-content p {
    margin: 0;
}

.footer-tagline {
    width: auto;
    border-top: none !important;
    padding-top: 0;
}

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

/* 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;
    }
}

.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;
}

.reset-container {
    display: none;
}

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

@media (max-width: 920px) {
    .app-wrapper {
        flex-direction: column;
        gap: 14px;
        padding-top: 28px;
        padding-bottom: 24px;
    }

    .forgot-panel {
        width: 100%;
        max-width: 500px;
        padding: 1.8rem 1.2rem;
        border-radius: 1.4rem;
    }
}

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

/* On small screens, avoid the fixed footer overlaying auth cards */
@media (max-width: 520px) {
    body {
        overflow-y: auto;
    }

    .app-wrapper {
        padding-bottom: 24px;
    }

    .auth-footer {
        position: static;
        bottom: auto;
        padding: 10px 14px;
        margin-top: 12px;
        z-index: 6;
        color: rgba(213, 224, 248, 0.8);
    }
}
