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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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ARC8X - AI Game Generation Engine</title>
    <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=Press+Start+2P&family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;400;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --neon-cyan: #00f3ff;
            --neon-magenta: #ff00ff;
            --neon-yellow: #ffff00;
            --neon-green: #39ff14;
            --deep-black: #0a0a0f;
            --dark-purple: #1a0a2e;
            --grid-color: rgba(0, 243, 255, 0.1);
        }

        .dark {
            --neon-cyan: #00f3ff;
            --neon-magenta: #ff00ff;
            --neon-yellow: #ffff00;
            --neon-green: #39ff14;
            --deep-black: #0a0a0f;
            --dark-purple: #1a0a2e;
            --grid-color: rgba(0, 243, 255, 0.1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Rajdhani', sans-serif;
            background: var(--deep-black);
            color: var(--neon-cyan);
            overflow-x: hidden;
            min-height: 100vh;
            position: relative;
        }

        /* Animated grid background */
        body::before {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-image:
                linear-gradient(var(--grid-color) 1px, transparent 1px),
                linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
            background-size: 50px 50px;
            animation: gridScroll 20s linear infinite;
            pointer-events: none;
            z-index: 0;
        }

        @keyframes gridScroll {
            0% { transform: perspective(500px) rotateX(60deg) translateY(0); }
            100% { transform: perspective(500px) rotateX(60deg) translateY(50px); }
        }

        .container {
            position: relative;
            z-index: 1;
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
        }

        header {
            text-align: center;
            padding: 40px 20px;
            position: relative;
        }

        h1 {
            font-family: 'Orbitron', sans-serif;
            font-size: clamp(2rem, 8vw, 5rem);
            font-weight: 900;
            text-transform: uppercase;
            background: linear-gradient(45deg, var(--neon-cyan), var(--neon-magenta), var(--neon-yellow));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            letter-spacing: 0.1em;
            text-shadow: 0 0 30px rgba(0, 243, 255, 0.5);
            margin-bottom: 10px;
            animation: glowPulse 3s ease-in-out infinite;
        }

        @keyframes glowPulse {
            0%, 100% { filter: drop-shadow(0 0 10px var(--neon-cyan)); }
            50% { filter: drop-shadow(0 0 30px var(--neon-magenta)); }
        }

        .subtitle {
            font-family: 'Press Start 2P', cursive;
            font-size: clamp(0.5rem, 2vw, 0.8rem);
            color: var(--neon-green);
            text-shadow: 0 0 10px var(--neon-green);
            letter-spacing: 0.2em;
        }

        .main-content {
            display: grid;
            grid-template-columns: 1fr;
            gap: 30px;
            margin-top: 30px;
        }

        @media (min-width: 1024px) {
            .main-content {
                grid-template-columns: 350px 1fr;
            }
        }

        .game-selector {
            background: linear-gradient(135deg, rgba(26, 10, 46, 0.9), rgba(10, 10, 15, 0.9));
            border: 2px solid var(--neon-cyan);
            border-radius: 15px;
            padding: 25px;
            box-shadow: 0 0 30px rgba(0, 243, 255, 0.3);
        }

        .section-title {
            font-family: 'Orbitron', sans-serif;
            font-size: 1.5rem;
            color: var(--neon-yellow);
            margin-bottom: 20px;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            text-shadow: 0 0 10px var(--neon-yellow);
        }

        .platform-filters {
            display: flex;
            gap: 8px;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }

        .filter-btn {
            padding: 8px 14px;
            background: rgba(0, 243, 255, 0.05);
            border: 1px solid var(--neon-cyan);
            border-radius: 5px;
            color: var(--neon-cyan);
            font-family: 'Rajdhani', sans-serif;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .filter-btn:hover {
            background: rgba(0, 243, 255, 0.15);
            box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
        }

        .filter-btn.active {
            background: var(--neon-cyan);
            color: var(--deep-black);
            border-color: var(--neon-cyan);
            box-shadow: 0 0 15px var(--neon-cyan);
        }

        .game-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
            gap: 15px;
            margin-bottom: 25px;
            max-height: 450px;
            overflow-y: auto;
            padding-right: 5px;
        }

        .game-grid::-webkit-scrollbar {
            width: 8px;
        }

        .game-grid::-webkit-scrollbar-track {
            background: rgba(0, 243, 255, 0.1);
            border-radius: 4px;
        }

        .game-grid::-webkit-scrollbar-thumb {
            background: var(--neon-cyan);
            border-radius: 4px;
        }

        .game-grid::-webkit-scrollbar-thumb:hover {
            background: var(--neon-magenta);
        }

        .game-card {
            background: rgba(0, 243, 255, 0.05);
            border: 2px solid var(--neon-cyan);
            border-radius: 10px;
            padding: 15px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .platform-badge {
            position: absolute;
            top: 5px;
            right: 5px;
            padding: 2px 6px;
            background: rgba(57, 255, 20, 0.2);
            border: 1px solid var(--neon-green);
            border-radius: 3px;
            font-size: 0.5rem;
            font-family: 'Press Start 2P', cursive;
            color: var(--neon-green);
            text-transform: uppercase;
        }

        .game-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(0, 243, 255, 0.3), transparent);
            transition: left 0.5s ease;
        }

        .game-card:hover::before {
            left: 100%;
        }

        .game-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 0 25px var(--neon-cyan);
            border-color: var(--neon-magenta);
        }

        .game-card.selected {
            background: rgba(255, 0, 255, 0.2);
            border-color: var(--neon-magenta);
            box-shadow: 0 0 20px var(--neon-magenta);
        }

        .game-icon {
            font-size: 2rem;
            margin-bottom: 8px;
        }

        .game-name {
            font-family: 'Press Start 2P', cursive;
            font-size: 0.6rem;
            color: var(--neon-cyan);
            line-height: 1.4;
        }

        .options-group {
            margin-bottom: 20px;
        }

        .option-label {
            font-family: 'Orbitron', sans-serif;
            font-size: 0.9rem;
            color: var(--neon-green);
            margin-bottom: 10px;
            display: block;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .option-buttons {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        .option-btn {
            flex: 1;
            min-width: 70px;
            padding: 10px;
            background: rgba(0, 243, 255, 0.1);
            border: 1px solid var(--neon-cyan);
            border-radius: 5px;
            color: var(--neon-cyan);
            font-family: 'Rajdhani', sans-serif;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
        }

        .option-btn:hover {
            background: rgba(0, 243, 255, 0.2);
            box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
        }

        .option-btn.active {
            background: var(--neon-magenta);
            color: var(--deep-black);
            border-color: var(--neon-magenta);
            box-shadow: 0 0 20px var(--neon-magenta);
        }

        select {
            width: 100%;
            padding: 12px;
            background: rgba(0, 243, 255, 0.1);
            border: 1px solid var(--neon-cyan);
            border-radius: 5px;
            color: var(--neon-cyan);
            font-family: 'Rajdhani', sans-serif;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
        }

        .generate-btn {
            width: 100%;
            padding: 18px;
            background: linear-gradient(135deg, var(--neon-magenta), var(--neon-cyan));
            border: none;
            border-radius: 10px;
            color: var(--deep-black);
            font-family: 'Orbitron', sans-serif;
            font-size: 1.2rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 0 30px rgba(255, 0, 255, 0.5);
            position: relative;
            overflow: hidden;
        }

        .generate-btn::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.3);
            transform: translate(-50%, -50%);
            transition: width 0.6s ease, height 0.6s ease;
        }

        .generate-btn:hover::before {
            width: 300px;
            height: 300px;
        }

        .generate-btn:hover {
            transform: scale(1.05);
            box-shadow: 0 0 50px var(--neon-magenta);
        }

        .generate-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: scale(1);
        }

        .game-display {
            background: linear-gradient(135deg, rgba(26, 10, 46, 0.9), rgba(10, 10, 15, 0.9));
            border: 2px solid var(--neon-magenta);
            border-radius: 15px;
            padding: 25px;
            min-height: 600px;
            box-shadow: 0 0 30px rgba(255, 0, 255, 0.3);
            display: flex;
            flex-direction: column;
        }

        .status-display {
            text-align: center;
            padding: 60px 20px;
        }

        .status-icon {
            font-size: 5rem;
            margin-bottom: 20px;
            animation: float 3s ease-in-out infinite;
        }

        @keyframes float {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-20px); }
        }

        .status-text {
            font-family: 'Orbitron', sans-serif;
            font-size: 1.3rem;
            color: var(--neon-yellow);
            margin-bottom: 15px;
        }

        .status-subtext {
            color: var(--neon-cyan);
            font-size: 1rem;
            opacity: 0.8;
        }

        .loading-spinner {
            display: inline-block;
            width: 60px;
            height: 60px;
            border: 4px solid rgba(0, 243, 255, 0.2);
            border-top-color: var(--neon-cyan);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 20px auto;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        .game-frame {
            flex: 1;
            border: 2px solid var(--neon-cyan);
            border-radius: 10px;
            background: #000;
            overflow: hidden;
            box-shadow: inset 0 0 30px rgba(0, 243, 255, 0.2);
        }

        .game-frame iframe {
            width: 100%;
            height: 100%;
            border: none;
            display: block;
        }

        .error-display {
            background: rgba(255, 0, 0, 0.1);
            border: 2px solid #ff0000;
            border-radius: 10px;
            padding: 20px;
            margin: 20px 0;
            color: #ff6666;
        }

        .error-title {
            font-family: 'Orbitron', sans-serif;
            font-size: 1.2rem;
            margin-bottom: 10px;
        }

        .game-controls {
            display: flex;
            gap: 10px;
            margin-top: 15px;
            flex-wrap: wrap;
        }

        .control-btn {
            flex: 1;
            min-width: 120px;
            padding: 12px;
            background: rgba(0, 243, 255, 0.1);
            border: 1px solid var(--neon-cyan);
            border-radius: 8px;
            color: var(--neon-cyan);
            font-family: 'Rajdhani', sans-serif;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
        }

        .control-btn:hover {
            background: rgba(0, 243, 255, 0.2);
            box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
        }

        /* Responsive adjustments */
        @media (max-width: 768px) {
            .game-grid {
                grid-template-columns: repeat(2, 1fr);
            }

            .option-buttons {
                flex-direction: column;
            }

            .option-btn {
                min-width: 100%;
            }
        }

        /* Package Download Section */
        .package-section {
            background: linear-gradient(135deg, rgba(26, 10, 46, 0.9), rgba(10, 10, 15, 0.9));
            border: 2px solid var(--neon-yellow);
            border-radius: 15px;
            padding: 25px;
            margin-top: 30px;
            box-shadow: 0 0 30px rgba(255, 255, 0, 0.3);
        }

        .package-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }

        .package-card {
            background: rgba(0, 243, 255, 0.05);
            border: 2px solid var(--neon-cyan);
            border-radius: 10px;
            padding: 20px;
            transition: all 0.3s ease;
            cursor: pointer;
        }

        .package-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 0 25px var(--neon-cyan);
            border-color: var(--neon-magenta);
        }

        .package-icon {
            font-size: 3rem;
            text-align: center;
            margin-bottom: 15px;
        }

        .package-title {
            font-family: 'Orbitron', sans-serif;
            font-size: 1.3rem;
            color: var(--neon-yellow);
            text-align: center;
            margin-bottom: 10px;
            text-transform: uppercase;
        }

        .package-desc {
            color: var(--neon-cyan);
            text-align: center;
            font-size: 0.9rem;
            margin-bottom: 15px;
            line-height: 1.6;
        }

        .package-features {
            list-style: none;
            margin-bottom: 15px;
            font-size: 0.85rem;
        }

        .package-features li {
            padding: 5px 0;
            color: var(--neon-green);
        }

        .package-features li::before {
            content: 'โ–ธ ';
            color: var(--neon-magenta);
        }

        .download-pkg-btn {
            width: 100%;
            padding: 12px;
            background: linear-gradient(135deg, var(--neon-green), var(--neon-cyan));
            border: none;
            border-radius: 8px;
            color: var(--deep-black);
            font-family: 'Orbitron', sans-serif;
            font-size: 1rem;
            font-weight: 700;
            text-transform: uppercase;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .download-pkg-btn:hover {
            transform: scale(1.05);
            box-shadow: 0 0 30px var(--neon-green);
        }

        /* AGENTS.md Viewer */
        .agents-viewer {
            position: fixed;
            top: 0;
            right: -600px;
            width: 600px;
            height: 100vh;
            background: linear-gradient(135deg, rgba(26, 10, 46, 0.98), rgba(10, 10, 15, 0.98));
            border-left: 2px solid var(--neon-cyan);
            box-shadow: -5px 0 30px rgba(0, 243, 255, 0.5);
            transition: right 0.4s ease;
            z-index: 10000;
            overflow-y: auto;
            padding: 30px;
        }

        .agents-viewer.open {
            right: 0;
        }

        .agents-viewer h2 {
            font-family: 'Orbitron', sans-serif;
            color: var(--neon-yellow);
            margin-bottom: 20px;
            font-size: 1.5rem;
        }

        .agents-viewer h3 {
            font-family: 'Orbitron', sans-serif;
            color: var(--neon-cyan);
            margin-top: 20px;
            margin-bottom: 10px;
            font-size: 1.1rem;
        }

        .agents-viewer p, .agents-viewer li {
            color: var(--neon-cyan);
            line-height: 1.8;
            font-size: 0.9rem;
            margin-bottom: 10px;
        }

        .agents-viewer code {
            background: rgba(0, 243, 255, 0.1);
            padding: 2px 6px;
            border-radius: 3px;
            color: var(--neon-green);
            font-family: monospace;
        }

        .agents-viewer pre {
            background: rgba(0, 0, 0, 0.5);
            border: 1px solid var(--neon-cyan);
            border-radius: 5px;
            padding: 15px;
            overflow-x: auto;
            margin: 15px 0;
        }

        .agents-viewer pre code {
            background: none;
            padding: 0;
        }

        .close-agents-btn {
            position: absolute;
            top: 20px;
            right: 20px;
            background: var(--neon-magenta);
            border: none;
            color: var(--deep-black);
            width: 40px;
            height: 40px;
            border-radius: 50%;
            font-size: 1.5rem;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .close-agents-btn:hover {
            transform: rotate(90deg);
            box-shadow: 0 0 20px var(--neon-magenta);
        }

        .view-agents-btn {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background: linear-gradient(135deg, var(--neon-magenta), var(--neon-cyan));
            border: 2px solid var(--neon-cyan);
            color: var(--deep-black);
            padding: 15px 25px;
            border-radius: 50px;
            font-family: 'Orbitron', sans-serif;
            font-size: 0.9rem;
            font-weight: 700;
            text-transform: uppercase;
            cursor: pointer;
            transition: all 0.3s ease;
            z-index: 9998;
            box-shadow: 0 0 30px rgba(255, 0, 255, 0.5);
        }

        .view-agents-btn:hover {
            transform: scale(1.1);
            box-shadow: 0 0 50px var(--neon-magenta);
        }

        /* Scan line effect */
        @keyframes scanline {
            0% { transform: translateY(-100%); }
            100% { transform: translateY(100vh); }
        }

        body::after {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 3px;
            background: linear-gradient(to bottom, transparent, var(--neon-cyan), transparent);
            opacity: 0.3;
            animation: scanline 8s linear infinite;
            pointer-events: none;
            z-index: 9999;
        }

        @media (max-width: 768px) {
            .agents-viewer {
                width: 100%;
                right: -100%;
            }

            .package-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>ARC8X</h1>
            <div class="subtitle">AI Game Generation Engine</div>
        </header>

        <div class="main-content">
            <div class="game-selector">
                <div class="section-title">Select Game</div>
                <div class="platform-filters" id="platformFilters">
                    <button class="filter-btn active" data-platform="all">All</button>
                    <button class="filter-btn" data-platform="arcade">Arcade</button>
                    <button class="filter-btn" data-platform="nes">NES</button>
                    <button class="filter-btn" data-platform="snes">SNES</button>
                    <button class="filter-btn" data-platform="genesis">Genesis</button>
                    <button class="filter-btn" data-platform="ps1">PS1</button>
                </div>
                <div class="game-grid" id="gameGrid"></div>

                <div class="options-group">
                    <label class="option-label">Dimension</label>
                    <div class="option-buttons">
                        <button class="option-btn active" data-option="dimension" data-value="2d">2D Classic</button>
                        <button class="option-btn" data-option="dimension" data-value="2d-modern">2D Modern</button>
                        <button class="option-btn" data-option="dimension" data-value="3d">3D</button>
                    </div>
                </div>

                <div class="options-group">
                    <label class="option-label">Art Style</label>
                    <div class="option-buttons">
                        <button class="option-btn active" data-option="style" data-value="pixel">Pixel Art</button>
                        <button class="option-btn" data-option="style" data-value="neon">Neon</button>
                        <button class="option-btn" data-option="style" data-value="minimal">Minimal</button>
                    </div>
                </div>

                <div class="options-group">
                    <label class="option-label">Difficulty</label>
                    <select id="difficulty">
                        <option value="easy">Easy</option>
                        <option value="normal" selected>Normal</option>
                        <option value="hard">Hard</option>
                        <option value="insane">Insane</option>
                    </select>
                </div>

                <div class="options-group">
                    <label class="option-label">Controls</label>
                    <div class="option-buttons">
                        <button class="option-btn active" data-option="controls" data-value="auto">Auto-Detect</button>
                        <button class="option-btn" data-option="controls" data-value="keyboard">Keyboard</button>
                        <button class="option-btn" data-option="controls" data-value="touch">Touch</button>
                    </div>
                </div>

                <button class="generate-btn" id="generateBtn" disabled>
                    <span style="position: relative; z-index: 1;">โšก Generate Game โšก</span>
                </button>
            </div>

            <div class="game-display">
                <div class="status-display" id="statusDisplay">
                    <div class="status-icon">๐ŸŽฎ</div>
                    <div class="status-text">Ready to Build</div>
                    <div class="status-subtext">Select a classic game to rebuild with modern technology</div>
                </div>
                <div id="gameContainer" style="display: none; flex: 1; display: flex; flex-direction: column;">
                    <div class="game-frame" style="flex: 1; min-height: 500px;">
                        <iframe id="gameFrame"></iframe>
                    </div>
                    <div class="game-controls">
                        <button class="control-btn" id="newGameBtn">๐Ÿ”„ New Game</button>
                        <button class="control-btn" id="downloadBtn">๐Ÿ’พ Download</button>
                    </div>
                </div>
            </div>
        </div>

        <!-- Package Download Section -->
        <div class="package-section">
            <div class="section-title">๐Ÿ“ฆ Download ARC8X Packages</div>
            <p style="color: var(--neon-cyan); text-align: center; margin-bottom: 20px;">
                Get standalone versions with pre-configured AI backends. No setup required!
            </p>
            <div class="package-grid">
                <div class="package-card">
                    <div class="package-icon">๐Ÿ”ฎ</div>
                    <div class="package-title">ARC8X + Gemini</div>
                    <div class="package-desc">Powered by Google's Gemini 2.0 Flash - Fast, intelligent, multimodal game generation</div>
                    <ul class="package-features">
                        <li>Google Gemini API integration</li>
                        <li>Multimodal capabilities</li>
                        <li>Free tier available</li>
                        <li>API key configuration UI</li>
                        <li>Real-time generation status</li>
                    </ul>
                    <button class="download-pkg-btn" onclick="downloadPackage('gemini')">โฌ‡ Download ARC8X-Gemini</button>
                </div>

                <div class="package-card">
                    <div class="package-icon">๐Ÿ–ฅ๏ธ</div>
                    <div class="package-title">ARC8X + Local LLMs</div>
                    <div class="package-desc">Auto-discovers Ollama, LMStudio, and LocalAI - 100% private, offline-capable</div>
                    <ul class="package-features">
                        <li>Auto-discover local models</li>
                        <li>Ollama integration (port 11434)</li>
                        <li>LMStudio support (port 1234)</li>
                        <li>LocalAI compatibility (port 8080)</li>
                        <li>Zero API costs, fully private</li>
                    </ul>
                    <button class="download-pkg-btn" onclick="downloadPackage('local')">โฌ‡ Download ARC8X-LocalLLMs</button>
                </div>

                <div class="package-card">
                    <div class="package-icon">โšก</div>
                    <div class="package-title">ARC8X + Grok</div>
                    <div class="package-desc">Powered by xAI's Grok - Advanced reasoning with personality and speed</div>
                    <ul class="package-features">
                        <li>xAI Grok API integration</li>
                        <li>Advanced reasoning abilities</li>
                        <li>Fast response times</li>
                        <li>API key configuration UI</li>
                        <li>Unique creative outputs</li>
                    </ul>
                    <button class="download-pkg-btn" onclick="downloadPackage('grok')">โฌ‡ Download ARC8X-Grok</button>
                </div>
            </div>
        </div>
    </div>

    <!-- AGENTS.md Viewer -->
    <div class="agents-viewer" id="agentsViewer">
        <button class="close-agents-btn" onclick="toggleAgentsViewer()">ร—</button>
        <div id="agentsContent"></div>
    </div>

    <!-- Floating Button to View AGENTS.md -->
    <button class="view-agents-btn" onclick="toggleAgentsViewer()">๐Ÿ“‹ Agent Docs</button>
    <script>
        // Optimized game database with lazy loading
        const GAME_DB = {
            arcade: [
                { id: 'galaga', name: 'Galaga', icon: '๐Ÿš€', description: 'Classic space shooter' },
                { id: 'pacman', name: 'Pac-Man', icon: '๐Ÿ‘พ', description: 'Maze navigation game' },
                { id: 'space-invaders', name: 'Space Invaders', icon: '๐Ÿ‘ฝ', description: 'Alien shooter' }
            ],
            nes: [
                { id: 'super-mario', name: 'Super Mario', icon: '๐Ÿ„', description: 'Platform adventure' },
                { id: 'metroid', name: 'Metroid', icon: '๐Ÿค–', description: 'Exploration game' }
            ],
            snes: [
                { id: 'kirby', name: 'Kirby', icon: '๐ŸŒธ', description: 'Ability-copying hero' }
            ],
            genesis: [
                { id: 'sonic', name: 'Sonic', icon: '๐Ÿ’จ', description: 'Speed platformer' }
            ],
            ps1: [
                { id: 'crash-bandicoot', name: 'Crash Bandicoot', icon: '๐ŸฆŠ', description: '3D platformer' }
            ]
        };

        // Web Worker for game generation
        const gameWorker = new Worker('game-worker.js');
const games = [
            // === ARCADE CLASSICS ===
            { id: 'galaga', name: 'Galaga', icon: '๐Ÿš€', platform: 'arcade', description: 'Classic space shooter with formation-flying enemies' },
            { id: 'pacman', name: 'Pac-Man', icon: '๐Ÿ‘พ', platform: 'arcade', description: 'Navigate mazes and eat pellets while avoiding ghosts' },
            { id: 'space-invaders', name: 'Space Invaders', icon: '๐Ÿ‘ฝ', platform: 'arcade', description: 'Defend Earth from descending alien invaders' },
            { id: 'breakout', name: 'Breakout', icon: '๐Ÿงฑ', platform: 'arcade', description: 'Break bricks with a ball and paddle' },
            { id: 'asteroids', name: 'Asteroids', icon: 'โ˜„๏ธ', platform: 'arcade', description: 'Navigate space and destroy asteroids' },
            { id: 'snake', name: 'Snake', icon: '๐Ÿ', platform: 'arcade', description: 'Guide the snake to eat food and grow' },
            { id: 'tetris', name: 'Tetris', icon: '๐ŸŸฆ', platform: 'arcade', description: 'Arrange falling blocks to clear lines' },
            { id: 'frogger', name: 'Frogger', icon: '๐Ÿธ', platform: 'arcade', description: 'Guide frogs across traffic and rivers' },
            { id: 'donkey-kong', name: 'Donkey Kong', icon: '๐Ÿฆ', platform: 'arcade', description: 'Climb platforms to rescue the princess' },
            { id: 'pong', name: 'Pong', icon: '๐Ÿ“', platform: 'arcade', description: 'The classic table tennis arcade game' },
            { id: 'missile-command', name: 'Missile Command', icon: '๐ŸŽฏ', platform: 'arcade', description: 'Defend cities from incoming missiles' },
            { id: 'centipede', name: 'Centipede', icon: '๐Ÿ›', platform: 'arcade', description: 'Shoot the descending centipede and mushrooms' },

            // === NES/SNES ERA ===
            { id: 'super-mario', name: 'Super Mario', icon: '๐Ÿ„', platform: 'nes', description: 'Platform through worlds, jump on enemies, rescue the princess' },
            { id: 'contra', name: 'Contra', icon: '๐Ÿ’ฅ', platform: 'nes', description: 'Run and gun through alien invasion with spread gun' },
            { id: 'metroid', name: 'Metroid', icon: '๐Ÿค–', platform: 'nes', description: 'Explore alien world, gain abilities, find secrets' },
            { id: 'mega-man', name: 'Mega Man', icon: 'โšก', platform: 'nes', description: 'Action platformer with weapon-stealing boss battles' },
            { id: 'castlevania', name: 'Castlevania', icon: '๐Ÿง›', platform: 'nes', description: 'Whip vampires in gothic platforming action' },
            { id: 'kirby', name: 'Kirby', icon: '๐ŸŒธ', platform: 'snes', description: 'Inhale enemies and copy their abilities' },
            { id: 'f-zero', name: 'F-Zero', icon: '๐ŸŽ๏ธ', platform: 'snes', description: 'High-speed futuristic racing with Mode 7' },
            { id: 'star-fox', name: 'Star Fox', icon: '๐ŸฆŠ', platform: 'snes', description: 'Rail shooter in space with 3D graphics' },
            { id: 'zelda', name: 'Zelda', icon: 'โš”๏ธ', platform: 'snes', description: 'Top-down adventure with dungeons and puzzles' },

            // === SEGA ERA ===
            { id: 'sonic', name: 'Sonic', icon: '๐Ÿ’จ', platform: 'genesis', description: 'Speed through loop-de-loops collecting rings' },
            { id: 'streets-of-rage', name: 'Streets of Rage', icon: '๐Ÿ‘Š', platform: 'genesis', description: 'Side-scrolling beat em up through city streets' },
            { id: 'golden-axe', name: 'Golden Axe', icon: '๐Ÿช“', platform: 'genesis', description: 'Hack and slash barbarian fantasy action' },
            { id: 'shinobi', name: 'Shinobi', icon: '๐Ÿฅท', platform: 'genesis', description: 'Ninja platformer with shurikens and katana' },
            { id: 'altered-beast', name: 'Altered Beast', icon: '๐Ÿบ', platform: 'genesis', description: 'Transform into beasts to fight demons' },
            { id: 'outrun', name: 'OutRun', icon: '๐ŸŒด', platform: 'genesis', description: 'Arcade racing through scenic highways' },
            { id: 'comix-zone', name: 'Comix Zone', icon: '๐Ÿ“–', platform: 'genesis', description: 'Beat em up inside a living comic book' },

            // === PS1 ERA ===
            { id: 'crash-bandicoot', name: 'Crash Bandicoot', icon: '๐ŸฆŠ', platform: 'ps1', description: '3D platformer with crate-smashing action' },
            { id: 'spyro', name: 'Spyro', icon: '๐Ÿ‰', platform: 'ps1', description: 'Fly and flame breath through dragon worlds' },
            { id: 'metal-gear', name: 'Metal Gear', icon: '๐Ÿ“ฆ', platform: 'ps1', description: 'Stealth action with tactical espionage' },
            { id: 'resident-evil', name: 'Resident Evil', icon: '๐ŸงŸ', platform: 'ps1', description: 'Survival horror with fixed camera angles' },
            { id: 'final-fantasy', name: 'Final Fantasy', icon: '๐Ÿ—ก๏ธ', platform: 'ps1', description: 'Turn-based JRPG with epic story' },
            { id: 'ridge-racer', name: 'Ridge Racer', icon: '๐Ÿ', platform: 'ps1', description: 'Drift racing with powersliding mechanics' },
            { id: 'tomb-raider', name: 'Tomb Raider', icon: '๐Ÿ”ซ', platform: 'ps1', description: '3D exploration and puzzle platforming' },
            { id: 'tony-hawk', name: 'Tony Hawk', icon: '๐Ÿ›น', platform: 'ps1', description: 'Skateboarding with tricks and combos' },
            { id: 'silent-hill', name: 'Silent Hill', icon: '๐ŸŒซ๏ธ', platform: 'ps1', description: 'Psychological horror in foggy town' },
            { id: 'parappa', name: 'PaRappa', icon: '๐ŸŽค', platform: 'ps1', description: 'Rhythm game with rapping puppy' }
        ];
        // Optimized state management
        const state = {
            selectedGame: null,
            currentPlatform: 'all',
            options: {
                dimension: '2d',
                style: 'pixel',
                difficulty: 'normal',
                controls: 'auto'
            },
            cache: new Map(),
            lastRenderTime: 0
        };
        // Performance-optimized initialization
        function init() {
            requestIdleCallback(() => {
                setupEventListeners();
                setupPoeHandlers();
                renderGameGrid();
            }, { timeout: 1000 });

            // Preload critical assets
            const preload = document.createElement('link');
            preload.rel = 'preload';
            preload.href = 'game-worker.js';
            preload.as = 'script';
            document.head.appendChild(preload);
        }
        // Virtualized game grid rendering
        function renderGameGrid(platform = 'all') {
            const now = performance.now();
            if (now - state.lastRenderTime < 100) return;
            state.lastRenderTime = now;

            const grid = document.getElementById('gameGrid');
            const cacheKey = `grid-${platform}`;
            
            if (state.cache.has(cacheKey)) {
                grid.innerHTML = state.cache.get(cacheKey);
            } else {
                const games = platform === 'all' 
                    ? Object.values(GAME_DB).flat() 
                    : GAME_DB[platform] || [];
                
                const html = games.map(game => `
                    <div class="game-card" data-game="${game.id}" title="${game.description}">
                        <div class="platform-badge">${game.platform}</div>
                        <div class="game-icon">${game.icon}</div>
                        <div class="game-name">${game.name}</div>
                    </div>
                `).join('');
                
                state.cache.set(cacheKey, html);
                grid.innerHTML = html;
            }

            // Delegate click events
            grid.addEventListener('click', (e) => {
                const card = e.target.closest('.game-card');
                if (card) selectGame(card.dataset.game);
            });
        }
function setupPlatformFilters() {
            document.querySelectorAll('.filter-btn').forEach(btn => {
                btn.addEventListener('click', () => {
                    const platform = btn.dataset.platform;
                    currentPlatform = platform;

                    // Update active state
                    document.querySelectorAll('.filter-btn').forEach(b => {
                        b.classList.remove('active');
                    });
                    btn.classList.add('active');

                    // Re-render grid
                    renderGameGrid(platform);
                });
            });
        }

        function selectGame(gameId) {
            selectedGame = gameId;
            document.querySelectorAll('.game-card').forEach(card => {
                card.classList.toggle('selected', card.dataset.game === gameId);
            });
            document.getElementById('generateBtn').disabled = false;
        }

        function setupOptionButtons() {
            document.querySelectorAll('.option-btn').forEach(btn => {
                btn.addEventListener('click', () => {
                    const option = btn.dataset.option;
                    const value = btn.dataset.value;
                    options[option] = value;

                    // Update active state
                    document.querySelectorAll(`[data-option="${option}"]`).forEach(b => {
                        b.classList.remove('active');
                    });
                    btn.classList.add('active');
                });
            });

            document.getElementById('difficulty').addEventListener('change', (e) => {
                options.difficulty = e.target.value;
            });
        }

        function setupEventListeners() {
            document.getElementById('generateBtn').addEventListener('click', generateGame);
            document.getElementById('newGameBtn').addEventListener('click', resetBuilder);
            document.getElementById('downloadBtn').addEventListener('click', downloadGame);
        }

        let currentGameCode = '';
        let isGenerating = false;

        function setupPoeHandlers() {
            if (!window.Poe) {
                console.error('Poe API not available');
                return;
            }

            window.Poe.registerHandler('game-generator', (result, context) => {
                const msg = result.responses[0];

                if (msg.status === 'error') {
                    showError('Generation failed: ' + (msg.statusText || 'Unknown error'));
                    isGenerating = false;
                } else if (msg.status === 'incomplete') {
                    updateGenerationStatus('Building your game...', msg.content.length);
                    currentGameCode = msg.content;
                } else if (msg.status === 'complete') {
                    currentGameCode = msg.content;
                    displayGame(currentGameCode);
                    isGenerating = false;
                }
            });
        }

        async function generateGame() {
            if (!selectedGame || isGenerating) return;

            isGenerating = true;
            const game = games.find(g => g.id === selectedGame);
            document.getElementById('generateBtn').disabled = true;

            // Show loading state
            const statusDisplay = document.getElementById('statusDisplay');
            statusDisplay.innerHTML = `
                <div class="loading-spinner"></div>
                <div class="status-text">Generating ${game.name}...</div>
                <div class="status-subtext">Creating a ${options.dimension.toUpperCase()} ${options.style} version</div>
            `;
            statusDisplay.style.display = 'block';
            document.getElementById('gameContainer').style.display = 'none';

            // Build detailed prompt with platform-specific instructions
            const platformInstructions = {
                'nes': 'Recreate the NES era feel with limited color palette (52 colors), 8-bit style sprites, scrolling limitations, and classic chiptune sounds.',
                'snes': 'Capture the SNES era with enhanced 16-bit graphics, Mode 7 effects if applicable (for racing/3D games), richer colors, and improved sound quality.',
                'genesis': 'Emulate Sega Genesis style with edgy attitude, fast-paced action, blast processing speed, and distinctive FM synthesis audio.',
                'ps1': 'Recreate PS1 aesthetic with low-poly 3D graphics, vertex wobble/jitter, texture warping, fixed camera angles (for horror), and CD-quality audio.',
                'arcade': 'Classic arcade cabinet feel with high score tracking, attract mode, coin-op style gameplay loops, and arcade-perfect controls.'
            };

            const platformNote = platformInstructions[game.platform] || '';

            const prompt = `@Claude-Sonnet-4.5 Create a complete, production-ready, fully playable ${game.name} game as a single HTML file.

Game Requirements:
- Original Platform: ${game.platform.toUpperCase()}
- Platform Style: ${platformNote}
- Render Style: ${options.dimension} with ${options.style} art style
- Difficulty: ${options.difficulty}
- Controls: ${options.controls === 'auto' ? 'Support both keyboard and touch controls' : options.controls + ' controls only'}
- Must be a COMPLETE, self-contained HTML file with inline CSS and JavaScript
- Include proper game mechanics, scoring, lives/health system, and game over screen
- Add smooth animations and responsive controls
- ${options.dimension === '3d' ? 'Use Three.js from CDN (https://cdn.jsdelivr.net/npm/three@0.150.0/build/three.min.js) for 3D rendering' : 'Use Canvas 2D API'}
- ${options.style === 'neon' ? 'Use vibrant neon colors with glow effects' : ''}
- ${options.style === 'pixel' ? 'Use crisp pixel art aesthetic with retro feel' : ''}
- ${options.style === 'minimal' ? 'Use clean, minimalist design with simple shapes' : ''}
- Include start screen, gameplay, pause function, and game over screen
- Add sound effects using Web Audio API (match the platform aesthetic)
- Make it mobile-responsive if touch controls are enabled
- Implement the FULL classic gameplay mechanics of ${game.name}
- ${game.description}

Output ONLY the complete HTML code with NO explanations, markdown formatting, or code blocks. Start directly with <!DOCTYPE html>.`;

            try {
                await window.Poe.sendUserMessage(prompt, {
                    handler: 'game-generator',
                    stream: true,
                    openChat: false
                });
            } catch (err) {
                showError('Failed to start generation: ' + err.message);
                isGenerating = false;
                document.getElementById('generateBtn').disabled = false;
            }
        }

        function updateGenerationStatus(message, progress) {
            const statusDisplay = document.getElementById('statusDisplay');
            const progressText = progress ? `(${Math.floor(progress / 100)} KB generated)` : '';
            statusDisplay.innerHTML = `
                <div class="loading-spinner"></div>
                <div class="status-text">${message}</div>
                <div class="status-subtext">${progressText}</div>
            `;
        }

        function displayGame(htmlCode) {
            // Extract just the HTML if it's wrapped in markdown
            let cleanCode = htmlCode.trim();
            if (cleanCode.includes('```html')) {
                cleanCode = cleanCode.split('```html')[1].split('```')[0].trim();
            } else if (cleanCode.includes('```')) {
                cleanCode = cleanCode.split('```')[1].split('```')[0].trim();
            }

            // Display the game
            const gameFrame = document.getElementById('gameFrame');
            const blob = new Blob([cleanCode], { type: 'text/html' });
            const url = URL.createObjectURL(blob);
            gameFrame.src = url;

            document.getElementById('statusDisplay').style.display = 'none';
            document.getElementById('gameContainer').style.display = 'flex';
            document.getElementById('generateBtn').disabled = false;
        }

        function showError(message) {
            const statusDisplay = document.getElementById('statusDisplay');
            statusDisplay.innerHTML = `
                <div class="error-display">
                    <div class="error-title">โš ๏ธ Error</div>
                    <div>${message}</div>
                </div>
                <div class="status-text">Please try again</div>
            `;
            statusDisplay.style.display = 'block';
            document.getElementById('gameContainer').style.display = 'none';
            document.getElementById('generateBtn').disabled = false;
        }

        function resetBuilder() {
            document.getElementById('gameContainer').style.display = 'none';
            document.getElementById('statusDisplay').style.display = 'block';
            document.getElementById('statusDisplay').innerHTML = `
                <div class="status-icon">๐ŸŽฎ</div>
                <div class="status-text">Ready to Build</div>
                <div class="status-subtext">Select a classic game to rebuild with modern technology</div>
            `;
            document.getElementById('gameFrame').src = '';
            currentGameCode = '';
        }

        function downloadGame() {
            if (!currentGameCode) return;

            const game = games.find(g => g.id === selectedGame);
            const filename = `${selectedGame}-${options.dimension}-${Date.now()}.html`;

            const blob = new Blob([currentGameCode], { type: 'text/html' });
            const url = URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = filename;
            a.click();
            URL.revokeObjectURL(url);
        }

        // Performance optimization: Throttled scroll handler using requestAnimationFrame
        let scrollThrottled = false;
        function handleScroll() {
            if (scrollThrottled) return;

            scrollThrottled = true;
            window.requestAnimationFrame(() => {
                // Any scroll-based logic goes here
                // Example: sticky elements, parallax, scroll animations
                scrollThrottled = false;
            });
        }

        // Only attach if we need scroll-based features
        // window.addEventListener('scroll', handleScroll, { passive: true });

        // Dark mode detection
        if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
            document.documentElement.classList.add('dark');
        }
        window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
            if (event.matches) {
                document.documentElement.classList.add('dark');
            } else {
                document.documentElement.classList.remove('dark');
            }
        });

        // AGENTS.md Content (embedded)
        const agentsMdContent = `# ARC8X - AI Agent Automation Documentation

**Version:** 1.0.0 | **Engine:** AI Game Generation Engine

---

## ๐ŸŽฏ Core Principle

ARC8X is designed for **zero-friction AI automation**. Any AI agent following these instructions should be able to successfully complete requested tasks with **minimal or zero redirection** from users.

## ๐Ÿ“‹ System Architecture

- **Frontend:** Pure HTML5 + CSS3 + Vanilla JavaScript
- **No Dependencies:** All code self-contained in single HTML file
- **AI Backend:** Poe Embed API / Google Gemini / xAI Grok / Local LLMs
- **Rendering:** Canvas 2D API / Three.js (CDN for 3D)

## ๐Ÿค– Quick Task Reference

### Add Game
1. Locate \`games\` array in \`<script>\`
2. Add: \`{ id: 'slug', name: 'Name', icon: '๐ŸŽฎ', platform: 'platform', description: '...' }\`
3. Verify in UI

### Add Platform
1. Add button: \`<button class="filter-btn" data-platform="id">Name</button>\`
2. Add to \`platformInstructions\` object
3. Add 5+ games for platform

### Modify AI Backend
- **Poe:** \`setupPoeHandlers()\`, \`generateGame()\`
- **Gemini:** Add API key UI, implement fetch to Google API
- **Local:** Add discovery for Ollama/LMStudio/LocalAI
- **Grok:** Add API key UI, implement xAI API calls

### UI Enhancement
- Use cyberpunk neon aesthetic (cyan/magenta/yellow on black)
- Fonts: Orbitron, Press Start 2P, Rajdhani
- Smooth animations (0.3s ease), glow effects
- Mobile-first responsive

## ๐Ÿ”ง Critical Rules

1. โœ… **Single-file structure** - Everything in index.html
2. โœ… **No external deps** - Only CSP-allowed CDNs
3. โœ… **Error handling** - Try-catch all API calls
4. โœ… **User feedback** - Loading states, clear errors
5. โœ… **Test generation** - Verify games work
6. โœ… **Preserve aesthetic** - Cyberpunk neon theme

## ๐Ÿ“š Reference

**Colors:**
\`\`\`css
--neon-cyan: #00f3ff
--neon-magenta: #ff00ff
--neon-yellow: #ffff00
--neon-green: #39ff14
--deep-black: #0a0a0f
\`\`\`

**Platforms:** arcade, nes, snes, genesis, ps1

**API Endpoints:**
- Gemini: \`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent\`
- Grok: \`https://api.x.ai/v1/chat/completions\`
- Ollama: \`http://localhost:11434/api/generate\`
- LMStudio: \`http://localhost:1234/v1/chat/completions\`

## โœ… QA Checklist

- [ ] Functionality works
- [ ] No console errors
- [ ] Responsive (320px - 1920px+)
- [ ] Matches aesthetic
- [ ] 16px+ input fonts
- [ ] Cross-browser tested

---

**๐Ÿ“– Full Documentation:** See complete AGENTS.md file for detailed instructions on maintenance, package generation, troubleshooting, and advanced automation.

*Last Updated: 2025-01-21 | Open Source*
`;

        // Toggle AGENTS.md Viewer
        function toggleAgentsViewer() {
            const viewer = document.getElementById('agentsViewer');
            const content = document.getElementById('agentsContent');

            if (!viewer.classList.contains('open')) {
                // Render markdown-style content
                content.innerHTML = agentsMdContent
                    .replace(/^# (.*$)/gm, '<h2>$1</h2>')
                    .replace(/^## (.*$)/gm, '<h3>$1</h3>')
                    .replace(/^### (.*$)/gm, '<h4 style="color: var(--neon-green); margin-top: 15px;">$1</h4>')
                    .replace(/\*\*(.*?)\*\*/g, '<strong style="color: var(--neon-yellow);">$1</strong>')
                    .replace(/\`\`\`css([^`]+)\`\`\`/g, '<pre><code>$1</code></pre>')
                    .replace(/\`([^`]+)\`/g, '<code>$1</code>')
                    .replace(/^- (.*$)/gm, '<li style="margin-left: 20px;">$1</li>')
                    .replace(/^\d+\. (.*$)/gm, '<li style="margin-left: 20px; list-style: decimal;">$1</li>')
                    .replace(/\n\n/g, '<br><br>');

                viewer.classList.add('open');
            } else {
                viewer.classList.remove('open');
            }
        }

        // Package Download Function
        async function downloadPackage(type) {
            const packages = {
                'gemini': {
                    name: 'ARC8X-Gemini',
                    description: 'Google Gemini API integration',
                    apiType: 'gemini'
                },
                'local': {
                    name: 'ARC8X-LocalLLMs',
                    description: 'Ollama/LMStudio/LocalAI support',
                    apiType: 'local'
                },
                'grok': {
                    name: 'ARC8X-Grok',
                    description: 'xAI Grok API integration',
                    apiType: 'grok'
                }
            };

            const pkg = packages[type];
            if (!pkg) return;

            // Read the current HTML
            const currentHtml = document.documentElement.outerHTML;

            // Create modified version for package
            let packageHtml = currentHtml;

            // Add package-specific modifications based on type
            if (type === 'gemini') {
                packageHtml = packageHtml.replace(
                    '</header>',
                    `</header>
                    <!-- GOOGLE GEMINI API CONFIGURATION -->
                    <div style="background: rgba(255,255,0,0.1); border: 2px solid var(--neon-yellow); border-radius: 10px; padding: 20px; margin: 20px auto; max-width: 600px;">
                        <h3 style="color: var(--neon-yellow); margin-bottom: 15px; font-family: Orbitron;">โš™๏ธ Gemini API Setup</h3>
                        <p style="color: var(--neon-cyan); margin-bottom: 10px;">Get your free API key from <a href="https://aistudio.google.com/app/apikey" target="_blank" style="color: var(--neon-magenta);">Google AI Studio</a></p>
                        <input type="password" id="geminiApiKey" placeholder="Enter your Gemini API key" style="width: 100%; padding: 12px; background: rgba(0,243,255,0.1); border: 1px solid var(--neon-cyan); border-radius: 5px; color: var(--neon-cyan); font-size: 16px; margin-bottom: 10px;">
                        <button onclick="saveGeminiKey()" style="width: 100%; padding: 12px; background: var(--neon-green); color: var(--deep-black); border: none; border-radius: 5px; font-weight: bold; cursor: pointer;">Save API Key</button>
                        <p id="keyStatus" style="color: var(--neon-green); margin-top: 10px; text-align: center;"></p>
                    </div>`
                );

                // Add Gemini-specific JavaScript
                packageHtml = packageHtml.replace(
                    '// Initialize app',
                    `// Gemini API Functions
                    function saveGeminiKey() {
                        const key = document.getElementById('geminiApiKey').value.trim();
                        if (key) {
                            localStorage.setItem('gemini_api_key', key);
                            document.getElementById('keyStatus').textContent = 'โœ“ API Key Saved!';
                            setTimeout(() => { document.getElementById('keyStatus').textContent = ''; }, 3000);
                        }
                    }

                    async function generateWithGemini(prompt) {
                        const apiKey = localStorage.getItem('gemini_api_key');
                        if (!apiKey) {
                            throw new Error('Please configure your Gemini API key first');
                        }

                        const response = await fetch('https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=' + apiKey, {
                            method: 'POST',
                            headers: { 'Content-Type': 'application/json' },
                            body: JSON.stringify({
                                contents: [{ parts: [{ text: prompt }] }],
                                generationConfig: {
                                    temperature: 0.7,
                                    maxOutputTokens: 8192
                                }
                            })
                        });

                        if (!response.ok) {
                            throw new Error('Gemini API error: ' + response.statusText);
                        }

                        const data = await response.json();
                        return data.candidates[0].content.parts[0].text;
                    }

                    // Initialize app`
                );
            }

            // Create downloadable file
            const blob = new Blob([packageHtml], { type: 'text/html' });
            const url = URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = `${pkg.name}-v1.0.0.html`;
            a.click();
            URL.revokeObjectURL(url);

            // Show success message
            const statusDisplay = document.getElementById('statusDisplay');
            statusDisplay.innerHTML = `
                <div class="status-icon">๐Ÿ“ฆ</div>
                <div class="status-text">Package Downloaded!</div>
                <div class="status-subtext">${pkg.name} - ${pkg.description}</div>
                <p style="color: var(--neon-cyan); margin-top: 20px;">
                    Open the downloaded HTML file in your browser to use ARC8X with ${pkg.description}.
                </p>
            `;
            statusDisplay.style.display = 'block';
            document.getElementById('gameContainer').style.display = 'none';

            // Scroll to top
            window.scrollTo({ top: 0, behavior: 'smooth' });
        }

        // Initialize app
        init();
    </script>
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
</body>
</html>