File size: 71,673 Bytes
a5bdb47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Parchís Royale | El juego de mesa clásico reinventado</title>
    <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🎲</text></svg>">
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
        
        body {
            font-family: 'Poppins', sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .board-4 {
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="600" height="600" viewBox="0 0 600 600"><path d="M300,0 L600,300 L300,600 L0,300 Z" fill="%23FF5252"/><path d="M300,0 L600,300 L300,600" fill="%234CAF50"/><path d="M300,0 L0,300 L300,600" fill="%23FFC107"/><path d="M300,0 L600,300 L0,300 Z" fill="%232196F3"/><circle cx="300" cy="300" r="100" fill="white"/></svg>');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
        }
        
        .board-6 {
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="600" height="600" viewBox="0 0 600 600"><path d="M300,0 L600,300 L300,600 L0,300 Z" fill="%23FF5252"/><path d="M300,0 L520,150 L450,300 L520,450 L300,600 L80,450 L150,300 L80,150 Z" fill="%234CAF50"/><path d="M300,0 L520,150 L600,300 L520,450 L300,600" fill="%23FFC107"/><path d="M300,0 L80,150 L0,300 L80,450 L300,600" fill="%232196F3"/><path d="M300,0 L520,150 L450,300 L600,300 L520,450 L300,600" fill="%239C27B0"/><path d="M300,0 L80,150 L150,300 L0,300 L80,450 L300,600" fill="%23FF9800"/><circle cx="300" cy="300" r="100" fill="white"/></svg>');
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
        }
        
        .piece {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: white;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
        }
        
        .piece:hover {
            transform: scale(1.1);
            box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
        }
        
        .dice {
            width: 60px;
            height: 60px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            font-weight: bold;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            cursor: pointer;
            transition: all 0.3s ease;
            background: white;
        }
        
        .dice:hover {
            transform: scale(1.05);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
        }
        
        .home-base {
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
        }
        
        .safe-spot {
            border: 3px dashed white;
            box-sizing: border-box;
        }
        
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }
        
        .modal-content {
            background: white;
            border-radius: 16px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
            max-width: 90%;
            max-height: 90%;
            overflow-y: auto;
        }
        
        .player-color-selector {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            cursor: pointer;
            margin: 0 5px;
            border: 2px solid transparent;
            transition: all 0.2s ease;
        }
        
        .player-color-selector:hover, .player-color-selector.selected {
            transform: scale(1.1);
            border-color: white;
        }
        
        .glow {
            animation: glow 1.5s infinite alternate;
        }
        
        @keyframes glow {
            from {
                box-shadow: 0 0 5px -5px currentColor;
            }
            to {
                box-shadow: 0 0 10px 5px currentColor;
            }
        }
        
        .path-cell {
            position: relative;
        }
        
        .path-cell::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 60%;
            height: 60%;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.2);
        }
        
        .winner-crown {
            position: absolute;
            top: -15px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 24px;
            color: gold;
            text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
        }
    </style>
</head>
<body class="text-gray-800">
    <!-- Pantalla de inicio -->
    <div id="start-screen" class="fixed inset-0 flex flex-col items-center justify-center p-4 z-50 bg-gradient-to-br from-blue-500 to-purple-600 text-white">
        <div class="text-center mb-8">
            <h1 class="text-5xl md:text-6xl font-bold mb-2 flex items-center justify-center">
                <span class="mr-3">🎲</span>
                <span>Parchís</span>
                <span class="text-yellow-300 ml-2">Royale</span>
            </h1>
            <p class="text-xl md:text-2xl opacity-90">El clásico juego de mesa reinventado</p>
        </div>
        
        <div class="w-full max-w-md bg-white bg-opacity-10 backdrop-blur-sm rounded-xl p-6 shadow-xl">
            <h2 class="text-2xl font-semibold mb-4 text-center">Crear o unirse a una partida</h2>
            
            <div class="flex space-x-4 mb-6">
                <button id="create-game-btn" class="flex-1 bg-yellow-400 hover:bg-yellow-500 text-gray-900 font-bold py-3 px-4 rounded-lg transition-all transform hover:scale-105 flex items-center justify-center">
                    <i class="fas fa-plus-circle mr-2"></i> Crear
                </button>
                <button id="join-game-btn" class="flex-1 bg-blue-400 hover:bg-blue-500 text-white font-bold py-3 px-4 rounded-lg transition-all transform hover:scale-105 flex items-center justify-center">
                    <i class="fas fa-sign-in-alt mr-2"></i> Unirse
                </button>
            </div>
            
            <div class="text-center text-sm opacity-80">
                <p>Juega con amigos o contra la IA</p>
                <p class="mt-1">Diversión garantizada para 2-6 jugadores</p>
            </div>
        </div>
        
        <button id="rules-btn" class="mt-8 text-white bg-transparent border border-white hover:bg-white hover:bg-opacity-20 px-4 py-2 rounded-lg transition-all flex items-center">
            <i class="fas fa-book mr-2"></i> Ver reglas del juego
        </button>
    </div>
    
    <!-- Modal de creación de partida -->
    <div id="create-game-modal" class="modal-overlay hidden">
        <div class="modal-content w-full max-w-md bg-white p-6">
            <div class="flex justify-between items-center mb-4">
                <h3 class="text-2xl font-bold text-gray-800">Nueva partida</h3>
                <button id="close-create-modal" class="text-gray-500 hover:text-gray-700">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div class="mb-6">
                <label class="block text-gray-700 font-medium mb-2">Nombre del jugador</label>
                <input type="text" id="player-name" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Tu nombre">
            </div>
            
            <div class="mb-6">
                <label class="block text-gray-700 font-medium mb-2">Tablero</label>
                <div class="flex space-x-4">
                    <div class="flex-1">
                        <input type="radio" id="board-4" name="board-type" value="4" class="hidden peer" checked>
                        <label for="board-4" class="block p-4 border border-gray-300 rounded-lg cursor-pointer peer-checked:border-blue-500 peer-checked:bg-blue-50 peer-checked:ring-2 peer-checked:ring-blue-200">
                            <div class="flex flex-col items-center">
                                <div class="w-24 h-24 board-4 mb-2"></div>
                                <span>4 jugadores</span>
                            </div>
                        </label>
                    </div>
                    <div class="flex-1">
                        <input type="radio" id="board-6" name="board-type" value="6" class="hidden peer">
                        <label for="board-6" class="block p-4 border border-gray-300 rounded-lg cursor-pointer peer-checked:border-blue-500 peer-checked:bg-blue-50 peer-checked:ring-2 peer-checked:ring-blue-200">
                            <div class="flex flex-col items-center">
                                <div class="w-24 h-24 board-6 mb-2"></div>
                                <span>6 jugadores</span>
                            </div>
                        </label>
                    </div>
                </div>
            </div>
            
            <div class="mb-6">
                <label class="block text-gray-700 font-medium mb-2">Dificultad</label>
                <select id="game-difficulty" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
                    <option value="easy">Fácil (Clásico)</option>
                    <option value="medium">Medio (Bloqueos)</option>
                    <option value="hard">Difícil (Poderes especiales)</option>
                </select>
            </div>
            
            <div class="mb-6">
                <label class="block text-gray-700 font-medium mb-2">Color</label>
                <div class="flex justify-center">
                    <div class="player-color-selector bg-red-500 selected" data-color="red"></div>
                    <div class="player-color-selector bg-blue-500" data-color="blue"></div>
                    <div class="player-color-selector bg-green-500" data-color="green"></div>
                    <div class="player-color-selector bg-yellow-400" data-color="yellow"></div>
                    <div class="player-color-selector bg-purple-500" data-color="purple"></div>
                    <div class="player-color-selector bg-orange-500" data-color="orange"></div>
                </div>
            </div>
            
            <button id="start-game-btn" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition-all transform hover:scale-105">
                <i class="fas fa-play mr-2"></i> Crear partida
            </button>
        </div>
    </div>
    
    <!-- Modal de código de invitación -->
    <div id="invite-modal" class="modal-overlay hidden">
        <div class="modal-content w-full max-w-md bg-white p-6">
            <div class="flex justify-between items-center mb-4">
                <h3 class="text-2xl font-bold text-gray-800">Invitar jugadores</h3>
                <button id="close-invite-modal" class="text-gray-500 hover:text-gray-700">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div class="mb-6 text-center">
                <p class="text-gray-700 mb-4">Comparte este código con otros jugadores para que se unan a tu partida:</p>
                <div class="flex items-center justify-center mb-4">
                    <div id="game-code" class="text-3xl font-bold bg-gray-100 px-6 py-3 rounded-lg tracking-widest">ABCD12</div>
                    <button id="copy-code" class="ml-2 bg-blue-100 text-blue-600 p-2 rounded-lg hover:bg-blue-200 transition-all">
                        <i class="fas fa-copy"></i>
                    </button>
                </div>
                <p class="text-sm text-gray-500">O envía este enlace:</p>
                <div class="flex items-center mt-2">
                    <input type="text" id="game-link" class="flex-1 px-3 py-2 border border-gray-300 rounded-l-lg focus:outline-none" readonly>
                    <button id="copy-link" class="bg-blue-600 text-white px-4 py-2 rounded-r-lg hover:bg-blue-700 transition-all">
                        <i class="fas fa-copy"></i>
                    </button>
                </div>
            </div>
            
            <div class="bg-blue-50 p-4 rounded-lg mb-6">
                <h4 class="font-medium text-blue-800 mb-2 flex items-center">
                    <i class="fas fa-users mr-2"></i> Jugadores conectados
                </h4>
                <ul id="players-list" class="space-y-2">
                    <li class="flex items-center">
                        <div class="w-4 h-4 rounded-full bg-red-500 mr-2"></div>
                        <span>Jugador 1 (Tú)</span>
                    </li>
                </ul>
            </div>
            
            <button id="begin-game-btn" class="w-full bg-green-600 hover:bg-green-700 text-white font-bold py-3 px-4 rounded-lg transition-all transform hover:scale-105 disabled:opacity-50 disabled:cursor-not-allowed" disabled>
                <i class="fas fa-flag-checkered mr-2"></i> Comenzar partida
            </button>
        </div>
    </div>
    
    <!-- Modal de unirse a partida -->
    <div id="join-game-modal" class="modal-overlay hidden">
        <div class="modal-content w-full max-w-md bg-white p-6">
            <div class="flex justify-between items-center mb-4">
                <h3 class="text-2xl font-bold text-gray-800">Unirse a partida</h3>
                <button id="close-join-modal" class="text-gray-500 hover:text-gray-700">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div class="mb-6">
                <label class="block text-gray-700 font-medium mb-2">Nombre del jugador</label>
                <input type="text" id="join-player-name" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Tu nombre">
            </div>
            
            <div class="mb-6">
                <label class="block text-gray-700 font-medium mb-2">Código de partida</label>
                <input type="text" id="join-game-code" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 uppercase" placeholder="ABCD12" maxlength="6">
            </div>
            
            <div class="mb-6">
                <label class="block text-gray-700 font-medium mb-2">Color</label>
                <div class="flex justify-center">
                    <div class="player-color-selector bg-red-500" data-color="red"></div>
                    <div class="player-color-selector bg-blue-500 selected" data-color="blue"></div>
                    <div class="player-color-selector bg-green-500" data-color="green"></div>
                    <div class="player-color-selector bg-yellow-400" data-color="yellow"></div>
                    <div class="player-color-selector bg-purple-500" data-color="purple"></div>
                    <div class="player-color-selector bg-orange-500" data-color="orange"></div>
                </div>
            </div>
            
            <button id="confirm-join-btn" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition-all transform hover:scale-105">
                <i class="fas fa-sign-in-alt mr-2"></i> Unirse a partida
            </button>
        </div>
    </div>
    
    <!-- Modal de reglas -->
    <div id="rules-modal" class="modal-overlay hidden">
        <div class="modal-content w-full max-w-2xl bg-white p-6">
            <div class="flex justify-between items-center mb-4">
                <h3 class="text-2xl font-bold text-gray-800">Reglas del Parchís</h3>
                <button id="close-rules-modal" class="text-gray-500 hover:text-gray-700">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div class="prose max-w-none">
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <h4 class="text-lg font-semibold text-blue-600 mb-2">Objetivo del juego</h4>
                        <p>El objetivo es llevar todas tus fichas desde tu base de salida hasta la base de llegada en el centro del tablero.</p>
                        
                        <h4 class="text-lg font-semibold text-blue-600 mt-4 mb-2">Movimiento básico</h4>
                        <ul class="list-disc pl-5 space-y-1">
                            <li>Los jugadores tiran un dado por turnos.</li>
                            <li>Para sacar una ficha de la base, se necesita un 5.</li>
                            <li>Las fichas avanzan en sentido horario según el número del dado.</li>
                            <li>Si sacas un 6, puedes volver a tirar.</li>
                        </ul>
                        
                        <h4 class="text-lg font-semibold text-blue-600 mt-4 mb-2">Capturas</h4>
                        <ul class="list-disc pl-5 space-y-1">
                            <li>Si una ficha cae en una casilla ocupada por una ficha rival, la ficha rival regresa a su base.</li>
                            <li>No puedes capturar en casillas seguras (marcadas con ⭐).</li>
                            <li>Si tienes dos fichas en la misma casilla, forman un bloqueo que no puede ser capturado.</li>
                        </ul>
                    </div>
                    
                    <div>
                        <h4 class="text-lg font-semibold text-blue-600 mb-2">Zona final</h4>
                        <ul class="list-disc pl-5 space-y-1">
                            <li>Cuando una ficha completa una vuelta al tablero, entra en su pasillo de color.</li>
                            <li>Para entrar en la casilla final, el dado debe mostrar el número exacto necesario.</li>
                            <li>La primera persona en meter todas sus fichas gana.</li>
                        </ul>
                        
                        <h4 class="text-lg font-semibold text-blue-600 mt-4 mb-2">Variantes especiales</h4>
                        <ul class="list-disc pl-5 space-y-1">
                            <li><strong>Modo bloqueos:</strong> Los bloqueos duran solo 2 turnos.</li>
                            <li><strong>Poderes especiales:</strong> Cada jugador tiene habilidades únicas.</li>
                            <li><strong>Super 6:</strong> Tres 6 seguidos hacen que tu ficha regrese a la base.</li>
                        </ul>
                        
                        <h4 class="text-lg font-semibold text-blue-600 mt-4 mb-2">Consejos</h4>
                        <ul class="list-disc pl-5 space-y-1">
                            <li>Intenta mantener al menos una ficha en juego.</li>
                            <li>Usa los bloqueos estratégicamente para proteger tus fichas.</li>
                            <li>No te apresures a meter todas tus fichas al pasillo final.</li>
                        </ul>
                    </div>
                </div>
                
                <div class="mt-6 p-4 bg-yellow-50 rounded-lg border border-yellow-200">
                    <h4 class="text-lg font-semibold text-yellow-700 mb-2 flex items-center">
                        <i class="fas fa-lightbulb mr-2"></i> Dificultades especiales
                    </h4>
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div class="bg-white p-3 rounded-lg shadow-sm">
                            <h5 class="font-medium text-green-600">Fácil</h5>
                            <p class="text-sm">Juego clásico sin modificaciones.</p>
                        </div>
                        <div class="bg-white p-3 rounded-lg shadow-sm">
                            <h5 class="font-medium text-yellow-600">Medio</h5>
                            <p class="text-sm">Bloqueos temporales y casillas especiales.</p>
                        </div>
                        <div class="bg-white p-3 rounded-lg shadow-sm">
                            <h5 class="font-medium text-red-600">Difícil</h5>
                            <p class="text-sm">Poderes especiales y reglas avanzadas.</p>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mt-6 flex justify-center">
                <button id="close-rules-btn" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded-lg transition-all">
                    Entendido
                </button>
            </div>
        </div>
    </div>
    
    <!-- Pantalla de juego -->
    <div id="game-screen" class="hidden">
        <!-- Barra superior -->
        <div class="bg-gray-800 text-white p-3 shadow-md">
            <div class="container mx-auto flex justify-between items-center">
                <div class="flex items-center">
                    <button id="menu-btn" class="mr-4 text-white hover:text-yellow-300 transition-all">
                        <i class="fas fa-bars text-xl"></i>
                    </button>
                    <h1 class="text-xl font-bold flex items-center">
                        <span class="mr-2">🎲</span>
                        <span>Parchís</span>
                        <span class="text-yellow-300 ml-1">Royale</span>
                    </h1>
                </div>
                
                <div class="flex items-center space-x-4">
                    <div id="turn-indicator" class="px-3 py-1 rounded-full bg-blue-600 text-sm font-medium flex items-center">
                        <div class="w-3 h-3 rounded-full bg-red-500 mr-2"></div>
                        <span>Tu turno</span>
                    </div>
                    <button id="dice-btn" class="dice bg-yellow-400 text-gray-900">🎲</button>
                </div>
            </div>
        </div>
        
        <!-- Contenido principal del juego -->
        <div class="container mx-auto p-4">
            <div class="flex flex-col lg:flex-row gap-6">
                <!-- Tablero de juego -->
                <div class="flex-1 flex justify-center">
                    <div id="game-board" class="relative w-full max-w-2xl aspect-square board-4">
                        <!-- Las celdas y fichas se generarán dinámicamente con JavaScript -->
                    </div>
                </div>
                
                <!-- Panel lateral -->
                <div class="w-full lg:w-80 space-y-4">
                    <!-- Información del jugador actual -->
                    <div class="bg-white rounded-xl shadow-md p-4">
                        <h3 class="font-bold text-lg mb-2 flex items-center">
                            <i class="fas fa-user mr-2"></i> Tu jugador
                        </h3>
                        <div class="flex items-center mb-3">
                            <div id="current-player-color" class="w-5 h-5 rounded-full mr-2"></div>
                            <span id="current-player-name" class="font-medium">Jugador 1</span>
                        </div>
                        <div class="grid grid-cols-2 gap-2">
                            <div class="bg-gray-100 p-2 rounded-lg">
                                <p class="text-xs text-gray-500">Fichas en juego</p>
                                <p id="pieces-in-play" class="font-bold">2</p>
                            </div>
                            <div class="bg-gray-100 p-2 rounded-lg">
                                <p class="text-xs text-gray-500">Fichas en meta</p>
                                <p id="pieces-in-home" class="font-bold">0</p>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Historial de dados -->
                    <div class="bg-white rounded-xl shadow-md p-4">
                        <h3 class="font-bold text-lg mb-3 flex items-center">
                            <i class="fas fa-history mr-2"></i> Historial
                        </h3>
                        <div id="dice-history" class="space-y-2 max-h-40 overflow-y-auto">
                            <!-- Los resultados de dados se agregarán aquí -->
                        </div>
                    </div>
                    
                    <!-- Lista de jugadores -->
                    <div class="bg-white rounded-xl shadow-md p-4">
                        <h3 class="font-bold text-lg mb-3 flex items-center">
                            <i class="fas fa-users mr-2"></i> Jugadores
                        </h3>
                        <ul id="players-game-list" class="space-y-2">
                            <!-- Los jugadores se listarán aquí -->
                        </ul>
                    </div>
                    
                    <!-- Chat (opcional) -->
                    <div class="bg-white rounded-xl shadow-md p-4 hidden">
                        <h3 class="font-bold text-lg mb-3 flex items-center">
                            <i class="fas fa-comments mr-2"></i> Chat
                        </h3>
                        <div class="bg-gray-50 rounded-lg p-2 h-32 overflow-y-auto mb-2">
                            <!-- Mensajes de chat -->
                        </div>
                        <div class="flex">
                            <input type="text" placeholder="Escribe un mensaje..." class="flex-1 border border-gray-300 rounded-l-lg px-3 py-2 focus:outline-none">
                            <button class="bg-blue-600 text-white px-4 rounded-r-lg">
                                <i class="fas fa-paper-plane"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Modal de menú -->
    <div id="menu-modal" class="modal-overlay hidden">
        <div class="modal-content w-full max-w-md bg-white p-6">
            <div class="flex justify-between items-center mb-6">
                <h3 class="text-2xl font-bold text-gray-800">Menú del juego</h3>
                <button id="close-menu-modal" class="text-gray-500 hover:text-gray-700">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div class="space-y-4">
                <button class="w-full flex items-center justify-between p-3 bg-gray-100 hover:bg-gray-200 rounded-lg transition-all">
                    <span class="flex items-center">
                        <i class="fas fa-book mr-3 text-blue-600"></i>
                        <span>Reglas del juego</span>
                    </span>
                    <i class="fas fa-chevron-right text-gray-400"></i>
                </button>
                
                <button class="w-full flex items-center justify-between p-3 bg-gray-100 hover:bg-gray-200 rounded-lg transition-all">
                    <span class="flex items-center">
                        <i class="fas fa-cog mr-3 text-purple-600"></i>
                        <span>Ajustes</span>
                    </span>
                    <i class="fas fa-chevron-right text-gray-400"></i>
                </button>
                
                <button class="w-full flex items-center justify-between p-3 bg-gray-100 hover:bg-gray-200 rounded-lg transition-all">
                    <span class="flex items-center">
                        <i class="fas fa-users mr-3 text-green-600"></i>
                        <span>Invitar jugadores</span>
                    </span>
                    <i class="fas fa-chevron-right text-gray-400"></i>
                </button>
                
                <button id="exit-game-btn" class="w-full flex items-center justify-between p-3 bg-red-100 hover:bg-red-200 text-red-700 rounded-lg transition-all mt-6">
                    <span class="flex items-center">
                        <i class="fas fa-sign-out-alt mr-3"></i>
                        <span>Salir del juego</span>
                    </span>
                </button>
            </div>
        </div>
    </div>
    
    <!-- Modal de ganador -->
    <div id="winner-modal" class="modal-overlay hidden">
        <div class="modal-content w-full max-w-md bg-white p-8 text-center">
            <div class="mb-6">
                <div class="text-6xl mb-4">🏆</div>
                <h3 class="text-3xl font-bold text-gray-800 mb-2">¡Felicidades!</h3>
                <p id="winner-name" class="text-xl text-gray-600">Jugador Rojo ha ganado</p>
            </div>
            
            <div class="bg-gray-100 rounded-lg p-4 mb-6">
                <h4 class="font-medium text-gray-700 mb-2">Resumen de la partida</h4>
                <div class="grid grid-cols-3 gap-2 text-sm">
                    <div class="bg-white p-2 rounded">
                        <p class="text-gray-500">Duración</p>
                        <p class="font-medium">12 min</p>
                    </div>
                    <div class="bg-white p-2 rounded">
                        <p class="text-gray-500">Turnos</p>
                        <p class="font-medium">24</p>
                    </div>
                    <div class="bg-white p-2 rounded">
                        <p class="text-gray-500">Dificultad</p>
                        <p class="font-medium">Media</p>
                    </div>
                </div>
            </div>
            
            <div class="flex space-x-4">
                <button id="rematch-btn" class="flex-1 bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition-all">
                    <i class="fas fa-redo mr-2"></i> Revancha
                </button>
                <button id="new-game-btn" class="flex-1 bg-green-600 hover:bg-green-700 text-white font-bold py-3 px-4 rounded-lg transition-all">
                    <i class="fas fa-plus mr-2"></i> Nueva partida
                </button>
            </div>
        </div>
    </div>

    <script>
        // Variables del juego
        let gameState = {
            players: [],
            currentPlayerIndex: 0,
            diceValue: 0,
            boardType: 4,
            difficulty: 'medium',
            gameStarted: false,
            gameCode: '',
            pieces: [],
            paths: {},
            safeSpots: [],
            playerColors: ['red', 'blue', 'green', 'yellow', 'purple', 'orange'],
            colorNames: {
                red: 'Rojo',
                blue: 'Azul',
                green: 'Verde',
                yellow: 'Amarillo',
                purple: 'Morado',
                orange: 'Naranja'
            },
            gameHistory: [],
            playerName: '',
            playerColor: 'red'
        };

        // Elementos del DOM
        const elements = {
            startScreen: document.getElementById('start-screen'),
            gameScreen: document.getElementById('game-screen'),
            createGameModal: document.getElementById('create-game-modal'),
            inviteModal: document.getElementById('invite-modal'),
            joinGameModal: document.getElementById('join-game-modal'),
            rulesModal: document.getElementById('rules-modal'),
            menuModal: document.getElementById('menu-modal'),
            winnerModal: document.getElementById('winner-modal'),
            gameBoard: document.getElementById('game-board'),
            playerName: document.getElementById('player-name'),
            joinPlayerName: document.getElementById('join-player-name'),
            joinGameCode: document.getElementById('join-game-code'),
            gameCode: document.getElementById('game-code'),
            gameLink: document.getElementById('game-link'),
            playersList: document.getElementById('players-list'),
            playersGameList: document.getElementById('players-game-list'),
            diceHistory: document.getElementById('dice-history'),
            currentPlayerName: document.getElementById('current-player-name'),
            currentPlayerColor: document.getElementById('current-player-color'),
            piecesInPlay: document.getElementById('pieces-in-play'),
            piecesInHome: document.getElementById('pieces-in-home'),
            turnIndicator: document.getElementById('turn-indicator'),
            diceBtn: document.getElementById('dice-btn')
        };

        // Inicialización del juego
        document.addEventListener('DOMContentLoaded', () => {
            // Generar código de juego aleatorio
            gameState.gameCode = generateGameCode();
            elements.gameCode.textContent = gameState.gameCode;
            elements.gameLink.value = `${window.location.href}?game=${gameState.gameCode}`;
            
            // Event listeners para botones
            document.getElementById('create-game-btn').addEventListener('click', showCreateGameModal);
            document.getElementById('join-game-btn').addEventListener('click', showJoinGameModal);
            document.getElementById('rules-btn').addEventListener('click', showRulesModal);
            document.getElementById('close-create-modal').addEventListener('click', hideCreateGameModal);
            document.getElementById('close-invite-modal').addEventListener('click', hideInviteModal);
            document.getElementById('close-join-modal').addEventListener('click', hideJoinGameModal);
            document.getElementById('close-rules-modal').addEventListener('click', hideRulesModal);
            document.getElementById('close-rules-btn').addEventListener('click', hideRulesModal);
            document.getElementById('start-game-btn').addEventListener('click', startGameCreation);
            document.getElementById('begin-game-btn').addEventListener('click', beginGame);
            document.getElementById('confirm-join-btn').addEventListener('click', joinGame);
            document.getElementById('copy-code').addEventListener('click', copyGameCode);
            document.getElementById('copy-link').addEventListener('click', copyGameLink);
            document.getElementById('menu-btn').addEventListener('click', showMenuModal);
            document.getElementById('close-menu-modal').addEventListener('click', hideMenuModal);
            document.getElementById('exit-game-btn').addEventListener('click', exitGame);
            document.getElementById('rematch-btn').addEventListener('click', startRematch);
            document.getElementById('new-game-btn').addEventListener('click', newGame);
            elements.diceBtn.addEventListener('click', rollDice);
            
            // Selectores de color
            document.querySelectorAll('.player-color-selector').forEach(selector => {
                selector.addEventListener('click', function() {
                    document.querySelector('.player-color-selector.selected')?.classList.remove('selected');
                    this.classList.add('selected');
                    gameState.playerColor = this.dataset.color;
                });
            });
            
            // Verificar si hay un código de juego en la URL
            const urlParams = new URLSearchParams(window.location.search);
            const gameCodeParam = urlParams.get('game');
            if (gameCodeParam) {
                showJoinGameModal();
                document.getElementById('join-game-code').value = gameCodeParam.toUpperCase();
            }
        });

        // Funciones del juego
        function generateGameCode() {
            const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
            let result = '';
            for (let i = 0; i < 6; i++) {
                result += chars.charAt(Math.floor(Math.random() * chars.length));
            }
            return result;
        }

        function showCreateGameModal() {
            elements.createGameModal.classList.remove('hidden');
        }

        function hideCreateGameModal() {
            elements.createGameModal.classList.add('hidden');
        }

        function showInviteModal() {
            elements.inviteModal.classList.remove('hidden');
        }

        function hideInviteModal() {
            elements.inviteModal.classList.add('hidden');
        }

        function showJoinGameModal() {
            elements.joinGameModal.classList.remove('hidden');
        }

        function hideJoinGameModal() {
            elements.joinGameModal.classList.add('hidden');
        }

        function showRulesModal() {
            elements.rulesModal.classList.remove('hidden');
        }

        function hideRulesModal() {
            elements.rulesModal.classList.add('hidden');
        }

        function showMenuModal() {
            elements.menuModal.classList.remove('hidden');
        }

        function hideMenuModal() {
            elements.menuModal.classList.add('hidden');
        }

        function showWinnerModal(winnerName) {
            document.getElementById('winner-name').textContent = winnerName;
            elements.winnerModal.classList.remove('hidden');
        }

        function hideWinnerModal() {
            elements.winnerModal.classList.add('hidden');
        }

        function copyGameCode() {
            navigator.clipboard.writeText(gameState.gameCode);
            showToast('Código copiado al portapapeles');
        }

        function copyGameLink() {
            navigator.clipboard.writeText(elements.gameLink.value);
            showToast('Enlace copiado al portapapeles');
        }

        function showToast(message) {
            const toast = document.createElement('div');
            toast.className = 'fixed bottom-4 left-1/2 transform -translate-x-1/2 bg-gray-800 text-white px-4 py-2 rounded-lg shadow-lg z-50 animate-fade-in-out';
            toast.textContent = message;
            document.body.appendChild(toast);
            
            setTimeout(() => {
                toast.remove();
            }, 3000);
        }

        function startGameCreation() {
            const playerName = elements.playerName.value.trim();
            if (!playerName) {
                showToast('Por favor ingresa tu nombre');
                return;
            }
            
            gameState.playerName = playerName;
            gameState.boardType = parseInt(document.querySelector('input[name="board-type"]:checked').value);
            gameState.difficulty = document.getElementById('game-difficulty').value;
            
            // Crear jugador local
            const player = {
                id: 'player-' + Date.now(),
                name: playerName,
                color: gameState.playerColor,
                pieces: [],
                isLocal: true,
                isHost: true
            };
            
            gameState.players.push(player);
            updatePlayersList();
            
            hideCreateGameModal();
            showInviteModal();
        }

        function updatePlayersList() {
            elements.playersList.innerHTML = '';
            elements.playersGameList.innerHTML = '';
            
            gameState.players.forEach(player => {
                // Para el modal de invitación
                const playerItem = document.createElement('li');
                playerItem.className = 'flex items-center';
                playerItem.innerHTML = `
                    <div class="w-4 h-4 rounded-full bg-${player.color}-500 mr-2"></div>
                    <span>${player.name} ${player.isHost ? '(Anfitrión)' : ''}</span>
                `;
                elements.playersList.appendChild(playerItem);
                
                // Para el panel de jugadores en el juego
                const gamePlayerItem = document.createElement('li');
                gamePlayerItem.className = 'flex items-center justify-between p-2 bg-gray-50 rounded-lg';
                gamePlayerItem.innerHTML = `
                    <div class="flex items-center">
                        <div class="w-4 h-4 rounded-full bg-${player.color}-500 mr-2"></div>
                        <span class="font-medium">${player.name}</span>
                    </div>
                    <div class="text-sm text-gray-500">0/4</div>
                `;
                elements.playersGameList.appendChild(gamePlayerItem);
            });
            
            // Habilitar botón de comenzar si hay al menos 2 jugadores
            document.getElementById('begin-game-btn').disabled = gameState.players.length < 2;
        }

        function beginGame() {
            initializeGame();
            hideInviteModal();
            elements.startScreen.classList.add('hidden');
            elements.gameScreen.classList.remove('hidden');
        }

        function joinGame() {
            const playerName = elements.joinPlayerName.value.trim();
            const gameCode = elements.joinGameCode.value.trim().toUpperCase();
            
            if (!playerName) {
                showToast('Por favor ingresa tu nombre');
                return;
            }
            
            if (!gameCode || gameCode.length !== 6) {
                showToast('Por favor ingresa un código de juego válido');
                return;
            }
            
            // Simular unirse a una partida existente
            gameState.playerName = playerName;
            gameState.gameCode = gameCode;
            
            // Crear jugador local (no anfitrión)
            const player = {
                id: 'player-' + Date.now(),
                name: playerName,
                color: gameState.playerColor,
                pieces: [],
                isLocal: true,
                isHost: false
            };
            
            // Simular que ya hay un anfitrión
            const hostPlayer = {
                id: 'player-host',
                name: 'Anfitrión',
                color: 'red',
                pieces: [],
                isLocal: false,
                isHost: true
            };
            
            gameState.players = [hostPlayer, player];
            gameState.boardType = 4; // Asumir tablero de 4 jugadores
            
            updatePlayersList();
            
            hideJoinGameModal();
            elements.startScreen.classList.add('hidden');
            elements.gameScreen.classList.remove('hidden');
            
            // Simular que el anfitrión comienza el juego después de unirse
            setTimeout(() => {
                initializeGame();
            }, 1000);
        }

        function initializeGame() {
            gameState.gameStarted = true;
            gameState.currentPlayerIndex = 0;
            
            // Configurar el tablero según el tipo
            elements.gameBoard.className = `relative w-full max-w-2xl aspect-square board-${gameState.boardType}`;
            
            // Crear las rutas del tablero
            createBoardPaths();
            
            // Inicializar fichas para cada jugador
            initializePieces();
            
            // Actualizar la interfaz del jugador actual
            updateCurrentPlayerUI();
            
            // Mostrar mensaje de inicio
            showToast(`¡Comienza la partida! Es el turno de ${gameState.players[0].name}`);
        }

        function createBoardPaths() {
            // Esto es una simplificación - en un juego real necesitarías coordenadas precisas
            gameState.paths = {};
            gameState.safeSpots = [];
            
            // Crear rutas básicas para el tablero de 4 jugadores
            if (gameState.boardType === 4) {
                // 68 casillas estándar en el parchís de 4 jugadores
                for (let i = 0; i < 68; i++) {
                    gameState.paths[`path-${i}`] = {
                        id: `path-${i}`,
                        position: i,
                        pieces: []
                    };
                }
                
                // 5 casillas seguras por jugador (incluyendo la de salida)
                for (let i = 0; i < 4; i++) {
                    for (let j = 0; j < 5; j++) {
                        gameState.safeSpots.push(`safe-${i}-${j}`);
                    }
                }
            } else {
                // Tablero de 6 jugadores con más casillas
                for (let i = 0; i < 96; i++) {
                    gameState.paths[`path-${i}`] = {
                        id: `path-${i}`,
                        position: i,
                        pieces: []
                    };
                }
                
                // 5 casillas seguras por jugador
                for (let i = 0; i < 6; i++) {
                    for (let j = 0; j < 5; j++) {
                        gameState.safeSpots.push(`safe-${i}-${j}`);
                    }
                }
            }
            
            // Renderizar el tablero
            renderBoard();
        }

        function renderBoard() {
            elements.gameBoard.innerHTML = '';
            
            // Esto es una representación simplificada del tablero
            // En una implementación real, necesitarías posicionar cada celda con precisión
            
            // Bases de inicio
            gameState.players.forEach((player, index) => {
                const base = document.createElement('div');
                base.className = `absolute home-base bg-${player.color}-100 border-4 border-${player.color}-500`;
                base.style.width = '80px';
                base.style.height = '80px';
                
                // Posicionar las bases según el número de jugadores
                if (gameState.boardType === 4) {
                    if (index === 0) {
                        base.style.top = '10%';
                        base.style.left = '10%';
                    } else if (index === 1) {
                        base.style.top = '10%';
                        base.style.right = '10%';
                    } else if (index === 2) {
                        base.style.bottom = '10%';
                        base.style.right = '10%';
                    } else {
                        base.style.bottom = '10%';
                        base.style.left = '10%';
                    }
                } else {
                    // Posicionamiento para 6 jugadores
                    const angle = (index * 60) - 90; // -90 para empezar desde arriba
                    const radius = 35;
                    const centerX = 50;
                    const centerY = 50;
                    
                    const x = centerX + radius * Math.cos(angle * Math.PI / 180);
                    const y = centerY + radius * Math.sin(angle * Math.PI / 180);
                    
                    base.style.left = `${x}%`;
                    base.style.top = `${y}%`;
                    base.style.transform = 'translate(-50%, -50%)';
                }
                
                elements.gameBoard.appendChild(base);
            });
            
            // Casillas del camino
            Object.values(gameState.paths).forEach(path => {
                const cell = document.createElement('div');
                cell.className = 'absolute path-cell';
                cell.id = path.id;
                cell.dataset.position = path.position;
                
                // Posicionamiento simplificado - en realidad necesitarías calcular la posición exacta
                cell.style.width = '20px';
                cell.style.height = '20px';
                cell.style.backgroundColor = '#f0f0f0';
                cell.style.borderRadius = '50%';
                cell.style.border = '1px solid #ddd';
                
                // Posicionar en un círculo alrededor del tablero
                const totalCells = gameState.boardType === 4 ? 68 : 96;
                const angle = (path.position / totalCells) * 2 * Math.PI;
                const radius = 40;
                const centerX = 50;
                const centerY = 50;
                
                const x = centerX + radius * Math.cos(angle);
                const y = centerY + radius * Math.sin(angle);
                
                cell.style.left = `${x}%`;
                cell.style.top = `${y}%`;
                cell.style.transform = 'translate(-50%, -50%)';
                
                elements.gameBoard.appendChild(cell);
            });
            
            // Casillas seguras (simplificado)
            gameState.safeSpots.forEach(spot => {
                const safeCell = document.createElement('div');
                safeCell.className = 'absolute safe-spot';
                safeCell.id = spot;
                safeCell.style.width = '25px';
                safeCell.style.height = '25px';
                safeCell.style.backgroundColor = 'rgba(255, 255, 255, 0.7)';
                safeCell.style.borderRadius = '50%';
                
                // Posicionamiento simplificado
                const parts = spot.split('-');
                const playerIndex = parseInt(parts[1]);
                const spotIndex = parseInt(parts[2]);
                
                if (gameState.boardType === 4) {
                    if (playerIndex === 0) {
                        safeCell.style.left = `${20 + spotIndex * 5}%`;
                        safeCell.style.top = '30%';
                    } else if (playerIndex === 1) {
                        safeCell.style.right = `${20 + spotIndex * 5}%`;
                        safeCell.style.top = '30%';
                    } else if (playerIndex === 2) {
                        safeCell.style.right = `${20 + spotIndex * 5}%`;
                        safeCell.style.bottom = '30%';
                    } else {
                        safeCell.style.left = `${20 + spotIndex * 5}%`;
                        safeCell.style.bottom = '30%';
                    }
                } else {
                    // Posicionamiento para 6 jugadores
                    const angle = (playerIndex * 60) - 90; // -90 para empezar desde arriba
                    const radius = 30 + spotIndex * 5;
                    const centerX = 50;
                    const centerY = 50;
                    
                    const x = centerX + radius * Math.cos(angle * Math.PI / 180);
                    const y = centerY + radius * Math.sin(angle * Math.PI / 180);
                    
                    safeCell.style.left = `${x}%`;
                    safeCell.style.top = `${y}%`;
                    safeCell.style.transform = 'translate(-50%, -50%)';
                }
                
                elements.gameBoard.appendChild(safeCell);
            });
            
            // Zona central (meta)
            const center = document.createElement('div');
            center.className = 'absolute home-base bg-white';
            center.style.width = '100px';
            center.style.height = '100px';
            center.style.left = '50%';
            center.style.top = '50%';
            center.style.transform = 'translate(-50%, -50%)';
            center.style.boxShadow = 'inset 0 0 15px rgba(0,0,0,0.2)';
            elements.gameBoard.appendChild(center);
        }

        function initializePieces() {
            gameState.pieces = [];
            
            gameState.players.forEach(player => {
                for (let i = 0; i < 4; i++) {
                    const piece = {
                        id: `piece-${player.id}-${i}`,
                        playerId: player.id,
                        color: player.color,
                        position: 'home', // 'home', 'path-X', 'safe-X-Y', 'final'
                        pathPosition: null,
                        number: i + 1
                    };
                    
                    gameState.pieces.push(piece);
                    player.pieces.push(piece);
                    
                    // Renderizar la ficha
                    renderPiece(piece);
                }
            });
        }

        function renderPiece(piece) {
            // Eliminar cualquier representación previa de la ficha
            const existingPiece = document.getElementById(`piece-${piece.id}`);
            if (existingPiece) existingPiece.remove();
            
            const pieceElement = document.createElement('div');
            pieceElement.id = `piece-${piece.id}`;
            pieceElement.className = `absolute piece bg-${piece.color}-500`;
            pieceElement.textContent = piece.number;
            pieceElement.dataset.pieceId = piece.id;
            
            // Posicionar la ficha según su estado actual
            if (piece.position === 'home') {
                const player = gameState.players.find(p => p.id === piece.playerId);
                const playerIndex = gameState.players.indexOf(player);
                
                // Encontrar la base del jugador
                const base = document.querySelectorAll('.home-base')[playerIndex];
                const baseRect = base.getBoundingClientRect();
                const boardRect = elements.gameBoard.getBoundingClientRect();
                
                // Calcular posición relativa dentro de la base
                const offsetX = (piece.number % 2 === 0) ? 15 : -15;
                const offsetY = (piece.number > 2) ? 15 : -15;
                
                pieceElement.style.left = `${((baseRect.left - boardRect.left) / boardRect.width * 100) + offsetX}%`;
                pieceElement.style.top = `${((baseRect.top - boardRect.top) / boardRect.height * 100) + offsetY}%`;
            } else if (piece.position.startsWith('path')) {
                const pathId = piece.position;
                const pathElement = document.getElementById(pathId);
                if (pathElement) {
                    const pathRect = pathElement.getBoundingClientRect();
                    const boardRect = elements.gameBoard.getBoundingClientRect();
                    
                    pieceElement.style.left = `${(pathRect.left - boardRect.left + pathRect.width / 2) / boardRect.width * 100}%`;
                    pieceElement.style.top = `${(pathRect.top - boardRect.top + pathRect.height / 2) / boardRect.height * 100}%`;
                }
            } else if (piece.position.startsWith('safe')) {
                const safeSpotId = piece.position;
                const safeSpotElement = document.getElementById(safeSpotId);
                if (safeSpotElement) {
                    const safeRect = safeSpotElement.getBoundingClientRect();
                    const boardRect = elements.gameBoard.getBoundingClientRect();
                    
                    pieceElement.style.left = `${(safeRect.left - boardRect.left + safeRect.width / 2) / boardRect.width * 100}%`;
                    pieceElement.style.top = `${(safeRect.top - boardRect.top + safeRect.height / 2) / boardRect.height * 100}%`;
                }
            } else if (piece.position === 'final') {
                // Posicionar en la zona central
                pieceElement.style.left = '50%';
                pieceElement.style.top = '50%';
                pieceElement.style.transform = 'translate(-50%, -50%)';
                
                // Agregar corona si es la última ficha
                if (piece.number === 4) {
                    const crown = document.createElement('div');
                    crown.className = 'winner-crown';
                    crown.innerHTML = '👑';
                    pieceElement.appendChild(crown);
                }
            }
            
            // Agregar evento de clic si es la ficha del jugador actual
            const currentPlayer = gameState.players[gameState.currentPlayerIndex];
            if (currentPlayer.isLocal && currentPlayer.id === piece.playerId) {
                pieceElement.classList.add('cursor-pointer', 'hover:scale-110');
                pieceElement.addEventListener('click', () => selectPiece(piece));
            }
            
            elements.gameBoard.appendChild(pieceElement);
        }

        function updateCurrentPlayerUI() {
            const currentPlayer = gameState.players[gameState.currentPlayerIndex];
            
            // Actualizar panel del jugador
            elements.currentPlayerName.textContent = currentPlayer.name;
            elements.currentPlayerColor.className = `w-5 h-5 rounded-full mr-2 bg-${currentPlayer.color}-500`;
            
            // Contar fichas en juego y en casa
            const piecesInPlay = currentPlayer.pieces.filter(p => p.position !== 'home' && p.position !== 'final').length;
            const piecesInHome = currentPlayer.pieces.filter(p => p.position === 'final').length;
            
            elements.piecesInPlay.textContent = piecesInPlay;
            elements.piecesInHome.textContent = piecesInHome;
            
            // Actualizar indicador de turno
            elements.turnIndicator.innerHTML = `
                <div class="w-3 h-3 rounded-full bg-${currentPlayer.color}-500 mr-2"></div>
                <span>${currentPlayer.isLocal ? 'Tu turno' : 'Turno de ' + currentPlayer.name}</span>
            `;
            
            // Habilitar/deshabilitar dado
            if (currentPlayer.isLocal) {
                elements.diceBtn.classList.remove('opacity-50', 'cursor-not-allowed');
                elements.diceBtn.classList.add('cursor-pointer', 'hover:scale-105');
            } else {
                elements.diceBtn.classList.add('opacity-50', 'cursor-not-allowed');
                elements.diceBtn.classList.remove('cursor-pointer', 'hover:scale-105');
            }
            
            // Actualizar lista de jugadores
            elements.playersGameList.innerHTML = '';
            gameState.players.forEach(player => {
                const piecesInHome = player.pieces.filter(p => p.position === 'final').length;
                
                const playerItem = document.createElement('li');
                playerItem.className = `flex items-center justify-between p-2 rounded-lg ${player.id === currentPlayer.id ? 'bg-gray-200' : 'bg-gray-50'}`;
                playerItem.innerHTML = `
                    <div class="flex items-center">
                        <div class="w-4 h-4 rounded-full bg-${player.color}-500 mr-2"></div>
                        <span class="font-medium">${player.name}</span>
                    </div>
                    <div class="text-sm ${piecesInHome === 4 ? 'text-green-600 font-bold' : 'text-gray-500'}">${piecesInHome}/4</div>
                `;
                
                elements.playersGameList.appendChild(playerItem);
            });
        }

        function rollDice() {
            const currentPlayer = gameState.players[gameState.currentPlayerIndex];
            if (!currentPlayer.isLocal) return;
            
            // Deshabilitar el dado durante el lanzamiento
            elements.diceBtn.classList.add('opacity-50', 'cursor-not-allowed');
            elements.diceBtn.classList.remove('cursor-pointer', 'hover:scale-105');
            
            // Animación del dado
            let rolls = 0;
            const maxRolls = 10;
            const rollInterval = setInterval(() => {
                gameState.diceValue = Math.floor(Math.random() * 6) + 1;
                elements.diceBtn.textContent = getDiceFace(gameState.diceValue);
                rolls++;
                
                if (rolls >= maxRolls) {
                    clearInterval(rollInterval);
                    finishDiceRoll();
                }
            }, 100);
        }

        function getDiceFace(value) {
            const faces = ['⚀', '⚁', '⚂', '⚃', '⚄', '⚅'];
            return faces[value - 1];
        }

        function finishDiceRoll() {
            // Agregar al historial
            const currentPlayer = gameState.players[gameState.currentPlayerIndex];
            const historyItem = document.createElement('div');
            historyItem.className = 'flex items-center justify-between py-1 px-2 bg-gray-100 rounded';
            historyItem.innerHTML = `
                <div class="flex items-center">
                    <div class="w-3 h-3 rounded-full bg-${currentPlayer.color}-500 mr-2"></div>
                    <span>${currentPlayer.name}</span>
                </div>
                <span class="font-bold">${gameState.diceValue}</span>
            `;
            elements.diceHistory.insertBefore(historyItem, elements.diceHistory.firstChild);
            
            // Verificar si el jugador tiene movimientos posibles
            const movablePieces = currentPlayer.pieces.filter(piece => {
                if (piece.position === 'home' && gameState.diceValue === 5) return true;
                if (piece.position.startsWith('path') || piece.position.startsWith('safe')) return true;
                return false;
            });
            
            if (movablePieces.length === 0) {
                showToast('No tienes movimientos posibles. Pasando turno...');
                setTimeout(nextTurn, 1500);
            } else {
                // Resaltar fichas que se pueden mover
                movablePieces.forEach(piece => {
                    const pieceElement = document.getElementById(`piece-${piece.id}`);
                    if (pieceElement) {
                        pieceElement.classList.add('glow');
                    }
                });
                
                showToast(`Elige una ficha para mover ${gameState.diceValue} espacios`);
            }
        }

        function selectPiece(piece) {
            // Solo permitir selección si es el turno del jugador y hay un valor de dado
            const currentPlayer = gameState.players[gameState.currentPlayerIndex];
            if (!currentPlayer.isLocal || gameState.diceValue === 0 || piece.playerId !== currentPlayer.id) return;
            
            // Quitar resaltado de todas las fichas
            document.querySelectorAll('.piece').forEach(el => el.classList.remove('glow'));
            
            // Mover la ficha según las reglas
            movePiece(piece, gameState.diceValue);
            
            // Resetear el valor del dado
            gameState.diceValue = 0;
            elements.diceBtn.textContent = '🎲';
            
            // Pasar al siguiente turno después de un breve retraso
            setTimeout(nextTurn, 1000);
        }

        function movePiece(piece, spaces) {
            const currentPlayer = gameState.players[gameState.currentPlayerIndex];
            
            // Mover ficha desde la base
            if (piece.position === 'home') {
                if (spaces === 5) {
                    piece.position = `path-${currentPlayer.id}-0`; // Posición inicial del jugador
                    showToast(`¡Ficha ${piece.number} ha salido de la base!`);
                } else {
                    showToast('Necesitas un 5 para sacar una ficha de la base');
                    return;
                }
            } 
            // Mover ficha en el camino
            else if (piece.position.startsWith('path') || piece.position.startsWith('safe')) {
                // Lógica simplificada de movimiento
                const currentPath = piece.position;
                let newPosition;
                
                if (currentPath.startsWith('path')) {
                    const currentPos = parseInt(currentPath.split('-')[1]);
                    newPosition = `path-${(currentPos + spaces) % (gameState.boardType === 4 ? 68 : 96)}`;
                } else {
                    // Para casillas seguras, avanzar en el pasillo final
                    const parts = currentPath.split('-');
                    const playerIndex = parseInt(parts[1]);
                    const spotIndex = parseInt(parts[2]);
                    
                    if (spotIndex + spaces < 5) {
                        newPosition = `safe-${playerIndex}-${spotIndex + spaces}`;
                    } else {
                        piece.position = 'final';
                        showToast(`¡Ficha ${piece.number} ha llegado a la meta!`);
                        
                        // Verificar si el jugador ha ganado
                        checkWinCondition(currentPlayer);
                    }
                }
                
                if (newPosition) {
                    // Verificar si hay una ficha rival en la nueva posición
                    const targetPieces = gameState.pieces.filter(p => p.position === newPosition && p.playerId !== piece.playerId);
                    
                    if (targetPieces.length > 0 && !gameState.safeSpots.includes(newPosition)) {
                        // Capturar la ficha rival
                        targetPieces.forEach(targetPiece => {
                            targetPiece.position = 'home';
                            renderPiece(targetPiece);
                            showToast(`¡Has capturado una ficha de ${gameState.players.find(p => p.id === targetPiece.playerId).name}!`);
                        });
                    }
                    
                    piece.position = newPosition;
                }
            }
            
            // Renderizar la ficha en su nueva posición
            renderPiece(piece);
            
            // Si el dado fue 6, permitir otro lanzamiento
            if (spaces === 6) {
                showToast('¡Obtuviste un 6! Tira de nuevo');
                gameState.diceValue = 0;
                elements.diceBtn.textContent = '🎲';
                elements.diceBtn.classList.remove('opacity-50', 'cursor-not-allowed');
                elements.diceBtn.classList.add('cursor-pointer', 'hover:scale-105');
            }
        }

        function checkWinCondition(player) {
            const piecesInHome = player.pieces.filter(p => p.position === 'final').length;
            
            if (piecesInHome === 4) {
                // Juego terminado
                showWinnerModal(`${player.name} (${gameState.colorNames[player.color]}) ha ganado!`);
                
                // Deshabilitar interacciones
                elements.diceBtn.classList.add('opacity-50', 'cursor-not-allowed');
                elements.diceBtn.classList.remove('cursor-pointer', 'hover:scale-105');
                
                // Quitar eventos de clic de las fichas
                document.querySelectorAll('.piece').forEach(p => p.style.pointerEvents = 'none');
            }
        }

        function nextTurn() {
            gameState.currentPlayerIndex = (gameState.currentPlayerIndex + 1) % gameState.players.length;
            updateCurrentPlayerUI();
            
            // Simular turno de IA si no es el jugador local
            const currentPlayer = gameState.players[gameState.currentPlayerIndex];
            if (!currentPlayer.isLocal && gameState.gameStarted) {
                setTimeout(() => {
                    rollDice();
                    
                    // Simular selección de ficha después de un retraso
                    setTimeout(() => {
                        const movablePieces = currentPlayer.pieces.filter(piece => {
                            if (piece.position === 'home' && gameState.diceValue === 5) return true;
                            if (piece.position.startsWith('path') || piece.position.startsWith('safe')) return true;
                            return false;
                        });
                        
                        if (movablePieces.length > 0) {
                            const randomPiece = movablePieces[Math.floor(Math.random() * movablePieces.length)];
                            movePiece(randomPiece, gameState.diceValue);
                            
                            // Pasar al siguiente turno
                            setTimeout(nextTurn, 1000);
                        } else {
                            nextTurn();
                        }
                    }, 1000);
                }, 1500);
            }
        }

        function exitGame() {
            if (confirm('¿Estás seguro de que quieres salir de la partida?')) {
                hideMenuModal();
                elements.gameScreen.classList.add('hidden');
                elements.startScreen.classList.remove('hidden');
                
                // Resetear estado del juego
                resetGameState();
            }
        }

        function startRematch() {
            hideWinnerModal();
            resetGameState();
            initializeGame();
        }

        function newGame() {
            hideWinnerModal();
            elements.gameScreen.classList.add('hidden');
            elements.startScreen.classList.remove('hidden');
            resetGameState();
        }

        function resetGameState() {
            gameState = {
                ...gameState,
                currentPlayerIndex: 0,
                diceValue: 0,
                gameStarted: false,
                pieces: [],
                paths: {},
                players: gameState.players.filter(p => p.isLocal)
            };
            
            // Resetear UI
            elements.diceHistory.innerHTML = '';
            elements.diceBtn.textContent = '🎲';
        }
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Dommos/parch" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>