:root {
    /* Default Theme (Purple/Indigo - Fallback) */
    --theme-glow: rgba(138, 99, 210, 0.15);
    --theme-border: rgba(167, 139, 250, 0.3);
    --theme-accent: #A78BFA;
    --theme-accent-hover: #9178e8;
    --theme-text-gradient: linear-gradient(135deg, #A78BFA 0%, #C084FC 100%);
    --spotlight-color: rgba(138, 99, 210, 0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: #050505;
    /* Deep black for better contrast */
    color: #FFFFFF;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow: hidden;
}

/* Spotlight Glow */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, var(--spotlight-color) 0%, transparent 45%);
    pointer-events: none;
    z-index: 0;
    opacity: 0.8;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

.auth-container {
    width: 100%;
    max-width: 480px;
    padding: 24px;
    position: relative;
    z-index: 2;
}

.login-box {
    background: rgba(10, 10, 10, 0.6);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 64px 48px;
    position: relative;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.login-box::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(180deg,
            var(--theme-border) 0%,
            transparent 100%);
    border-radius: inherit;
    padding: 1px;
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0.5;
}

/* Secondary faint inner glow */
.login-box::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% -20%,
            var(--theme-glow) 0%,
            transparent 70%);
    pointer-events: none;
    opacity: 0.4;
}

.logo-section {
    text-align: center;
    margin-bottom: 48px;
}

.logo-section h1 {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 8px;
    background: #FFFFFF;
    /* Clean white text usually looks more premium than gradients for headers like this */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background: var(--theme-text-gradient, #FFFFFF);
}

.logo-section p {
    font-size: 16px;
    color: #FFFFFF;
    opacity: 0.7;
    font-weight: 400;
}

.login-form {
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #FFFFFF;
    margin-bottom: 16px;
    text-align: center;
    letter-spacing: 0.5px;
}

.key-input-container {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.key-digit {
    width: 58px;
    height: 68px;
    background: linear-gradient(135deg,
            rgba(20, 20, 30, 0.5) 0%,
            rgba(16, 16, 24, 0.6) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    font-size: 30px;
    font-weight: 700;
    color: #FFFFFF;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.key-digit:focus {
    border-color: var(--theme-accent);
    box-shadow:
        0 0 0 4px var(--theme-glow),
        0 8px 24px var(--theme-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transform: scale(1.08);
    background: linear-gradient(135deg,
            rgba(30, 30, 40, 0.7) 0%,
            rgba(24, 24, 34, 0.8) 100%);
}

.key-digit::-webkit-outer-spin-button,
.key-digit::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.error-message {
    min-height: 24px;
    font-size: 14px;
    color: #FF3B30;
    text-align: center;
    margin-top: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.error-message.show {
    opacity: 1;
}

.login-button {
    width: 100%;
    height: 60px;
    background: var(--theme-accent);
    /* Solid or gradient via var if complex */
    color: var(--theme-btn-text, #FFFFFF);
    /* Default to white for white buttons */
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 36px;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 12px 32px var(--theme-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.12);
}

.login-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.25) 0%,
            transparent 50%);
    opacity: 0.6;
}

.login-button::after {
    content: '';
    position: absolute;
    inset: -100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.3),
            transparent);
    transform: translateX(-100%) rotate(45deg);
    transition: transform 0.6s ease;
}

.login-button:hover::after {
    transform: translateX(100%) rotate(45deg);
}

.login-button:hover {
    transform: translateY(-3px);
    box-shadow:
        0 16px 48px var(--theme-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 60px var(--theme-glow);
    filter: brightness(1.1);
}

.login-button:active {
    transform: translateY(-1px);
}

.login-button .arrow-icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-button:hover .arrow-icon {
    transform: translateX(4px);
}

.login-footer {
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid #FFFFFF;
}

.login-footer p {
    font-size: 14px;
    color: #FFFFFF;
    opacity: 0.6;
}

/* Loading state */
.login-button.loading {
    pointer-events: none;
    opacity: 0.7;
}

.login-button.loading span {
    opacity: 0;
}

/* Onboarding styles */
.onboarding-container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
}

.onboarding-box {
    background: linear-gradient(135deg,
            rgba(20, 20, 30, 0.7) 0%,
            rgba(16, 16, 24, 0.8) 100%);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 28px;
    padding: 64px 48px;
    box-shadow:
        0 16px 64px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.03);
    position: relative;
    overflow: hidden;
}

.onboarding-box::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(135deg,
            rgba(184, 148, 244, 0.3) 0%,
            rgba(253, 230, 138, 0.2) 50%,
            rgba(99, 102, 241, 0.25) 100%);
    border-radius: inherit;
    padding: 2px;
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0.5;
}

.onboarding-box::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%,
            rgba(167, 139, 250, 0.08) 0%,
            transparent 50%);
    pointer-events: none;
}

.onboarding-header {
    text-align: center;
    margin-bottom: 48px;
}

.onboarding-header h1 {
    font-size: 36px;
    font-weight: 700;
    color: #FFFFFF;
    margin-bottom: 12px;
}

.onboarding-header p {
    font-size: 16px;
    color: #FFFFFF;
    opacity: 0.7;
}

.progress-bar {
    height: 5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    margin-bottom: 52px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.progress-fill {
    height: 100%;
    background: var(--theme-accent);
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 0 12px var(--theme-glow),
        0 0 24px var(--theme-glow);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.3),
            transparent 50%);
}

.onboarding-step {
    display: none;
}

.onboarding-step.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-title {
    font-size: 24px;
    font-weight: 600;
    color: #FFFFFF;
    margin-bottom: 24px;
}

.input-group {
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #FFFFFF;
    margin-bottom: 8px;
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 16px 18px;
    background: linear-gradient(135deg,
            rgba(20, 20, 30, 0.5) 0%,
            rgba(16, 16, 24, 0.6) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    font-size: 15px;
    color: #FFFFFF;
    font-family: inherit;
    transition: all 0.4s ease;
    outline: none;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.input-group input:focus,
.input-group textarea:focus {
    border-color: var(--theme-accent);
    box-shadow:
        0 0 0 4px var(--theme-glow),
        0 4px 16px var(--theme-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg,
            rgba(30, 30, 40, 0.7) 0%,
            rgba(24, 24, 34, 0.8) 100%);
}

.input-group textarea {
    resize: vertical;
    min-height: 100px;
}

.input-hint {
    font-size: 12px;
    color: #FFFFFF;
    opacity: 0.5;
    margin-top: 8px;
}

.button-group {
    display: flex;
    gap: 16px;
    margin-top: 32px;
}

.btn {
    flex: 1;
    height: 56px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: var(--theme-accent);
    color: var(--theme-btn-text, #FFFFFF);
    border: none;
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 8px 16px var(--theme-glow);
}

.btn-secondary {
    background: transparent;
    color: var(--theme-accent);
    border: 1px solid var(--theme-border);
}

.btn-secondary:hover {
    background: var(--theme-glow);
    border-color: var(--theme-accent);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.success-message {
    text-align: center;
    padding: 60px 0;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    border: 3px solid var(--theme-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-icon svg {
    width: 40px;
    height: 40px;
    color: var(--theme-accent);
}

.success-message h2 {
    font-size: 28px;
    font-weight: 600;
    color: #FFFFFF;
    margin-bottom: 12px;
}

.success-message p {
    font-size: 16px;
    color: #FFFFFF;
    opacity: 0.7;
    margin-bottom: 32px;
}

/* Responsive */
@media (max-width: 768px) {

    .login-box,
    .onboarding-box {
        padding: 40px 24px;
    }

    .logo-section h1,
    .onboarding-header h1 {
        font-size: 32px;
    }

    .key-digit {
        width: 48px;
        height: 56px;
        font-size: 24px;
    }

    .key-input-container {
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .key-digit {
        width: 40px;
        height: 48px;
        font-size: 20px;
    }

    .key-input-container {
        gap: 6px;
    }

    .button-group {
        flex-direction: column;
    }
}