File size: 42,605 Bytes
5eecde7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e95ed5f
 
5eecde7
 
 
 
 
 
 
 
 
 
e95ed5f
 
 
 
 
 
5eecde7
 
 
 
e95ed5f
5eecde7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e95ed5f
 
 
 
 
 
 
 
 
 
 
 
5eecde7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4e5ade9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5eecde7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4e5ade9
5eecde7
4e5ade9
 
 
 
 
 
5eecde7
 
4e5ade9
 
 
 
 
 
 
5eecde7
 
 
 
 
e95ed5f
 
 
5eecde7
 
 
 
4e5ade9
 
 
 
5eecde7
 
 
4e5ade9
 
5eecde7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e95ed5f
 
 
5eecde7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>Stop Game - Multiplayer Word Challenge</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>
        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }
        .animate-pulse-custom {
            animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
        }
        .category-input:focus {
            outline: none;
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
        }
        .flip-card {
            perspective: 1000px;
        }
        .flip-card-inner {
            transition: transform 0.6s;
            transform-style: preserve-3d;
        }
        .flip-card.flipped .flip-card-inner {
            transform: rotateY(180deg);
        }
        .flip-card-front, .flip-card-back {
            backface-visibility: hidden;
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
        .flip-card-back {
            transform: rotateY(180deg);
        }
    </style>
</head>
<body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen">
    <!-- Audio elements for sound effects and music -->
    <audio id="bgMusic" loop src="https://assets.mixkit.co/music/preview/mixkit-game-show-suspense-waiting-668.mp3" preload="auto"></audio>
    <audio id="tickSound" src="https://assets.mixkit.co/sfx/preview/mixkit-clock-countdown-bleeps-916.mp3" preload="auto"></audio>
    <audio id="stopSound" src="https://assets.mixkit.co/sfx/preview/mixkit-game-show-suspense-waiting-668.mp3" preload="auto"></audio>
    <audio id="correctSound" src="https://assets.mixkit.co/sfx/preview/mixkit-correct-answer-tone-2870.mp3" preload="auto"></audio>
    <audio id="wrongSound" src="https://assets.mixkit.co/sfx/preview/mixkit-wrong-answer-fail-notification-946.mp3" preload="auto"></audio>
    <audio id="winSound" src="https://assets.mixkit.co/sfx/preview/mixkit-winning-chimes-2015.mp3" preload="auto"></audio>
    <div class="container mx-auto px-4 py-8 max-w-6xl">
        <!-- Header -->
        <header class="text-center mb-8">
            <h1 class="text-4xl md:text-5xl font-bold text-indigo-800 mb-2">STOP!</h1>
            <p class="text-lg text-indigo-600">The Ultimate Word Challenge Game</p>
            <a href="path/to/game.apk" class="mt-4 inline-block bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-lg transition">
                <i class="fas fa-download mr-2"></i> Download Android App
            </a>
            <button id="musicToggle" class="mt-4 ml-4 inline-block bg-purple-600 hover:bg-purple-700 text-white font-bold py-2 px-4 rounded-lg transition">
                <i class="fas fa-music mr-2"></i> Toggle Music
            </button>
        </header>

        <!-- Game Setup Modal -->
        <div id="setupModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 px-4">
            <div class="bg-white rounded-xl shadow-2xl p-6 w-full max-w-md max-h-[80vh] overflow-y-auto">
                <h2 class="text-2xl font-bold text-indigo-800 mb-4">Game Setup</h2>
                
                <div class="mb-6">
                    <h3 class="text-lg font-semibold text-gray-800 mb-2">Game Mode</h3>
                    <div class="grid grid-cols-2 gap-3">
                        <button onclick="setGameMode('multiplayer')" class="mode-btn bg-indigo-100 hover:bg-indigo-200 text-indigo-800 py-4 px-4 rounded-lg transition flex flex-col items-center" style="min-height: 80px;">
                            <i class="fas fa-users text-2xl mb-1"></i>
                            <span>Multiplayer</span>
                        </button>
                        <button onclick="setGameMode('computer')" class="mode-btn bg-indigo-100 hover:bg-indigo-200 text-indigo-800 py-4 px-4 rounded-lg transition flex flex-col items-center" style="min-height: 80px;">
                            <i class="fas fa-robot text-2xl mb-1"></i>
                            <span>Vs Computer</span>
                        </button>
                    </div>
                </div>

                <div id="playerSetup" class="mb-6">
                    <h3 class="text-lg font-semibold text-gray-800 mb-2">Players</h3>
                    <div id="playerInputs" class="space-y-2">
                        <div class="flex items-center">
                            <input type="text" placeholder="Player 1" class="player-name flex-1 border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
                            <button class="ml-2 text-red-500 hover:text-red-700" onclick="removePlayer(this)" disabled>
                                <i class="fas fa-times"></i>
                            </button>
                        </div>
                    </div>
                    <button onclick="addPlayer()" class="mt-2 text-indigo-600 hover:text-indigo-800 flex items-center">
                        <i class="fas fa-plus-circle mr-1"></i> Add Player
                    </button>
                </div>

                <div class="mb-6">
                    <h3 class="text-lg font-semibold text-gray-800 mb-2">Categories</h3>
                    <div class="grid grid-cols-2 gap-2">
                        <label class="flex items-center">
                            <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Name"> Name
                        </label>
                        <label class="flex items-center">
                            <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="City"> City
                        </label>
                        <label class="flex items-center">
                            <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Animal"> Animal
                        </label>
                        <label class="flex items-center">
                            <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Food"> Food
                        </label>
                        <label class="flex items-center">
                            <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Job"> Job
                        </label>
                        <label class="flex items-center">
                            <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Verb"> Verb
                        </label>
                        <label class="flex items-center">
                            <input type="checkbox" checked class="mr-2 h-5 w-5 text-indigo-600" value="Object"> Object
                        </label>
                    </div>
                </div>

                <button onclick="startGame()" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-4 rounded-lg transition">
                    Start Game <i class="fas fa-play ml-2"></i>
                </button>
            </div>
        </div>

        <!-- Game Container -->
        <div id="gameContainer" class="hidden">
            <!-- Game Controls -->
            <div class="bg-white rounded-xl shadow-lg p-4 mb-6">
                <div class="flex flex-wrap items-center justify-between gap-4">
                    <div>
                        <h2 class="text-xl font-bold text-indigo-800">Round <span id="roundNumber">1</span></h2>
                        <p class="text-gray-600">Letter: <span id="currentLetter" class="font-bold text-2xl text-indigo-600">A</span></p>
                    </div>
                    
                    <div class="flex items-center space-x-3">
                        <div id="timerContainer" class="flex items-center">
                            <i class="fas fa-clock text-indigo-600 mr-2"></i>
                            <span id="timer" class="font-mono text-xl">60</span>
                        </div>
                        <button id="stopBtn" class="bg-red-600 hover:bg-red-700 text-white font-bold py-3 px-8 rounded-full transition flex items-center text-lg">
                            STOP <i class="fas fa-hand-paper ml-2"></i>
                        </button>
                    </div>
                </div>
            </div>

            <!-- Game Board -->
            <div class="bg-white rounded-xl shadow-lg overflow-hidden mb-6">
                <div class="overflow-x-auto">
                    <table class="w-full">
                        <thead>
                            <tr class="bg-indigo-100 text-indigo-800">
                                <th class="py-3 px-4 text-left">Player</th>
                                <th id="nameHeader" class="py-3 px-4 text-left">Name</th>
                                <th id="cityHeader" class="py-3 px-4 text-left">City</th>
                                <th id="animalHeader" class="py-3 px-4 text-left">Animal</th>
                                <th id="foodHeader" class="py-3 px-4 text-left">Food</th>
                                <th id="jobHeader" class="py-3 px-4 text-left">Job</th>
                                <th id="verbHeader" class="py-3 px-4 text-left">Verb</th>
                                <th id="objectHeader" class="py-3 px-4 text-left">Object</th>
                                <th class="py-3 px-4 text-left">Score</th>
                            </tr>
                        </thead>
                        <tbody id="scoreboardBody" class="divide-y divide-gray-200">
                            <!-- Player rows will be added here -->
                        </tbody>
                    </table>
                </div>
            </div>

            <!-- Player Input Area -->
            <div id="playerInputArea" class="bg-white rounded-xl shadow-lg p-6 mb-6">
                <h3 class="text-lg font-semibold text-gray-800 mb-4">Your Answers</h3>
                <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
                    <div id="nameInputContainer" class="category-input-container">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Name</label>
                        <input type="text" id="nameInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with...">
                    </div>
                    <div id="cityInputContainer" class="category-input-container">
                        <label class="block text-sm font-medium text-gray-700 mb-1">City</label>
                        <input type="text" id="cityInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with...">
                    </div>
                    <div id="animalInputContainer" class="category-input-container">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Animal</label>
                        <input type="text" id="animalInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with...">
                    </div>
                    <div id="foodInputContainer" class="category-input-container">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Food</label>
                        <input type="text" id="foodInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with...">
                    </div>
                    <div id="jobInputContainer" class="category-input-container">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Job</label>
                        <input type="text" id="jobInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with...">
                    </div>
                    <div id="verbInputContainer" class="category-input-container">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Verb</label>
                        <input type="text" id="verbInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with...">
                    </div>
                    <div id="objectInputContainer" class="category-input-container">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Object</label>
                        <input type="text" id="objectInput" class="category-input w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Starting with...">
                    </div>
                </div>
            </div>

            <!-- Game Actions -->
            <div class="flex flex-wrap justify-between gap-4">
                <button onclick="showSetupModal()" class="bg-gray-200 hover:bg-gray-300 text-gray-800 font-bold py-2 px-4 rounded-lg transition flex items-center">
                    <i class="fas fa-cog mr-2"></i> Settings
                </button>
                <button id="nextRoundBtn" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-6 rounded-lg transition flex items-center">
                    Next Round <i class="fas fa-arrow-right ml-2"></i>
                </button>
            </div>
        </div>

        <!-- Results Modal -->
        <div id="resultsModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 px-4 hidden">
            <div class="bg-white rounded-xl shadow-2xl p-6 w-full max-w-2xl">
                <h2 class="text-2xl font-bold text-indigo-800 mb-4">Round Results</h2>
                
                <div class="mb-4">
                    <div class="overflow-x-auto mb-6">
                        <table class="w-full">
                            <thead>
                                <tr class="bg-indigo-100 text-indigo-800">
                                    <th class="py-3 px-4 text-left">Player</th>
                                    <th class="py-3 px-4 text-left">Score</th>
                                    <th class="py-3 px-4 text-left">Details</th>
                                </tr>
                            </thead>
                            <tbody id="resultsBody" class="divide-y divide-gray-200">
                                <!-- Results will be added here -->
                            </tbody>
                        </table>
                    </div>

                    <div class="bg-gray-50 rounded-lg p-4">
                        <h3 class="text-lg font-semibold text-gray-800 mb-3">Answer Comparison</h3>
                        <div class="overflow-x-auto">
                            <table class="w-full text-sm">
                                <thead>
                                    <tr class="text-left border-b">
                                        <th class="py-2 px-3">Category</th>
                                        <th class="py-2 px-3" id="currentPlayerName"></th>
                                        <th class="py-2 px-3">Others</th>
                                    </tr>
                                </thead>
                                <tbody id="comparisonBody">
                                    <!-- Comparison will be added here -->
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>

                <div class="flex justify-end">
                    <button onclick="nextRound()" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-6 rounded-lg transition">
                        Continue <i class="fas fa-arrow-right ml-2"></i>
                    </button>
                </div>
            </div>
        </div>

        <!-- Winner Modal -->
        <div id="winnerModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 px-4 hidden">
            <div class="bg-white rounded-xl shadow-2xl p-8 w-full max-w-md text-center">
                <div class="text-6xl mb-4 text-yellow-500">
                    <i class="fas fa-trophy"></i>
                </div>
                <h2 class="text-3xl font-bold text-indigo-800 mb-2">Game Over!</h2>
                <p class="text-xl mb-6"><span id="winnerName" class="font-bold text-indigo-600">Player 1</span> wins!</p>
                
                <div class="mb-6">
                    <p class="text-gray-600 mb-1">Final Scores:</p>
                    <div id="finalScores" class="space-y-1">
                        <!-- Final scores will be added here -->
                    </div>
                </div>

                <button onclick="resetGame()" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-6 rounded-lg transition">
                    Play Again <i class="fas fa-redo ml-2"></i>
                </button>
            </div>
        </div>
    </div>

    <script>
        // Game state
        const gameState = {
            players: [],
            currentPlayerIndex: 0,
            categories: [],
            currentLetter: '',
            round: 1,
            timer: null,
            timeLeft: 60,
            gameMode: 'multiplayer', // 'multiplayer' or 'computer'
            isGameRunning: false,
            playerAnswers: {},
            computerAnswers: {
                Name: ["Alice", "Adam", "Anna", "Alex", "Amy", "Andrew", "Aaron", "Abigail", "Austin", "Ava"],
                City: ["Amsterdam", "Athens", "Atlanta", "Austin", "Ankara", "Auckland", "Albuquerque", "Anchorage", "Alexandria", "Antalya"],
                Animal: ["Ant", "Ape", "Albatross", "Alligator", "Anaconda", "Armadillo", "Aardvark", "Alpaca", "Angelfish", "Anemone"],
                Food: ["Apple", "Avocado", "Asparagus", "Almond", "Apricot", "Artichoke", "Arugula", "Acai", "Anchovy", "Angelcake"],
                Job: ["Actor", "Accountant", "Architect", "Artist", "Astronaut", "Athlete", "Author", "Attorney", "Auditor", "Animator"],
                Verb: ["Act", "Ask", "Arrange", "Assist", "Attach", "Adjust", "Admire", "Advise", "Agree", "Announce"],
                Object: ["Album", "Anchor", "Apron", "Arrow", "Atlas", "Amulet", "Amplifier", "Antenna", "Automobile", "Awl"]
            }
        };

        // DOM elements
        const setupModal = document.getElementById('setupModal');
        const gameContainer = document.getElementById('gameContainer');
        const resultsModal = document.getElementById('resultsModal');
        const winnerModal = document.getElementById('winnerModal');
        const timerElement = document.getElementById('timer');
        const stopBtn = document.getElementById('stopBtn');
        const nextRoundBtn = document.getElementById('nextRoundBtn');

        // Initialize the game
        document.addEventListener('DOMContentLoaded', () => {
            // Set up music toggle
            const musicToggle = document.getElementById('musicToggle');
            const bgMusic = document.getElementById('bgMusic');
            musicToggle.addEventListener('click', () => {
                if (bgMusic.paused) {
                    bgMusic.play();
                    musicToggle.innerHTML = '<i class="fas fa-music mr-2"></i> Pause Music';
                } else {
                    bgMusic.pause();
                    musicToggle.innerHTML = '<i class="fas fa-music mr-2"></i> Play Music';
                }
            });
            // Set up event listeners for input fields
            document.querySelectorAll('.category-input').forEach(input => {
                input.addEventListener('keypress', function(e) {
                    if (e.key === 'Enter') {
                        stopGame();
                    }
                });
            });

            // Show setup modal initially
            showSetupModal();
        });

        // Game setup functions
        function showSetupModal() {
            if (gameState.isGameRunning) {
                pauseGame();
            }
            setupModal.classList.remove('hidden');
        }

        function setGameMode(mode) {
            gameState.gameMode = mode;
            document.querySelectorAll('.mode-btn').forEach(btn => {
                btn.classList.remove('bg-indigo-600', 'text-white');
                btn.classList.add('bg-indigo-100', 'text-indigo-800');
            });
            
            const selectedBtn = mode === 'multiplayer' 
                ? document.querySelector('button[onclick="setGameMode(\'multiplayer\')"]')
                : document.querySelector('button[onclick="setGameMode(\'computer\')"]');
            
            selectedBtn.classList.remove('bg-indigo-100', 'text-indigo-800');
            selectedBtn.classList.add('bg-indigo-600', 'text-white');

            // Clear existing players
            const playerInputs = document.getElementById('playerInputs');
            playerInputs.innerHTML = '';

            // Add human player
            const humanDiv = document.createElement('div');
            humanDiv.className = 'flex items-center';
            humanDiv.innerHTML = `
                <input type="text" placeholder="Player 1" class="player-name flex-1 border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
                <button class="ml-2 text-red-500 hover:text-red-700" onclick="removePlayer(this)" disabled>
                    <i class="fas fa-times"></i>
                </button>
            `;
            playerInputs.appendChild(humanDiv);

            // Add computer player if in computer mode
            if (mode === 'computer') {
                const computerDiv = document.createElement('div');
                computerDiv.className = 'flex items-center';
                computerDiv.innerHTML = `
                    <input type="text" value="Computer" readonly class="player-name flex-1 border border-gray-300 rounded px-3 py-2 bg-gray-100">
                    <button class="ml-2 text-red-500 hover:text-red-700" onclick="removePlayer(this)">
                        <i class="fas fa-times"></i>
                    </button>
                `;
                playerInputs.appendChild(computerDiv);
            }
        }

        function addPlayer() {
            const playerInputs = document.getElementById('playerInputs');
            const playerCount = playerInputs.children.length + 1;
            
            const playerDiv = document.createElement('div');
            playerDiv.className = 'flex items-center';
            playerDiv.innerHTML = `
                <input type="text" placeholder="Player ${playerCount}" class="player-name flex-1 border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
                <button class="ml-2 text-red-500 hover:text-red-700" onclick="removePlayer(this)">
                    <i class="fas fa-times"></i>
                </button>
            `;
            
            playerInputs.appendChild(playerDiv);
            
            // Disable remove button if there's only one player left
            if (playerInputs.children.length === 1) {
                playerDiv.querySelector('button').disabled = true;
            } else {
                playerInputs.querySelectorAll('button').forEach(btn => {
                    btn.disabled = false;
                });
            }
        }

        function removePlayer(button) {
            const playerDiv = button.parentNode;
            const playerInputs = document.getElementById('playerInputs');
            const playerName = playerDiv.querySelector('.player-name').value;
            
            // Don't allow removing the last human player
            const humanPlayers = Array.from(playerInputs.children).filter(div => 
                !div.querySelector('.player-name').value.includes('Computer')
            );
            
            if (humanPlayers.length > 1 || playerName.includes('Computer')) {
                playerDiv.remove();
                
                // Disable remove buttons if only one human player left
                const remainingHumanPlayers = Array.from(playerInputs.children).filter(div => 
                    !div.querySelector('.player-name').value.includes('Computer')
                );
                
                if (remainingHumanPlayers.length === 1) {
                    remainingHumanPlayers[0].querySelector('button').disabled = true;
                }
            }
        }

        function startGame() {
            // Start background music
            document.getElementById('bgMusic').play();
            document.getElementById('musicToggle').innerHTML = '<i class="fas fa-music mr-2"></i> Pause Music';
            // Get player names
            gameState.players = [];
            const playerNames = document.querySelectorAll('.player-name');
            playerNames.forEach(input => {
                let name = input.value.trim();
                if (!name) {
                    name = input.hasAttribute('readonly') ? 'Computer' : `Player ${gameState.players.length + 1}`;
                }
                gameState.players.push({
                    name: name,
                    score: 0,
                    completedCategories: 0,
                    isComputer: name.includes('Computer')
                });
            });
            
            // Get selected categories
            gameState.categories = [];
            document.querySelectorAll('input[type="checkbox"]:checked').forEach(checkbox => {
                gameState.categories.push(checkbox.value);
            });
            
            // Hide/show category columns
            const allCategories = ['Name', 'City', 'Animal', 'Food', 'Job', 'Verb', 'Object'];
            allCategories.forEach(category => {
                const header = document.getElementById(`${category.toLowerCase()}Header`);
                const inputContainer = document.getElementById(`${category.toLowerCase()}InputContainer`);
                
                if (gameState.categories.includes(category)) {
                    if (header) header.classList.remove('hidden');
                    if (inputContainer) inputContainer.classList.remove('hidden');
                } else {
                    if (header) header.classList.add('hidden');
                    if (inputContainer) inputContainer.classList.add('hidden');
                }
            });
            
            // Initialize game state
            gameState.round = 1;
            gameState.isGameRunning = false;
            gameState.playerAnswers = {};
            gameState.players.forEach(player => {
                gameState.playerAnswers[player.name] = {};
            });
            
            // Update UI
            setupModal.classList.add('hidden');
            gameContainer.classList.remove('hidden');
            updateScoreboard();
            
            // Start first round
            startRound();
        }

        function resetGame() {
            // Pause background music when resetting
            document.getElementById('bgMusic').pause();
            document.getElementById('musicToggle').innerHTML = '<i class="fas fa-music mr-2"></i> Play Music';
            winnerModal.classList.add('hidden');
            showSetupModal();
        }

        // Game round functions
        function startRound() {
            gameState.isGameRunning = true;
            gameState.timeLeft = 60;
            updateTimerDisplay();
            
            // Select a random letter (excluding Q, X, Y, Z for better gameplay)
            const letters = 'ABCDEFGHIJKLMNOPRSTUVW';
            gameState.currentLetter = letters[Math.floor(Math.random() * letters.length)];
            document.getElementById('currentLetter').textContent = gameState.currentLetter;
            document.getElementById('roundNumber').textContent = gameState.round;
            
            // Clear previous answers
            gameState.players.forEach(player => {
                gameState.playerAnswers[player.name] = {};
            });
            
            // Clear input fields
            document.querySelectorAll('.category-input').forEach(input => {
                input.value = '';
            });
            
            // Focus first input
            const firstInput = document.querySelector('.category-input');
            if (firstInput) firstInput.focus();
            
            // Start timer
            gameState.timer = setInterval(() => {
                gameState.timeLeft--;
                updateTimerDisplay();
                
                if (gameState.timeLeft <= 0) {
                    stopGame();
                }
            }, 1000);
            
            // Enable stop button
            stopBtn.disabled = false;
            stopBtn.classList.remove('opacity-50');
            stopBtn.classList.add('hover:bg-red-700');
            
            // Disable next round button
            nextRoundBtn.disabled = true;
            nextRoundBtn.classList.add('opacity-50');
            
            // If playing against computer, set computer answers
            if (gameState.gameMode === 'computer') {
                setTimeout(() => {
                    gameState.players.forEach(player => {
                        if (player.name.startsWith('Computer')) {
                            gameState.categories.forEach(category => {
                                const possibleAnswers = gameState.computerAnswers[category].filter(word => 
                                    word.charAt(0).toUpperCase() === gameState.currentLetter
                                );
                                if (possibleAnswers.length > 0) {
                                    gameState.playerAnswers[player.name][category] = possibleAnswers[Math.floor(Math.random() * possibleAnswers.length)];
                                }
                            });
                        }
                    });
                    updateScoreboard();
                }, Math.random() * 20000 + 5000); // Computer answers between 5-25 seconds
            }
        }

        function pauseGame() {
            clearInterval(gameState.timer);
            gameState.isGameRunning = false;
        }

        function resumeGame() {
            if (!gameState.isGameRunning) {
                gameState.isGameRunning = true;
                gameState.timer = setInterval(() => {
                    gameState.timeLeft--;
                    updateTimerDisplay();
                    
                    if (gameState.timeLeft <= 0) {
                        stopGame();
                    }
                }, 1000);
            }
        }

        function stopGame() {
            if (!gameState.isGameRunning) return;
            
            clearInterval(gameState.timer);
            gameState.isGameRunning = false;
            
            // Disable stop button
            stopBtn.disabled = true;
            stopBtn.classList.add('opacity-50');
            stopBtn.classList.remove('hover:bg-red-700');
            
            // Enable next round button
            nextRoundBtn.disabled = false;
            nextRoundBtn.classList.remove('opacity-50');
            
            // Get human player answers
            gameState.categories.forEach(category => {
                const input = document.getElementById(`${category.toLowerCase()}Input`);
                if (input) {
                    const playerName = gameState.players[0].name; // Assuming first player is human
                    gameState.playerAnswers[playerName][category] = input.value.trim();
                }
            });
            
            // Calculate scores
            calculateScores();
            
            // Show results and answer comparison
            showResults();
            showAnswerComparison();
        }

        function nextRound() {
            resultsModal.classList.add('hidden');
            
            // Check if game is over (all categories completed by any player)
            const winner = gameState.players.find(player => 
                player.completedCategories >= gameState.categories.length
            );
            
            if (winner) {
                showWinner(winner);
            } else {
                gameState.round++;
                startRound();
            }
        }

        function updateTimerDisplay() {
            timerElement.textContent = gameState.timeLeft;
            
            if (gameState.timeLeft <= 10) {
                timerElement.classList.add('text-red-600', 'animate-pulse-custom');
                if (gameState.timeLeft > 0) {
                    document.getElementById('tickSound').play();
                }
            } else {
                timerElement.classList.remove('text-red-600', 'animate-pulse-custom');
            }
        }

        // Scoreboard functions
        function updateScoreboard() {
            const scoreboardBody = document.getElementById('scoreboardBody');
            scoreboardBody.innerHTML = '';
            
            gameState.players.forEach(player => {
                const row = document.createElement('tr');
                row.className = 'hover:bg-gray-50';
                
                // Player name cell
                const nameCell = document.createElement('td');
                nameCell.className = 'py-3 px-4 font-medium';
                nameCell.textContent = player.name;
                row.appendChild(nameCell);
                
                // Category cells
                gameState.categories.forEach(category => {
                    const cell = document.createElement('td');
                    cell.className = 'py-3 px-4';
                    
                    const answer = gameState.playerAnswers[player.name][category];
                    if (answer !== undefined && answer !== '') {
                        cell.textContent = answer;
                    } else {
                        cell.innerHTML = '<span class="text-gray-400">-</span>';
                    }
                    
                    row.appendChild(cell);
                });
                
                // Score cell
                const scoreCell = document.createElement('td');
                scoreCell.className = 'py-3 px-4 font-bold';
                scoreCell.textContent = player.score;
                row.appendChild(scoreCell);
                
                scoreboardBody.appendChild(row);
            });
        }

        function calculateScores() {
            // Reset completed categories count
            gameState.players.forEach(player => {
                player.completedCategories = 0;
            });
            
            // Calculate scores for each category
            gameState.categories.forEach(category => {
                const answers = {};
                
                // Count occurrences of each answer
                gameState.players.forEach(player => {
                    const answer = gameState.playerAnswers[player.name][category];
                    if (answer && answer !== '') {
                        const key = answer.toLowerCase();
                        answers[key] = (answers[key] || 0) + 1;
                    }
                });
                
                // Assign points
                gameState.players.forEach(player => {
                    const answer = gameState.playerAnswers[player.name][category];
                    if (answer && answer !== '') {
                        const key = answer.toLowerCase();
                        
                        if (answers[key] === 1) {
                            // Unique answer - 10 points
                            player.score += 10;
                        } else {
                            // Repeated answer - 5 points
                            player.score += 5;
                        }
                        
                        // Count completed categories
                        player.completedCategories++;
                    }
                });
            });
            
            updateScoreboard();
        }

        function showResults() {
            document.getElementById('stopSound').play();
            
            const resultsBody = document.getElementById('resultsBody');
            resultsBody.innerHTML = '';
            
            // Sort players by score (descending)
            const sortedPlayers = [...gameState.players].sort((a, b) => b.score - a.score);
            
            sortedPlayers.forEach((player, index) => {
                const row = document.createElement('tr');
                
                // Player name cell
                const nameCell = document.createElement('td');
                nameCell.className = 'py-3 px-4 font-medium';
                nameCell.textContent = player.name;
                row.appendChild(nameCell);
                
                // Score cell
                const scoreCell = document.createElement('td');
                scoreCell.className = 'py-3 px-4 font-bold';
                scoreCell.textContent = player.score;
                row.appendChild(scoreCell);
                
                // Details cell
                const detailsCell = document.createElement('td');
                detailsCell.className = 'py-3 px-4';
                
                const completedCount = player.completedCategories;
                const totalCategories = gameState.categories.length;
                detailsCell.textContent = `${completedCount}/${totalCategories} categories`;
                
                row.appendChild(detailsCell);
                
                resultsBody.appendChild(row);
            });
            
            resultsModal.classList.remove('hidden');
        }

        function showAnswerComparison() {
            const comparisonBody = document.getElementById('comparisonBody');
            comparisonBody.innerHTML = '';
            
            const currentPlayer = gameState.players[0]; // Assuming first player is human
            document.getElementById('currentPlayerName').textContent = currentPlayer.name;
            
            gameState.categories.forEach(category => {
                const row = document.createElement('tr');
                row.className = 'border-b border-gray-200';
                
                // Category cell
                const categoryCell = document.createElement('td');
                categoryCell.className = 'py-2 px-3 font-medium';
                categoryCell.textContent = category;
                row.appendChild(categoryCell);
                
                // Player's answer cell
                const playerAnswerCell = document.createElement('td');
                playerAnswerCell.className = 'py-2 px-3';
                const playerAnswer = gameState.playerAnswers[currentPlayer.name][category] || '-';
                playerAnswerCell.textContent = playerAnswer;
                row.appendChild(playerAnswerCell);
                
                // Others' answers cell
                const othersCell = document.createElement('td');
                othersCell.className = 'py-2 px-3';
                
                const otherAnswers = [];
                gameState.players.slice(1).forEach(player => {
                    const answer = gameState.playerAnswers[player.name][category];
                    if (answer) otherAnswers.push(`${player.name}: ${answer}`);
                });
                
                othersCell.textContent = otherAnswers.join(', ') || '-';
                row.appendChild(othersCell);
                
                comparisonBody.appendChild(row);
            });
        }

        function showWinner(winner) {
            document.getElementById('winSound').play();
            document.getElementById('winnerName').textContent = winner.name;
            
            const finalScores = document.getElementById('finalScores');
            finalScores.innerHTML = '';
            
            // Sort players by score (descending)
            const sortedPlayers = [...gameState.players].sort((a, b) => b.score - a.score);
            
            sortedPlayers.forEach((player, index) => {
                const scoreDiv = document.createElement('div');
                scoreDiv.className = 'flex justify-between items-center';
                
                const nameSpan = document.createElement('span');
                nameSpan.className = 'font-medium';
                nameSpan.textContent = player.name;
                
                const scoreSpan = document.createElement('span');
                scoreSpan.className = 'font-bold';
                scoreSpan.textContent = player.score;
                
                scoreDiv.appendChild(nameSpan);
                scoreDiv.appendChild(scoreSpan);
                finalScores.appendChild(scoreDiv);
            });
            
            winnerModal.classList.remove('hidden');
        }
    </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=Jocaa91/stop" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>