File size: 28,262 Bytes
4d6ad68
 
 
 
 
 
 
 
 
 
 
 
 
 
635d40a
4d6ad68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8e05c03
 
 
4d6ad68
 
 
 
 
 
 
635d40a
4d6ad68
 
8b91465
 
 
 
 
 
 
 
 
 
4d6ad68
 
 
 
 
 
 
635d40a
 
4d6ad68
 
 
 
 
 
 
 
 
 
 
 
 
635d40a
 
 
 
8e05c03
635d40a
 
4d6ad68
635d40a
 
 
 
4d6ad68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635d40a
4d6ad68
635d40a
 
 
 
 
 
 
 
 
 
 
4d6ad68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635d40a
8b91465
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4d6ad68
 
 
 
 
 
 
635d40a
 
 
4d6ad68
 
 
 
 
 
 
635d40a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4d6ad68
 
 
 
 
635d40a
4d6ad68
635d40a
 
 
8b91465
635d40a
 
 
 
4d6ad68
 
 
 
 
 
 
635d40a
 
4d6ad68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8e05c03
 
 
 
 
 
 
 
 
635d40a
 
 
 
 
 
8e05c03
 
 
 
 
 
8b91465
8e05c03
 
 
 
 
 
 
 
 
 
 
 
635d40a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b91465
635d40a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4d6ad68
 
8b91465
 
4d6ad68
 
 
55196ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>German Flashcards</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
    <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <style>
        .flashcard {
            perspective: 1000px;
            min-height: 80px;
        }
        .flashcard-inner {
            transition: transform 0.6s;
            transform-style: preserve-3d;
        }
        .flashcard.flipped .flashcard-inner {
            transform: rotateY(180deg);
        }
        .flashcard-front, .flashcard-back {
            backface-visibility: hidden;
            position: absolute;
            width: 100%;
            height: 100%;
        }
        .flashcard-back {
            transform: rotateY(180deg);
        }
        .progress-bar {
            transition: width 0.3s ease;
        }
    </style>
</head>
<body class="bg-gray-100 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <header class="mb-8 text-center">
            <h1 class="text-4xl font-bold text-indigo-700 mb-2">German Flashcards</h1>
            <p class="text-gray-600">Master German vocabulary with interactive flashcards</p>
            
            <div class="mt-6 flex justify-center items-center space-x-4">
                <div class="w-full max-w-md bg-white rounded-lg shadow p-4">
                    <div class="flex justify-between mb-1">
                        <span class="text-sm font-medium text-indigo-700">Progress</span>
                        <span id="progress-percentage" class="text-sm font-medium text-indigo-700">0%</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2.5">
                        <div id="progress-bar" class="progress-bar bg-indigo-600 h-2.5 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
            </div>
        </header>

        <div class="mb-8 flex flex-col items-center space-y-4">
            <div class="w-full max-w-md bg-white rounded-lg shadow p-4">
                <h3 class="text-lg font-medium text-indigo-700 mb-2">Add New Flashcards</h3>
                <input id="list-name-input" type="text" class="w-full p-2 border rounded mb-2" placeholder="List name (e.g. 'Food Vocabulary')">
                <textarea id="new-flashcards-input" class="w-full h-40 p-2 border rounded mb-2" placeholder="Enter German - English pairs (e.g. neun – nine)"></textarea>
                <button id="add-flashcards-btn" class="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition flex items-center justify-center w-full">
                    <i data-feather="plus" class="mr-2"></i> Add Flashcards
                </button>
            </div>

            <div class="flex flex-col items-center space-y-4">
                <div class="flex justify-center space-x-4">
                    <button id="shuffle-btn" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition flex items-center">
                        <i data-feather="shuffle" class="mr-2"></i> Shuffle
                    </button>
                    <button id="reset-btn" class="px-4 py-2 bg-gray-600 text-white rounded-lg hover:bg-gray-700 transition flex items-center">
                        <i data-feather="refresh-cw" class="mr-2"></i> Reset Progress
                    </button>
                    <button id="show-original-btn" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition flex items-center">
                        <i data-feather="book" class="mr-2"></i> Original List
                    </button>
                    <button id="show-not-mastered-btn" class="px-4 py-2 bg-yellow-600 text-white rounded-lg hover:bg-yellow-700 transition flex items-center">
                        <i data-feather="alert-circle" class="mr-2"></i> Not Mastered
                    </button>
                </div>
                <div id="custom-lists-container" class="flex flex-wrap justify-center gap-2">
                    <!-- Custom list buttons will be added here -->
                </div>
            </div>
        </div>

        <div id="flashcards-container" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4">
            <!-- Flashcards will be inserted here by JavaScript -->
        </div>

        <div id="pagination-controls" class="mt-8 flex justify-center items-center space-x-4 hidden">
            <button id="prev-page-btn" class="px-4 py-2 bg-gray-600 text-white rounded-lg hover:bg-gray-700 transition flex items-center">
                <i data-feather="chevron-left" class="mr-2"></i> Previous
            </button>
            <span id="page-info" class="text-gray-600 font-medium">Page 1 of 1</span>
            <button id="next-page-btn" class="px-4 py-2 bg-gray-600 text-white rounded-lg hover:bg-gray-700 transition flex items-center">
                Next <i data-feather="chevron-right" class="ml-2"></i>
            </button>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            feather.replace();
            AOS.init();

            // Get flashcards from localStorage
            let flashcards = JSON.parse(localStorage.getItem('germanFlashcards')) || [];

            // Render flashcards
            function renderFlashcards() {
                const container = document.getElementById('flashcards-container');
                container.innerHTML = '';
                
                flashcards.forEach((card, index) => {
                    const flashcard = document.createElement('div');
                    flashcard.className = `flashcard ${card.mastered ? 'border-2 border-green-500' : ''}`;
                    flashcard.dataset.index = index;
                    
                    flashcard.innerHTML = `
                        <div class="flashcard-inner h-full">
                            <div class="flashcard-front bg-white rounded-lg shadow-md p-3 flex flex-col items-center justify-center cursor-pointer h-full">
                                <h3 class="text-sm font-bold text-center text-indigo-700">${card.german}</h3>
                                <button class="speak-btn mt-1 p-1 bg-indigo-100 rounded-full hover:bg-indigo-200 transition">
                                    <i data-feather="volume-2" class="text-indigo-700 w-3 h-3"></i>
                                </button>
                                <p class="text-xs text-gray-500 mt-1">Click to flip</p>
                                ${card.mastered ? '<i data-feather="check-circle" class="text-green-500 mt-1 w-3 h-3"></i>' : ''}
                            </div>
                            <div class="flashcard-back bg-indigo-100 rounded-lg shadow-md p-2 flex flex-col items-center justify-center cursor-pointer h-full">
                                <h3 class="text-xs font-semibold text-center text-gray-800">${card.english}</h3>
                                <div class="mt-1 flex space-x-1">
                                    <button class="master-btn px-2 py-0.5 ${card.mastered ? 'bg-green-500' : 'bg-gray-500'} text-white rounded text-xs">
                                        ${card.mastered ? 'Mastered' : 'Mark as Mastered'}
                                    </button>
                                </div>
                            </div>
                        </div>
                    `;
                    
                    container.appendChild(flashcard);
                    
                    // Add click event to flip card
                    flashcard.addEventListener('click', function() {
                        if (!event.target.classList.contains('master-btn')) {
                            this.classList.toggle('flipped');
                        }
                    });
                });
                
                // Add event listeners to master buttons
                document.querySelectorAll('.master-btn').forEach(btn => {
                    btn.addEventListener('click', function(e) {
                        e.stopPropagation();
                        const index = this.closest('.flashcard').dataset.index;
                        flashcards[index].mastered = !flashcards[index].mastered;
                        saveFlashcards();
                        updateProgress();
                        renderFlashcards();
                    });
                });
                
                feather.replace();
                updateProgress();
            }

            // Save flashcards to localStorage
            function saveFlashcards() {
                localStorage.setItem('germanFlashcards', JSON.stringify(flashcards));
            }

            // Update progress bar
            function updateProgress() {
                const masteredCount = flashcards.filter(card => card.mastered).length;
                const totalCount = flashcards.length;
                const percentage = Math.round((masteredCount / totalCount) * 100);
                
                document.getElementById('progress-bar').style.width = `${percentage}%`;
                document.getElementById('progress-percentage').textContent = `${percentage}%`;
            }

            // Shuffle flashcards
            document.getElementById('shuffle-btn').addEventListener('click', function() {
                flashcards = shuffleArray(flashcards);
                saveFlashcards();
                renderFlashcards();
            });

            // Reset progress of current list
            document.getElementById('reset-btn').addEventListener('click', function() {
                if (confirm('Are you sure you want to reset progress for the current list?')) {
                    const currentListName = getCurrentListName();
                    if (currentListName && customLists[currentListName]) {
                        // Reset all cards in the current list to not mastered
                        customLists[currentListName] = customLists[currentListName].map(card => ({ ...card, mastered: false }));
                        localStorage.setItem('customGermanLists', JSON.stringify(customLists));
                        // Reload the current list
                        flashcards = [...customLists[currentListName]];
                        saveFlashcards();
                        renderFlashcards();
                    }
                }
            });

            // Helper function to shuffle array
            function shuffleArray(array) {
                const newArray = [...array];
                for (let i = newArray.length - 1; i > 0; i--) {
                    const j = Math.floor(Math.random() * (i + 1));
                    [newArray[i], newArray[j]] = [newArray[j], newArray[i]];
                }
                return newArray;
            }


            // Object to store all custom lists
            let customLists = JSON.parse(localStorage.getItem('customGermanLists')) || {};
            let currentPage = 1;
            const cardsPerPage = 20;

            // Render flashcards with pagination
            function renderFlashcards() {
                const container = document.getElementById('flashcards-container');
                container.innerHTML = '';
                
                const startIndex = (currentPage - 1) * cardsPerPage;
                const endIndex = Math.min(startIndex + cardsPerPage, flashcards.length);
                const currentPageCards = flashcards.slice(startIndex, endIndex);
                
                currentPageCards.forEach((card, index) => {
                    const actualIndex = startIndex + index;
                    const flashcard = document.createElement('div');
                    flashcard.className = `flashcard ${card.mastered ? 'border-2 border-green-500' : ''}`;
                    flashcard.dataset.index = actualIndex;
                    
                    flashcard.innerHTML = `
                        <div class="flashcard-inner h-full">
                            <div class="flashcard-front bg-white rounded-lg shadow-md p-3 flex flex-col items-center justify-center cursor-pointer h-full">
                                <h3 class="text-sm font-bold text-center text-indigo-700">${card.german}</h3>
                                <button class="speak-btn mt-1 p-1 bg-indigo-100 rounded-full hover:bg-indigo-200 transition">
                                    <i data-feather="volume-2" class="text-indigo-700 w-3 h-3"></i>
                                </button>
                                <p class="text-xs text-gray-500 mt-1">Click to flip</p>
                                ${card.mastered ? '<i data-feather="check-circle" class="text-green-500 mt-1 w-3 h-3"></i>' : ''}
                            </div>
                            <div class="flashcard-back bg-indigo-100 rounded-lg shadow-md p-2 flex flex-col items-center justify-center cursor-pointer h-full">
                                <h3 class="text-xs font-semibold text-center text-gray-800">${card.english}</h3>
                                <div class="mt-1 flex space-x-1">
                                    <button class="master-btn px-2 py-0.5 ${card.mastered ? 'bg-green-500' : 'bg-gray-500'} text-white rounded text-xs">
                                        ${card.mastered ? 'Mastered' : 'Mark as Mastered'}
                                    </button>
                                </div>
                            </div>
                        </div>
                    `;
                    
                    container.appendChild(flashcard);
                    
                    // Add click event to flip card
                    flashcard.addEventListener('click', function() {
                        if (!event.target.classList.contains('master-btn')) {
                            this.classList.toggle('flipped');
                        }
                    });
                });
                
                // Add event listeners to master buttons
                document.querySelectorAll('.master-btn').forEach(btn => {
                    btn.addEventListener('click', function(e) {
                        e.stopPropagation();
                        const index = parseInt(this.closest('.flashcard').dataset.index);
                        flashcards[index].mastered = !flashcards[index].mastered;
                        saveFlashcards();
                        updateProgress();
                        renderFlashcards();
                    });
                });
                
                // Update pagination controls
                updatePaginationControls();
                feather.replace();
                updateProgress();
            }

            // Update pagination controls
            function updatePaginationControls() {
                const totalPages = Math.ceil(flashcards.length / cardsPerPage);
                const paginationControls = document.getElementById('pagination-controls');
                const pageInfo = document.getElementById('page-info');
                const prevBtn = document.getElementById('prev-page-btn');
                const nextBtn = document.getElementById('next-page-btn');
                
                pageInfo.textContent = `Page ${currentPage} of ${totalPages}`;
                
                if (totalPages <= 1) {
                    paginationControls.classList.add('hidden');
                } else {
                    paginationControls.classList.remove('hidden');
                    
                    prevBtn.disabled = currentPage === 1;
                    prevBtn.classList.toggle('opacity-50', currentPage === 1);
                    prevBtn.classList.toggle('cursor-not-allowed', currentPage === 1);
                    
                    nextBtn.disabled = currentPage === totalPages;
                    nextBtn.classList.toggle('opacity-50', currentPage === totalPages);
                    nextBtn.classList.toggle('cursor-not-allowed', currentPage === totalPages);
                }
            }

            // Next page button
            document.getElementById('next-page-btn').addEventListener('click', function() {
                const totalPages = Math.ceil(flashcards.length / cardsPerPage);
                if (currentPage < totalPages) {
                    currentPage++;
                    renderFlashcards();
                }
            });

            // Previous page button
            document.getElementById('prev-page-btn').addEventListener('click', function() {
                if (currentPage > 1) {
                    currentPage--;
                    renderFlashcards();
                }
            });

            // Render custom list buttons
            function renderCustomListButtons() {
                const container = document.getElementById('custom-lists-container');
                container.innerHTML = '';
                
                Object.keys(customLists).forEach(listName => {
                    const buttonContainer = document.createElement('div');
                    buttonContainer.className = 'relative group';
                    
                    const button = document.createElement('button');
                    button.className = 'px-4 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition flex items-center';
                    button.innerHTML = `<i data-feather="list" class="mr-2"></i> ${listName}`;
                    button.addEventListener('click', () => {
                        flashcards = [...customLists[listName]];
                        renderFlashcards();
                    });
                    
                    const removeBtn = document.createElement('button');
                    removeBtn.className = 'absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-600';
                    removeBtn.innerHTML = '×';
                    removeBtn.addEventListener('click', (e) => {
                        e.stopPropagation();
                        if (confirm(`Are you sure you want to delete the "${listName}" list?`)) {
                            delete customLists[listName];
                            localStorage.setItem('customGermanLists', JSON.stringify(customLists));
                            renderCustomListButtons();
                            // If we deleted the current list, load the first available list
                            const listNames = Object.keys(customLists);
                            if (listNames.length > 0) {
                                flashcards = [...customLists[listNames[0]]];
                                renderFlashcards();
                            } else {
                                flashcards = [];
                                renderFlashcards();
                            }
                        }
                    });
                    
                    buttonContainer.appendChild(button);
                    buttonContainer.appendChild(removeBtn);
                    container.appendChild(buttonContainer);
                });
                
                feather.replace();
            }

            // Show original flashcards (first custom list or empty)
            document.getElementById('show-original-btn').addEventListener('click', function() {
                const listNames = Object.keys(customLists);
                if (listNames.length > 0) {
                    flashcards = [...customLists[listNames[0]]];
                    currentPage = 1;
                    renderFlashcards();
                } else {
                    alert('No custom lists available. Please create a list first.');
                }
            });

            // Parse and add new flashcards
            document.getElementById('add-flashcards-btn').addEventListener('click', function() {
                const input = document.getElementById('new-flashcards-input').value.trim();
                const listName = document.getElementById('list-name-input').value.trim();
                
                if (!input || !listName) {
                    alert('Please enter both a list name and flashcards!');
                    return;
                }

                const lines = input.split('\n');
                const newCards = [];

                lines.forEach(line => {
                    const parts = line.split('–').map(part => part.trim());
                    if (parts.length === 2 && parts[0] && parts[1]) {
                        newCards.push({
                            german: parts[0],
                            english: parts[1],
                            mastered: false
                        });
                    }
                });

                if (newCards.length > 0) {
                    // Add or update the custom list
                    customLists[listName] = newCards;
                    localStorage.setItem('customGermanLists', JSON.stringify(customLists));
                    
                    document.getElementById('new-flashcards-input').value = '';
                    document.getElementById('list-name-input').value = '';
                    
                    // Update the flashcards to show the newly added list
                    flashcards = [...newCards];
                    
                    // Save and render
                    saveFlashcards();
                    renderFlashcards();
                    renderCustomListButtons();
                    
                    alert(`Added ${newCards.length} new flashcards to "${listName}" list!`);
                }
            });

            // Speak German word
            function speakWord(text) {
                const utterance = new SpeechSynthesisUtterance(text);
                utterance.lang = 'de-DE';
                speechSynthesis.speak(utterance);
            }

            // Show only not mastered words
            document.getElementById('show-not-mastered-btn').addEventListener('click', function() {
                // Reload current list from localStorage to get latest mastered status
                const currentListName = getCurrentListName();
                if (currentListName && customLists[currentListName]) {
                    flashcards = [...customLists[currentListName]];
                }
                
                const notMastered = flashcards.filter(card => !card.mastered);
                if (notMastered.length === 0) {
                    alert('All words in this list are mastered!');
                    return;
                }
                flashcards = [...notMastered];
                currentPage = 1;
                renderFlashcards();
            });

            // Add event delegation for speak buttons
            document.addEventListener('click', function(e) {
                if (e.target.closest('.speak-btn') || e.target.closest('.speak-btn i')) {
                    const flashcard = e.target.closest('.flashcard');
                    const index = flashcard.dataset.index;
                    speakWord(flashcards[index].german);
                }
            });

            // Helper function to get current list name
            function getCurrentListName() {
                const currentFlashcards = JSON.stringify(flashcards);
                for (const [listName, listCards] of Object.entries(customLists)) {
                    if (JSON.stringify(listCards) === currentFlashcards) {
                        return listName;
                    }
                }
                return null;
            }

            // Update custom list when flashcards change
            function updateCurrentCustomList() {
                const currentListName = getCurrentListName();
                if (currentListName && customLists[currentListName]) {
                    customLists[currentListName] = [...flashcards];
                    localStorage.setItem('customGermanLists', JSON.stringify(customLists));
                }
            }

            // Modified saveFlashcards to also update custom lists
            function saveFlashcards() {
                localStorage.setItem('germanFlashcards', JSON.stringify(flashcards));
                updateCurrentCustomList();
            }

            // Modified renderCustomListButtons to load from current list when clicked
            function renderCustomListButtons() {
                const container = document.getElementById('custom-lists-container');
                container.innerHTML = '';
                
                Object.keys(customLists).forEach(listName => {
                    const buttonContainer = document.createElement('div');
                    buttonContainer.className = 'relative group';
                    
                    const button = document.createElement('button');
                    button.className = 'px-4 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition flex items-center';
                    button.innerHTML = `<i data-feather="list" class="mr-2"></i> ${listName}`;
                    button.addEventListener('click', () => {
                        // Load the full list from localStorage (including mastered status)
                        flashcards = [...customLists[listName]];
                        saveFlashcards();
                        currentPage = 1;
                        renderFlashcards();
                    });
                    
                    const removeBtn = document.createElement('button');
                    removeBtn.className = 'absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-600';
                    removeBtn.innerHTML = '×';
                    removeBtn.addEventListener('click', (e) => {
                        e.stopPropagation();
                        if (confirm(`Are you sure you want to delete the "${listName}" list?`)) {
                            delete customLists[listName];
                            localStorage.setItem('customGermanLists', JSON.stringify(customLists));
                            renderCustomListButtons();
                            // If we deleted the current list, load the first available list
                            const listNames = Object.keys(customLists);
                            if (listNames.length > 0) {
                                flashcards = [...customLists[listNames[0]]];
                                saveFlashcards();
                                renderFlashcards();
                            } else {
                                flashcards = [];
                                saveFlashcards();
                                renderFlashcards();
                            }
                        }
                    });
                    
                    buttonContainer.appendChild(button);
                    buttonContainer.appendChild(removeBtn);
                    container.appendChild(buttonContainer);
                });
                
                feather.replace();
            }

            // Initial render - load first custom list if available
            const listNames = Object.keys(customLists);
            if (listNames.length > 0) {
                flashcards = [...customLists[listNames[0]]];
            }
            
            renderFlashcards();
            renderCustomListButtons();
            currentPage = 1;
            updatePaginationControls();
        });
    </script>
</body>
</html>