<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Data Life Eyes Pro - Secure Access</title>
    <style>
        #auth-system {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
            background-size: 400% 400%;
            animation: gradientBG 15s ease infinite;
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        }

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

        .auth-container {
            width: 90%;
            max-width: 380px;
            background: rgba(255, 255, 255, 0.95);
            padding: 2.5rem;
            border-radius: 20px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
            backdrop-filter: blur(10px);
            animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
            position: relative;
            overflow: hidden;
        }

        .auth-container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(90deg, #ff4757, #5352ed, #20bf6b);
            animation: shimmer 2s linear infinite;
        }

        .auth-header {
            text-align: center;
            margin-bottom: 2.5rem;
        }

        .auth-logo-container {
            position: relative;
            height: 80px;
            margin-bottom: 1.5rem;
        }

        .auth-logo {
            font-size: 3.5rem;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            animation: logoFloat 3s ease-in-out infinite;
        }

        .auth-logo-shadow {
            width: 50px;
            height: 10px;
            background: rgba(0, 0, 0, 0.1);
            border-radius: 50%;
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            animation: shadowPulse 3s ease-in-out infinite;
        }

        .auth-title {
            color: #1a1a1a;
            font-size: 1.8rem;
            font-weight: 700;
            margin-bottom: 0.5rem;
            background: linear-gradient(45deg, #1a2a6c, #b21f1f);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .auth-subtitle {
            color: #666;
            font-size: 1rem;
            font-weight: 500;
            opacity: 0.8;
        }

        .auth-form {
            position: relative;
        }

        .input-container {
            position: relative;
            margin-bottom: 1.5rem;
        }

        .auth-input {
            width: 100%;
            padding: 1.2rem;
            border: 2px solid #e0e0e0;
            border-radius: 12px;
            font-size: 1.1rem;
            font-weight: 500;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            background: rgba(255, 255, 255, 0.9);
            letter-spacing: 0.2em;
            text-align: center;
        }

        .auth-input:focus {
            border-color: #1a2a6c;
            outline: none;
            box-shadow: 0 0 0 4px rgba(26, 42, 108, 0.15);
        }

        .auth-input::placeholder {
            color: #999;
            letter-spacing: normal;
        }

        .auth-hint {
            font-size: 0.9rem;
            color: #666;
            margin: 0.5rem 0;
            text-align: center;
            font-weight: 500;
        }

        .auth-error {
            color: #ff4757;
            font-size: 0.9rem;
            margin: 0.5rem 0;
            min-height: 1.2rem;
            text-align: center;
            font-weight: 500;
            transform: translateY(0);
            transition: all 0.3s ease;
        }

        .auth-error.shake {
            animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
        }

        .auth-button {
            width: 100%;
            padding: 1.2rem;
            border: none;
            border-radius: 12px;
            background: linear-gradient(45deg, #1a2a6c, #b21f1f);
            background-size: 200% 200%;
            color: white;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .auth-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(26, 42, 108, 0.2);
            animation: gradientMove 3s ease infinite;
        }

        .auth-button:active {
            transform: translateY(0);
        }

        .auth-button:disabled {
            opacity: 0.7;
            cursor: not-allowed;
        }

        .loader {
            display: none;
            width: 24px;
            height: 24px;
            border: 3px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: white;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            animation: spin 0.8s linear infinite;
        }

        .digit-display {
            display: flex;
            justify-content: center;
            gap: 8px;
            margin-bottom: 1rem;
        }

        .digit {
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: #e0e0e0;
            transition: all 0.3s ease;
        }

        .digit.filled {
            background: #1a2a6c;
            transform: scale(1.2);
        }

        @keyframes gradientBG {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        @keyframes slideUp {
            0% {
                opacity: 0;
                transform: translateY(30px);
            }
            100% {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes logoFloat {
            0%, 100% { transform: translateY(0) translateX(-50%); }
            50% { transform: translateY(-15px) translateX(-50%); }
        }

        @keyframes shadowPulse {
            0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.3; }
            50% { transform: translateX(-50%) scale(0.7); opacity: 0.1; }
        }

        @keyframes shake {
            10%, 90% { transform: translateX(-1px); }
            20%, 80% { transform: translateX(2px); }
            30%, 50%, 70% { transform: translateX(-4px); }
            40%, 60% { transform: translateX(4px); }
        }

        @keyframes shimmer {
            0% { background-position: -200% 0; }
            100% { background-position: 200% 0; }
        }

        @keyframes gradientMove {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        @media (max-width: 480px) {
            .auth-container {
                padding: 2rem;
                width: 95%;
            }

            .auth-title {
                font-size: 1.5rem;
            }

            .auth-input {
                font-size: 1rem;
                padding: 1rem;
            }
        }
    </style>
</head>
<body>
    <div id="auth-system">
        <div class="auth-container">
            <div class="auth-header">
                <div class="auth-logo-container">
                    <div class="auth-logo">🧠🤖</div>
                    <div class="auth-logo-shadow"></div>
                </div>
                <h1 class="auth-title">Type Pro</h1>
                <p class="auth-subtitle">Secure Authentication Required</p>
            </div>
            <form class="auth-form" onsubmit="return authenticateUser(event)">
                <div class="digit-display">
                    <div class="digit"></div>
                    <div class="digit"></div>
                    <div class="digit"></div>
                    <div class="digit"></div>
                    <div class="digit"></div>
                    <div class="digit"></div>
                </div>
                <div class="input-container">
                    <input 
                        type="password" 
                        class="auth-input" 
                        id="authCode"
                        placeholder="Enter Security Code"
                        maxlength="6"
                        pattern="[0-9]*"
                        inputmode="numeric"
                        autocomplete="off"
                        required
                    >
                </div>
                <div class="auth-hint">Please enter your 6-digit security code</div>
                <div class="auth-error" id="authError"></div>
                <button type="submit" class="auth-button" id="authButton">
                    <span class="button-text">Verify Access</span>
                    <span class="loader"></span>
                </button>
            </form>
        </div>
    </div>

    <script>
        function authenticateUser(event) {
            event.preventDefault();
            
            const input = document.getElementById('authCode');
            const error = document.getElementById('authError');
            const button = document.getElementById('authButton');
            const buttonText = button.querySelector('.button-text');
            const loader = button.querySelector('.loader');
            
            // Reset error
            error.textContent = '';
            
            // Validate input
            if (!/^\d{6}$/.test(input.value)) {
                showError('Please enter a valid 6-digit code');
                return false;
            }
            
            // Show loading state
            button.disabled = true;
            buttonText.style.opacity = '0';
            loader.style.display = 'block';
            
            // Authenticate with delay for UX
            setTimeout(() => {
                if (input.value === '590245') {
                    localStorage.setItem('authenticated', 'true');
                    
                    // Success animation
                    document.getElementById('auth-system').style.transition = 'opacity 0.5s ease';
                    document.getElementById('auth-system').style.opacity = '0';
                    
                    setTimeout(() => {
                        document.getElementById('auth-system').style.display = 'none';
                    }, 500);
                } else {
                    showError('Invalid security code');
                    button.disabled = false;
                    buttonText.style.opacity = '1';
                    loader.style.display = 'none';
                    input.value = '';
                    input.focus();
                    updateDigitDisplay('');
                }
            }, 1500);
            
            return false;
        }

        function showError(message) {
            const error = document.getElementById('authError');
            error.textContent = message;
            error.classList.add('shake');
            setTimeout(() => error.classList.remove('shake'), 500);
        }

        function updateDigitDisplay(value) {
            const digits = document.querySelectorAll('.digit');
            digits.forEach((digit, index) => {
                digit.classList.toggle('filled', index < value.length);
            });
        }

        // Input validation and digit display update
        document.getElementById('authCode').addEventListener('input', (e) => {
            const input = e.target;
            const error = document.getElementById('authError');
            
            if (input.value.length > 0 && !/^\d+$/.test(input.value)) {
                error.textContent = 'Numbers only';
                input.value = input.value.replace(/\D/g, '');
            } else {
                error.textContent = '';
            }
            
            updateDigitDisplay(input.value);
        });

        // Check if already authenticated
        if (localStorage.getItem('authenticated') === 'true') {
            document.getElementById('auth-system').style.display = 'none';
        }
    </script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Advanced Touch Typing Master</title>
    <style>
        :root {
            --primary-gradient: linear-gradient(135deg, #1e3c72, #2a5298);
            --secondary-gradient: linear-gradient(45deg, #2193b0, #6dd5ed);
            --text-color: #ffffff;
            --error-color: #ff4444;
            --success-color: #00C851;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', system-ui, sans-serif;
        }

        body {
            min-height: 100vh;
            background: var(--primary-gradient);
            color: var(--text-color);
            padding: 20px;
            overflow-x: hidden;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
        }

        .header {
            text-align: center;
            padding: 20px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            backdrop-filter: blur(10px);
            margin-bottom: 20px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .header h1 {
            font-size: 2.5em;
            margin-bottom: 10px;
            background: var(--secondary-gradient);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .stats-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }

        .stat-card {
            background: rgba(255, 255, 255, 0.1);
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            backdrop-filter: blur(5px);
            transition: transform 0.3s ease;
        }

        .stat-card:hover {
            transform: translateY(-5px);
        }

        .stat-value {
            font-size: 2em;
            font-weight: bold;
            margin: 10px 0;
        }

        .text-display {
            background: rgba(255, 255, 255, 0.1);
            padding: 25px;
            border-radius: 15px;
            font-size: 1.3em;
            line-height: 1.8;
            margin-bottom: 20px;
            min-height: 200px;
            white-space: pre-wrap;
            position: relative;
        }

        .text-display.focus-mode {
            background: rgba(0, 0, 0, 0.8);
        }

        .character {
            display: inline-block;
            position: relative;
            transition: all 0.2s ease;
        }

        .character.current {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 3px;
        }

        .character.correct {
            color: var(--success-color);
        }

        .character.incorrect {
            color: var(--error-color);
            text-decoration: underline wavy var(--error-color);
        }

        .input-area {
            width: 100%;
            padding: 20px;
            background: rgba(255, 255, 255, 0.15);
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 10px;
            color: var(--text-color);
            font-size: 1.2em;
            margin-bottom: 20px;
            transition: all 0.3s ease;
            resize: none;
        }

        .input-area:focus {
            outline: none;
            border-color: rgba(255, 255, 255, 0.4);
            background: rgba(255, 255, 255, 0.2);
        }

        .keyboard-container {
            perspective: 1000px;
            margin-top: 30px;
        }

        .keyboard {
            background: rgba(255, 255, 255, 0.1);
            padding: 20px;
            border-radius: 15px;
            display: grid;
            grid-template-columns: repeat(30, 1fr);
            gap: 5px;
            transform: rotateX(10deg);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }

        .key {
            aspect-ratio: 1;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.9em;
            transition: all 0.2s ease;
            cursor: default;
            user-select: none;
            position: relative;
            overflow: hidden;
        }

        .key::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0));
            border-radius: inherit;
        }

        .key.active {
            background: rgba(255, 255, 255, 0.8);
            color: #1e3c72;
            transform: scale(0.95) translateY(2px);
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
        }

        .finger-hint {
            position: absolute;
            bottom: -15px;
            font-size: 0.7em;
            color: rgba(255, 255, 255, 0.6);
        }

        .controls {
            display: flex;
            gap: 15px;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }

        .control-btn {
            padding: 10px 20px;
            background: rgba(255, 255, 255, 0.1);
            border: none;
            border-radius: 8px;
            color: var(--text-color);
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .control-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: translateY(-2px);
        }

        .modal {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.8);
            display: none;
            justify-content: center;
            align-items: center;
            backdrop-filter: blur(5px);
            z-index: 1000;
        }

        .modal.active {
            display: flex;
        }

        .modal-content {
            background: var(--primary-gradient);
            padding: 30px;
            border-radius: 15px;
            max-width: 500px;
            width: 90%;
            position: relative;
        }

        .close-modal {
            position: absolute;
            top: 15px;
            right: 15px;
            background: none;
            border: none;
            color: var(--text-color);
            font-size: 1.5em;
            cursor: pointer;
        }

        .achievement {
            background: rgba(255, 255, 255, 0.1);
            padding: 15px;
            border-radius: 10px;
            margin: 10px 0;
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .achievement-icon {
            font-size: 1.5em;
        }

        @media (max-width: 768px) {
            .stats-container {
                grid-template-columns: 1fr;
            }

            .keyboard {
                grid-template-columns: repeat(10, 1fr);
            }
        }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        .pulse {
            animation: pulse 0.5s ease;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>Advanced Touch Typing Master</h1>
            <p>Master the art of touch typing with real-time feedback and analytics</p>
        </div>

        <div class="controls">
            <button class="control-btn" id="start-btn">
                <span class="icon">▶</span> Start New Session
            </button>
            <button class="control-btn" id="pause-btn">
                <span class="icon">⏸</span> Pause
            </button>
            <button class="control-btn" id="focus-mode-btn">
                <span class="icon">👁</span> Focus Mode
            </button>
            <button class="control-btn" id="achievements-btn">
                <span class="icon">🏆</span> Achievements
            </button>
        </div>

        <div class="stats-container">
            <div class="stat-card">
                <h3>Words Per Minute</h3>
                <div class="stat-value" id="wpm">0</div>
            </div>
            <div class="stat-card">
                <h3>Accuracy</h3>
                <div class="stat-value" id="accuracy">100%</div>
            </div>
            <div class="stat-card">
                <h3>Time</h3>
                <div class="stat-value" id="timer">0:00</div>
            </div>
            <div class="stat-card">
                <h3>Level</h3>
                <div class="stat-value" id="level">1</div>
            </div>
        </div>

        <div class="text-display" id="text-display"></div>
        <textarea class="input-area" id="input-area" rows="3" 
                  placeholder="Start typing here..."></textarea>

        <div class="keyboard-container">
            <div class="keyboard" id="keyboard"></div>
        </div>
    </div>

    <div class="modal" id="achievements-modal">
        <div class="modal-content">
            <button class="close-modal" id="close-achievements">&times;</button>
            <h2>Your Achievements</h2>
            <div id="achievements-list"></div>
        </div>
    </div>

    <script>
        const API_KEY = 'AIzaSyCAfOKX7SVDpMJCuVvE-JrsGssvPknJZg8';
        
        class TypingTrainer {
            constructor() {
                this.currentText = '';
                this.timer = null;
                this.startTime = null;
                this.mistakes = 0;
                this.currentLevel = 1;
                this.isPaused = false;
                this.achievements = new Set();
                this.stats = {
                    totalWords: 0,
                    totalMistakes: 0,
                    bestWPM: 0,
                    sessionsCompleted: 0
                };

                this.initialize();
            }

            initialize() {
                this.initializeKeyboard();
                this.initializeEventListeners();
                this.loadLevel(1);
                this.loadStats();
            }

            initializeKeyboard() {
                const layout = [
                    '`1234567890-=',
                    'qwertyuiop[]\\',
                    'asdfghjkl;\'',
                    'zxcvbnm,./'
                ];

                const fingerMap = {
                    'q': 'L4', 'w': 'L3', 'e': 'L2', 'r': 'L2', 't': 'L2',
                    'y': 'R2', 'u': 'R2', 'i': 'R3', 'o': 'R4', 'p': 'R4',
                    'a': 'L4', 's': 'L3', 'd': 'L2', 'f': 'L1', 'g': 'L1',
                    'h': 'R1', 'j': 'R1', 'k': 'R2', 'l': 'R3', ';': 'R4',
                    'z': 'L4', 'x': 'L3', 'c': 'L2', 'v': 'L1', 'b': 'L1',
                    'n': 'R1', 'm': 'R1', ',': 'R2', '.': 'R3', '/': 'R4'
                };

                const keyboard = document.getElementById('keyboard');
                layout.forEach(row => {
                    [...row].forEach(key => {
                        const keyElement = document.createElement('div');
                        keyElement.className = 'key';
                        keyElement.textContent = key;
                        keyElement.dataset.key = key;

                        if (fingerMap[key]) {
                            const hint = document.createElement('span');
                            hint.className = 'finger-hint';
                            hint.textContent = fingerMap[key];
                            keyElement.appendChild(hint);
                        }

                        keyboard.appendChild(keyElement);
                    });
                });
            }

            async fetchText(level) {
                try {
                    const response = await fetch(
                        `https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=${API_KEY}`,
                        {
                            method: 'POST',
                            headers: { 'Content-Type': 'application/json' },
                            body: JSON.stringify({
                                contents: [{
                                    parts: [{
                                        text: `Generate a ${this.getLevelDescription(level)} typing practice text`
                                    }]
                                }]
                            })
                        }
                    );
                    const data = await response.json();
                    return data.candidates[0].content.parts[0].text;
                } catch (error) {
                    console.error('Error fetching text:', error);
                    return this.getDefaultText(level);
                }
            }

            getLevelDescription(level) {
                const descriptions = {
                    1: 'simple home row keys only',
                    2: 'basic words with common letters',
                    3: 'moderate sentences with punctuation',
                    4: 'complex paragraphs with varied vocabulary'
                };
                return descriptions[level] || descriptions[1];
            }

            getDefaultText(level) {
                const texts = {
                    1: "asdf jkl; asdf jkl; asdf jkl;",
                    2: "The quick brown fox jumps over the lazy dog.",
                    3: "Programming requires attention to detail and consistent practice.",
                    4: "In the realm of technology, mastering touch typing is an essential skill that can significantly improve productivity and efficiency in various tasks."
                };
                return texts[level] || texts[1];
            }

            updateStats() {
                if (!this.startTime || this.isPaused) return;

                const currentTime = new Date();
                const timeElapsed = (currentTime - this.startTime) / 1000;
                const words = document.getElementById('input-area').value.trim().split(/\s+/).length;
                const wpm = Math.round((words / timeElapsed) * 60);
                const accuracy = Math.round(((this.currentText.length - this.mistakes) / this.currentText.length) * 100);

                document.getElementById('wpm').textContent = wpm;
                document.getElementById('accuracy').textContent = `${accuracy}%`;
                document.getElementById('timer').textContent = this.formatTime(timeElapsed);

                this.checkAchievements(wpm, accuracy);
            }

            checkAchievements(wpm, accuracy) {
                const newAchievements = [
                    { id: 'wpm30', condition: wpm >= 30, title: '30 WPM Achieved!' },
                    { id: 'wpm50', condition: wpm >= 50, title: '50 WPM Master!' },
                    { id: 'accuracy95', condition: accuracy >= 95, title: '95% Accuracy Expert!' },
                    { id: 'perfect', condition: accuracy === 100, title: 'Perfect Accuracy!' }
                ];

                newAchievements.forEach(achievement => {
                    if (achievement.condition && !this.achievements.has(achievement.id)) {
                        this.achievements.add(achievement.id);
                        this.showAchievementNotification(achievement.title);
                    }
                });
            }

            showAchievementNotification(title) {
                // Implementation of achievement notification
                const notification = document.createElement('div');
                notification.className = 'achievement-notification';
                notification.textContent = `🏆 ${title}`;
                document.body.appendChild(notification);
                setTimeout(() => notification.remove(), 3000);
            }

            formatTime(seconds) {
                const minutes = Math.floor(seconds / 60);
                seconds = Math.floor(seconds % 60);
                return `${minutes}:${seconds.toString().padStart(2, '0')}`;
            }

            highlightKey(key) {
                const keyElement = document.querySelector(`[data-key="${key}"]`);
                if (keyElement) {
                    keyElement.classList.add('active');
                    setTimeout(() => keyElement.classList.remove('active'), 100);
                }
            }

            async loadLevel(level) {
                this.currentLevel = level;
                document.getElementById('level').textContent = level;
                const text = await this.fetchText(level);
                this.currentText = text;
                this.displayText(text);
                document.getElementById('input-area').value = '';
                this.startTime = null;
                this.mistakes = 0;
                this.updateStats();
            }

            displayText(text) {
                const display = document.getElementById('text-display');
                display.innerHTML = '';
                [...text].forEach((char, index) => {
                    const span = document.createElement('span');
                    span.className = 'character';
                    span.textContent = char;
                    span.dataset.index = index;
                    display.appendChild(span);
                });
            }

            toggleFocusMode() {
                const display = document.getElementById('text-display');
                display.classList.toggle('focus-mode');
            }

            saveStats() {
                localStorage.setItem('typingStats', JSON.stringify(this.stats));
            }

            loadStats() {
                const saved = localStorage.getItem('typingStats');
                if (saved) {
                    this.stats = JSON.parse(saved);
                }
            }

            initializeEventListeners() {
                document.getElementById('input-area').addEventListener('input', (e) => {
                    if (this.isPaused) return;
                    if (!this.startTime) this.startTime = new Date();
                    if (!this.timer) {
                        this.timer = setInterval(() => this.updateStats(), 1000);
                    }

                    const input = e.target.value;
                    this.highlightKey(e.data);

                    if (input.length > this.currentText.length) {
                        e.target.value = input.slice(0, this.currentText.length);
                        return;
                    }

                    this.updateCharacterDisplay(input);

                    if (input === this.currentText) {
                        this.completeLevel();
                    }
                });

                document.getElementById('focus-mode-btn').addEventListener('click', () => {
                    this.toggleFocusMode();
                });

                document.getElementById('pause-btn').addEventListener('click', () => {
                    this.togglePause();
                });

                document.getElementById('start-btn').addEventListener('click', () => {
                    this.loadLevel(this.currentLevel);
                });

                document.getElementById('achievements-btn').addEventListener('click', () => {
                    this.showAchievements();
                });
            }

            updateCharacterDisplay(input) {
                const characters = document.querySelectorAll('.character');
                characters.forEach((char, index) => {
                    char.classList.remove('current', 'correct', 'incorrect');
                    if (index === input.length) {
                        char.classList.add('current');
                    } else if (index < input.length) {
                        if (input[index] === this.currentText[index]) {
                            char.classList.add('correct');
                        } else {
                            char.classList.add('incorrect');
                            this.mistakes++;
                        }
                    }
                });
            }

            togglePause() {
                this.isPaused = !this.isPaused;
                const pauseBtn = document.getElementById('pause-btn');
                pauseBtn.innerHTML = this.isPaused ? 
                    '<span class="icon">▶</span> Resume' : 
                    '<span class="icon">⏸</span> Pause';
            }

            completeLevel() {
                clearInterval(this.timer);
                this.timer = null;
                
                const wpm = parseInt(document.getElementById('wpm').textContent);
                const accuracy = parseInt(document.getElementById('accuracy').textContent);
                
                this.stats.totalWords += this.currentText.split(/\s+/).length;
                this.stats.totalMistakes += this.mistakes;
                this.stats.bestWPM = Math.max(this.stats.bestWPM, wpm);
                this.stats.sessionsCompleted++;
                
                this.saveStats();
                
                const message = `
                    Level Complete!
                    WPM: ${wpm}
                    Accuracy: ${accuracy}%
                    Mistakes: ${this.mistakes}
                    
                    Continue to next level?
                `;
                
                if (confirm(message)) {
                    this.loadLevel(Math.min(this.currentLevel + 1, 4));
                }
            }

            showAchievements() {
                const modal = document.getElementById('achievements-modal');
                const list = document.getElementById('achievements-list');
                list.innerHTML = '';

                const achievementsList = Array.from(this.achievements).map(id => {
                    const div = document.createElement('div');
                    div.className = 'achievement';
                    div.innerHTML = `
                        <span class="achievement-icon">🏆</span>
                        <div>
                            <h3>${this.getAchievementTitle(id)}</h3>
                            <p>${this.getAchievementDescription(id)}</p>
                        </div>
                    `;
                    return div;
                });

                if (achievementsList.length === 0) {
                    list.innerHTML = '<p>No achievements yet. Keep practicing!</p>';
                } else {
                    achievementsList.forEach(achievement => list.appendChild(achievement));
                }

                modal.classList.add('active');
            }

            getAchievementTitle(id) {
                const titles = {
                    'wpm30': '30 WPM Achieved!',
                    'wpm50': '50 WPM Master!',
                    'accuracy95': '95% Accuracy Expert!',
                    'perfect': 'Perfect Accuracy!'
                };
                return titles[id] || 'Achievement Unlocked!';
            }

            getAchievementDescription(id) {
                const descriptions = {
                    'wpm30': 'Reached 30 words per minute',
                    'wpm50': 'Achieved professional typing speed',
                    'accuracy95': 'Maintained 95% or higher accuracy',
                    'perfect': 'Completed a session with no mistakes'
                };
                return descriptions[id] || 'Keep improving!';
            }
        }

        // Initialize the application
        const typingTrainer = new TypingTrainer();

        // Close modal handler
        document.getElementById('close-achievements').addEventListener('click', () => {
            document.getElementById('achievements-modal').classList.remove('active');
        });

        // Close modal when clicking outside
        window.addEventListener('click', (e) => {
            const modal = document.getElementById('achievements-modal');
            if (e.target === modal) {
                modal.classList.remove('active');
            }
        });
    </script>
<footer class="modern-footer">
  <style>
    @import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Raleway:wght@300;400;600&display=swap');
    
    .modern-footer {
      background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
      color: rgba(255,255,255,0.9);
      padding: 3rem 2rem;
      font-family: 'Raleway', sans-serif;
      text-align: center;
      position: relative;
      overflow: hidden;
      min-height: 250px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      box-shadow: 0 -10px 20px rgba(0,0,0,0.1);
    }

    .modern-footer::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.1) 0%, transparent 50%);
      animation: pulse 4s ease infinite;
    }

    .footer-text {
      position: relative;
      z-index: 1;
      line-height: 1.8;
      animation: fadeIn 1s ease-out;
    }

    .developer-name {
      font-family: 'Cinzel', serif;
      color: #4a90e2;
      font-weight: 700;
      font-size: 1.4em;
      margin: 0.5em 0;
      text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
      transition: all 0.3s ease;
    }

    .developer-name:hover {
      color: #66d9ef;
      transform: scale(1.05);
    }

    .title {
      color: #66d9ef;
      font-size: 1em;
      font-style: italic;
      letter-spacing: 1px;
      margin-bottom: 1em;
    }

    .ai-logo {
      width: 80px;
      height: 80px;
      margin: 1.5em auto;
      position: relative;
    }

    .ai-logo svg {
      width: 100%;
      height: 100%;
      filter: drop-shadow(0 0 8px rgba(102, 217, 239, 0.5));
      animation: float 3s ease-in-out infinite;
    }

    @keyframes float {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-10px); }
    }

    @keyframes pulse {
      0% { opacity: 0.5; }
      50% { opacity: 0.8; }
      100% { opacity: 0.5; }
    }

    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(20px); }
      to { opacity: 1; transform: translateY(0); }
    }

    @media (max-width: 768px) {
      .modern-footer {
        padding: 2rem 1rem;
      }
      
      .footer-text {
        font-size: 0.9em;
      }

      .developer-name {
        font-size: 1.2em;
      }

      .ai-logo {
        width: 60px;
        height: 60px;
      }
    }
  </style>

  <div class="footer-text">
    <div>All intellectual and material rights of this work are reserved for the developer</div>
    <div class="developer-name">Thank you, Reza Salehi (Albert)</div>
    <div class="title">AI Platforms & Data Developer</div>
    
    <div class="ai-logo">
      <svg viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M50 10L90 30V70L50 90L10 70V30L50 10Z" stroke="#66d9ef" stroke-width="2"/>
        <path d="M50 10V90" stroke="#66d9ef" stroke-width="2"/>
        <path d="M90 30L10 70" stroke="#66d9ef" stroke-width="2"/>
        <path d="M10 30L90 70" stroke="#66d9ef" stroke-width="2"/>
        <circle cx="50" cy="50" r="10" fill="#4a90e2"/>
        <circle cx="50" cy="50" r="5" fill="#66d9ef"/>
        <circle cx="50" cy="10" r="3" fill="#66d9ef"/>
        <circle cx="90" cy="30" r="3" fill="#66d9ef"/>
        <circle cx="90" cy="70" r="3" fill="#66d9ef"/>
        <circle cx="50" cy="90" r="3" fill="#66d9ef"/>
        <circle cx="10" cy="70" r="3" fill="#66d9ef"/>
        <circle cx="10" cy="30" r="3" fill="#66d9ef"/>
      </svg>
    </div>
  </div>
</footer>
<head>
    <!-- Prevent page indexing by search engines -->
    <meta name="robots" content="noindex, nofollow">
    <meta name="googlebot" content="noindex, nofollow">
</head>
<body>
    <!-- Your page content goes here -->
</body>
</html>