Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
1116 lines (1056 loc) · 59 KB
/
Copy pathindex.html
File metadata and controls
1116 lines (1056 loc) · 59 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="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Outsider — Party Game</title>
<link href="https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&family=Permanent+Marker&family=Patrick+Hand&display=swap" rel="stylesheet">
<style>
:root {
--paper: #fefdf5;
--paper2: #faf8ec;
--lines: #c2d4ed;
--margin: #e87a72;
--ink: #1a3a9f;
--ink2: #2952cc;
--ink-dim: #3d5299;
--pencil: #b0b8d0;
--highlight: #f7e84a;
--highlight-alpha: rgba(247,232,74,0.55);
--highlight-pink: #ffb3d9;
--red-ink: #cc2222;
--spiral: #c8c0b0;
--line-h: 28px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
height: 100%; width: 100%;
background: var(--paper);
font-family: 'Caveat', cursive;
font-size: 18px;
overflow: hidden;
-webkit-tap-highlight-color: transparent;
touch-action: manipulation;
color: var(--ink);
}
body {
padding-left: 38px;
background-color: var(--paper);
background-image: repeating-linear-gradient(transparent 0px, transparent 27px, var(--lines) 27px, var(--lines) 28px);
background-attachment: fixed;
}
body::before {
content: '';
position: fixed; left: 0; top: 0; bottom: 0; width: 38px; z-index: 10;
pointer-events: none;
background-color: #e8e0d0;
background-image:
radial-gradient(circle at 50% 50%, #b0a898 28%, #d8d0c4 30%, #e8e0d0 52%),
linear-gradient(to right, #c8c0b0 0%, #e0d8cc 40%, #e8e0d0 100%);
background-size: 100% 32px;
background-repeat: repeat-y;
border-right: 2px solid #c0b8a8;
box-shadow: 2px 0 6px rgba(0,0,0,0.08);
}
body::after {
content: '';
position: fixed; left: 54px; top: 0; bottom: 0; width: 2px; z-index: 9;
background: var(--margin); pointer-events: none; opacity: 0.7;
}
.screen {
display: none; flex-direction: column; align-items: center;
width: 100%; max-width: 480px;
height: 100dvh; max-height: 100dvh;
padding: 20px 18px 20px 60px;
position: relative; z-index: 1;
overflow-y: auto;
}
.screen.active { display: flex; }
.screen::-webkit-scrollbar { width: 4px; }
.screen::-webkit-scrollbar-thumb { background: var(--pencil); border-radius: 4px; }
.logo {
font-family: 'Permanent Marker', cursive;
font-size: clamp(2.4rem, 9vw, 3.2rem);
color: var(--ink); letter-spacing: 0.04em; line-height: 1;
position: relative; display: inline-block;
}
.logo-sub { font-family: 'Caveat', cursive; font-size: 1rem; color: var(--ink-dim); letter-spacing: 0.05em; margin-top: 4px; }
h2 { font-family: 'Permanent Marker', cursive; font-size: 1.3rem; color: var(--ink); letter-spacing: 0.02em; position: relative; display: inline-block; }
h3 { font-family: 'Caveat', cursive; font-size: 1.05rem; color: var(--ink-dim); font-weight: 600; letter-spacing: 0.05em; }
p { font-family: 'Patrick Hand', cursive; font-size: 1rem; color: var(--ink-dim); line-height: 1.6; }
.divider { width: 80%; height: 3px; margin: 12px auto; background: var(--ink); border-radius: 2px; opacity: 0.18; transform: rotate(-0.3deg); filter: url(#sketchy); }
.btn {
display: flex; align-items: center; justify-content: center; gap: 6px;
width: 100%; padding: 12px 18px;
background: white; border: 2.5px solid var(--ink); color: var(--ink);
font-family: 'Caveat', cursive; font-size: 1.1rem; font-weight: 700; letter-spacing: 0.03em;
cursor: pointer; border-radius: 6px; position: relative;
transition: transform 0.1s, box-shadow 0.1s; filter: url(#sketchy); overflow: visible;
}
.btn::before {
content: ''; position: absolute; inset: 3px 4px; background: var(--highlight-alpha);
border-radius: 4px; z-index: 0; opacity: 0; transition: opacity 0.15s;
}
.btn:hover::before, .btn:active::before { opacity: 1; }
.btn:active { transform: translate(2px,2px) scale(0.98); }
.btn-primary:active { box-shadow: 1px 1px 0 var(--ink) !important; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary { background: var(--highlight); border-color: var(--ink); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.btn-primary::before { background: rgba(255,255,255,0.4); }
.btn-ghost { border-color: rgba(26,58,159,0.35); color: var(--ink); background: transparent; }
.btn-ghost::before { background: rgba(200,210,240,0.3); }
.btn-sm { padding: 9px 14px; font-size: 1rem; }
@keyframes readyPulse {
0%,100% { box-shadow: 0 0 0 0 rgba(247,232,74,0.8), 3px 3px 0 var(--ink); transform: scale(1) rotate(-0.5deg); }
50% { box-shadow: 0 0 0 10px rgba(247,232,74,0), 3px 3px 0 var(--ink); transform: scale(1.04) rotate(-0.5deg); }
}
.btn-ready { animation: readyPulse 1s ease-in-out infinite; background: var(--highlight) !important; }
.card-grid { display: grid; gap: 10px; width: 100%; }
.card-grid.cols2 { grid-template-columns: 1fr 1fr; }
.sel-card {
display: flex; flex-direction: column; align-items: flex-start; padding: 14px 12px;
background: white; border: 2.5px solid var(--ink); border-radius: 8px; cursor: pointer;
transition: transform 0.1s; filter: url(#sketchy); box-shadow: 3px 3px 0 var(--ink); position: relative;
}
.sel-card:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.sel-card.selected { background: var(--highlight); }
.sel-card .card-icon { font-size: 1.5rem; margin-bottom: 6px; }
.sel-card .card-title { font-family: 'Permanent Marker', cursive; font-size: 0.9rem; color: var(--ink); }
.sel-card .card-desc { font-family: 'Patrick Hand', cursive; font-size: 0.9rem; color: var(--ink-dim); margin-top: 4px; line-height: 1.4; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.chip {
padding: 5px 12px; background: white; border: 2px solid rgba(26,58,159,0.4);
border-radius: 50px; cursor: pointer; transition: all 0.15s; color: var(--ink);
font-family: 'Caveat', cursive; font-size: 1rem; filter: url(#sketchy);
}
.chip:hover { background: var(--highlight-alpha); }
.chip.selected { background: var(--highlight); border-color: var(--ink); font-weight: 700; }
input[type="text"], input[type="password"] {
width: 100%; padding: 10px 14px; background: white; border: 2.5px solid var(--ink);
border-radius: 6px; color: var(--ink); font-family: 'Caveat', cursive; font-size: 1.1rem;
outline: none; transition: box-shadow 0.2s; filter: url(#sketchy);
}
input:focus { box-shadow: 3px 3px 0 var(--ink); }
input::placeholder { color: var(--ink-dim); opacity: 0.7; }
.player-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.player-row {
display: flex; align-items: center; gap: 8px; background: white; border: 2px solid var(--ink);
border-radius: 6px; padding: 8px 12px; animation: slideIn 0.18s ease; filter: url(#sketchy);
}
@keyframes slideIn { from { opacity:0; transform:translateY(-6px) rotate(-0.5deg); } to { opacity:1; transform:translateY(0); } }
.player-num { font-family: 'Permanent Marker', cursive; font-size: 0.85rem; color: var(--ink-dim); min-width: 22px; }
.player-name-input { flex:1; background:transparent; border:none; padding:2px 0; color:var(--ink); font-size:1.05rem; font-family:'Caveat',cursive; font-weight:600; }
.player-name-input:focus { outline:none; border-bottom:2px solid var(--ink); }
.remove-btn { background:none; border:none; cursor:pointer; color:var(--pencil); font-size:1.1rem; padding:2px 4px; transition:color 0.2s; }
.remove-btn:hover { color:var(--red-ink); }
.card-hold-wrap {
width: min(72vw, 280px); aspect-ratio: 2/3;
position: relative; flex-shrink: 0;
cursor: pointer; user-select: none; -webkit-user-select: none;
-webkit-tap-highlight-color: transparent;
}
.card-face {
position: absolute; inset: 0; border-radius: 10px;
display: flex; flex-direction: column; align-items: center; justify-content: center;
overflow: hidden; transition: opacity 0.12s ease;
}
.card-back {
background: var(--paper2); border: 3px solid var(--ink); filter: url(#sketchy); box-shadow: 4px 4px 0 var(--ink);
background-image: repeating-linear-gradient(transparent 0px, transparent 27px, var(--lines) 27px, var(--lines) 28px);
}
.card-back .back-icon { font-size: 2.8rem; opacity: 0.4; }
.card-back .back-label { font-family: 'Caveat', cursive; font-size: 1.05rem; color: var(--ink); margin-top: 10px; letter-spacing: 0.04em; font-weight: 600; }
.card-front {
background: white; border: 3px solid var(--ink); filter: url(#sketchy); box-shadow: 4px 4px 0 var(--ink);
background-image: repeating-linear-gradient(transparent 0px, transparent 27px, rgba(194,212,237,0.45) 27px, rgba(194,212,237,0.45) 28px);
}
.card-front.outsider {
border-color: var(--red-ink); box-shadow: 4px 4px 0 var(--red-ink);
background-image: repeating-linear-gradient(transparent 0px, transparent 27px, rgba(255,160,160,0.3) 27px, rgba(255,160,160,0.3) 28px);
}
.timer-wrap { position: relative; display: flex; align-items: center; justify-content: center; width: 170px; height: 170px; flex-shrink: 0; }
.timer-svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer-track { fill: none; stroke: var(--lines); stroke-width: 6; }
.timer-arc { fill: none; stroke: var(--ink); stroke-width: 6; stroke-linecap: round; transition: stroke 0.5s; }
.timer-text { font-family: 'Permanent Marker', cursive; font-size: 2.2rem; color: var(--ink); z-index: 1; letter-spacing: 0.02em; }
.ai-status { display:flex; align-items:center; gap:8px; padding:9px 13px; background:white; border:2px solid var(--ink); border-radius:6px; font-family:'Caveat',cursive; font-size:1rem; color:var(--ink); filter:url(#sketchy); }
.ai-dot { width:8px; height:8px; border-radius:50%; background:var(--pencil); flex-shrink:0; animation:pulse 1.2s ease-in-out infinite; }
.ai-dot.active { background:var(--ink); }
.ai-dot.error { background:var(--red-ink); animation:none; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.3;} }
.modal-overlay { display:none; position:fixed; inset:0; z-index:100; background:rgba(200,196,180,0.7); align-items:center; justify-content:center; padding:24px; }
.modal-overlay.open { display:flex; }
.modal {
background:var(--paper); border:3px solid var(--ink); border-radius:10px; padding:26px 22px;
width:100%; max-width:420px; box-shadow:5px 5px 0 var(--ink); filter:url(#sketchy); animation:modalIn 0.2s ease;
background-image: repeating-linear-gradient(transparent 0px, transparent 27px, rgba(194,212,237,0.5) 27px, rgba(194,212,237,0.5) 28px);
}
@keyframes modalIn { from{opacity:0;transform:scale(0.93) rotate(-1deg);} to{opacity:1;transform:scale(1) rotate(0deg);} }
.check-row { display:flex; align-items:center; gap:10px; cursor:pointer; user-select:none; }
.check-box { width:20px; height:20px; border:2.5px solid var(--ink); border-radius:4px; display:flex; align-items:center; justify-content:center; flex-shrink:0; background:white; transition:all 0.15s; filter:url(#sketchy); }
.check-box.checked { background:var(--highlight); border-color:var(--ink); }
.check-box.checked::after { content:'✓'; font-size:0.85rem; color:var(--ink); font-weight:900; font-family:'Permanent Marker',cursive; }
.check-label { font-size:0.95rem; color:var(--ink-dim); font-family:'Caveat',cursive; }
.reveal-table { width:100%; border-collapse:collapse; }
.reveal-table th { font-family:'Permanent Marker',cursive; font-size:0.85rem; color:var(--ink-dim); text-align:left; padding:7px 8px; border-bottom:2px solid var(--ink); }
.reveal-table td { padding:9px 8px; border-bottom:1px solid var(--lines); font-family:'Caveat',cursive; font-size:1.05rem; vertical-align:middle; color:var(--ink); }
.reveal-table tr.outsider-row td { color:var(--red-ink); font-weight:700; }
.pregame-count {
font-family:'Permanent Marker',cursive; font-size:clamp(5rem,22vw,8rem); color:var(--ink);
line-height:1; position:relative; display:inline-block; animation:countPop 0.3s ease;
}
.pregame-count::after { content:''; position:absolute; bottom:-4px; left:-4px; right:-4px; height:6px; background:var(--highlight); z-index:-1; transform:rotate(-1deg); filter:url(#sketchy); }
@keyframes countPop { 0%{transform:scale(1.25) rotate(-2deg);opacity:0.5;} 100%{transform:scale(1) rotate(0deg);opacity:1;} }
.handoff-bar { width:130px; height:4px; background:var(--lines); border-radius:2px; overflow:hidden; margin-top:10px; }
.handoff-fill { height:100%; width:0%; background:var(--ink); border-radius:2px; transition:width linear; }
.badge { display:inline-block; padding:2px 10px; background:var(--highlight); border:2px solid var(--ink); border-radius:50px; font-family:'Caveat',cursive; font-size:0.95rem; color:var(--ink); font-weight:700; filter:url(#sketchy); }
.doodle { position:absolute; opacity:0.18; pointer-events:none; color:var(--ink); font-size:1.1rem; font-family:'Caveat',cursive; }
.scrollable-ctx { max-height:230px; overflow-y:auto; width:100%; }
.scrollable-ctx::-webkit-scrollbar { width:4px; }
.scrollable-ctx::-webkit-scrollbar-thumb { background:var(--pencil); border-radius:4px; }
.w100{width:100%} .row{display:flex;gap:8px;width:100%} .row>*{flex:1} .text-center{text-align:center}
.g4{height:4px} .g8{height:8px} .g12{height:12px} .g16{height:16px} .g20{height:20px} .g24{height:24px}
@media (max-width: 400px) {
/* Tighter left padding on very small phones */
body { padding-left: 30px; }
body::before { width: 30px; }
body::after { left: 44px; }
.screen { padding: 16px 14px 16px 48px; }
/* Reduce filter further on small screens */
.btn, .sel-card, .chip, input, .player-row,
.card-back, .card-front, .ai-status, .modal,
.check-box, .badge { filter: url(#sketchy-soft); }
}
@media (max-width: 480px) {
/* Slightly smaller base for mid-size phones */
html, body { font-size: 16px; }
/* Reduce box shadows so they don't clip on narrow screens */
.btn-primary { box-shadow: 2px 2px 0 var(--ink); }
.sel-card { box-shadow: 2px 2px 0 var(--ink); }
.card-back, .card-front { box-shadow: 3px 3px 0 var(--ink); }
}
</style>
</head>
<body>
<svg style="position:absolute;width:0;height:0;overflow:hidden" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="sketchy" x="-5%" y="-5%" width="110%" height="110%">
<feTurbulence type="fractalNoise" baseFrequency="0.035" numOctaves="3" seed="7" result="noise"/>
<feDisplacementMap in="SourceGraphic" in2="noise" scale="0.7" xChannelSelector="R" yChannelSelector="G"/>
</filter>
<filter id="sketchy-soft" x="-3%" y="-3%" width="106%" height="106%">
<feTurbulence type="fractalNoise" baseFrequency="0.04" numOctaves="2" seed="7" result="noise"/>
<feDisplacementMap in="SourceGraphic" in2="noise" scale="0.4" xChannelSelector="R" yChannelSelector="G"/>
</filter>
</defs>
</svg>
<!-- HOME -->
<div id="s-home" class="screen active">
<div class="doodle" style="top:80px;left:-30px;transform:rotate(-15deg);font-size:1.3rem">✈</div>
<div class="doodle" style="top:200px;left:-28px;font-size:0.9rem">★</div>
<div class="doodle" style="bottom:160px;left:-30px;transform:rotate(10deg)">♦</div>
<div style="flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;gap:0">
<div style="font-size:3.2rem;margin-bottom:8px;filter:url(#sketchy)">🕵️</div>
<div class="logo">OUTSIDER</div>
<div class="logo-sub">spyfall meets mafia ✦</div>
<div class="divider" style="margin:20px auto"></div>
<p class="text-center" style="max-width:280px;margin-bottom:28px;font-size:1rem;color:var(--ink)">
One player is the outsider — they don't know the location. Everyone else does. Ask questions. Bluff. Deduce.
</p>
<div style="width:100%;max-width:300px;display:flex;flex-direction:column;gap:10px">
<button class="btn btn-primary" onclick="goto('s-category')">✎ Begin Mission</button>
<button class="btn btn-ghost" onclick="document.getElementById('modal-rules').classList.add('open')">? How to Play</button>
</div>
</div>
</div>
<!-- CATEGORY -->
<div id="s-category" class="screen">
<div class="doodle" style="top:100px;left:-30px;transform:rotate(-20deg);font-size:1.2rem">★</div>
<div class="doodle" style="bottom:120px;left:-28px;font-size:1rem">✈</div>
<div class="g20"></div>
<h2>Choose Mode</h2>
<div class="g4"></div><h3>what are we playing with?</h3>
<div class="g16"></div>
<div class="card-grid cols2" style="margin-bottom:12px">
<div class="sel-card" onclick="selectCategory('locations')" id="cat-locations">
<div class="card-icon">📍</div><div class="card-title">Locations</div>
<div class="card-desc">Classic Spyfall — real-world places</div>
</div>
<div class="sel-card" onclick="selectCategory('tvshows')" id="cat-tvshows">
<div class="card-icon">📺</div><div class="card-title">TV Shows</div>
<div class="card-desc">Guess the show, not the spot</div>
</div>
<div class="sel-card" onclick="selectCategory('movies')" id="cat-movies">
<div class="card-icon">🎬</div><div class="card-title">Movies</div>
<div class="card-desc">Characters from the big screen</div>
</div>
<div class="sel-card" onclick="selectCategory('ai')" id="cat-ai">
<div class="card-icon">🤖</div><div class="card-title">AI Mode</div>
<div class="card-desc">Any scenario — AI makes the roles</div>
</div>
</div>
<div style="flex:1"></div>
<button class="btn btn-ghost w100" onclick="goto('s-home')">← back</button>
<div class="g20"></div>
</div>
<!-- CONTEXT -->
<div id="s-context" class="screen">
<div class="doodle" style="top:90px;left:-28px;transform:rotate(-10deg)">★</div>
<div class="g20"></div>
<h2 id="ctx-heading">Select Location</h2>
<div class="g4"></div><h3 id="ctx-sub">pick one or let fate decide</h3>
<div class="g16"></div>
<div id="ctx-preset" style="width:100%"><div class="chip-grid" id="ctx-chips"></div></div>
<div id="ctx-ai" style="display:none;width:100%">
<div class="ai-status" id="ai-status-box">
<div class="ai-dot active" id="ai-dot"></div>
<span id="ai-status-text">AI connected — ready</span>
</div>
<div class="g12"></div>
<input type="text" id="ai-prompt" placeholder="any scenario… (e.g. antarctic base)" />
<div class="g8"></div>
<div class="row">
<button class="btn btn-sm btn-primary" onclick="aiGenerate('custom')">✦ Use This</button>
<button class="btn btn-ghost btn-sm" onclick="aiGenerate('surprise')">🎲 Surprise Me</button>
</div>
<div class="g12"></div>
<div id="ai-preview" style="display:none;background:white;border:2.5px solid var(--ink);border-radius:8px;padding:14px;filter:url(#sketchy);box-shadow:3px 3px 0 var(--ink)">
<h3 id="ai-prev-name" style="color:var(--ink);font-family:'Permanent Marker',cursive;font-size:1rem;margin-bottom:10px"></h3>
<div id="ai-prev-roles" class="chip-grid"></div>
</div>
<div class="g8"></div>
<button class="btn btn-ghost btn-sm w100" onclick="openApiModal()" style="font-size:0.95rem">⚙ change API key</button>
</div>
<div style="flex:1;min-height:12px"></div>
<div class="row">
<button class="btn btn-ghost" onclick="goBackCategory()">← back</button>
<button class="btn btn-primary" id="ctx-next-btn" onclick="gotoPlayers()" disabled>Players →</button>
</div>
<div class="g20"></div>
</div>
<!-- PLAYERS -->
<div id="s-players" class="screen">
<div class="doodle" style="top:85px;left:-30px;transform:rotate(-18deg);font-size:1.1rem">✈</div>
<div class="g20"></div>
<h2>Players</h2>
<div class="g4"></div><h3>3 – 10 players</h3>
<div class="g16"></div>
<div class="player-list" id="player-list"></div>
<button class="btn btn-ghost w100" id="add-player-btn" onclick="addPlayer()" style="margin-top:10px">+ add player</button>
<div style="flex:1;min-height:12px"></div>
<div class="row">
<button class="btn btn-ghost" onclick="goto('s-context')">← back</button>
<button class="btn btn-primary" id="deal-btn" onclick="startDeal()">Deal Cards →</button>
</div>
<div class="g20"></div>
</div>
<!-- DEAL CARDS -->
<div id="s-deal" class="screen">
<div class="g24"></div>
<h2 id="deal-player-name" class="text-center w100">PLAYER 1</h2>
<div class="g4"></div>
<h3 id="deal-instruction" class="text-center w100">hold to peek</h3>
<div class="g20"></div>
<div class="card-hold-wrap" id="card-hold-wrap"
onmousedown="holdCard()" onmouseup="releaseCard()" onmouseleave="releaseCard()"
ontouchstart="holdCard(event)" ontouchend="releaseCard()" ontouchcancel="releaseCard()">
<div class="card-face card-back" id="card-back-face">
<div id="card-back-name" style="font-family:'Permanent Marker',cursive;font-size:clamp(1.4rem,6vw,1.9rem);color:var(--ink);text-align:center;line-height:1.2;padding:0 14px;margin-bottom:14px"></div>
<div class="back-icon">🔒</div>
<div class="back-label">hold to reveal</div>
</div>
<div class="card-face card-front" id="card-front-face" style="opacity:0;pointer-events:none"></div>
</div>
<div class="g20"></div>
<div style="display:flex;flex-direction:column;align-items:center;gap:12px;width:100%">
<p class="text-center" id="deal-hint-text" style="font-size:1rem;color:var(--ink)">Hold to peek — release to hide. Pass when done.</p>
<button class="btn btn-primary btn-sm" id="deal-next-btn" onclick="nextDeal()" disabled style="max-width:280px">Next Player →</button>
</div>
<div style="flex:1"></div>
<div class="g16"></div>
</div>
<!-- HANDOFF -->
<div id="s-handoff" class="screen" style="justify-content:center">
<div class="doodle" style="top:100px;left:-28px;transform:rotate(-15deg)">★</div>
<div style="display:flex;flex-direction:column;align-items:center;gap:14px">
<div id="handoff-name" style="font-family:'Permanent Marker',cursive;font-size:clamp(1.6rem,7vw,2.2rem);color:var(--ink);text-align:center;line-height:1.3"></div>
<div class="handoff-bar" style="margin-top:4px"><div class="handoff-fill" id="handoff-fill"></div></div>
</div>
</div>
<!-- PREGAME COUNTDOWN -->
<div id="s-pregame" class="screen">
<div style="flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;gap:0">
<h3 style="margin-bottom:18px;font-size:1rem">game starts in...</h3>
<div class="pregame-count" id="pregame-count">15</div>
<div class="divider" style="margin:26px auto;width:100%"></div>
<button class="btn btn-primary" onclick="startGame()" style="max-width:260px">Start Now →</button>
</div>
</div>
<!-- GAME -->
<div id="s-game" class="screen">
<div class="doodle" style="top:80px;left:-28px;transform:rotate(-12deg);font-size:1.2rem">★</div>
<div style="flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;gap:18px">
<div class="timer-wrap">
<svg class="timer-svg" viewBox="0 0 170 170">
<circle class="timer-track" cx="85" cy="85" r="72"/>
<circle class="timer-arc" id="timer-arc" cx="85" cy="85" r="72" stroke-dasharray="452.39" stroke-dashoffset="0"/>
</svg>
<span class="timer-text" id="timer-text">8:00</span>
</div>
<div id="timer-controls" class="row" style="max-width:300px">
<button class="btn btn-sm" id="timer-toggle" onclick="toggleTimer()">⏸ Pause</button>
<button class="btn btn-ghost btn-sm" onclick="resetTimer()">↺ Reset</button>
<button class="btn btn-ghost btn-sm" onclick="disableTimer()" style="color:var(--red-ink);border-color:var(--red-ink)">✕ No Timer</button>
</div>
</div>
<div style="display:flex;flex-direction:column;gap:8px;width:100%;padding-bottom:4px">
<button class="btn btn-primary" onclick="endGame()">✎ Reveal All Roles</button>
<button class="btn btn-ghost" onclick="gotoHome()">✕ Abandon Mission</button>
</div>
<div class="g20"></div>
</div>
<!-- END -->
<div id="s-end" class="screen">
<div class="doodle" style="top:80px;left:-30px;transform:rotate(-16deg);font-size:1.2rem">★</div>
<div class="doodle" style="bottom:150px;left:-28px;font-size:1rem">✈</div>
<div class="g24"></div>
<h2 class="text-center w100">Mission Debrief</h2>
<div class="g4"></div>
<h3 class="text-center w100" id="end-context-label"></h3>
<div class="divider" style="margin:14px auto;width:100%"></div>
<div style="width:100%;overflow:auto;flex:1">
<table class="reveal-table">
<thead><tr><th>player</th><th>role</th></tr></thead>
<tbody id="reveal-body"></tbody>
</table>
</div>
<div class="g16"></div>
<div style="display:flex;flex-direction:column;gap:8px;width:100%">
<button class="btn btn-primary" onclick="playAgain()">🎲 Shuffle & Play Again</button>
<button class="btn btn-ghost" onclick="gotoHome()">✎ New Game</button>
</div>
<div class="g20"></div>
</div>
<!-- MODAL: API KEY -->
<div class="modal-overlay" id="modal-api">
<div class="modal">
<h2 style="margin-bottom:8px">AI Mode 🤖</h2>
<p style="margin-bottom:14px;font-size:0.9rem">Pick a provider and paste your API key. Stays on this device.</p>
<div style="display:flex;gap:8px;margin-bottom:12px">
<button class="btn btn-sm" id="prov-anthropic" onclick="selectProvider('anthropic')">Anthropic</button>
<button class="btn btn-ghost btn-sm" id="prov-google" onclick="selectProvider('google')">Google Gemini</button>
</div>
<div id="provider-hint" style="font-size:0.85rem;color:var(--ink-dim);margin-bottom:10px;line-height:1.5;font-family:'Patrick Hand',cursive">Claude Sonnet — console.anthropic.com</div>
<input type="password" id="api-key-input" placeholder="sk-ant-…" autocomplete="off"/>
<div class="g12"></div>
<div class="check-row" onclick="toggleRemember()">
<div class="check-box checked" id="remember-check"></div>
<span class="check-label">Remember on this device</span>
</div>
<div class="g16"></div>
<div class="row">
<button class="btn btn-ghost" onclick="closeApiModal()">cancel</button>
<button class="btn btn-primary" onclick="saveApiKey()">Connect ✦</button>
</div>
</div>
</div>
<!-- MODAL: RULES -->
<div class="modal-overlay" id="modal-rules">
<div class="modal">
<h2 style="margin-bottom:14px">How to Play 📋</h2>
<div style="display:flex;flex-direction:column;gap:12px">
<p><strong style="color:var(--ink);font-family:'Permanent Marker',cursive;font-size:0.9rem">SETUP</strong><br>
Everyone gets a secret card. One player gets The Outsider — they don't know the location.</p>
<p><strong style="color:var(--ink);font-family:'Permanent Marker',cursive;font-size:0.9rem">DISCUSS</strong><br>
Take turns asking questions about the context to prove you belong — without giving it away.</p>
<p><strong style="color:var(--ink);font-family:'Permanent Marker',cursive;font-size:0.9rem">THE OUTSIDER</strong><br>
Listen carefully. Work out the location before you're caught. Ask vague questions.</p>
<p><strong style="color:var(--ink);font-family:'Permanent Marker',cursive;font-size:0.9rem">ACCUSATION</strong><br>
Majority vote to accuse. Catch the Outsider → everyone wins. Wrong call → Outsider wins.</p>
<p><strong style="color:var(--ink);font-family:'Permanent Marker',cursive;font-size:0.9rem">OUTSIDER GUESS</strong><br>
If the Outsider correctly names the location — they win.</p>
</div>
<div class="g16"></div>
<button class="btn btn-primary" onclick="document.getElementById('modal-rules').classList.remove('open')">got it ✓</button>
</div>
</div>
<script>
// ════════════════════════════════════════════
// PRESET DATA
// ════════════════════════════════════════════
const PRESETS = {
locations: [
{ name: 'Beach', roles: ['Lifeguard','Surfer','Sunbather','Ice Cream Vendor','Tourist','Volleyball Player','Sandcastle Builder','Parasailing Instructor','Fisherman','Photographer'] },
{ name: 'Hospital', roles: ['Surgeon','Nurse','Patient','Radiologist','Anaesthetist','Orderly','Receptionist','Paramedic','Pharmacist','Cleaner'] },
{ name: 'Casino', roles: ['Blackjack Dealer','High Roller','Pit Boss','Cocktail Waitress','Security Guard','Card Counter','Poker Player','Croupier','Casino Manager','Slot Enthusiast'] },
{ name: 'Airport', roles: ['Pilot','Flight Attendant','Customs Officer','Baggage Handler','Gate Agent','Frequent Flyer','Nervous Traveller','Air Traffic Controller','Duty-Free Vendor','Immigration Officer'] },
{ name: 'Military Base', roles: ['General','Drill Sergeant','Soldier','Intelligence Analyst','Medic','Mechanic','Cook','Communications Officer','Sniper','Bomb Disposal Expert'] },
{ name: 'Movie Studio', roles: ['Director','Actor','Cinematographer','Makeup Artist','Stuntperson','Producer','Script Supervisor','Grip','Location Scout','Method Actor'] },
{ name: 'Space Station', roles: ['Commander','Mission Specialist','Flight Engineer','Geologist','Botanist','Medical Officer','Systems Engineer','Spacewalker','Rookie Astronaut','Ground Liaison'] },
{ name: 'Submarine', roles: ['Captain','Sonar Operator','Torpedo Tech','Navigator','Cook','Engineer','Medic','Comms Officer','Diving Officer','Lookout'] },
{ name: 'Circus', roles: ['Ringmaster','Trapeze Artist','Clown','Lion Tamer','Acrobat','Tightrope Walker','Magician','Strongman','Juggler','Ticket Collector'] },
{ name: 'Pirate Ship', roles: ['Captain','First Mate','Navigator','Cook','Surgeon','Gunner','Lookout','Swabbie','Prisoner','Treasure Hunter'] },
{ name: 'Restaurant', roles: ['Head Chef','Sous Chef','Waiter','Sommelier','Maître D\'','Food Critic','Dishwasher','Regular Customer','Health Inspector','Delivery Driver'] },
{ name: 'Police Station', roles: ['Detective','Uniformed Officer','Forensics Expert','Dispatcher','Desk Sergeant','Informant','Lawyer','Suspect','Crime Scene Photographer','Internal Affairs'] },
{ name: 'Medieval Castle', roles: ['King','Queen','Knight','Jester','Court Mage','Lady-in-Waiting','Blacksmith','Stable Hand','Royal Spy','Guard Captain'] },
{ name: 'Cruise Ship', roles: ['Captain','Social Director','Passenger','Chef','Shore Excursion Guide','Photographer','Bartender','Cabin Steward','Honeymooner','Gambler'] },
{ name: 'Ski Resort', roles: ['Ski Instructor','Ski Patrol','Après-Ski Enthusiast','Snowboarder','Chalet Host','Lift Operator','Beginner','Ice Sculptor','Hot Cocoa Vendor','Resort Manager'] },
{ name: 'University', roles: ['Professor','Student','Dean','Lab Technician','Librarian','Exchange Student','Campus Cop','Janitor','Dropout','Admissions Officer'] },
{ name: 'Supermarket', roles: ['Checkout Operator','Store Manager','Shelf Stocker','Security Guard','Butcher','Baker','Delivery Driver','Shopper','Loss Prevention','Floor Supervisor'] },
{ name: 'Film Set', roles: ['Director','Screenwriter','Lead Actor','Boom Operator','Lighting Tech','Wardrobe Stylist','PA','Producer','Continuity Supervisor','Extras Coordinator'] },
],
tvshows: [
{ name: 'Breaking Bad', roles: ['Walter White','Jesse Pinkman','Skyler White','Hank Schrader','Mike Ehrmantraut','Saul Goodman','Gus Fring','Marie Schrader','Todd Alquist','Lydia Rodarte-Quayle'] },
{ name: 'Game of Thrones', roles: ['Jon Snow','Daenerys Targaryen','Tyrion Lannister','Cersei Lannister','Arya Stark','Sansa Stark','Jaime Lannister','The Hound','Littlefinger','Ned Stark'] },
{ name: 'The Office (US)', roles: ['Michael Scott','Jim Halpert','Dwight Schrute','Pam Beesly','Ryan Howard','Andy Bernard','Kevin Malone','Angela Martin','Oscar Martinez','Toby Flenderson'] },
{ name: 'Stranger Things', roles: ['Eleven','Mike Wheeler','Dustin Henderson','Lucas Sinclair','Will Byers','Joyce Byers','Jim Hopper','Max Mayfield','Billy Hargrove','Steve Harrington'] },
{ name: 'Friends', roles: ['Ross Geller','Rachel Green','Monica Geller','Chandler Bing','Joey Tribbiani','Phoebe Buffay','Richard Burke','Gunther','Janice','Emily Waltham'] },
{ name: 'Succession', roles: ['Logan Roy','Kendall Roy','Siobhan Roy','Roman Roy','Tom Wambsgans','Greg Hirsch','Gerri Kellman','Connor Roy','Frank Vernon','Stewy Hosseini'] },
{ name: 'Seinfeld', roles: ['Jerry Seinfeld','George Costanza','Elaine Benes','Cosmo Kramer','Newman','Frank Costanza','Estelle Costanza','J. Peterman','Uncle Leo','The Soup Nazi'] },
{ name: 'Suits', roles: ['Harvey Specter','Mike Ross','Donna Paulsen','Louis Litt','Rachel Zane','Jessica Pearson','Robert Zane','Alex Williams','Katrina Bennett','Samantha Wheeler'] },
{ name: 'The Bear', roles: ['Carmy','Sydney Adamu','Richie','Marcus Brooks','Tina Marrero','Neil Fak','Sugar','Cousin Natalie','Chef Terry','Jimmy Cicero'] },
{ name: 'Yellowstone', roles: ['John Dutton','Beth Dutton','Rip Wheeler','Kayce Dutton','Monica Long Dutton','Jamie Dutton','Thomas Rainwater','Lloyd Pierce','Walker','Tate Dutton'] },
{ name: 'Sopranos', roles: ['Tony Soprano','Carmela Soprano','Christopher Moltisanti','Paulie Walnuts','Bobby Baccalieri','Janice Soprano','Artie Bucco','Junior Soprano','Silvio Dante','Dr Melfi'] },
{ name: 'Peaky Blinders', roles: ['Tommy Shelby','Arthur Shelby','Polly Gray','John Shelby','Ada Shelby','Alfie Solomons','Inspector Campbell','Grace Burgess','Michael Gray','Charlie Strong'] },
],
movies: [
{ name: 'The Godfather', roles: ['Don Vito Corleone','Michael Corleone','Sonny Corleone','Fredo Corleone','Tom Hagen','Kay Adams','Virgil Sollozzo','Jack Woltz','Luca Brasi','Clemenza'] },
{ name: 'Pulp Fiction', roles: ['Vincent Vega','Jules Winnfield','Mia Wallace','Butch Coolidge','Marsellus Wallace','The Gimp','Honey Bunny','Pumpkin','Winston Wolf','Jimmy Dimmick'] },
{ name: 'Harry Potter', roles: ['Harry Potter','Hermione Granger','Ron Weasley','Albus Dumbledore','Severus Snape','Draco Malfoy','Lord Voldemort','Rubeus Hagrid','Minerva McGonagall','Sirius Black'] },
{ name: 'Jurassic Park', roles: ['Dr Alan Grant','Dr Ellie Sattler','Ian Malcolm','John Hammond','Dennis Nedry','Tim Murphy','Lex Murphy','Robert Muldoon','Ray Arnold','Henry Wu'] },
{ name: 'Inception', roles: ['Dom Cobb','Arthur','Ariadne','Eames','Yusuf','Robert Fischer','Mal Cobb','Saito','Miles','Nash'] },
{ name: 'The Dark Knight', roles: ['Bruce Wayne','The Joker','Harvey Dent','Rachel Dawes','Alfred Pennyworth','Commissioner Gordon','Lucius Fox','Salvatore Maroni','Joker\'s Henchman','Detective Ramirez'] },
{ name: 'Gladiator', roles: ['Maximus','Commodus','Lucilla','Proximo','Juba','Marcus Aurelius','Hagen','Tigris of Gaul','Senator Gracchus','Quintus'] },
{ name: 'The Avengers', roles: ['Iron Man','Captain America','Thor','Black Widow','Hulk','Hawkeye','Loki','Nick Fury','Agent Coulson','Maria Hill'] },
{ name: 'Knives Out', roles: ['Benoit Blanc','Marta Cabrera','Harlan Thrombey','Ransom Drysdale','Linda Drysdale','Walt Thrombey','Richard Drysdale','Joni Thrombey','Trooper Wagner','Lt Elliott'] },
{ name: 'Top Gun: Maverick', roles: ['Maverick','Rooster','Hangman','Phoenix','Bob','Penny Benjamin','Admiral Cyclone','Hondo','Payback','Fanboy'] },
{ name: 'Oppenheimer', roles: ['J. Robert Oppenheimer','General Groves','Niels Bohr','Lewis Strauss','Jean Tatlock','Kitty Oppenheimer','Edward Teller','Ernest Lawrence','David Hill','Roger Robb'] },
{ name: 'Barbie', roles: ['Stereotypical Barbie','Ken','Weird Barbie','Gloria','Sasha','President Barbie','Physicist Barbie','Ruth Handler','Allan','Midge'] },
]
};
const CAT_META = {
locations: { label:'Location', catLabel:'LOCATIONS', outsiderName:'THE OUTSIDER', outsiderTag:'You don\'t know the location. Listen carefully and deduce.' },
tvshows: { label:'TV Show', catLabel:'TV SHOWS', outsiderName:'THE OUTSIDER', outsiderTag:'You don\'t know the show. Bluff your way through.' },
movies: { label:'Movie', catLabel:'MOVIES', outsiderName:'THE OUTSIDER', outsiderTag:'You don\'t know the film. Keep your cover.' },
ai: { label:'Scenario', catLabel:'AI MODE', outsiderName:'THE OUTSIDER', outsiderTag:'You don\'t know the scenario. Listen and deduce.' },
};
// ════════════════════════════════════════════
// STATE
// ════════════════════════════════════════════
let S = {
category: null,
context: null,
outsiderName: null,
outsiderTag: null,
catLabel: null,
players: [],
assignments: [],
dealIndex: 0,
cardRevealed: false,
timerSecs: 480,
timerMax: 480,
timerRunning: false,
timerRaf: null,
timerLast: null,
aiKey: null,
aiProvider: 'anthropic',
};
let rememberKey = true;
// ════════════════════════════════════════════
// NAVIGATION
// ════════════════════════════════════════════
function goto(id) {
document.querySelectorAll('.screen').forEach(s => s.classList.remove('active'));
const el = document.getElementById(id);
el.classList.add('active');
el.scrollTop = 0;
}
function gotoHome() {
stopTimer();
S.category = null; S.context = null; S.players = []; S.assignments = [];
goto('s-home');
}
// ════════════════════════════════════════════
// CATEGORY SELECTION
// ════════════════════════════════════════════
function selectCategory(cat) {
document.querySelectorAll('.sel-card').forEach(c => c.classList.remove('selected'));
document.getElementById('cat-' + cat).classList.add('selected');
S.category = cat;
if (cat === 'ai') {
const saved = localStorage.getItem('covert_api_key');
if (saved) { S.aiKey = saved; gotoContextAI(); }
else openApiModal();
} else {
gotoContextPreset();
}
}
function goBackCategory() {
S.category = null; S.context = null;
goto('s-category');
}
// ════════════════════════════════════════════
// PRESET CONTEXT
// ════════════════════════════════════════════
function gotoContextPreset() {
const meta = CAT_META[S.category];
document.getElementById('ctx-heading').textContent = 'Select ' + meta.label;
document.getElementById('ctx-sub').textContent = 'Choose one or let fate decide';
document.getElementById('ctx-preset').style.display = '';
document.getElementById('ctx-ai').style.display = 'none';
const items = PRESETS[S.category];
const chips = document.getElementById('ctx-chips');
chips.innerHTML = '';
items.forEach(item => {
const c = document.createElement('div');
c.className = 'chip';
c.textContent = item.name;
c.onclick = () => {
document.querySelectorAll('#ctx-chips .chip').forEach(x => x.classList.remove('selected'));
c.classList.add('selected');
setContext(item);
};
chips.appendChild(c);
});
const rand = document.createElement('div');
rand.className = 'chip';
rand.innerHTML = '🎲 Random';
rand.style.cssText = 'border-color:rgba(200,168,80,0.4);color:var(--gold)';
rand.onclick = () => {
const pick = items[Math.floor(Math.random() * items.length)];
document.querySelectorAll('#ctx-chips .chip').forEach(x => x.classList.remove('selected'));
rand.classList.add('selected');
setContext(pick);
};
chips.appendChild(rand);
S.context = null;
document.getElementById('ctx-next-btn').disabled = true;
goto('s-context');
}
function setContext(item) {
S.context = item;
S.outsiderName = CAT_META[S.category].outsiderName;
S.outsiderTag = CAT_META[S.category].outsiderTag;
S.catLabel = CAT_META[S.category].catLabel;
document.getElementById('ctx-next-btn').disabled = false;
}
// ════════════════════════════════════════════
// AI CONTEXT
// ════════════════════════════════════════════
function gotoContextAI() {
document.getElementById('ctx-heading').textContent = 'AI Scenario';
document.getElementById('ctx-sub').textContent = 'Type a scenario or let AI surprise you';
document.getElementById('ctx-preset').style.display = 'none';
document.getElementById('ctx-ai').style.display = '';
document.getElementById('ai-preview').style.display = 'none';
document.getElementById('ai-prompt').value = '';
setAIStatus('ready');
S.context = null;
document.getElementById('ctx-next-btn').disabled = true;
goto('s-context');
}
function setAIStatus(type, msg) {
const dot = document.getElementById('ai-dot');
const txt = document.getElementById('ai-status-text');
dot.className = 'ai-dot';
if (type === 'ready') { dot.classList.add('active'); txt.textContent = msg || 'AI connected — ready'; }
if (type === 'loading') { dot.classList.add('active'); txt.textContent = msg || 'Generating…'; }
if (type === 'error') { dot.classList.add('error'); txt.textContent = msg || 'Error — check key & try again'; }
if (type === 'done') { dot.classList.add('active'); txt.textContent = msg || 'Scenario ready ✦'; }
}
async function aiGenerate(mode) {
const prompt = document.getElementById('ai-prompt').value.trim();
if (mode === 'custom' && !prompt) { setAIStatus('error','Enter a scenario first'); return; }
setAIStatus('loading');
document.getElementById('ai-preview').style.display = 'none';
document.getElementById('ctx-next-btn').disabled = true;
const jsonSchema = '{"contextName":"Name","catLabel":"Short label e.g. LOCATION / TV SHOW / VIDEO GAME","outsiderName":"THE OUTSIDER","outsiderTagline":"Short sentence for outsider card","roles":["Role 1","Role 2","Role 3","Role 4","Role 5","Role 6","Role 7","Role 8","Role 9","Role 10"]}';
const userPrompt = mode === 'surprise'
? 'Generate a creative Spyfall scenario — location, TV show, movie, historical event, video game, sport, anything fun for a party game. outsiderName must always be THE OUTSIDER. Return JSON: ' + jsonSchema
: 'Create a Spyfall scenario for: "' + prompt + '". outsiderName must always be THE OUTSIDER. Return JSON: ' + jsonSchema;
try {
let rawText = '';
if (S.aiProvider === 'google') {
const res = await fetch(
'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=' + S.aiKey,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
systemInstruction: { parts: [{ text: 'You are a Spyfall game master. Respond ONLY with valid JSON, no markdown fences, no preamble.' }] },
contents: [{ role: 'user', parts: [{ text: userPrompt }] }],
generationConfig: { maxOutputTokens: 600 }
})
}
);
if (!res.ok) {
const e = await res.json().catch(() => ({}));
throw new Error(e.error?.message || 'Gemini API error ' + res.status);
}
const data = await res.json();
rawText = data.candidates?.[0]?.content?.parts?.[0]?.text || '';
} else {
const res = await fetch('https://api.anthropic.com/v1/messages', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': S.aiKey,
'anthropic-version': '2023-06-01',
'anthropic-dangerous-direct-browser-access': 'true'
},
body: JSON.stringify({
model: 'claude-sonnet-4-20250514',
max_tokens: 600,
system: 'You are a Spyfall game master. Respond ONLY with valid JSON, no markdown fences, no preamble.',
messages: [{ role: 'user', content: userPrompt }]
})
});
if (!res.ok) {
const e = await res.json().catch(() => ({}));
throw new Error(e.error?.message || 'API error ' + res.status);
}
const data = await res.json();
rawText = data.content.find(b => b.type === 'text')?.text || '';
}
const parsed = JSON.parse(rawText.replace(/```json|```/g,'').trim());
S.context = { name: parsed.contextName, roles: parsed.roles };
S.outsiderName = 'THE OUTSIDER';
S.outsiderTag = parsed.outsiderTagline || "You don't know the scenario.";
S.catLabel = parsed.catLabel || 'AI MODE';
document.getElementById('ai-prev-name').textContent = parsed.contextName + ' · ' + parsed.catLabel;
const rc = document.getElementById('ai-prev-roles');
rc.innerHTML = '';
parsed.roles.forEach(r => {
const c = document.createElement('div');
c.className = 'chip selected';
c.textContent = r;
rc.appendChild(c);
});
document.getElementById('ai-preview').style.display = '';
document.getElementById('ctx-next-btn').disabled = false;
setAIStatus('done', '❆ ' + parsed.contextName);
} catch(e) {
console.error(e);
setAIStatus('error', e.message || 'Generation failed');
}
}
// API KEY MODAL
const PROVIDERS = {
anthropic: { placeholder: 'sk-ant-…', hint: 'Claude Sonnet — get key at console.anthropic.com' },
google: { placeholder: 'AIza…', hint: 'Gemini 2.0 Flash (free tier) — get key at aistudio.google.com' },
};
function selectProvider(p) {
S.aiProvider = p;
const activeStyle = "background:var(--gold);border-color:var(--gold);color:#0c0b0e;font-weight:700;font-family:'Cinzel',serif;font-size:0.66rem;letter-spacing:0.18em;text-transform:uppercase;padding:10px 16px;border-radius:10px;cursor:pointer";
const inactiveStyle = "background:transparent;border:1px solid var(--border);color:var(--text-dim);font-family:'Cinzel',serif;font-size:0.66rem;letter-spacing:0.18em;text-transform:uppercase;padding:10px 16px;border-radius:10px;cursor:pointer";
document.getElementById('prov-anthropic').style.cssText = p === 'anthropic' ? activeStyle : inactiveStyle;
document.getElementById('prov-google').style.cssText = p === 'google' ? activeStyle : inactiveStyle;
document.getElementById('api-key-input').placeholder = PROVIDERS[p].placeholder;
document.getElementById('provider-hint').textContent = PROVIDERS[p].hint;
const savedKey = localStorage.getItem('covert_key_' + p);
document.getElementById('api-key-input').value = savedKey || '';
}
function openApiModal() {
selectProvider(S.aiProvider || 'anthropic');
rememberKey = true;
document.getElementById('remember-check').classList.add('checked');
document.getElementById('modal-api').classList.add('open');
}
function closeApiModal() {
document.getElementById('modal-api').classList.remove('open');
if (!S.aiKey) {
S.category = null;
document.querySelectorAll('.sel-card').forEach(c => c.classList.remove('selected'));
}
}
function toggleRemember() {
rememberKey = !rememberKey;
document.getElementById('remember-check').classList.toggle('checked', rememberKey);
}
function saveApiKey() {
const key = document.getElementById('api-key-input').value.trim();
if (!key) return;
S.aiKey = key;
if (rememberKey) localStorage.setItem('covert_key_' + S.aiProvider, key);
else localStorage.removeItem('covert_key_' + S.aiProvider);
document.getElementById('modal-api').classList.remove('open');
gotoContextAI();
}
function gotoPlayers() {
if (S.players.length === 0) S.players = ['Player 1','Player 2','Player 3','Player 4'];
renderPlayers();
goto('s-players');
}
function renderPlayers() {
const list = document.getElementById('player-list');
list.innerHTML = '';
S.players.forEach((name, i) => {
const row = document.createElement('div');
row.className = 'player-row';
row.innerHTML = `
<span class="player-num">${String(i+1).padStart(2,'0')}</span>
<input class="player-name-input" type="text" value="${esc(name)}" placeholder="Player ${i+1}"
oninput="S.players[${i}]=this.value"/>
<button class="remove-btn" onclick="removePlayer(${i})">✕</button>`;
list.appendChild(row);
});
document.getElementById('add-player-btn').style.display = S.players.length >= 10 ? 'none' : '';
document.getElementById('deal-btn').disabled = S.players.length < 3;
}
function addPlayer() {
if (S.players.length >= 10) return;
S.players.push('Player ' + (S.players.length + 1));
renderPlayers();
setTimeout(() => {
const ins = document.querySelectorAll('.player-name-input');
ins[ins.length-1].focus(); ins[ins.length-1].select();
}, 50);
}
function removePlayer(i) {
if (S.players.length <= 3) return;
S.players.splice(i, 1);
renderPlayers();
}
// ════════════════════════════════════════════
// DEAL
// ════════════════════════════════════════════
function startDeal() {
document.querySelectorAll('.player-name-input').forEach((inp, i) => {
S.players[i] = inp.value || 'Player ' + (i+1);
});
const roles = shuffle([...S.context.roles]);
const outsiderIdx = Math.floor(Math.random() * S.players.length);
let roleIdx = 0;
S.assignments = shuffle(S.players.map((player, i) => {
const isOutsider = i === outsiderIdx;
const role = isOutsider ? S.outsiderName : (roles[roleIdx++ % roles.length]);
return { player, role, isOutsider };
}));
S.dealIndex = 0;
goto('s-deal');
loadCard();
}
function loadCard() {
const a = S.assignments[S.dealIndex];
const isLast = S.dealIndex === S.assignments.length - 1;
S.cardRevealed = false;
document.getElementById('deal-player-name').textContent = a.player.toUpperCase();
document.getElementById('deal-instruction').textContent =
'Card ' + (S.dealIndex+1) + ' of ' + S.assignments.length + ' — hold to peek';
document.getElementById('card-back-name').textContent = a.player;
const front = document.getElementById('card-front-face');
const back = document.getElementById('card-back-face');
front.style.opacity = '0';
front.style.pointerEvents = 'none';
back.style.opacity = '1';
const nextBtn = document.getElementById('deal-next-btn');
nextBtn.disabled = true;
nextBtn.classList.remove('btn-ready');
nextBtn.textContent = isLast ? 'READY' : 'Next Player →';
document.getElementById('deal-hint-text').textContent = isLast
? 'Hold to peek — release to hide. Tap Ready when done.'
: 'Hold to peek — release to hide. Pass when done.';
if (a.isOutsider) {
front.className = 'card-face card-front outsider';
front.innerHTML =
'<div style="position:absolute;top:12px;left:14px;right:14px;font-family:\'Cinzel\',serif;font-size:0.55rem;letter-spacing:0.18em;color:rgba(201,64,64,0.4);display:flex;justify-content:space-between"><span>◆</span><span>◆</span></div>' +
'<div style="font-size:2.2rem;margin-bottom:10px">👁</div>' +
'<div style="font-family:\'Cinzel\',serif;font-size:0.65rem;letter-spacing:0.3em;color:rgba(201,64,64,0.65);margin-bottom:8px">YOUR STATUS</div>' +
'<div style="font-family:\'Crimson Text\',serif;font-size:clamp(1.1rem,4vw,1.4rem);font-weight:600;color:var(--crimson);text-align:center">' + esc(S.outsiderName) + '</div>' +
'<div style="font-family:\'Crimson Text\',serif;font-size:0.78rem;font-style:italic;color:rgba(201,64,64,0.6);text-align:center;margin-top:10px;max-width:88%;line-height:1.4">' + esc(S.outsiderTag) + '</div>' +
'<div style="position:absolute;bottom:12px;font-family:\'Cinzel\',serif;font-size:0.55rem;letter-spacing:0.15em;color:rgba(201,64,64,0.4)">' + esc(S.catLabel) + '</div>';
} else {
front.className = 'card-face card-front';
front.innerHTML =
'<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;padding:14px 10px;gap:0">' +
'<div style="font-family:\'Permanent Marker\',cursive;font-size:0.72rem;color:#3d5299;margin-bottom:4px">your role</div>' +
'<div style="font-family:\'Permanent Marker\',cursive;font-size:clamp(1.3rem,4.5vw,1.7rem);color:#1a3a9f;text-align:center;line-height:1.2;padding:0 6px">' + esc(a.role) + '</div>' +
'<div style="width:55%;height:2px;background:#1a3a9f;opacity:0.15;margin:10px 0;border-radius:2px"></div>' +
'<div style="font-family:\'Permanent Marker\',cursive;font-size:0.72rem;color:#3d5299;margin-bottom:5px">location</div>' +
'<div style="font-family:\'Permanent Marker\',cursive;font-size:clamp(1.9rem,7vw,2.6rem);color:#1a3a9f;text-align:center;line-height:1.05;padding:0 4px">' + esc(S.context.name) + '</div>' +
'</div>';
}
}
function holdCard(e) {
if (e) e.preventDefault();
const front = document.getElementById('card-front-face');
const back = document.getElementById('card-back-face');
front.style.opacity = '1';
front.style.pointerEvents = 'auto';
back.style.opacity = '0';
if (!S.cardRevealed) {
S.cardRevealed = true;
const nextBtn = document.getElementById('deal-next-btn');
nextBtn.disabled = false;
if (S.dealIndex === S.assignments.length - 1) nextBtn.classList.add('btn-ready');
}
}
function releaseCard() {
const front = document.getElementById('card-front-face');
const back = document.getElementById('card-back-face');
front.style.opacity = '0';
front.style.pointerEvents = 'none';
back.style.opacity = '1';
}
function nextDeal() {
S.dealIndex++;
if (S.dealIndex >= S.assignments.length) { startPregame(); return; }
// Show handoff screen briefly before next card
const nextPlayer = S.assignments[S.dealIndex].player;
document.getElementById('handoff-name').innerHTML = 'Pass the phone to...<br><span style="font-size:1.5em;background:var(--highlight);padding:2px 10px;border-radius:4px;display:inline-block;margin-top:6px;transform:rotate(-1deg);box-shadow:2px 2px 0 var(--ink);filter:url(#sketchy)">' + nextPlayer + '</span>';
goto('s-handoff');
// Animate progress bar
const fill = document.getElementById('handoff-fill');
fill.style.transition = 'none';
fill.style.width = '0%';
fill.offsetHeight; // reflow
fill.style.transition = 'width 2.8s linear';
fill.style.width = '100%';
setTimeout(() => { goto('s-deal'); loadCard(); }, 2800);
}
// PREGAME COUNTDOWN
// ════════════════════════════════════════════
let pregameRaf = null;
let pregameSecs = 15;
function startPregame() {
pregameSecs = 15;
goto('s-pregame');
renderPregameCount();
tickPregame(null);
}
function renderPregameCount() {
const el = document.getElementById('pregame-count');
el.textContent = pregameSecs;
el.style.animation = 'none';
el.offsetHeight;
el.style.animation = '';
}
function tickPregame(last) {
if (pregameRaf) cancelAnimationFrame(pregameRaf);
pregameRaf = requestAnimationFrame(ts => {
if (last === null) { tickPregame(ts); return; }
if (ts - last >= 1000) {
pregameSecs--;
renderPregameCount();
if (pregameSecs <= 0) { startGame(); return; }
tickPregame(ts);
} else {
tickPregame(last);
}
});
}
// GAME
// ════════════════════════════════════════════
function startGame() {
if (pregameRaf) { cancelAnimationFrame(pregameRaf); pregameRaf = null; }
S.timerSecs = 480; S.timerMax = 480; S.timerRunning = false;
S.noTimer = false;
updateTimerDisplay();
document.getElementById('timer-controls').style.display = '';
document.getElementById('timer-arc').style.opacity = '1';
startTimer();
goto('s-game');