File size: 29,228 Bytes
0d416bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Quiz Interativo - 50 Perguntas</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .progress-bar {
            transition: width 0.5s ease-in-out;
        }
        .question-card {
            transform: translateX(0);
            transition: transform 0.5s ease-in-out;
        }
        .question-card.hidden {
            transform: translateX(-100%);
            opacity: 0;
            position: absolute;
        }
        .option:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .option.selected {
            background-color: #3b82f6;
            color: white;
            border-color: #3b82f6;
        }
        .option.correct {
            background-color: #10b981;
            color: white;
            border-color: #10b981;
        }
        .option.incorrect {
            background-color: #ef4444;
            color: white;
            border-color: #ef4444;
        }
        .confetti {
            position: fixed;
            width: 10px;
            height: 10px;
            background-color: #f00;
            border-radius: 50%;
            animation: fall 5s linear forwards;
        }
        @keyframes fall {
            to {
                transform: translateY(100vh) rotate(360deg);
                opacity: 0;
            }
        }
    </style>
</head>
<body class="bg-gray-100 min-h-screen font-sans">
    <div class="container mx-auto px-4 py-8 max-w-4xl">
        <!-- Header -->
        <header class="text-center mb-8">
            <h1 class="text-4xl font-bold text-indigo-700 mb-2">Quiz Interativo</h1>
            <p class="text-gray-600">Teste seus conhecimentos com 50 perguntas desafiadoras!</p>
        </header>

        <!-- Start Screen -->
        <div id="start-screen" class="bg-white rounded-xl shadow-lg p-8 text-center">
            <div class="mb-6">
                <i class="fas fa-brain text-6xl text-indigo-500 mb-4"></i>
                <h2 class="text-2xl font-bold text-gray-800 mb-2">Bem-vindo ao Quiz!</h2>
                <p class="text-gray-600 mb-6">Responda 50 perguntas de diferentes categorias e descubra o quanto você sabe.</p>
            </div>
            <div class="mb-6">
                <label for="username" class="block text-gray-700 mb-2">Seu nome (opcional):</label>
                <input type="text" id="username" class="w-full max-w-xs px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
            </div>
            <button id="start-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-8 rounded-lg transition duration-300 transform hover:scale-105">
                Começar Quiz <i class="fas fa-play ml-2"></i>
            </button>
        </div>

        <!-- Quiz Container -->
        <div id="quiz-container" class="hidden bg-white rounded-xl shadow-lg overflow-hidden">
            <!-- Quiz Header -->
            <div class="bg-indigo-600 text-white p-4 flex justify-between items-center">
                <div class="flex items-center">
                    <i class="fas fa-question-circle text-xl mr-2"></i>
                    <span id="question-counter" class="font-bold">Pergunta 1/50</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-clock mr-2"></i>
                    <span id="timer">00:00</span>
                </div>
            </div>

            <!-- Progress Bar -->
            <div class="h-2 bg-gray-200">
                <div id="progress-bar" class="progress-bar h-full bg-indigo-500" style="width: 0%"></div>
            </div>

            <!-- Question Area -->
            <div id="question-area" class="p-6 relative min-h-64">
                <!-- Questions will be inserted here by JavaScript -->
            </div>

            <!-- Quiz Footer -->
            <div class="bg-gray-50 p-4 flex justify-between">
                <button id="prev-btn" class="bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded-lg transition disabled:opacity-50" disabled>
                    <i class="fas fa-arrow-left mr-2"></i> Anterior
                </button>
                <button id="next-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded-lg transition">
                    Próxima <i class="fas fa-arrow-right ml-2"></i>
                </button>
            </div>
        </div>

        <!-- Results Screen -->
        <div id="results-screen" class="hidden bg-white rounded-xl shadow-lg p-8 text-center">
            <div class="mb-6">
                <i class="fas fa-trophy text-6xl text-yellow-500 mb-4"></i>
                <h2 class="text-3xl font-bold text-gray-800 mb-2">Quiz Concluído!</h2>
                <p id="results-message" class="text-xl text-gray-600 mb-6">Você acertou <span class="font-bold text-indigo-600">X</span> de 50 perguntas.</p>
            </div>
            <div class="bg-gray-100 rounded-lg p-4 mb-6">
                <div class="flex justify-between mb-2">
                    <span>Tempo total:</span>
                    <span id="total-time" class="font-bold">00:00</span>
                </div>
                <div class="flex justify-between mb-2">
                    <span>Porcentagem de acertos:</span>
                    <span id="percentage" class="font-bold">0%</span>
                </div>
                <div class="flex justify-between">
                    <span>Pontuação:</span>
                    <span id="score" class="font-bold">0/50</span>
                </div>
            </div>
            <div class="flex justify-center space-x-4">
                <button id="restart-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-6 rounded-lg transition">
                    <i class="fas fa-redo mr-2"></i> Refazer
                </button>
                <button id="share-btn" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-6 rounded-lg transition">
                    <i class="fas fa-share-alt mr-2"></i> Compartilhar
                </button>
            </div>
        </div>
    </div>

    <script>
        // Quiz questions
        const questions = [
            {
                question: "Qual é o maior planeta do sistema solar?",
                options: ["Terra", "Marte", "Júpiter", "Saturno"],
                answer: 2,
                category: "Ciência"
            },
            {
                question: "Quem pintou a Mona Lisa?",
                options: ["Vincent van Gogh", "Pablo Picasso", "Leonardo da Vinci", "Michelangelo"],
                answer: 2,
                category: "Arte"
            },
            {
                question: "Qual é o elemento químico com símbolo 'O'?",
                options: ["Ouro", "Oxigênio", "Ósmio", "Oganésson"],
                answer: 1,
                category: "Ciência"
            },
            {
                question: "Em que ano o homem pisou na Lua pela primeira vez?",
                options: ["1965", "1969", "1972", "1958"],
                answer: 1,
                category: "História"
            },
            {
                question: "Qual é o maior oceano do mundo?",
                options: ["Atlântico", "Índico", "Ártico", "Pacífico"],
                answer: 3,
                category: "Geografia"
            },
            {
                question: "Quem escreveu 'Dom Quixote'?",
                options: ["Miguel de Cervantes", "Gabriel García Márquez", "Pablo Neruda", "Fernando Pessoa"],
                answer: 0,
                category: "Literatura"
            },
            {
                question: "Qual é a capital do Canadá?",
                options: ["Toronto", "Vancouver", "Ottawa", "Montreal"],
                answer: 2,
                category: "Geografia"
            },
            {
                question: "Quantos continentes existem?",
                options: ["5", "6", "7", "8"],
                answer: 2,
                category: "Geografia"
            },
            {
                question: "Qual é o animal terrestre mais rápido?",
                options: ["Leão", "Guepardo", "Antílope", "Leopardo"],
                answer: 1,
                category: "Natureza"
            },
            {
                question: "Quem foi o primeiro presidente do Brasil?",
                options: ["Getúlio Vargas", "Deodoro da Fonseca", "Prudente de Morais", "Floriano Peixoto"],
                answer: 1,
                category: "História"
            },
            {
                question: "Qual é o livro mais vendido do mundo depois da Bíblia?",
                options: ["Dom Quixote", "Um Conto de Duas Cidades", "O Pequeno Príncipe", "O Senhor dos Anéis"],
                answer: 0,
                category: "Literatura"
            },
            {
                question: "Qual é a língua mais falada no mundo?",
                options: ["Inglês", "Mandarim", "Espanhol", "Hindi"],
                answer: 1,
                category: "Cultura"
            },
            {
                question: "Quantos ossos tem o corpo humano adulto?",
                options: ["206", "300", "150", "187"],
                answer: 0,
                category: "Ciência"
            },
            {
                question: "Qual é o menor país do mundo?",
                options: ["Mônaco", "Vaticano", "San Marino", "Liechtenstein"],
                answer: 1,
                category: "Geografia"
            },
            {
                question: "Quem descobriu a penicilina?",
                options: ["Marie Curie", "Alexander Fleming", "Louis Pasteur", "Robert Koch"],
                answer: 1,
                category: "Ciência"
            },
            {
                question: "Qual é o rio mais longo do mundo?",
                options: ["Amazonas", "Nilo", "Yangtzé", "Mississipi"],
                answer: 0,
                category: "Geografia"
            },
            {
                question: "Em que ano começou a Segunda Guerra Mundial?",
                options: ["1939", "1941", "1935", "1945"],
                answer: 0,
                category: "História"
            },
            {
                question: "Qual é a montanha mais alta do mundo?",
                options: ["K2", "Monte Everest", "Aconcágua", "Kilimanjaro"],
                answer: 1,
                category: "Geografia"
            },
            {
                question: "Quem foi o autor de '1984'?",
                options: ["Aldous Huxley", "George Orwell", "Ray Bradbury", "J.R.R. Tolkien"],
                answer: 1,
                category: "Literatura"
            },
            {
                question: "Qual é a moeda oficial do Japão?",
                options: ["Won", "Yen", "Yuan", "Dólar"],
                answer: 1,
                category: "Cultura"
            },
            {
                question: "Quantas cores tem o arco-íris?",
                options: ["5", "6", "7", "8"],
                answer: 2,
                category: "Ciência"
            },
            {
                question: "Qual é o maior deserto do mundo?",
                options: ["Deserto do Saara", "Deserto de Gobi", "Deserto da Arábia", "Antártida"],
                answer: 3,
                category: "Geografia"
            },
            {
                question: "Quem foi o primeiro homem a viajar no espaço?",
                options: ["Neil Armstrong", "Yuri Gagarin", "John Glenn", "Alan Shepard"],
                answer: 1,
                category: "História"
            },
            {
                question: "Qual é o símbolo químico do ouro?",
                options: ["Ag", "Au", "Og", "Gd"],
                answer: 1,
                category: "Ciência"
            },
            {
                question: "Em que país nasceu o futebolista Lionel Messi?",
                options: ["Brasil", "Espanha", "Portugal", "Argentina"],
                answer: 3,
                category: "Esportes"
            },
            {
                question: "Qual é a capital da Austrália?",
                options: ["Sydney", "Melbourne", "Canberra", "Brisbane"],
                answer: 2,
                category: "Geografia"
            },
            {
                question: "Quantos anos durou a Guerra dos Cem Anos?",
                options: ["100", "116", "97", "110"],
                answer: 1,
                category: "História"
            },
            {
                question: "Qual é o maior órgão do corpo humano?",
                options: ["Coração", "Fígado", "Pele", "Cérebro"],
                answer: 2,
                category: "Ciência"
            },
            {
                question: "Quem escreveu 'Romeu e Julieta'?",
                options: ["Charles Dickens", "William Shakespeare", "Jane Austen", "Mark Twain"],
                answer: 1,
                category: "Literatura"
            },
            {
                question: "Qual é o país mais populoso do mundo?",
                options: ["Índia", "Estados Unidos", "China", "Indonésia"],
                answer: 2,
                category: "Geografia"
            },
            {
                question: "Qual destes não é um sistema operacional?",
                options: ["Windows", "Linux", "MacOS", "Google"],
                answer: 3,
                category: "Tecnologia"
            },
            {
                question: "Qual é a capital da Islândia?",
                options: ["Oslo", "Reykjavik", "Helsinque", "Estocolmo"],
                answer: 1,
                category: "Geografia"
            },
            {
                question: "Quantas peças tem um xadrez tradicional?",
                options: ["16", "24", "32", "40"],
                answer: 2,
                category: "Jogos"
            },
            {
                question: "Qual é o nome do processo de transformação de lagarta em borboleta?",
                options: ["Fotossíntese", "Metamorfose", "Osmose", "Fertilização"],
                answer: 1,
                category: "Natureza"
            },
            {
                question: "Qual destes é um instrumento de percussão?",
                options: ["Violino", "Trompete", "Bateria", "Harpa"],
                answer: 2,
                category: "Música"
            },
            {
                question: "Em que ano o Brasil foi descoberto?",
                options: ["1492", "1500", "1520", "1450"],
                answer: 1,
                category: "História"
            },
            {
                question: "Qual é o nome do maior osso do corpo humano?",
                options: ["Úmero", "Fêmur", "Tíbia", "Crânio"],
                answer: 1,
                category: "Ciência"
            },
            {
                question: "Qual destes não é um planeta do sistema solar?",
                options: ["Vênus", "Urano", "Plutão", "Marte"],
                answer: 2,
                category: "Ciência"
            },
            {
                question: "Quem foi o criador da teoria da relatividade?",
                options: ["Isaac Newton", "Albert Einstein", "Galileu Galilei", "Stephen Hawking"],
                answer: 1,
                category: "Ciência"
            },
            {
                question: "Qual é o nome do processo de divisão celular?",
                options: ["Fotossíntese", "Mitose", "Respiração", "Digestão"],
                answer: 1,
                category: "Ciência"
            },
            {
                question: "Qual é o nome do famoso quadro de Edvard Munch que representa uma pessoa gritando?",
                options: ["O Grito", "A Noite Estrelada", "Guernica", "A Persistência da Memória"],
                answer: 0,
                category: "Arte"
            },
            {
                question: "Qual é o metal mais condutor de eletricidade?",
                options: ["Ouro", "Prata", "Cobre", "Alumínio"],
                answer: 1,
                category: "Ciência"
            },
            {
                question: "Quantas cordas tem um violão tradicional?",
                options: ["4", "5", "6", "7"],
                answer: 2,
                category: "Música"
            },
            {
                question: "Qual é o nome do autor de 'O Pequeno Príncipe'?",
                options: ["Jules Verne", "Antoine de Saint-Exupéry", "Victor Hugo", "Charles Perrault"],
                answer: 1,
                category: "Literatura"
            },
            {
                question: "Qual é o país de origem da vodka?",
                options: ["Polônia", "Rússia", "Suécia", "Finlândia"],
                answer: 1,
                category: "Cultura"
            },
            {
                question: "Qual é o nome do processo de formação de palavras novas?",
                options: ["Conjugação", "Derivação", "Flexão", "Concordância"],
                answer: 1,
                category: "Linguística"
            },
            {
                question: "Qual é o nome do maior felino do mundo?",
                options: ["Leão", "Tigre", "Onça-pintada", "Leopardo"],
                answer: 1,
                category: "Natureza"
            },
            {
                question: "Qual é o nome do inventor da lâmpada elétrica?",
                options: ["Nikola Tesla", "Thomas Edison", "Alexander Graham Bell", "Guglielmo Marconi"],
                answer: 1,
                category: "História"
            },
            {
                question: "Qual é o nome do maior osso do crânio humano?",
                options: ["Mandíbula", "Frontal", "Parietal", "Occipital"],
                answer: 0,
                category: "Ciência"
            },
            {
                question: "Qual é o nome do processo de formação de gametas?",
                options: ["Mitose", "Meiose", "Fertilização", "Osmose"],
                answer: 1,
                category: "Ciência"
            },
            {
                question: "Qual é o nome do autor de 'Crime e Castigo'?",
                options: ["Leo Tolstoy", "Fyodor Dostoevsky", "Anton Chekhov", "Vladimir Nabokov"],
                answer: 1,
                category: "Literatura"
            },
            {
                question: "Qual é o nome do maior lago de água doce do mundo?",
                options: ["Lago Vitória", "Lago Superior", "Lago Baikal", "Lago Tanganica"],
                answer: 1,
                category: "Geografia"
            }
        ];

        // DOM Elements
        const startScreen = document.getElementById('start-screen');
        const quizContainer = document.getElementById('quiz-container');
        const resultsScreen = document.getElementById('results-screen');
        const questionArea = document.getElementById('question-area');
        const questionCounter = document.getElementById('question-counter');
        const progressBar = document.getElementById('progress-bar');
        const prevBtn = document.getElementById('prev-btn');
        const nextBtn = document.getElementById('next-btn');
        const startBtn = document.getElementById('start-btn');
        const restartBtn = document.getElementById('restart-btn');
        const shareBtn = document.getElementById('share-btn');
        const resultsMessage = document.getElementById('results-message');
        const totalTime = document.getElementById('total-time');
        const percentage = document.getElementById('percentage');
        const score = document.getElementById('score');
        const timer = document.getElementById('timer');
        const usernameInput = document.getElementById('username');

        // Quiz Variables
        let currentQuestion = 0;
        let userAnswers = Array(questions.length).fill(null);
        let startTime;
        let timerInterval;
        let correctAnswers = 0;

        // Start Quiz
        startBtn.addEventListener('click', () => {
            startScreen.classList.add('hidden');
            quizContainer.classList.remove('hidden');
            startTime = new Date();
            startTimer();
            showQuestion(currentQuestion);
        });

        // Restart Quiz
        restartBtn.addEventListener('click', () => {
            resultsScreen.classList.add('hidden');
            startScreen.classList.remove('hidden');
            currentQuestion = 0;
            userAnswers = Array(questions.length).fill(null);
            correctAnswers = 0;
            clearInterval(timerInterval);
        });

        // Share Results
        shareBtn.addEventListener('click', () => {
            const username = usernameInput.value || 'Anônimo';
            const scoreText = `${correctAnswers}/50`;
            const percentageText = `${Math.round((correctAnswers / questions.length) * 100)}%`;
            const timeText = document.getElementById('total-time').textContent;
            
            if (navigator.share) {
                navigator.share({
                    title: 'Meu resultado no Quiz',
                    text: `${username} acertou ${scoreText} (${percentageText}) no Quiz em ${timeText}!`,
                    url: window.location.href
                }).catch(err => {
                    console.log('Erro ao compartilhar:', err);
                    fallbackShare();
                });
            } else {
                fallbackShare();
            }
        });

        function fallbackShare() {
            const shareText = `Eu acertei ${correctAnswers} de 50 perguntas no Quiz!`;
            alert('Copie este texto para compartilhar:\n\n' + shareText);
        }

        // Timer Function
        function startTimer() {
            timerInterval = setInterval(() => {
                const now = new Date();
                const elapsed = new Date(now - startTime);
                const minutes = elapsed.getMinutes().toString().padStart(2, '0');
                const seconds = elapsed.getSeconds().toString().padStart(2, '0');
                timer.textContent = `${minutes}:${seconds}`;
            }, 1000);
        }

        // Show Question
        function showQuestion(index) {
            // Update progress
            const progress = ((index + 1) / questions.length) * 100;
            progressBar.style.width = `${progress}%`;
            questionCounter.textContent = `Pergunta ${index + 1}/${questions.length}`;
            
            // Update navigation buttons
            prevBtn.disabled = index === 0;
            nextBtn.textContent = index === questions.length - 1 ? 'Finalizar' : 'Próxima';
            
            // Clear previous question
            questionArea.innerHTML = '';
            
            // Create question card
            const questionCard = document.createElement('div');
            questionCard.className = 'question-card';
            
            // Add category
            const categoryDiv = document.createElement('div');
            categoryDiv.className = 'text-sm font-semibold text-indigo-600 mb-2';
            categoryDiv.textContent = questions[index].category;
            questionCard.appendChild(categoryDiv);
            
            // Add question
            const questionDiv = document.createElement('div');
            questionDiv.className = 'text-xl font-bold text-gray-800 mb-6';
            questionDiv.textContent = questions[index].question;
            questionCard.appendChild(questionDiv);
            
            // Add options
            const optionsDiv = document.createElement('div');
            optionsDiv.className = 'space-y-3';
            
            questions[index].options.forEach((option, i) => {
                const optionDiv = document.createElement('div');
                optionDiv.className = `option p-4 border rounded-lg cursor-pointer transition ${userAnswers[index] === i ? 'selected' : ''}`;
                optionDiv.textContent = option;
                optionDiv.dataset.index = i;
                
                optionDiv.addEventListener('click', () => {
                    // Remove selected class from all options
                    document.querySelectorAll('.option').forEach(opt => {
                        opt.classList.remove('selected');
                    });
                    
                    // Add selected class to clicked option
                    optionDiv.classList.add('selected');
                    
                    // Store user answer
                    userAnswers[index] = i;
                    
                    // Enable next button if not already enabled
                    if (nextBtn.disabled) {
                        nextBtn.disabled = false;
                    }
                });
                
                optionsDiv.appendChild(optionDiv);
            });
            
            questionCard.appendChild(optionsDiv);
            questionArea.appendChild(questionCard);
        }

        // Navigation
        nextBtn.addEventListener('click', () => {
            if (currentQuestion < questions.length - 1) {
                currentQuestion++;
                showQuestion(currentQuestion);
            } else {
                finishQuiz();
            }
        });

        prevBtn.addEventListener('click', () => {
            if (currentQuestion > 0) {
                currentQuestion--;
                showQuestion(currentQuestion);
            }
        });

        // Finish Quiz
        function finishQuiz() {
            clearInterval(timerInterval);
            
            // Calculate results
            const endTime = new Date();
            const elapsed = new Date(endTime - startTime);
            const minutes = elapsed.getMinutes().toString().padStart(2, '0');
            const seconds = elapsed.getSeconds().toString().padStart(2, '0');
            
            correctAnswers = 0;
            for (let i = 0; i < questions.length; i++) {
                if (userAnswers[i] === questions[i].answer) {
                    correctAnswers++;
                }
            }
            
            const percentageCorrect = Math.round((correctAnswers / questions.length) * 100);
            
            // Display results
            quizContainer.classList.add('hidden');
            resultsScreen.classList.remove('hidden');
            
            const username = usernameInput.value || 'Você';
            resultsMessage.innerHTML = `${username} acertou <span class="font-bold text-indigo-600">${correctAnswers}</span> de 50 perguntas.`;
            totalTime.textContent = `${minutes}:${seconds}`;
            percentage.textContent = `${percentageCorrect}%`;
            score.textContent = `${correctAnswers}/50`;
            
            // Add confetti for good scores
            if (percentageCorrect >= 70) {
                createConfetti();
            }
        }

        // Confetti effect
        function createConfetti() {
            const colors = ['#f00', '#0f0', '#00f', '#ff0', '#f0f', '#0ff'];
            
            for (let i = 0; i < 100; i++) {
                const confetti = document.createElement('div');
                confetti.className = 'confetti';
                confetti.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
                confetti.style.left = `${Math.random() * 100}vw`;
                confetti.style.animationDuration = `${3 + Math.random() * 4}s`;
                confetti.style.transform = `scale(${0.5 + Math.random()})`;
                
                document.body.appendChild(confetti);
                
                // Remove confetti after animation
                setTimeout(() => {
                    confetti.remove();
                }, 5000);
            }
        }

        // Initialize
        showQuestion(currentQuestion);
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Leandroprofessor/teste-de-programa-o" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>