/* Invite Popup Styles */
.invite-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(20px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.invite-popup {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 48px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: slideUp 0.4s ease;
}

.invite-popup::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--gradient-1);
    border-radius: 24px;
    z-index: -1;
    opacity: 0.3;
}

.invite-popup-content {
    text-align: center;
}

.invite-header {
    margin-bottom: 40px;
}

.invite-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
    animation: pulse 2s ease-in-out infinite;
}

.invite-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #a0a0b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.invite-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

.invite-form {
    margin-bottom: 32px;
}

.input-group {
    position: relative;
    margin-bottom: 24px;
}

.input-label {
    display: block;
    text-align: left;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.invite-input {
    width: 100%;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.invite-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}

.invite-input::placeholder {
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: 0;
}

.error-message {
    display: none;
    color: var(--accent-color);
    font-size: 0.85rem;
    margin-top: 8px;
    text-align: left;
    animation: shake 0.5s ease;
}

.error-message.show {
    display: block;
}

.invite-submit-btn {
    width: 100%;
    background: var(--gradient-1);
    color: var(--dark-bg);
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.invite-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 212, 255, 0.4);
}

.invite-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.invite-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
}

.footer-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.footer-link:hover {
    color: var(--secondary-color);
}

/* Main content when hidden */
.main-content {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.main-content.unlocked {
    opacity: 1;
    pointer-events: auto;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .invite-popup {
        padding: 32px 24px;
        margin: 20px;
    }
    
    .invite-title {
        font-size: 1.5rem;
    }
    
    .invite-icon {
        font-size: 3rem;
    }
}

@media (max-width: 480px) {
    .invite-popup {
        padding: 24px 20px;
        margin: 10px;
    }
    
    .invite-title {
        font-size: 1.25rem;
    }
    
    .invite-subtitle {
        font-size: 0.9rem;
    }
}
invite-popup.js (New File)
// Invite Code Validation System
class InviteCodeSystem {
    constructor() {
        this.validCode = 'R752K';
        this.maxAttempts = 3;
        this.currentAttempts = 0;
        this.isLocked = false;
        this.lockoutTime = 300000; // 5 minutes in milliseconds
        this.init();
    }

    init() {
        this.checkStoredAccess();
        this.setupEventListeners();
        this.showPopup();
    }

    checkStoredAccess() {
        const storedAccess = localStorage.getItem('unclaimedSolAccess');
        const lockoutEnd = localStorage.getItem('lockoutEnd');
        
        if (lockoutEnd && Date.now() < parseInt(lockoutEnd)) {
            this.handleLockout();
            return;
        }
        
        if (storedAccess === 'granted') {
            this.grantAccess();
        }
    }

    setupEventListeners() {
        const form = document.getElementById('inviteForm');
        const input = document.getElementById('inviteCode');
        
        if (form) {
            form.addEventListener('submit', (e) => this.handleSubmit(e));
        }
        
        if (input) {
            input.addEventListener('input', (e) => this.handleInput(e));
            input.addEventListener('paste', (e) => this.handlePaste(e));
        }
        
        // Prevent access without valid code
        document.addEventListener('keydown', (e) => {
            if (e.key === 'Escape' && !this.isUnlocked) {
                e.preventDefault();
                return false;
            }
        });
        
        // Disable right-click on popup
        document.addEventListener('contextmenu', (e) => {
            if (!this.isUnlocked) {
                e.preventDefault();
                return false;
            }
        });
    }

    handleInput(e) {
        const value = e.target.value;
        // Auto-format to uppercase
        e.target.value = value.toUpperCase();
        
        // Clear error message when user starts typing
        this.hideError();
    }

    handlePaste(e) {
        e.preventDefault();
        const pastedData = (e.clipboardData || window.clipboardData).getData('text');
        e.target.value = pastedData.toUpperCase();
        this.hideError();
    }

    async handleSubmit(e) {
        e.preventDefault();
        
        if (this.isLocked) {
            this.showLockoutMessage();
            return;
        }
        
        const input = document.getElementById('inviteCode');
        const code = input.value.trim().toUpperCase();
        
        if (!code) {
            this.showError('Please enter an invite code.');
            return;
        }
        
        // Disable submit button during validation
        const submitBtn = e.target.querySelector('.invite-submit-btn');
        const originalText = submitBtn.innerHTML;
        submitBtn.disabled = true;
        submitBtn.innerHTML = '<span class="loading-spinner">⟳</span> Validating...';
        
        // Simulate validation delay
        await this.delay(1000);
        
        if (code === this.validCode) {
            this.handleSuccess();
        } else {
            this.handleFailure();
        }
        
        submitBtn.disabled = false;
        submitBtn.innerHTML = originalText;
    }

    handleSuccess() {
        // Store access grant
        localStorage.setItem('unclaimedSolAccess', 'granted');
        localStorage.setItem('accessTime', Date.now().toString());
        
        // Clear any lockout data
        localStorage.removeItem('lockoutEnd');
        localStorage.removeItem('attempts');
        
        // Show success animation
        this.showSuccessAnimation();
        
        // Grant access after delay
        setTimeout(() => {
            this.grantAccess();
        }, 1500);
    }

    handleFailure() {
        this.currentAttempts++;
        localStorage.setItem('attempts', this.currentAttempts.toString());
        
        if (this.currentAttempts >= this.maxAttempts) {
            this.handleLockout();
        } else {
            const remaining = this.maxAttempts - this.currentAttempts;
            this.showError(`Invalid code. ${remaining} attempts remaining.`);
            
            // Clear input
            document.getElementById('inviteCode').value = '';
            
            // Shake animation
            const popup = document.querySelector('.invite-popup');
            popup.style.animation = 'shake 0.5s ease';
            setTimeout(() => {
                popup.style.animation = '';
            }, 500);
        }
    }

    handleLockout() {
        this.isLocked = true;
        const lockoutEnd = Date.now() + this.lockoutTime;
        localStorage.setItem('lockoutEnd', lockoutEnd.toString());
        
        this.showLockoutMessage();
        
        // Start countdown
        this.startLockoutCountdown();
    }

    showLockoutMessage() {
        const lockoutEnd = localStorage.getItem('lockoutEnd');
        const remainingTime = lockoutEnd ? Math.ceil((parseInt(lockoutEnd) - Date.now()) / 60000) : 5;
        
        this.showError(`Too many failed attempts. Please try again in ${remainingTime} minutes.`);
        
        const input = document.getElementById('inviteCode');
        const submitBtn = document.querySelector('.invite-submit-btn');
        
        if (input) input.disabled = true;
        if (submitBtn) submitBtn.disabled = true;
    }

    startLockoutCountdown() {
        const checkLockout = () => {
            const lockoutEnd = localStorage.getItem('lockoutEnd');
            
            if (!lockoutEnd || Date.now() >= parseInt(lockoutEnd)) {
                this.isLocked = false;
                this.currentAttempts = 0;
                localStorage.removeItem('lockoutEnd');
                localStorage.removeItem('attempts');
                
                const input = document.getElementById('inviteCode');
                const submitBtn = document.querySelector('.invite-submit-btn');
                
                if (input) input.disabled = false;
                if (submitBtn) submitBtn.disabled = false;
                
                this.hideError();
                return;
            }
            
            // Update message every minute
            setTimeout(checkLockout, 60000);
        };
        
        checkLockout();
    }

    grantAccess() {
        this.isUnlocked = true;
        
        // Hide popup
        const popup = document.getElementById('invitePopup');
        popup.style.animation = 'fadeOut 0.3s ease';
        
        setTimeout(() => {
            popup.style.display = 'none';
        }, 300);
        
        // Show main content
        const mainContent = document.getElementById('mainContent');
        mainContent.style.display = 'block';
        
        setTimeout(() => {
            mainContent.classList.add('unlocked');
        }, 100);
        
        // Re-enable normal site functionality
        this.enableSiteFunctionality();
    }

    enableSiteFunctionality() {
        // Initialize the main app
        if (typeof UnclaimedSOLApp !== 'undefined') {
            new UnclaimedSOLApp();
        }
        
        // Enable scrolling
        document.body.style.overflow = '';
        
        // Enable keyboard shortcuts
        document.removeEventListener('keydown', this.blockKeyboard);
    }

    showPopup() {
        if (this.isUnlocked) return;
        
        // Prevent scrolling
        document.body.style.overflow = 'hidden';
        
        // Show popup
        const popup = document.getElementById('invitePopup');
        popup.style.display = 'flex';
    }

    showError(message) {
        const errorElement = document.getElementById('errorMessage');
        if (errorElement) {
            errorElement.textContent = message;
            errorElement.classList.add('show');
        }
    }

    hideError() {
        const errorElement = document.getElementById('errorMessage');
        if (errorElement) {
            errorElement.classList.remove('show');
        }
    }

    showSuccessAnimation() {
        const popup = document.querySelector('.invite-popup');
        const icon = document.querySelector('.invite-icon');
        
        // Change icon to success
        icon.textContent = '✅';
        icon.style.color = '#14F195';
        
        // Add success glow
        popup.style.boxShadow = '0 25px 50px rgba(20, 241, 149, 0.3)';
    }

    delay(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    // Security methods
    blockKeyboard(e) {
        // Block common shortcuts
        const blockedKeys = ['F12', 'Ctrl+Shift+I', 'Ctrl+Shift+J', 'Ctrl+U'];
        if (blockedKeys.includes(e.key) || 
            (e.ctrlKey && e.shiftKey && ['I', 'J', 'C'].includes(e.key)) ||
            (e.ctrlKey && e.key === 'U')) {
            e.preventDefault();
            return false;
        }
    }
}

// Add fade out animation
const style = document.createElement('style');
style.textContent = `
    @keyframes fadeOut {
        from {
            opacity: 1;
        }
        to {
            opacity: 0;
        }
    }
    
    .loading-spinner {
        animation: spin 1s linear infinite;
        display: inline-block;
    }
`;
document.head.appendChild(style);

// Initialize invite system when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
    new InviteCodeSystem();
});

// Prevent access via browser back button after lockout
window.addEventListener('pageshow', (event) => {
    if (event.persisted) {
        window.location.reload();
    }
});