-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1086 lines (931 loc) · 42 KB
/
index.html
File metadata and controls
1086 lines (931 loc) · 42 KB
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
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- SEO Meta Tags -->
<title>TalkOrDrink - Game Bài Gen Z | Thử Thách & Sự Thật Online</title>
<meta name="description"
content="Chơi Talk Or Drink Online miễn phí! Game bài Drinking Game cực cuốn cho Gen Z: Check Var người yêu cũ, Góc chữa lành, Đại hội Flex. Thử thách Truth or Dare vui nhộn cho mọi bữa tiệc.">
<meta name="keywords"
content="talkordrink, talk or drink, drinking game online, game bài uống rượu, truth or dare online, board game việt hóa, game check var, game gen z, game tiệc tùng">
<meta name="author" content="nconghau">
<link rel="canonical" href="https://talkordrink.surge.sh/">
<!-- Open Graph / Facebook / Zalo -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://talkordrink.surge.sh/">
<meta property="og:title" content="TalkOrDrink - Game Bài Gen Z | Thử Thách & Sự Thật Online">
<meta property="og:description"
content="Game bài Drinking Game cực cuốn cho Gen Z. Chơi miễn phí ngay trên điện thoại không cần cài đặt! 🍻">
<meta property="og:image"
content="https://res.cloudinary.com/dkeupjars/image/upload/v1765720971/other_project/talkordrink-banner-03_gyssmx.png">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://talkordrink.surge.sh/">
<meta property="twitter:title" content="TalkOrDrink - Game Bài Gen Z | Thử Thách & Sự Thật Online">
<meta property="twitter:description" content="Chơi Talk Or Drink Online miễn phí! Drinking Game cực cuốn cho Gen Z.">
<meta property="twitter:image"
content="https://res.cloudinary.com/dkeupjars/image/upload/v1765720971/other_project/talkordrink-banner-03_gyssmx.png">
<!-- Favicon (using emoji as temporary favicon) -->
<link rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🍻</text></svg>">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;900&family=Pixelify+Sans:wght@400;500;600;700;900&display=swap"
rel="stylesheet">
<!-- Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Html2Canvas -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<!-- Canvas Confetti -->
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.6.0/dist/confetti.browser.min.js"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
'y2k-pink': '#FF00FF',
'y2k-green': '#00FF00',
'y2k-blue': '#00FFFF',
'y2k-yellow': '#FFFF00',
'neon-purple': '#bc13fe',
},
fontFamily: {
'sans': ['"Be Vietnam Pro"', 'sans-serif'],
'pixel': ['"Pixelify Sans"', 'sans-serif'],
'display': ['"Be Vietnam Pro"', 'sans-serif'],
},
boxShadow: {
'retro': '4px 4px 0px 0px #000',
'retro-sm': '2px 2px 0px 0px #000',
'retro-lg': '8px 8px 0px 0px #000',
'glow': '0 0 10px #FF00FF, 0 0 20px #FF00FF',
},
animation: {
'bounce-slight': 'bounce-slight 2s infinite',
'float': 'float 3s ease-in-out infinite',
'slide-up': 'slideUp 0.5s ease-out forwards',
'pulse-fast': 'pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite',
},
keyframes: {
'bounce-slight': {
'0%, 100%': { transform: 'translateY(0)' },
'50%': { transform: 'translateY(-5px)' },
},
slideUp: {
'0%': { transform: 'translateY(20px)', opacity: '0' },
'100%': { transform: 'translateY(0)', opacity: '1' },
}
}
}
}
}
</script>
<style>
body {
font-family: 'Be Vietnam Pro', sans-serif;
background-color: #f0f0f0;
background-image:
radial-gradient(#000 1px, transparent 1px),
linear-gradient(to bottom right, #f0f0f0 0%, #e0e0e0 100%);
background-size: 20px 20px, 100% 100%;
overflow-x: hidden;
overscroll-behavior-y: none;
}
/* Use pixel font only for very specific decorative elements if needed, otherwise default to readable font */
.pixel-font {
font-family: 'Be Vietnam Pro', sans-serif;
/* Overriding pixel font class to use readable font as requested */
letter-spacing: -0.02em;
}
/* Keep header logo as pixel if desired, creating a specific class for it */
.brand-font {
font-family: 'Pixelify Sans', sans-serif;
}
/* Animated Background Elements */
.bg-shape {
position: absolute;
z-index: -1;
opacity: 0.1;
animation: float 6s infinite ease-in-out;
}
/* 3D Flip Card Styles */
.perspective-1000 {
perspective: 1000px;
}
.transform-style-3d {
transform-style: preserve-3d;
}
.backface-hidden {
backface-visibility: hidden;
}
.rotate-y-180 {
transform: rotateY(180deg);
}
/* Hide Scrollbar */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
.no-scrollbar {
-ms-overflow-style: none;
scrollbar-width: none;
}
/* Custom Animations */
.card-special {
background-image: linear-gradient(135deg, #FF00FF 0%, #bc13fe 100%);
color: white;
text-shadow: 2px 2px 0px #000;
}
.card-special-icon {
animation: spin 3s linear infinite;
}
@keyframes spin {
100% {
transform: rotate(360deg);
}
}
.transition-screen {
transition: transform 0.4s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0.4s;
}
.fade-enter {
opacity: 0;
transform: scale(0.95);
}
.fade-enter-active {
opacity: 1;
transform: scale(1);
}
.fade-exit {
opacity: 1;
transform: scale(1);
}
.fade-exit-active {
opacity: 0;
transform: scale(1.05);
}
.pattern-grid {
background-image: linear-gradient(0deg, transparent 24%, rgba(0, 0, 0, .3) 25%, rgba(0, 0, 0, .3) 26%, transparent 27%, transparent 74%, rgba(0, 0, 0, .3) 75%, rgba(0, 0, 0, .3) 76%, transparent 77%, transparent), linear-gradient(90deg, transparent 24%, rgba(0, 0, 0, .3) 25%, rgba(0, 0, 0, .3) 26%, transparent 27%, transparent 74%, rgba(0, 0, 0, .3) 75%, rgba(0, 0, 0, .3) 76%, transparent 77%, transparent);
background-size: 30px 30px;
}
/* Typography Polish */
.text-glow {
text-shadow: 0 0 5px rgba(255, 255, 255, 0.8), 0 0 10px rgba(255, 0, 255, 0.5);
}
@keyframes float {
0% {
transform: translateY(0px);
}
50% {
transform: translateY(-5px);
}
100% {
transform: translateY(0px);
}
}
.animate-float {
animation: float 3s ease-in-out infinite;
}
@keyframes popup-bounce {
0% {
transform: scale(0);
}
60% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
.popup-animate {
animation: popup-bounce 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
</style>
<script>(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-P2W79B6T');</script>
<script>
// --- AUDIO CONTROLLER (Web Audio API) ---
const AudioController = {
ctx: null,
isMuted: false,
init() {
if (!this.ctx) {
const AudioContext = window.AudioContext || window.webkitAudioContext;
this.ctx = new AudioContext();
}
},
unlock() {
if (this.ctx && this.ctx.state === 'suspended') {
this.ctx.resume().then(() => {
console.log("AudioContext unlocked!");
});
}
},
toggleMute() {
this.isMuted = !this.isMuted;
const btn = document.getElementById('sound-toggle-btn');
if (this.isMuted) {
btn.innerHTML = '<i class="fa-solid fa-volume-xmark text-red-500"></i>';
btn.classList.add('border-red-500');
} else {
btn.innerHTML = '<i class="fa-solid fa-volume-high text-green-600"></i>';
btn.classList.remove('border-red-500');
this.play('pop');
}
},
play(type) {
if (this.isMuted) return;
// Lazy init
if (!this.ctx) this.init();
// Try to resume if strictly needed, though 'unlock' should handle it
if (this.ctx.state === 'suspended') this.ctx.resume();
const t = this.ctx.currentTime;
const osc = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.connect(gain);
gain.connect(this.ctx.destination);
switch (type) {
case 'pop':
osc.type = 'sine';
osc.frequency.setValueAtTime(800, t);
osc.frequency.exponentialRampToValueAtTime(400, t + 0.1);
gain.gain.setValueAtTime(0.1, t);
gain.gain.exponentialRampToValueAtTime(0.01, t + 0.1);
osc.start(t);
osc.stop(t + 0.1);
break;
case 'flip':
osc.type = 'triangle';
osc.frequency.setValueAtTime(300, t);
osc.frequency.linearRampToValueAtTime(600, t + 0.15);
gain.gain.setValueAtTime(0.05, t);
gain.gain.linearRampToValueAtTime(0, t + 0.15);
osc.start(t);
osc.stop(t + 0.15);
break;
case 'special':
osc.type = 'square';
osc.frequency.setValueAtTime(500, t);
osc.frequency.setValueAtTime(800, t + 0.1);
gain.gain.setValueAtTime(0.05, t);
gain.gain.exponentialRampToValueAtTime(0.01, t + 0.4);
osc.start(t);
osc.stop(t + 0.4);
const osc2 = this.ctx.createOscillator();
const gain2 = this.ctx.createGain();
osc2.connect(gain2);
gain2.connect(this.ctx.destination);
osc2.type = 'sine';
osc2.frequency.setValueAtTime(300, t);
osc2.frequency.setValueAtTime(600, t + 0.1);
gain2.gain.setValueAtTime(0.1, t);
gain2.gain.exponentialRampToValueAtTime(0.01, t + 0.4);
osc2.start(t);
osc2.stop(t + 0.4);
break;
}
}
};
// --- MUSIC CONTROLLER ---
const MusicController = {
audio: null,
isPlaying: false,
userInteracted: false,
init() {
this.audio = document.getElementById('bg-music');
this.audio.volume = 0.5;
},
toggle() {
if (!this.audio) this.init();
const btn = document.getElementById('music-toggle-btn');
if (this.isPlaying) {
this.audio.pause();
this.isPlaying = false;
btn.innerHTML = '<i class="fa-solid fa-music text-gray-400 opacity-50"></i>';
btn.classList.add('border-gray-400');
} else {
// Must be triggered by user interaction
const playPromise = this.audio.play();
if (playPromise !== undefined) {
playPromise.then(_ => {
this.isPlaying = true;
btn.innerHTML = '<i class="fa-solid fa-music text-y2k-pink animate-pulse"></i>';
btn.classList.remove('border-gray-400');
})
.catch(error => {
console.log("Music play prevented:", error);
// UI should reflect paused state if failed
this.isPlaying = false;
btn.innerHTML = '<i class="fa-solid fa-music text-gray-400 opacity-50"></i>';
btn.classList.add('border-gray-400');
});
}
}
},
// iOS UNLOCK FUNCTION
unlockAndPlay() {
if (this.userInteracted) return;
this.userInteracted = true;
// 1. Unlock Music
if (!this.audio) this.init();
if (!this.isPlaying) {
this.toggle(); // Try to play
}
// 2. Unlock SFX
AudioController.init();
AudioController.unlock();
// Remove listeners
document.removeEventListener('click', MusicController.unlockAndPlay);
document.removeEventListener('touchstart', MusicController.unlockAndPlay);
console.log("Audio Unlocked via interaction");
}
};
</script>
</head>
<body class="h-screen text-black select-none flex flex-col overflow-hidden relative">
<script>
// Add global unlock listeners immediately
document.addEventListener('click', () => MusicController.unlockAndPlay(), { once: true });
document.addEventListener('touchstart', () => MusicController.unlockAndPlay(), { once: true });
</script>
<!-- BACKGROUND MUSIC -->
<audio id="bg-music" loop>
<source src="./assets/music.mp3" type="audio/mp3">
</audio>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-P2W79B6T" height="0" width="0"
style="display:none;visibility:hidden"></iframe></noscript>
<!-- Background Shapes -->
<div class="fixed top-10 left-[-20px] text-6xl text-y2k-pink opacity-20 animate-float" style="animation-delay: 0s;">★
</div>
<div class="fixed bottom-20 right-[-10px] text-8xl text-y2k-blue opacity-20 animate-float"
style="animation-delay: 1s;">●</div>
<div class="fixed top-1/2 left-10 text-4xl text-y2k-green opacity-20 animate-float" style="animation-delay: 2s;">▲
</div>
<!-- Container -->
<div id="app"
class="w-full md:max-w-2xl mx-auto h-full relative bg-white/95 backdrop-blur-sm border-x-0 md:border-x-4 border-black box-border flex flex-col shadow-2xl overflow-hidden z-10">
<!-- Header Marquee -->
<div
class="shrink-0 bg-y2k-blue border-b-4 border-black py-2 overflow-hidden whitespace-nowrap z-20 shadow-retro-sm flex items-center justify-between pr-4 relative">
<div class="inline-block animate-[marquee_10s_linear_infinite] flex-1">
<span class="pixel-font font-bold text-sm mx-4">★ TALK OR DRINK ★</span>
<span class="pixel-font font-bold text-sm mx-4">GEN Z EDITION</span>
<span class="pixel-font font-bold text-sm mx-4">★ TALK OR DRINK ★</span>
<span class="pixel-font font-bold text-sm mx-4">NO ALCOHOL NO PARTY</span>
<span class="pixel-font font-bold text-sm mx-4">★ TALK OR DRINK ★</span>
</div>
<!-- Music Toggle -->
<button id="music-toggle-btn" event.stopPropagation();"
class="absolute right-12 top-1/2 -translate-y-1/2 bg-white border-2 border-black w-8 h-8 flex items-center justify-center shadow-retro-sm hover:translate-y-0.5 hover:shadow-none transition-all z-30">
<i class="fa-solid fa-music text-gray-400 opacity-50"></i>
</button>
<!-- Sound Toggle -->
<button id="sound-toggle-btn" event.stopPropagation();"
class="absolute right-2 top-1/2 -translate-y-1/2 bg-white border-2 border-black w-8 h-8 flex items-center justify-center shadow-retro-sm hover:translate-y-0.5 hover:shadow-none transition-all z-30">
<i class="fa-solid fa-volume-high text-green-600"></i>
</button>
</div>
<!-- LANDING SCREEN -->
<div id="landing-screen" class="flex-1 flex flex-col p-4 w-full h-full overflow-hidden transition-screen">
<div class="text-center mb-4 mt-2 shrink-0">
<h1
class="pixel-font font-bold text-5xl leading-none text-y2k-pink drop-shadow-[4px_4px_0_rgba(0,0,0,1)] uppercase tracking-tighter hover:scale-105 transition-transform duration-300">
Talk<br>Or<br>Drink
</h1>
<p
class="mt-4 font-bold text-lg bg-y2k-green inline-block px-3 py-1 border-2 border-black shadow-retro-sm transform -rotate-2 pixel-font hover:rotate-0 transition-transform cursor-default">
Chọn bộ bài đi fen!
</p>
</div>
<!-- Pack Grid -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 overflow-y-auto pb-20 px-1 no-scrollbar flex-1" id="pack-grid">
<!-- Dynamically populated -->
</div>
<!-- Custom Deck Button (Fixed at bottom of grid area) -->
<div class="mt-2 text-center shrink-0">
<button >
class="w-full md:w-auto bg-white border-2 border-black border-dashed px-6 py-3 font-bold text-gray-500 hover:text-black hover:border-solid hover:bg-gray-50 transition-all duration-300 shadow-sm hover:shadow-retro-sm">
<i class="fa-solid fa-plus mr-2"></i> Tự tạo bộ bài (Custom)
</button>
</div>
<footer class="mt-auto py-4 border-t border-slate-200 bg-slate-50 shrink-0">
<div class="flex flex-row items-center justify-center gap-4 text-center text-slate-600 text-sm">
<p>@nconghau - v1.0.0</p>
<a href="https://github.com/nconghau/talkordrink" target="_blank" rel="noopener noreferrer"
class="text-slate-500 hover:text-black transition-colors duration-300" aria-label="GitHub Repository">
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path fill-rule="evenodd"
d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"
clip-rule="evenodd" />
</svg>
</a>
</div>
</footer>
</div>
<!-- Custom Deck Modal -->
<div id="custom-deck-modal" class="hidden fixed inset-0 bg-black/80 z-50 flex items-center justify-center p-4">
<div class="bg-white w-full max-w-lg border-4 border-black shadow-retro p-6 relative">
<button >
class="absolute top-2 right-2 text-2xl font-bold hover:text-red-500">×</button>
<h2 class="text-2xl font-bold font-pixel uppercase mb-4 text-center">Tự tạo bộ bài</h2>
<div class="space-y-4">
<div>
<label class="block font-bold mb-1">Tên bộ bài:</label>
<input type="text" id="custom-deck-name" placeholder="Ví dụ: Team Building 2024"
class="w-full border-2 border-black p-2 font-sans focus:outline-none focus:bg-yellow-50">
</div>
<div>
<label class="block font-bold mb-1">Nội dung (Mỗi dòng 1 thẻ):</label>
<textarea id="custom-deck-content" rows="6"
placeholder="Người yêu cũ tên gì? Hát một bài tặng người bên trái Uống 1 ly..."
class="w-full border-2 border-black p-2 font-sans focus:outline-none focus:bg-yellow-50 resize-none"></textarea>
<p class="text-xs text-gray-500 mt-1">* Nhập ít nhất 5 dòng để chơi vui hơn nha!</p>
</div>
<div class="pt-2">
<button >
class="w-full bg-y2k-green border-2 border-black shadow-retro px-6 py-3 font-bold text-lg hover:translate-y-1 hover:shadow-none transition-all uppercase">
Vào chơi ngay! 🚀
</button>
</div>
</div>
</div>
</div>
<!-- GAME SCREEN -->
<div id="game-screen"
class="hidden flex-1 flex flex-col p-4 w-full h-full relative overflow-hidden transition-screen opacity-0">
<!-- Navbar -->
<div class="flex justify-between items-center mb-4 shrink-0 z-20">
<button >
class="bg-gray-200 border-2 border-black px-3 py-1 shadow-retro-sm text-sm hover:bg-gray-300 active:translate-y-1 active:shadow-none font-bold pixel-font transition-colors">
<i class="fa-solid fa-chevron-left mr-1"></i> MENU
</button>
<div class="pixel-font font-bold text-xs bg-black text-white px-3 py-1 uppercase tracking-wider shadow-retro-sm"
id="pack-title-display">
PACK NAME
</div>
</div>
<!-- Card Showcase -->
<div id="capture-area"
class="flex-1 flex items-center justify-center mb-4 perspective-1000 relative w-full h-full min-h-0">
<div id="flip-card"
class="relative w-full h-full max-h-[60vh] aspect-[3/4] transition-all duration-700 transform-style-3d cursor-pointer"
>
<!-- Front -->
<div
class="absolute inset-0 w-full h-full bg-y2k-pink border-4 border-black shadow-retro flex flex-col items-center justify-center backface-hidden z-10 pattern-grid group hover:bg-neon-purple transition-colors duration-300">
<div
class="border-4 border-black p-4 bg-white transform rotate-2 group-hover:rotate-0 transition-transform duration-300 shadow-retro-sm">
<h2 class="pixel-font font-bold text-3xl text-center leading-tight header-glow">TALK<br>OR<br>DRINK</h2>
</div>
<p
class="mt-6 font-bold bg-y2k-yellow border-2 border-black px-3 py-1 animate-pulse pixel-font text-sm shadow-retro-sm">
CHẠM ĐỂ LẬT</p>
</div>
<!-- Back -->
<div id="card-back"
class="absolute inset-0 w-full h-full bg-white border-4 border-black shadow-retro flex flex-col items-center justify-center backface-hidden rotate-y-180 p-6 z-0 overflow-hidden relative">
<!-- Decorative Icons -->
<div class="absolute top-2 left-2 text-y2k-pink opacity-50"><i class="fa-solid fa-star"></i></div>
<div class="absolute top-2 right-2 text-y2k-pink opacity-50"><i class="fa-solid fa-star"></i></div>
<!-- Content -->
<div cla
A470
ss="flex-1 flex items-center justify-center text-center w-full z-10">
<p id="card-content"
class="text-xl md:text-2xl lg:text-3xl font-bold leading-snug uppercase transform -rotate-1 break-words whitespace-pre-wrap max-h-full overflow-y-auto w-full no-scrollbar">
<!-- Card Content Goes Here -->
</p>
</div>
<!-- Special Effect Layer -->
<div id="special-effect-layer" class="absolute inset-0 pointer-events-none hidden z-0">
<!-- Gradient or pattern -->
</div>
<div
class="absolute bottom-2 left-2 text-[10px] text-gray-500 pixel-font font-bold uppercase tracking-widest bg-gray-100 px-2 py-0.5 rounded border border-gray-300"
id="deck-tag">
<!-- Deck Name -->
</div>
<div class="absolute bottom-2 right-2 text-[10px] text-gray-400 pixel-font opacity-50">talkordrink.surge.sh
</div>
</div>
</div>
</div>
<!-- Controls -->
<div class="grid grid-cols-2 md:grid-cols-4 gap-3 pb-2 shrink-0 z-20">
<!-- Next Button (Middle Desktop) -->
<div class="col-span-2 md:col-span-2 md:order-2">
<button >
class="w-full bg-y2k-blue border-4 border-black shadow-retro py-3 pixel-font font-bold text-lg hover:brightness-110 active:translate-y-1 active:shadow-none transition-all group">
TIẾP THEO <i class="fa-solid fa-forward ml-2 group-hover:translate-x-1 transition-transform"></i>
</button>
</div>
<!-- Penalty (Left Desktop) -->
<div class="col-span-1 md:col-span-1 md:order-1">
<button >
class="w-full bg-red-500 text-white border-4 border-black shadow-retro py-3 font-bold text-sm pixel-font hover:bg-red-600 active:translate-y-1 active:shadow-none transition-all uppercase h-full flex items-center justify-center">
Thôi, Uống! 🍺
</button>
</div>
<!-- Share (Right Desktop) -->
<div class="col-span-1 md:col-span-1 md:order-3">
<button >
class="w-full bg-white border-4 border-black shadow-retro py-3 font-bold text-sm pixel-font hover:bg-gray-100 active:translate-y-1 active:shadow-none transition-all uppercase h-full flex items-center justify-center">
Chụp lại 📸
</button>
</div>
</div>
</div>
<!-- Penalty Popup -->
<div id="penalty-popup"
class="hidden fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4"
>
<div
class="bg-y2k-yellow border-4 border-black w-full max-w-xs p-6 shadow-retro-lg text-center popup-animate relative">
<div class="absolute -top-6 -right-6 text-4xl animate-bounce">💀</div>
<h3 class="pixel-font text-xl mb-4">HÌNH PHẠT!</h3>
<p id="penalty-text" class="text-4xl font-bold uppercase mb-6 leading-tight"></p>
<button class="bg-black text-white pixel-font text-xs py-2 px-4 border-2 border-white shadow-retro-sm">
CHẤP NHẬN
</button>
</div>
</div>
<!-- Reshuffle/End Screen Overlay -->
<div id="reshuffle-overlay"
class="hidden fixed inset-0 z-40 bg-white/90 flex flex-col items-center justify-center p-8 text-center"
style="display: none;">
<h2 class="pixel-font text-2xl mb-4">HẾT BÀI RỒI!</h2>
<p class="mb-8 text-xl">Bạn đã chơi hết bộ này. Muốn chơi lại không?</p>
<button >
class="bg-y2k-green border-4 border-black shadow-retro px-6 py-3 pixel-font text-sm hover:scale-105 transition-transform">
XÀO LẠI BÀI ↺
</button>
<button class="mt-4 text-sm underline hover:text-y2k-pink">
Đổi bộ khác
</button>
</div>
</div>
<!-- Data & Logic -->
<script>
// --- STATE ---
let decks = [];
let currentDeckIndex = 0;
let drawPile = []; // Array of indices [0, 1, 2...]
let isFlipped = false;
const penalties = [
"1 NHẤP MÔI",
"50% LY",
"100% LY",
"ĐỒNG KHỞI (CẢ BÀN)"
];
// --- DOM ELEMENTS ---
const landingScreen = document.getElementById('landing-screen');
const packGrid = document.getElementById('pack-grid');
const gameScreen = document.getElementById('game-screen');
const packTitle = document.getElementById('pack-title-display');
const cardElement = document.getElementById('flip-card');
const cardBack = document.getElementById('card-back');
const cardContent = document.getElementById('card-content');
const penaltyPopup = document.getElementById('penalty-popup');
const penaltyText = document.getElementById('penalty-text');
const reshuffleOverlay = document.getElementById('reshuffle-overlay');
// --- INIT & DATA LOADING ---
async function initGame() {
try {
// Cache busting to ensure fresh data
const response = await fetch(`data.json?v=${new Date().getTime()}`);
if (!response.ok) throw new Error('Failed to load data');
decks = await response.json();
console.log("Loaded decks:", decks.map(d => d.name));
renderPacks();
} catch (error) {
console.error(error);
alert('Không tải được dữ liệu game. Vui lòng kiểm tra lại kết nối hoặc file data.json!');
}
}
function renderPacks() {
packGrid.innerHTML = '';
decks.forEach((deck, index) => {
const btn = document.createElement('button');
const hoverColorClass = `hover:bg-${deck.color}`;
btn.className = `group active:translate-y-1 active:shadow-none transition-all relative w-full bg-white border-4 border-black shadow-retro p-4 flex items-center ${hoverColorClass} animate-slide-up opacity-0`;
btn.style.animationDelay = `${index * 0.1}s`;
// Explicitly bind the index
btn. () {
console.log(`Clicked pack ${index}: ${deck.name}`);
startGame(index);
};
btn.innerHTML = `
<div class="w-12 h-12 bg-black text-white flex items-center justify-center text-3xl mr-4 border-2 border-white group-hover:scale-110 group-hover:rotate-6 transition-transform duration-300 shadow-sm">
${deck.icon}
</div>
<div class="text-left">
<h3 class="pixel-font text-sm mb-1 uppercase text-black font-bold group-hover:text-white group-hover:text-shadow-black transition-colors">${deck.name}</h3>
<p class="text-sm leading-tight text-gray-700 group-hover:text-black font-medium">${deck.description}</p>
</div>
`;
packGrid.appendChild(btn);
});
}
// Initialize immediately
initGame();
// --- FUNCTIONS ---
function startGame(deckIndex) {
AudioController.play('pop'); // Sound trigger
console.log(`Starting game with deck index: ${deckIndex}`);
currentDeckIndex = deckIndex;
packTitle.textContent = decks[deckIndex].name;
// Transition
landingScreen.classList.remove('fade-enter-active');
landingScreen.classList.add('fade-exit-active');
setTimeout(() => {
landingScreen.classList.add('hidden');
landingScreen.classList.remove('fade-exit-active');
gameScreen.classList.remove('hidden');
void gameScreen.offsetWidth;
gameScreen.classList.remove('opacity-0');
gameScreen.classList.add('fade-enter-active');
resetCurrentDeck();
}, 300);
}
function goHome() {
AudioController.play('pop'); // Sound trigger
gameScreen.classList.remove('fade-enter-active');
gameScreen.classList.add('opacity-0');
setTimeout(() => {
gameScreen.classList.add('hidden');
landingScreen.classList.remove('hidden');
void landingScreen.offsetWidth;
landingScreen.classList.add('fade-enter-active');
reshuffleOverlay.style.display = 'none';
}, 300);
}
// --- CUSTOM DECK LOGIC ---
const customDeckModal = document.getElementById('custom-deck-modal');
function openCustomDeckModal() {
customDeckModal.classList.remove('hidden');
}
function closeCustomDeckModal() {
customDeckModal.classList.add('hidden');
}
// Close modal when clicking outside
customDeckModal.addEventListener('click', (e) => {
if (e.target === customDeckModal) {
closeCustomDeckModal();
}
});
function startCustomDeck() {
const nameInput = document.getElementById('custom-deck-name');
const contentInput = document.getElementById('custom-deck-content');
const name = nameInput.value.trim() || "Bộ Bài Của Tui";
const rawContent = contentInput.value.trim();
if (!rawContent) {
alert("Bạn chưa nhập nội dung bộ bài kìa fen!");
return;
}
const cards = rawContent.split('\n').map(line => line.trim()).filter(line => line.length > 0);
if (cards.length < 1) {
alert("Nhập ít nhất 1 câu hỏi nha!");
return;
}
// Create new temporary deck
const newDeck = {
id: `custom_${Date.now()}`,
name: name,
description: "Bộ bài tự tạo bởi người chơi hệ Custom.",
color: "bg-white",
icon: "fa-pen-to-square",
content: cards
};
// Add to decks array
decks.push(newDeck);
const newIndex = decks.length - 1;
// Render card (optional, strictly not needed since we jump straight in, but good for returning home)
// For now, we just jump straight to game
closeCustomDeckModal();
startGame(newIndex);
// Clear inputs for next time
// nameInput.value = "";
// contentInput.value = "";
}
function resetCurrentDeck() {
reshuffleOverlay.style.display = 'none';
drawPile = Array.from({ length: decks[currentDeckIndex].content.length }, (_, i) => i);
shuffle(drawPile);
isFlipped = false;
cardElement.classList.remove('rotate-y-180');
// Clear previous content to avoid confusion
cardContent.innerText = "";
resetCardStyle();
// Update Deck Tag on Card Back
const deckTag = document.getElementById('deck-tag');
if (deckTag) {
deckTag.innerText = decks[currentDeckIndex].name;
}
}
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
function resetCardStyle() {
// Remove special styling
cardBack.className = 'absolute inset-0 w-full h-full bg-white border-4 border-black shadow-retro flex flex-col items-center justify-center backface-hidden rotate-y-180 p-6 z-0 overflow-hidden relative';
cardContent.className = 'text-xl md:text-2xl lg:text-3xl font-bold leading-snug uppercase transform -rotate-1 break-words whitespace-pre-wrap max-h-full overflow-y-auto w-full no-scrollbar';
}
function nextCard() {
if (!isFlipped) {
if (drawPile.length === 0) {
reshuffleOverlay.style.display = 'flex';
confetti({
particleCount: 100,
spread: 70,
origin: { y: 0.6 }
});
return;
}
// Get content
const cardIndex = drawPile.pop();
const text = decks[currentDeckIndex].content[cardIndex];
console.log(`Drawing card: ${text.substring(0, 20)}... from deck ${currentDeckIndex}`);
cardContent.innerText = text;
// DETECT SPECIAL CARDS
const isSpecial = text.match(/^(LÁ BÀI|SỐC|THỬ THÁCH|CHIA SẺ|TRÚNG THƯỞNG|SỰ CỐ|HOÁN ĐỔI)/i);
resetCardStyle();
if (isSpecial) {
AudioController.play('special'); // Sound trigger
triggerSpecialEffect();
cardBack.classList.remove('bg-white');
cardBack.classList.add('card-special');
cardContent.classList.add('text-glow');
} else {
AudioController.play('flip'); // Sound trigger
}
cardElement.classList.add('rotate-y-180');
isFlipped = true;
} else {
AudioController.play('flip'); // Sound trigger for flip back
cardElement.classList.remove('rotate-y-180');
isFlipped = false;
}
}
function triggerSpecialEffect() {
const count = 200;
const defaults = { origin: { y: 0.7 } };
function fire(particleRatio, opts) {
confetti(Object.assign({}, defaults, opts, {
particleCount: Math.floor(count * particleRatio)
}));
}
fire(0.25, { spread: 26, startVelocity: 55, });
fire(0.2, { spread: 60, });
fire(0.35, { spread: 100, decay: 0.91, scalar: 0.8 });
fire(0.1, { spread: 120, startVelocity: 25, decay: 0.92, scalar: 1.2 });
fire(0.1, { spread: 120, startVelocity: 45, });
}
function triggerPenalty() {
const randomPenalty = penalties[Math.floor(Math.random() * penalties.length)];
penaltyText.innerText = randomPenalty;
penaltyPopup.classList.remove('hidden');
}
function closePenalty() {
penaltyPopup.classList.add('hidden');
// The following lines seem to be misplaced from a different function or context.
// They are not part of the original closePenalty logic and would cause issues here.
// cardElement.classList.toggle('rotate-y-180');
// isFlipped = !isFlipped;
// AudioController.play('flip'); // Sound trigger
// if (isFlipped) {
// const randomContent = drawNextContent();
// const contentText = randomContent.text;
// const mainColor = decks[currentDeckIndex].color;
// const isSpecial = randomContent.isSpecial;
// }
}
function shareCard() {
if (!isFlipped) {
alert("Lật bài lên trước khi chụp nha fen!");
return;
}
const currentText = cardContent.innerText;
const currentDeck = decks[currentDeckIndex].name;
// Check deck type or content for specific styling
const isSpecial = currentText.match(/^(LÁ BÀI|SỐC|THỬ THÁCH|CHIA SẺ|TRÚNG THƯỞNG|SỰ CỐ|HOÁN ĐỔI)/i);
// Colors mapping based on deck index
const deckColors = ['#FFFF00', '#FF00FF', '#00FFFF', '#00FF00']; // yellow, pink, blue, green
const mainColor = deckColors[currentDeckIndex] || '#FFFF00';
// Create Wrapper
const wrapper = document.createElement('div');
wrapper.id = 'screenshot-wrapper';
wrapper.style.position = 'fixed';
wrapper.style.left = '-9999px';
wrapper.style.top = '0';
wrapper.style.width = '600px';
wrapper.style.height = '1066px'; // 9:16 ratio for stories
wrapper.style.zIndex = '-9999';
wrapper.style.display = 'flex';
wrapper.style.flexDirection = 'column';
wrapper.style.alignItems = 'center';
wrapper.style.justifyContent = 'space-between';
wrapper.style.fontFamily = '"Be Vietnam Pro", sans-serif';
wrapper.style.padding = '40px';
wrapper.style.boxSizing = 'border-box';
// Background
if (isSpecial) {
wrapper.style.background = "linear-gradient(180deg, #1a1a1a 0%, #2d002d 100%)";
wrapper.style.color = "white";
} else {
// Retro grid paper look
wrapper.style.backgroundColor = "#ffffff";
wrapper.style.color = "black";
wrapper.style.backgroundImage = `
linear-gradient(to right, #f0f0f0 1px, transparent 1px),
linear-gradient(to bottom, #f0f0f0 1px, transparent 1px)
`;
wrapper.style.backgroundSize = "40px 40px";
}
You can’t perform that action at this time.