File size: 57,280 Bytes
e6720d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Infinite Universe Explorer</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
    <style>
        @keyframes float {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-20px); }
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        @keyframes pulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.05); }
        }
        @keyframes rainbow {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }
        .floating {
            animation: float 6s ease-in-out infinite;
        }
        .spinning {
            animation: spin 20s linear infinite;
        }
        .pulsing {
            animation: pulse 3s ease infinite;
        }
        .theme-transition {
            transition: all 0.5s ease;
        }
        .particle {
            position: absolute;
            background: currentColor;
            border-radius: 50%;
            pointer-events: none;
        }
        .gradient-mask {
            mask-image: linear-gradient(to right, transparent 0%, black 20%, black 80%, transparent 100%);
        }
        .code-container {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.5s ease;
        }
        .code-container.open {
            max-height: 500px;
        }
        .copy-btn {
            transition: all 0.2s ease;
        }
        .copy-btn.copied {
            background-color: #10B981 !important;
        }
        .rainbow-text {
            background: linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3);
            background-size: 400% 400%;
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            animation: rainbow 8s ease infinite;
        }
        .history-item {
            position: relative;
            overflow: hidden;
        }
        .history-item::after {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.7));
        }
        .history-item:hover::after {
            background: linear-gradient(to bottom, transparent 30%, rgba(0,0,0,0.7));
        }
        .history-item-title {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            padding: 8px;
            font-size: 12px;
            text-align: center;
            z-index: 2;
        }
        .pattern-selector {
            opacity: 0;
            transition: all 0.3s ease;
        }
        .pattern-selector:hover {
            opacity: 1;
        }
        .pattern-container:hover .pattern-selector {
            opacity: 1;
        }
        .scrollbar-hide::-webkit-scrollbar {
            display: none;
        }
        .scrollbar-hide {
            -ms-overflow-style: none;
            scrollbar-width: none;
        }
        .tooltip {
            position: relative;
        }
        .tooltip-text {
            visibility: hidden;
            width: 120px;
            background-color: rgba(0,0,0,0.8);
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 5px;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            transform: translateX(-50%);
            opacity: 0;
            transition: opacity 0.3s;
        }
        .tooltip:hover .tooltip-text {
            visibility: visible;
            opacity: 1;
        }
        .favorite-btn {
            transition: all 0.3s ease;
        }
        .favorite-btn.active {
            color: #f59e0b;
            transform: scale(1.1);
        }
        .screenshot-btn {
            transition: all 0.3s ease;
        }
        .screenshot-btn:hover {
            transform: translateY(-2px);
        }
        .download-btn {
            transition: all 0.3s ease;
        }
        .download-btn:hover {
            transform: translateY(-2px);
        }
        .share-btn {
            transition: all 0.3s ease;
        }
        .share-btn:hover {
            transform: translateY(-2px);
        }
        .modal {
            transition: opacity 0.3s ease, transform 0.3s ease;
        }
        .modal-enter {
            opacity: 0;
            transform: scale(0.9);
        }
        .modal-enter-active {
            opacity: 1;
            transform: scale(1);
        }
        .modal-exit {
            opacity: 1;
            transform: scale(1);
        }
        .modal-exit-active {
            opacity: 0;
            transform: scale(0.9);
        }
        @media (max-width: 768px) {
            .main-content {
                flex-direction: column;
            }
            .pattern-container {
                order: -1;
                margin-bottom: 1.5rem;
            }
            .pattern-selector {
                opacity: 1;
                bottom: 8px;
            }
            .pattern-btn {
                width: 36px;
                height: 36px;
                font-size: 14px;
            }
            .color-grid {
                grid-template-columns: repeat(5, 1fr);
            }
            .header-text {
                font-size: 2.5rem;
            }
            .subheader-text {
                font-size: 1rem;
            }
            .action-buttons {
                flex-direction: column;
                gap: 0.5rem;
            }
            .action-buttons button {
                width: 100%;
            }
            .history-item, .favorite-item {
                width: 80px;
                height: 80px;
            }
            .history-item-title {
                font-size: 10px;
                padding: 4px;
            }
        }
    </style>
</head>
<body class="min-h-screen bg-gradient-to-br from-indigo-900 to-purple-800 text-white theme-transition">
    <div id="particles-container" class="fixed inset-0 overflow-hidden pointer-events-none"></div>
    
    <!-- Modal -->
    <div id="modal" class="fixed inset-0 bg-black/80 z-50 flex items-center justify-center p-4 hidden opacity-0 transition-opacity duration-300">
        <div class="bg-gradient-to-br from-gray-800 to-gray-900 rounded-2xl max-w-2xl w-full p-6 shadow-2xl border border-white/10 transform transition-all duration-300">
            <div class="flex justify-between items-center mb-4">
                <h3 class="text-xl font-bold" id="modal-title">Modal Title</h3>
                <button id="close-modal" class="text-white/70 hover:text-white text-2xl">&times;</button>
            </div>
            <div class="mb-4" id="modal-content">
                Modal content goes here
            </div>
            <div class="flex justify-end gap-2">
                <button id="modal-cancel" class="px-4 py-2 rounded-lg bg-white/10 hover:bg-white/20">Cancel</button>
                <button id="modal-confirm" class="px-4 py-2 rounded-lg bg-gradient-to-r from-amber-400 to-pink-500 hover:opacity-90">Confirm</button>
            </div>
        </div>
    </div>

    <div class="container mx-auto px-4 py-8 sm:py-12">
        <header class="text-center mb-8 sm:mb-16">
            <div class="floating inline-block mb-4 sm:mb-6">
                <div class="spinning text-4xl sm:text-6xl mb-2">
                    <i class="fas fa-infinity"></i>
                </div>
            </div>
            <h1 class="text-3xl sm:text-5xl font-bold mb-2 sm:mb-4 tracking-tighter bg-clip-text text-transparent bg-gradient-to-r from-amber-300 to-pink-400 header-text">
                Infinite Universe Explorer
            </h1>
            <p class="text-base sm:text-xl opacity-80 max-w-2xl mx-auto subheader-text">
                Discover truly infinite random themes with unique colors and patterns!
            </p>
        </header>

        <main class="max-w-4xl mx-auto">
            <div class="bg-white/10 backdrop-blur-lg rounded-3xl overflow-hidden border border-white/20 mb-8 sm:mb-12">
                <div class="p-6 sm:p-8 md:p-12">
                    <div class="flex flex-col sm:flex-row gap-6 sm:gap-8 items-center main-content">
                        <div class="flex-1 w-full">
                            <div class="flex justify-between items-center mb-3 sm:mb-4">
                                <h2 class="text-2xl sm:text-3xl font-bold">Current Dimension</h2>
                                <div class="flex gap-1 sm:gap-2">
                                    <button id="favorite-btn" class="favorite-btn text-lg sm:text-xl p-1 sm:p-2 rounded-full hover:bg-white/10">
                                        <i class="far fa-star"></i>
                                    </button>
                                    <button id="screenshot-btn" class="screenshot-btn text-lg sm:text-xl p-1 sm:p-2 rounded-full hover:bg-white/10 tooltip">
                                        <i class="fas fa-camera"></i>
                                        <span class="tooltip-text">Take Screenshot</span>
                                    </button>
                                    <button id="share-btn" class="share-btn text-lg sm:text-xl p-1 sm:p-2 rounded-full hover:bg-white/10 tooltip">
                                        <i class="fas fa-share-alt"></i>
                                        <span class="tooltip-text">Share Dimension</span>
                                    </button>
                                </div>
                            </div>
                            <div id="theme-display" class="mb-4 sm:mb-6 p-4 sm:p-6 rounded-xl bg-black/20 border border-white/10">
                                <div class="flex items-center gap-2 sm:gap-3 mb-2 sm:mb-4">
                                    <span id="theme-icon" class="text-2xl sm:text-3xl"><i class="fas fa-question"></i></span>
                                    <span id="theme-name" class="text-xl sm:text-2xl font-medium">Unknown Dimension</span>
                                </div>
                                <p id="theme-description" class="opacity-80 text-sm sm:text-base">
                                    Waiting to discover your first random dimension...
                                </p>
                            </div>
                            <div class="grid grid-cols-5 gap-1 sm:gap-2 mb-3 sm:mb-4 color-grid">
                                <div id="color1" class="h-10 sm:h-12 rounded-md relative group">
                                    <div class="hex-tooltip absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 bg-black/90 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap"></div>
                                </div>
                                <div id="color2" class="h-10 sm:h-12 rounded-md relative group">
                                    <div class="hex-tooltip absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 bg-black/90 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap"></div>
                                </div>
                                <div id="color3" class="h-10 sm:h-12 rounded-md relative group">
                                    <div class="hex-tooltip absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 bg-black/90 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap"></div>
                                </div>
                                <div id="color4" class="h-10 sm:h-12 rounded-md relative group">
                                    <div class="hex-tooltip absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 bg-black/90 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap"></div>
                                </div>
                                <div id="color5" class="h-10 sm:h-12 rounded-md relative group">
                                    <div class="hex-tooltip absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 bg-black/90 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap"></div>
                                </div>
                            </div>
                            <div class="flex justify-between items-center mb-4 sm:mb-6">
                                <div id="hex-codes" class="text-xs sm:text-sm opacity-80 flex gap-1 sm:gap-2 flex-wrap">
                                    <!-- Hex codes will be displayed here -->
                                </div>
                                <button id="copy-hex-btn" class="copy-btn text-xs bg-white/10 hover:bg-white/20 px-2 sm:px-3 py-1 rounded-full flex items-center gap-1">
                                    <i class="fas fa-copy"></i> Copy
                                </button>
                            </div>
                            <div class="flex flex-col sm:flex-row gap-2 sm:gap-4 mb-3 sm:mb-4 action-buttons">
                                <button id="generate-btn" class="pulsing flex-1 py-3 sm:py-4 px-4 sm:px-6 bg-gradient-to-r from-amber-400 to-pink-500 rounded-xl font-bold text-base sm:text-lg hover:opacity-90 transition-all duration-300 shadow-lg hover:shadow-xl active:scale-95">
                                    <i class="fas fa-random mr-1 sm:mr-2"></i> Explore New Dimension
                                </button>
                                <button id="download-btn" class="download-btn py-3 sm:py-4 px-4 sm:px-6 bg-white/5 hover:bg-white/10 rounded-xl font-bold text-base sm:text-lg transition-all duration-300 shadow hover:shadow-lg">
                                    <i class="fas fa-download"></i>
                                </button>
                            </div>
                            <button id="toggle-css-btn" class="w-full py-2 sm:py-3 px-4 sm:px-6 bg-white/5 hover:bg-white/10 rounded-xl font-medium transition-all duration-300 flex items-center justify-center gap-1 sm:gap-2">
                                <i class="fas fa-code"></i> Generate CSS Code
                            </button>
                        </div>
                        <div class="flex-1 w-full relative pattern-container">
                            <div class="relative h-48 sm:h-64 md:h-80 rounded-2xl overflow-hidden border-2 border-white/20">
                                <div id="pattern-display" class="absolute inset-0 flex items-center justify-center">
                                    <div class="text-4xl sm:text-6xl opacity-20"><i class="fas fa-star"></i></div>
                                </div>
                            </div>
                            <div class="pattern-selector absolute bottom-2 sm:bottom-4 left-0 right-0 flex justify-center gap-1 sm:gap-2">
                                <button data-pattern="0" class="pattern-btn bg-black/70 hover:bg-black/90 p-1 sm:p-2 rounded-full border border-white/20 tooltip">
                                    <i class="fas fa-border-all text-sm sm:text-base"></i>
                                    <span class="tooltip-text">Grid Pattern</span>
                                </button>
                                <button data-pattern="1" class="pattern-btn bg-black/70 hover:bg-black/90 p-1 sm:p-2 rounded-full border border-white/20 tooltip">
                                    <i class="fas fa-circle-notch text-sm sm:text-base"></i>
                                    <span class="tooltip-text">Radial Pattern</span>
                                </button>
                                <button data-pattern="2" class="pattern-btn bg-black/70 hover:bg-black/90 p-1 sm:p-2 rounded-full border border-white/20 tooltip">
                                    <i class="fas fa-dot-circle text-sm sm:text-base"></i>
                                    <span class="tooltip-text">Particle Field</span>
                                </button>
                                <button data-pattern="3" class="pattern-btn bg-black/70 hover:bg-black/90 p-1 sm:p-2 rounded-full border border-white/20 tooltip">
                                    <i class="fas fa-shapes text-sm sm:text-base"></i>
                                    <span class="tooltip-text">Organic Shapes</span>
                                </button>
                                <button data-pattern="4" class="pattern-btn bg-black/70 hover:bg-black/90 p-1 sm:p-2 rounded-full border border-white/20 tooltip">
                                    <i class="fas fa-grip-lines text-sm sm:text-base"></i>
                                    <span class="tooltip-text">Stripes</span>
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- CSS Code Container -->
                    <div id="css-code-container" class="code-container mt-4 sm:mt-6 bg-black/30 rounded-xl overflow-hidden">
                        <div class="p-3 sm:p-4 border-t border-white/10 flex justify-between items-center">
                            <h3 class="font-mono font-bold text-xs sm:text-sm">CSS Variables</h3>
                            <button id="copy-css-btn" class="copy-btn text-xs bg-white/10 hover:bg-white/20 px-2 sm:px-3 py-1 rounded-full flex items-center gap-1">
                                <i class="fas fa-copy"></i> Copy
                            </button>
                        </div>
                        <pre id="css-code" class="p-3 sm:p-4 text-xs sm:text-sm font-mono overflow-auto max-h-64 bg-black/20"></pre>
                    </div>
                </div>
            </div>

            <div class="grid grid-cols-1 sm:grid-cols-3 gap-4 sm:gap-6 mb-8 sm:mb-12">
                <div class="bg-white/5 backdrop-blur-sm p-4 sm:p-6 rounded-2xl border border-white/10 hover:bg-white/10 transition-all">
                    <div class="text-2xl sm:text-3xl mb-3 sm:mb-4 text-amber-300"><i class="fas fa-infinity"></i></div>
                    <h3 class="text-lg sm:text-xl font-bold mb-1 sm:mb-2">Infinite Variety</h3>
                    <p class="opacity-80 text-sm sm:text-base">Every dimension is completely unique with randomly generated colors and patterns.</p>
                </div>
                <div class="bg-white/5 backdrop-blur-sm p-4 sm:p-6 rounded-2xl border border-white/10 hover:bg-white/10 transition-all">
                    <div class="text-2xl sm:text-3xl mb-3 sm:mb-4 text-pink-400"><i class="fas fa-atom"></i></div>
                    <h3 class="text-lg sm:text-xl font-bold mb-1 sm:mb-2">Quantum Colors</h3>
                    <p class="opacity-80 text-sm sm:text-base">Colors are generated using quantum-inspired algorithms for maximum uniqueness.</p>
                </div>
                <div class="bg-white/5 backdrop-blur-sm p-4 sm:p-6 rounded-2xl border border-white/10 hover:bg-white/10 transition-all">
                    <div class="text-2xl sm:text-3xl mb-3 sm:mb-4 text-purple-300"><i class="fas fa-shapes"></i></div>
                    <h3 class="text-lg sm:text-xl font-bold mb-1 sm:mb-2">Dynamic Patterns</h3>
                    <p class="opacity-80 text-sm sm:text-base">Patterns are procedurally generated to match each dimension's unique properties.</p>
                </div>
            </div>

            <div class="bg-white/5 backdrop-blur-sm p-4 sm:p-6 rounded-2xl border border-white/10 mb-8 sm:mb-12">
                <div class="flex justify-between items-center mb-3 sm:mb-4">
                    <h2 class="text-xl sm:text-2xl font-bold">Dimension History</h2>
                    <div class="flex gap-1 sm:gap-2">
                        <button id="clear-history" class="text-xs bg-red-500/20 hover:bg-red-500/30 text-red-300 px-2 sm:px-3 py-1 rounded-full flex items-center gap-1">
                            <i class="fas fa-trash"></i> Clear
                        </button>
                    </div>
                </div>
                <div id="history-container" class="flex overflow-x-auto pb-3 sm:pb-4 gap-3 sm:gap-4 gradient-mask scrollbar-hide">
                    <!-- History items will be added here -->
                </div>
            </div>

            <div class="bg-white/5 backdrop-blur-sm p-4 sm:p-6 rounded-2xl border border-white/10 mb-8 sm:mb-12">
                <h2 class="text-xl sm:text-2xl font-bold mb-3 sm:mb-4">Favorites</h2>
                <div id="favorites-container" class="flex overflow-x-auto pb-3 sm:pb-4 gap-3 sm:gap-4 gradient-mask scrollbar-hide">
                    <!-- Favorites will be added here -->
                </div>
            </div>
        </main>

        <footer class="text-center opacity-70 mt-12 sm:mt-20 pb-6 sm:pb-8">
            <p>Journey through the infinite multiverse <i class="fas fa-infinity text-purple-300"></i></p>
        </footer>
    </div>

    <script>
        // Word banks for generating random theme names and descriptions
        const prefixes = ["Quantum", "Neon", "Cosmic", "Hyper", "Digital", "Fractal", "Ethereal", "Void", "Celestial", "Nebula", "Chromatic", "Prismatic", "Luminous", "Dimensional", "Parallel", "Alternate", "Infinite", "Singularity", "Holographic", "Psychedelic"];
        const suffixes = ["Realm", "Dimension", "Universe", "Expanse", "Continuum", "Vortex", "Matrix", "Spectrum", "Horizon", "Infinity", "Cosmos", "Nexus", "Plane", "Domain", "Eclipse", "Paradox", "Mandala", "Fabric", "Construct", "Abyss"];
        const descriptors = ["where time folds upon itself", "of shimmering possibilities", "where colors sing", "beyond the veil of perception", "where physics takes a vacation", "of infinite reflections", "where light dances differently", "of impossible geometries", "where dreams take form", "of vibrating energy fields", "where reality glitches beautifully", "of chromatic harmony", "where dimensions intertwine", "of pure potentiality", "where the laws of nature rewrite themselves"];

        // Icon options
        const icons = [
            "fa-atom", "fa-infinity", "fa-star", "fa-moon", "fa-sun", 
            "fa-galaxy", "fa-meteor", "fa-satellite", "fa-rocket", "fa-ufo",
            "fa-shapes", "fa-cubes", "fa-dna", "fa-microscope", "fa-telescope",
            "fa-mountain", "fa-water", "fa-fire", "fa-wind", "fa-leaf",
            "fa-gem", "fa-crystal-ball", "fa-magic", "fa-hat-wizard", "fa-scroll"
        ];

        // DOM elements
        const generateBtn = document.getElementById('generate-btn');
        const themeName = document.getElementById('theme-name');
        const themeIcon = document.getElementById('theme-icon');
        const themeDescription = document.getElementById('theme-description');
        const themeDisplay = document.getElementById('theme-display');
        const patternDisplay = document.getElementById('pattern-display');
        const body = document.querySelector('body');
        const particlesContainer = document.getElementById('particles-container');
        const historyContainer = document.getElementById('history-container');
        const favoritesContainer = document.getElementById('favorites-container');
        const hexCodesContainer = document.getElementById('hex-codes');
        const copyHexBtn = document.getElementById('copy-hex-btn');
        const toggleCssBtn = document.getElementById('toggle-css-btn');
        const cssCodeContainer = document.getElementById('css-code-container');
        const cssCode = document.getElementById('css-code');
        const copyCssBtn = document.getElementById('copy-css-btn');
        const favoriteBtn = document.getElementById('favorite-btn');
        const screenshotBtn = document.getElementById('screenshot-btn');
        const shareBtn = document.getElementById('share-btn');
        const downloadBtn = document.getElementById('download-btn');
        const clearHistoryBtn = document.getElementById('clear-history');
        const patternBtns = document.querySelectorAll('.pattern-btn');
        const modal = document.getElementById('modal');
        const modalTitle = document.getElementById('modal-title');
        const modalContent = document.getElementById('modal-content');
        const closeModal = document.getElementById('close-modal');
        const modalCancel = document.getElementById('modal-cancel');
        const modalConfirm = document.getElementById('modal-confirm');

        // Color elements
        const colorElements = [
            document.getElementById('color1'),
            document.getElementById('color2'),
            document.getElementById('color3'),
            document.getElementById('color4'),
            document.getElementById('color5')
        ];

        // Current theme
        let currentTheme = null;
        let favorites = JSON.parse(localStorage.getItem('favorites')) || [];
        let history = JSON.parse(localStorage.getItem('history')) || [];

        // Convert HSL to Hex
        function hslToHex(h, s, l) {
            l /= 100;
            const a = s * Math.min(l, 1 - l) / 100;
            const f = n => {
                const k = (n + h / 30) % 12;
                const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
                return Math.round(255 * color).toString(16).padStart(2, '0');
            };
            return `#${f(0)}${f(8)}${f(4)}`;
        }

        // Generate random HSL color
        function generateRandomColor() {
            const h = Math.floor(Math.random() * 360);
            const s = Math.floor(Math.random() * 30) + 70; // 70-100% saturation
            const l = Math.floor(Math.random() * 30) + 50; // 50-80% lightness
            return {
                hsl: `hsl(${h}, ${s}%, ${l}%)`,
                hex: hslToHex(h, s, l)
            };
        }

        // Generate a harmonious color palette
        function generateColorPalette() {
            const baseHue = Math.floor(Math.random() * 360);
            const colors = [];
            
            // Base color
            const baseS = Math.floor(Math.random() * 30) + 70;
            const baseL = Math.floor(Math.random() * 30) + 50;
            colors.push({
                hsl: `hsl(${baseHue}, ${baseS}%, ${baseL}%)`,
                hex: hslToHex(baseHue, baseS, baseL)
            });
            
            // Analogous colors (adjacent hues)
            const analogous1S = Math.floor(Math.random() * 20) + 70;
            const analogous1L = Math.floor(Math.random() * 20) + 60;
            colors.push({
                hsl: `hsl(${(baseHue + 30) % 360}, ${analogous1S}%, ${analogous1L}%)`,
                hex: hslToHex((baseHue + 30) % 360, analogous1S, analogous1L)
            });
            
            const analogous2S = Math.floor(Math.random() * 20) + 70;
            const analogous2L = Math.floor(Math.random() * 20) + 60;
            colors.push({
                hsl: `hsl(${(baseHue - 30 + 360) % 360}, ${analogous2S}%, ${analogous2L}%)`,
                hex: hslToHex((baseHue - 30 + 360) % 360, analogous2S, analogous2L)
            });
            
            // Complementary or split-complementary
            if (Math.random() > 0.5) {
                // Complementary
                const compS = Math.floor(Math.random() * 30) + 60;
                const compL = Math.floor(Math.random() * 20) + 40;
                colors.push({
                    hsl: `hsl(${(baseHue + 180) % 360}, ${compS}%, ${compL}%)`,
                    hex: hslToHex((baseHue + 180) % 360, compS, compL)
                });
            } else {
                // Split-complementary
                const split1S = Math.floor(Math.random() * 20) + 60;
                const split1L = Math.floor(Math.random() * 20) + 40;
                colors.push({
                    hsl: `hsl(${(baseHue + 150) % 360}, ${split1S}%, ${split1L}%)`,
                    hex: hslToHex((baseHue + 150) % 360, split1S, split1L)
                });
                
                const split2S = Math.floor(Math.random() * 20) + 60;
                const split2L = Math.floor(Math.random() * 20) + 40;
                colors.push({
                    hsl: `hsl(${(baseHue + 210) % 360}, ${split2S}%, ${split2L}%)`,
                    hex: hslToHex((baseHue + 210) % 360, split2S, split2L)
                });
            }
            
            // Accent color (either monochromatic or triadic)
            if (Math.random() > 0.5) {
                // Monochromatic
                const monoL = Math.random() > 0.5 ? baseL + 20 : baseL - 20;
                colors.push({
                    hsl: `hsl(${baseHue}, ${baseS}%, ${monoL}%)`,
                    hex: hslToHex(baseHue, baseS, monoL)
                });
            } else {
                // Triadic
                const triadS = Math.floor(Math.random() * 20) + 70;
                const triadL = Math.floor(Math.random() * 20) + 50;
                colors.push({
                    hsl: `hsl(${(baseHue + 120) % 360}, ${triadS}%, ${triadL}%)`,
                    hex: hslToHex((baseHue + 120) % 360, triadS, triadL)
                });
            }
            
            // Shuffle and return exactly 5 colors
            return colors.sort(() => Math.random() - 0.5).slice(0, 5);
        }

        // Generate random theme name
        function generateThemeName() {
            const prefix = prefixes[Math.floor(Math.random() * prefixes.length)];
            const suffix = suffixes[Math.floor(Math.random() * suffixes.length)];
            return `${prefix} ${suffix}`;
        }

        // Generate random description
        function generateDescription() {
            const descriptor = descriptors[Math.floor(Math.random() * descriptors.length)];
            return `A mysterious dimension ${descriptor}.`;
        }

        // Random pattern generators
        const patternGenerators = [
            function(container, colors) {
                // Geometric grid
                const angle = Math.floor(Math.random() * 4) * 45;
                const size = Math.floor(Math.random() * 30) + 20;
                container.style.background = `
                    linear-gradient(${angle}deg, currentColor 1px, transparent 1px),
                    linear-gradient(${angle + 90}deg, currentColor 1px, transparent 1px)
                `;
                container.style.backgroundSize = `${size}px ${size}px`;
                return `background: linear-gradient(${angle}deg, var(--color-primary) 1px, transparent 1px),
        linear-gradient(${angle + 90}deg, var(--color-primary) 1px, transparent 1px); background-size: ${size}px ${size}px;`;
            },
            function(container, colors) {
                // Radial gradient
                container.style.background = `
                    radial-gradient(circle at 20% 30%, currentColor 0%, transparent 30%),
                    radial-gradient(circle at 80% 70%, currentColor 0%, transparent 30%)
                `;
                return `background: radial-gradient(circle at 20% 30%, var(--color-primary) 0%, transparent 30%),
        radial-gradient(circle at 80% 70%, var(--color-primary) 0%, transparent 30%);`;
            },
            function(container, colors) {
                // Particle field
                container.innerHTML = '';
                const particleCount = Math.floor(Math.random() * 30) + 20;
                for (let i = 0; i < particleCount; i++) {
                    const particle = document.createElement('div');
                    particle.style.position = 'absolute';
                    particle.style.color = colors[Math.floor(Math.random() * colors.length)].hsl;
                    particle.style.opacity = Math.random() * 0.5 + 0.2;
                    particle.style.width = `${Math.random() * 10 + 2}px`;
                    particle.style.height = particle.style.width;
                    particle.style.borderRadius = '50%';
                    particle.style.left = `${Math.random() * 100}%`;
                    particle.style.top = `${Math.random() * 100}%`;
                    container.appendChild(particle);
                }
                return `/* Particle effect requires JavaScript to implement */`;
            },
            function(container, colors) {
                // Organic shapes
                container.innerHTML = '';
                const shapeCount = Math.floor(Math.random() * 8) + 3;
                for (let i = 0; i < shapeCount; i++) {
                    const shape = document.createElement('div');
                    shape.style.position = 'absolute';
                    shape.style.color = colors[Math.floor(Math.random() * colors.length)].hsl;
                    shape.style.opacity = Math.random() * 0.4 + 0.2;
                    shape.style.fontSize = `${Math.random() * 40 + 20}px`;
                    shape.style.left = `${Math.random() * 100}%`;
                    shape.style.top = `${Math.random() * 100}%`;
                    shape.style.transform = `rotate(${Math.random() * 360}deg) scale(${Math.random() * 1.5 + 0.5})`;
                    
                    const shapeTypes = ['fa-star', "fa-cloud", "fa-circle", "fa-square", "fa-heart", "fa-certificate"];
                    const randomShape = shapeTypes[Math.floor(Math.random() * shapeTypes.length)];
                    shape.innerHTML = `<i class="fas ${randomShape}"></i>`;
                    
                    container.appendChild(shape);
                }
                return `/* Organic shapes effect requires JavaScript to implement */`;
            },
            function(container, colors) {
                // Stripes
                const angle = Math.floor(Math.random() * 180);
                const width = Math.floor(Math.random() * 30) + 10;
                container.style.background = `repeating-linear-gradient(${angle}deg, currentColor 0px, currentColor ${width}px, transparent ${width}px, transparent ${width * 2}px)`;
                return `background: repeating-linear-gradient(${angle}deg, var(--color-primary) 0px, var(--color-primary) ${width}px, transparent ${width}px, transparent ${width * 2}px);`;
            }
        ];

        // Create floating particles
        function createParticles(colors) {
            // Clear existing particles
            particlesContainer.innerHTML = '';
            
            // Create new particles
            const particleCount = Math.floor(Math.random() * 50) + 30;
            for (let i = 0; i < particleCount; i++) {
                const particle = document.createElement('div');
                particle.className = 'particle';
                
                // Random size between 2px and 8px
                const size = Math.random() * 6 + 2;
                particle.style.width = `${size}px`;
                particle.style.height = `${size}px`;
                
                // Random position
                particle.style.left = `${Math.random() * 100}%`;
                particle.style.top = `${Math.random() * 100}%`;
                
                // Random color from theme
                particle.style.color = colors[Math.floor(Math.random() * colors.length)].hsl;
                
                // Random animation
                const duration = Math.random() * 30 + 10;
                const delay = Math.random() * 10;
                const xMovement = (Math.random() - 0.5) * 200;
                const yMovement = (Math.random() - 0.5) * 200;
                
                particle.style.animation = `
                    float ${duration}s ease-in-out ${delay}s infinite,
                    fade ${duration * 0.7}s ease-in-out infinite
                `;
                
                // Keyframes for this particle
                const keyframes = `
                    @keyframes float {
                        0%, 100% { transform: translate(0, 0); }
                        50% { transform: translate(${xMovement}px, ${yMovement}px); }
                    }
                    @keyframes fade {
                        0%, 100% { opacity: 0; }
                        50% { opacity: ${Math.random() * 0.6 + 0.1}; }
                    }
                `;
                
                const style = document.createElement('style');
                style.innerHTML = keyframes;
                document.head.appendChild(style);
                
                particlesContainer.appendChild(particle);
            }
        }

        // Add to history
        function addToHistory(theme) {
            // Check if theme already exists in history
            const exists = history.some(t => t.name === theme.name && 
                JSON.stringify(t.colors) === JSON.stringify(theme.colors));
            
            if (!exists) {
                history.unshift({
                    name: theme.name,
                    colors: theme.colors,
                    icon: theme.icon,
                    description: theme.description,
                    patternIndex: theme.patternIndex,
                    timestamp: new Date().toISOString()
                });
                
                // Limit history to 20 items
                if (history.length > 20) {
                    history.pop();
                }
                
                localStorage.setItem('history', JSON.stringify(history));
                renderHistory();
            }
        }

        // Add to favorites
        function addToFavorites(theme) {
            // Check if theme already exists in favorites
            const exists = favorites.some(t => t.name === theme.name && 
                JSON.stringify(t.colors) === JSON.stringify(theme.colors));
            
            if (!exists) {
                favorites.unshift({
                    name: theme.name,
                    colors: theme.colors,
                    icon: theme.icon,
                    description: theme.description,
                    patternIndex: theme.patternIndex,
                    timestamp: new Date().toISOString()
                });
                
                localStorage.setItem('favorites', JSON.stringify(favorites));
                renderFavorites();
                
                // Show notification
                showModal('Favorite Added', 'This dimension has been added to your favorites!');
            } else {
                // Remove from favorites
                favorites = favorites.filter(t => !(t.name === theme.name && 
                    JSON.stringify(t.colors) === JSON.stringify(theme.colors)));
                
                localStorage.setItem('favorites', JSON.stringify(favorites));
                renderFavorites();
                
                // Show notification
                showModal('Favorite Removed', 'This dimension has been removed from your favorites.');
            }
            
            // Update favorite button state
            updateFavoriteButton();
        }

        // Check if current theme is favorite
        function isFavorite() {
            if (!currentTheme) return false;
            
            return favorites.some(t => t.name === currentTheme.name && 
                JSON.stringify(t.colors) === JSON.stringify(currentTheme.colors));
        }

        // Update favorite button state
        function updateFavoriteButton() {
            if (isFavorite()) {
                favoriteBtn.innerHTML = '<i class="fas fa-star"></i>';
                favoriteBtn.classList.add('active');
            } else {
                favoriteBtn.innerHTML = '<i class="far fa-star"></i>';
                favoriteBtn.classList.remove('active');
            }
        }

        // Render history
        function renderHistory() {
            historyContainer.innerHTML = '';
            
            if (history.length === 0) {
                const emptyMessage = document.createElement('div');
                emptyMessage.className = 'text-center w-full py-8 opacity-70';
                emptyMessage.textContent = 'No history yet. Generate some dimensions!';
                historyContainer.appendChild(emptyMessage);
                return;
            }
            
            history.forEach((theme, index) => {
                const historyItem = document.createElement('div');
                historyItem.className = 'flex-shrink-0 w-20 sm:w-24 h-20 sm:h-24 rounded-xl overflow-hidden border-2 border-white/20 cursor-pointer transition-all hover:scale-105 history-item';
                historyItem.style.background = `linear-gradient(135deg, ${theme.colors[0].hsl}, ${theme.colors[2].hsl})`;
                
                const title = document.createElement('div');
                title.className = 'history-item-title truncate';
                title.textContent = theme.name;
                
                historyItem.appendChild(title);
                
                historyItem.addEventListener('click', () => {
                    applyTheme(theme);
                });
                
                historyContainer.appendChild(historyItem);
            });
        }

        // Render favorites
        function renderFavorites() {
            favoritesContainer.innerHTML = '';
            
            if (favorites.length === 0) {
                const emptyMessage = document.createElement('div');
                emptyMessage.className = 'text-center w-full py-8 opacity-70';
                emptyMessage.textContent = 'No favorites yet. Click the star button to add some!';
                favoritesContainer.appendChild(emptyMessage);
                return;
            }
            
            favorites.forEach((theme, index) => {
                const favoriteItem = document.createElement('div');
                favoriteItem.className = 'flex-shrink-0 w-20 sm:w-24 h-20 sm:h-24 rounded-xl overflow-hidden border-2 border-white/20 cursor-pointer transition-all hover:scale-105 history-item';
                favoriteItem.style.background = `linear-gradient(135deg, ${theme.colors[0].hsl}, ${theme.colors[2].hsl})`;
                
                const title = document.createElement('div');
                title.className = 'history-item-title truncate';
                title.textContent = theme.name;
                
                favoriteItem.appendChild(title);
                
                favoriteItem.addEventListener('click', () => {
                    applyTheme(theme);
                });
                
                favoritesContainer.appendChild(favoriteItem);
            });
        }

        // Clear history
        function clearHistory() {
            history = [];
            localStorage.setItem('history', JSON.stringify(history));
            renderHistory();
            showModal('History Cleared', 'Your dimension history has been cleared.');
        }

        // Generate CSS code for the current theme
        function generateCSSCode(theme) {
            let css = `:root {
    /* Color Variables */
    --color-primary: ${theme.colors[0].hsl};
    --color-secondary: ${theme.colors[1].hsl};
    --color-accent: ${theme.colors[2].hsl};
    --color-background: ${theme.colors[3].hsl};
    --color-text: ${theme.colors[4].hsl};

    /* Hex Codes */
    /* Primary: ${theme.colors[0].hex} */
    /* Secondary: ${theme.colors[1].hex} */
    /* Accent: ${theme.colors[2].hex} */
    /* Background: ${theme.colors[3].hex} */
    /* Text: ${theme.colors[4].hex} */
}

body {
    background: linear-gradient(to bottom right, var(--color-primary), var(--color-accent));
    color: var(--color-text);
}

/* Pattern Styles */
.pattern {
    ${theme.patternCSS}
}`;

            return css;
        }

        // Update hex code display
        function updateHexCodes(colors) {
            hexCodesContainer.innerHTML = '';
            colors.forEach((color, index) => {
                const hexCode = document.createElement('div');
                hexCode.className = 'flex items-center gap-1';
                hexCode.innerHTML = `
                    <span class="inline-block w-2 sm:w-3 h-2 sm:h-3 rounded-full" style="background-color: ${color.hex}"></span>
                    <span>${color.hex}</span>
                `;
                hexCodesContainer.appendChild(hexCode);
            });

            // Update tooltips
            colorElements.forEach((el, index) => {
                const tooltip = el.querySelector('.hex-tooltip');
                if (tooltip) {
                    tooltip.textContent = colors[index].hex;
                }
            });
        }

        // Apply a theme
        function applyTheme(theme) {
            currentTheme = theme;
            
            // Update theme info
            themeName.textContent = theme.name;
            themeIcon.innerHTML = `<i class="fas ${theme.icon}"></i>`;
            themeDescription.textContent = theme.description;
            
            // Update colors
            theme.colors.forEach((color, index) => {
                colorElements[index].style.backgroundColor = color.hsl;
            });
            
            // Update hex codes
            updateHexCodes(theme.colors);
            
            // Set main color
            const mainColor = theme.colors[0].hsl;
            themeDisplay.style.borderColor = `${mainColor}80`;
            
            // Apply pattern
            patternDisplay.innerHTML = '';
            patternDisplay.style.color = theme.colors[2].hsl;
            theme.patternCSS = patternGenerators[theme.patternIndex](patternDisplay, theme.colors);
            
            // Update background gradient
            body.style.background = `linear-gradient(to bottom right, ${theme.colors[0].hsl}, ${theme.colors[2].hsl})`;
            
            // Create particles
            createParticles(theme.colors);
            
            // Generate CSS code
            cssCode.textContent = generateCSSCode(theme);
            
            // Update favorite button state
            updateFavoriteButton();
        }

        // Generate random theme
        function generateRandomTheme() {
            const colors = generateColorPalette();
            
            const theme = {
                name: generateThemeName(),
                icon: icons[Math.floor(Math.random() * icons.length)],
                description: generateDescription(),
                colors: colors,
                patternIndex: Math.floor(Math.random() * patternGenerators.length),
                patternGenerator: patternGenerators[Math.floor(Math.random() * patternGenerators.length)],
                patternCSS: ''
            };
            
            addToHistory(theme);
            applyTheme(theme);
        }

        // Copy text to clipboard
        function copyToClipboard(text, button) {
            navigator.clipboard.writeText(text).then(() => {
                button.classList.add('copied');
                button.innerHTML = '<i class="fas fa-check"></i> Copied!';
                setTimeout(() => {
                    button.classList.remove('copied');
                    if (button.id === 'copy-hex-btn') {
                        button.innerHTML = '<i class="fas fa-copy"></i> Copy';
                    } else {
                        button.innerHTML = '<i class="fas fa-copy"></i> Copy';
                    }
                }, 2000);
            }).catch(err => {
                console.error('Failed to copy text: ', err);
                showModal('Copy Failed', 'Failed to copy text to clipboard. Please try again.');
            });
        }

        // Show modal
        function showModal(title, content, isConfirm = false) {
            modalTitle.textContent = title;
            modalContent.textContent = content;
            
            if (isConfirm) {
                modalConfirm.style.display = 'block';
            } else {
                modalConfirm.style.display = 'none';
            }
            
            modal.classList.remove('hidden');
            setTimeout(() => {
                modal.classList.add('opacity-100');
            }, 10);
        }

        // Hide modal
        function hideModal() {
            modal.classList.remove('opacity-100');
            setTimeout(() => {
                modal.classList.add('hidden');
            }, 300);
        }

        // Take screenshot
        function takeScreenshot() {
            showModal('Taking Screenshot', 'Preparing your dimension screenshot...');
            
            // Capture the main content area
            const element = document.querySelector('.bg-white\\/10.backdrop-blur-lg.rounded-3xl');
            
            html2canvas(element, {
                scale: 2,
                backgroundColor: null,
                logging: false,
                useCORS: true
            }).then(canvas => {
                // Create download link
                const link = document.createElement('a');
                link.download = `${currentTheme.name.toLowerCase().replace(/\s+/g, '-')}-screenshot.png`;
                link.href = canvas.toDataURL('image/png');
                link.click();
                
                showModal('Screenshot Saved', 'Your dimension screenshot has been downloaded!');
            }).catch(err => {
                console.error('Failed to take screenshot: ', err);
                showModal('Screenshot Failed', 'Failed to capture screenshot. Please try again.');
            });
        }

        // Share dimension
        function shareDimension() {
            if (!currentTheme) return;
            
            if (navigator.share) {
                // Use Web Share API if available
                navigator.share({
                    title: `Dimension: ${currentTheme.name}`,
                    text: `Check out this amazing dimension I found: ${currentTheme.description}`,
                    url: window.location.href
                }).then(() => {
                    showModal('Shared Successfully', 'Thanks for sharing this dimension!');
                }).catch(err => {
                    console.error('Error sharing:', err);
                    showModal('Share Failed', 'Could not share the dimension. Please try again.');
                });
            } else {
                // Fallback for browsers without Web Share API
                const shareText = `Check out this amazing dimension: ${currentTheme.name} - ${currentTheme.description}`;
                copyToClipboard(shareText, shareBtn);
                showModal('Share Dimension', 'The dimension details have been copied to your clipboard. You can now paste it anywhere to share!');
            }
        }

        // Download theme
        function downloadTheme() {
            if (!currentTheme) return;
            
            const cssContent = generateCSSCode(currentTheme);
            const blob = new Blob([cssContent], { type: 'text/css' });
            const url = URL.createObjectURL(blob);
            
            const a = document.createElement('a');
            a.href = url;
            a.download = `${currentTheme.name.toLowerCase().replace(/\s+/g, '-')}-theme.css`;
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
            URL.revokeObjectURL(url);
            
            showModal('Download Complete', `The CSS for "${currentTheme.name}" has been downloaded.`);
        }

        // Change pattern
        function changePattern(index) {
            if (!currentTheme) return;
            
            currentTheme.patternIndex = index;
            currentTheme.patternGenerator = patternGenerators[index];
            applyTheme(currentTheme);
        }

        // Initial generation
        generateRandomTheme();
        renderHistory();
        renderFavorites();

        // Button click event
        generateBtn.addEventListener('click', () => {
            // Add click animation
            generateBtn.classList.add('active:scale-95');
            setTimeout(() => {
                generateBtn.classList.remove('active:scale-95');
            }, 150);
            
            generateRandomTheme();
        });

        // Toggle CSS code container
        toggleCssBtn.addEventListener('click', () => {
            cssCodeContainer.classList.toggle('open');
            if (cssCodeContainer.classList.contains('open')) {
                toggleCssBtn.innerHTML = '<i class="fas fa-code"></i> Hide CSS Code';
            } else {
                toggleCssBtn.innerHTML = '<i class="fas fa-code"></i> Generate CSS Code';
            }
        });

        // Copy hex codes
        copyHexBtn.addEventListener('click', () => {
            const hexCodes = Array.from(hexCodesContainer.querySelectorAll('div')).map(div => {
                return div.textContent.trim().split('\n').pop().trim();
            }).join('\n');
            copyToClipboard(hexCodes, copyHexBtn);
        });

        // Copy CSS code
        copyCssBtn.addEventListener('click', () => {
            copyToClipboard(cssCode.textContent, copyCssBtn);
        });

        // Favorite button
        favoriteBtn.addEventListener('click', () => {
            if (currentTheme) {
                addToFavorites(currentTheme);
            }
        });

        // Screenshot button
        screenshotBtn.addEventListener('click', takeScreenshot);

        // Share button
        shareBtn.addEventListener('click', shareDimension);

        // Download button
        downloadBtn.addEventListener('click', downloadTheme);

        // Clear history button
        clearHistoryBtn.addEventListener('click', () => {
            showModal('Clear History', 'Are you sure you want to clear your dimension history?', true);
            
            modalConfirm.onclick = () => {
                clearHistory();
                hideModal();
            };
        });

        // Pattern buttons
        patternBtns.forEach(btn => {
            btn.addEventListener('click', () => {
                const patternIndex = parseInt(btn.dataset.pattern);
                changePattern(patternIndex);
            });
        });

        // Modal events
        closeModal.addEventListener('click', hideModal);
        modalCancel.addEventListener('click', hideModal);
        modal.addEventListener('click', (e) => {
            if (e.target === modal) {
                hideModal();
            }
        });

        // Initialize tooltips
        document.querySelectorAll('.tooltip').forEach(el => {
            el.addEventListener('mouseenter', () => {
                const tooltip = el.querySelector('.tooltip-text');
                tooltip.style.visibility = 'visible';
                tooltip.style.opacity = '1';
            });
            el.addEventListener('mouseleave', () => {
                const tooltip = el.querySelector('.tooltip-text');
                tooltip.style.visibility = 'hidden';
                tooltip.style.opacity = '0';
            });
        });

        // Touch events for mobile tooltips
        document.querySelectorAll('.tooltip').forEach(el => {
            el.addEventListener('touchstart', () => {
                const tooltip = el.querySelector('.tooltip-text');
                tooltip.style.visibility = 'visible';
                tooltip.style.opacity = '1';
                
                // Hide after 2 seconds
                setTimeout(() => {
                    tooltip.style.visibility = 'hidden';
                    tooltip.style.opacity = '0';
                }, 2000);
            });
        });
    </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=druvx13/infinite-universe-explorer" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
</html>