File size: 53,044 Bytes
7a85035
 
 
 
 
 
 
 
 
 
 
 
 
61c9cc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a85035
 
 
 
 
 
 
61c9cc3
7a85035
 
 
 
61c9cc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a85035
 
 
 
 
61c9cc3
 
 
 
 
 
7a85035
 
 
61c9cc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a85035
 
 
61c9cc3
 
 
7a85035
 
 
 
 
61c9cc3
 
 
7a85035
 
 
 
 
61c9cc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a85035
 
61c9cc3
 
 
 
 
7a85035
 
61c9cc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a85035
 
 
61c9cc3
 
7a85035
61c9cc3
 
 
7a85035
 
61c9cc3
 
 
 
 
7a85035
 
 
 
 
61c9cc3
 
7a85035
 
 
61c9cc3
7a85035
 
 
 
 
61c9cc3
7a85035
61c9cc3
 
 
 
7a85035
61c9cc3
 
 
7a85035
 
 
 
61c9cc3
7a85035
 
 
 
 
 
61c9cc3
 
 
 
7a85035
61c9cc3
 
 
7a85035
61c9cc3
7a85035
 
61c9cc3
7a85035
 
 
 
 
61c9cc3
 
 
 
7a85035
61c9cc3
 
 
7a85035
61c9cc3
7a85035
 
61c9cc3
7a85035
 
 
 
 
61c9cc3
 
 
 
7a85035
61c9cc3
 
 
7a85035
61c9cc3
7a85035
 
61c9cc3
7a85035
 
 
 
 
 
 
61c9cc3
 
 
 
7a85035
 
 
 
 
 
 
61c9cc3
7a85035
 
 
 
 
61c9cc3
 
 
 
 
7a85035
 
 
61c9cc3
7a85035
61c9cc3
 
 
7a85035
 
 
 
61c9cc3
 
7a85035
61c9cc3
 
 
7a85035
 
61c9cc3
 
 
7a85035
 
 
61c9cc3
 
 
 
 
 
7a85035
 
61c9cc3
 
 
 
 
 
7a85035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61c9cc3
 
7a85035
 
 
61c9cc3
 
7a85035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61c9cc3
7a85035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61c9cc3
7a85035
 
61c9cc3
7a85035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61c9cc3
7a85035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61c9cc3
 
 
 
 
 
 
 
 
7a85035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61c9cc3
7a85035
 
 
 
 
 
 
 
61c9cc3
 
7a85035
 
61c9cc3
7a85035
 
61c9cc3
7a85035
61c9cc3
7a85035
61c9cc3
7a85035
 
 
 
 
61c9cc3
 
7a85035
 
61c9cc3
 
7a85035
 
 
61c9cc3
7a85035
 
 
61c9cc3
7a85035
61c9cc3
 
7a85035
 
 
 
 
 
 
61c9cc3
7a85035
 
 
 
 
 
 
61c9cc3
 
 
 
7a85035
 
 
 
 
 
61c9cc3
 
7a85035
 
 
 
 
61c9cc3
7a85035
 
61c9cc3
 
 
 
 
 
 
 
7a85035
 
61c9cc3
 
7a85035
 
 
 
 
61c9cc3
 
7a85035
 
 
 
 
61c9cc3
7a85035
 
 
61c9cc3
 
 
7a85035
 
 
 
 
 
61c9cc3
 
7a85035
 
 
 
 
 
 
 
 
 
61c9cc3
7a85035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61c9cc3
7a85035
 
 
 
 
 
 
 
 
 
 
61c9cc3
7a85035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bitcoin Price Predictor</title>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/luxon@2.0.2"></script>
    <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@1.0.0"></script>
    <script src="https://accounts.google.com/gsi/client" async defer></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background-color: #f5f7fa;
            color: #333;
            line-height: 1.6;
        }
        
        .container {
            width: 95%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px 0;
        }
        
        /* Header Styles */
        .header {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }
        
        .logo {
            display: flex;
            align-items: center;
            font-size: 24px;
            font-weight: bold;
            color: #2d3748;
            margin-bottom: 15px;
        }
        
        .logo i {
            color: #f7931a;
            margin-right: 10px;
        }
        
        .header-actions {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .user-info {
            display: none;
            align-items: center;
        }
        
        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            margin-right: 10px;
        }
        
        .user-name {
            color: #4a5568;
        }
        
        .logout-btn {
            margin-left: 15px;
            padding: 5px 12px;
            background-color: #e2e8f0;
            color: #4a5568;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        
        .logout-btn:hover {
            background-color: #cbd5e0;
        }
        
        .refresh-btn {
            display: flex;
            align-items: center;
            padding: 8px 16px;
            background-color: #4299e1;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        
        .refresh-btn:hover {
            background-color: #3182ce;
        }
        
        .refresh-btn i {
            margin-right: 8px;
        }
        
        /* Prediction Cards */
        .cards-container {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .card {
            flex: 1;
            min-width: 250px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            padding: 20px;
            transition: transform 0.3s, box-shadow 0.3s;
        }
        
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        
        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .card-title {
            font-size: 18px;
            font-weight: 600;
            color: #2d3748;
        }
        
        .timeframe-badge {
            font-size: 12px;
            padding: 3px 8px;
            border-radius: 12px;
            font-weight: 500;
        }
        
        .badge-1h {
            background-color: #ebf8ff;
            color: #3182ce;
        }
        
        .badge-8h {
            background-color: #faf5ff;
            color: #805ad5;
        }
        
        .badge-24h {
            background-color: #f0fff4;
            color: #38a169;
        }
        
        .price-value {
            font-size: 28px;
            font-weight: 700;
            color: #2d3748;
        }
        
        .confidence {
            display: flex;
            align-items: center;
            margin-left: 10px;
            font-size: 14px;
        }
        
        .confidence.high {
            color: #38a169;
        }
        
        .confidence.medium {
            color: #d69e2e;
        }
        
        .confidence.low {
            color: #e53e3e;
        }
        
        .price-container {
            display: flex;
            align-items: flex-end;
        }
        
        .price-details {
            display: flex;
            font-size: 13px;
            color: #718096;
            margin-top: 10px;
        }
        
        .price-details span {
            margin-right: 10px;
        }
        
        /* Chart Section */
        .chart-section {
            background: white;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            padding: 20px;
            margin-bottom: 30px;
        }
        
        .chart-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        
        .section-title {
            font-size: 20px;
            font-weight: 600;
            color: #2d3748;
        }
        
        .timeframe-select {
            padding: 8px 12px;
            border: 1px solid #e2e8f0;
            border-radius: 4px;
            background-color: #f8fafc;
        }
        
        .chart-container {
            height: 400px;
            position: relative;
        }
        
        /* History Section */
        .history-section {
            background: white;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            padding: 20px;
            margin-bottom: 30px;
        }
        
        .history-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        
        .export-btn {
            display: flex;
            align-items: center;
            padding: 8px 16px;
            background-color: #f8fafc;
            color: #4a5568;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        
        .export-btn:hover {
            background-color: #e2e8f0;
        }
        
        .export-btn i {
            margin-right: 8px;
        }
        
        .history-items {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        
        .history-item {
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            padding: 15px;
        }
        
        .history-header-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        
        .history-details {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
        }
        
        .history-detail {
            flex: 1;
            min-width: 150px;
        }
        
        .detail-label {
            font-size: 13px;
            color: #718096;
            margin-bottom: 5px;
        }
        
        .detail-value {
            font-weight: 500;
        }
        
        .accuracy-high {
            background-color: #f0fff4;
            color: #38a169;
            padding: 3px 8px;
            border-radius: 4px;
            display: inline-block;
        }
        
        .accuracy-medium {
            background-color: #fffff0;
            color: #d69e2e;
            padding: 3px 8px;
            border-radius: 4px;
            display: inline-block;
        }
        
        .accuracy-low {
            background-color: #fff5f5;
            color: #e53e3e;
            padding: 3px 8px;
            border-radius: 4px;
            display: inline-block;
        }
        
        /* Stats Section */
        .stats-section {
            background: white;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            padding: 20px;
        }
        
        .stats-container {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
        }
        
        .stat-item {
            flex: 1;
            min-width: 200px;
            display: flex;
            align-items: center;
        }
        
        .gauge-container {
            width: 80px;
            height: 80px;
            margin-right: 20px;
        }
        
        .stat-info {
            flex: 1;
        }
        
        .stat-label {
            font-size: 14px;
            color: #718096;
            margin-bottom: 5px;
        }
        
        .stat-value {
            font-size: 24px;
            font-weight: 600;
            color: #2d3748;
        }
        
        .stat-subtext {
            font-size: 13px;
            color: #718096;
        }
        
        /* Responsive Adjustments */
        @media (max-width: 768px) {
            .cards-container {
                flex-direction: column;
            }
            
            .history-details {
                flex-direction: column;
                gap: 10px;
            }
            
            .stat-item {
                min-width: 100%;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- Header -->
        <header class="header">
            <div class="logo">
                <i class="fab fa-bitcoin"></i> Bitcoin Price Predictor
            </div>
            
            <div class="header-actions">
                <div id="userInfo" class="user-info">
                    <img id="userAvatar" class="user-avatar" src="" alt="User">
                    <span id="userName" class="user-name"></span>
                    <button id="logoutBtn" class="logout-btn">
                        Logout
                    </button>
                </div>
                <div id="loginContainer" class="g_id_signin" data-type="standard"></div>
                
                <button id="refreshBtn" class="refresh-btn">
                    <i class="fas fa-sync-alt"></i> Refresh
                </button>
            </div>
            
            <div style="width: 100%; margin-top: 10px; font-size: 14px; color: #718096;">
                Combined predictions from multiple models for different timeframes
            </div>
        </header>

        <!-- Current Price and Prediction Cards -->
        <div class="cards-container">
            <!-- Current Price Card -->
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">Current Price</h3>
                    <span class="timeframe-badge">Live</span>
                </div>
                <div class="price-container">
                    <span id="currentPrice" class="price-value">$--</span>
                    <span id="priceChange" class="confidence">
                        <span id="changeArrow" class="mr-1"></span>
                        <span id="changePercent"></span>
                    </span>
                </div>
                <div class="price-details">
                    <span id="marketCap">Market Cap: $--</span>
                    <span id="volume">Volume: $--</span>
                </div>
            </div>
            
            <!-- Prediction Cards for different timeframes -->
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">1 Hour Prediction</h3>
                    <span class="timeframe-badge badge-1h">1h</span>
                </div>
                <div class="price-container">
                    <span id="prediction1h" class="price-value">$--</span>
                    <span id="confidence1h" class="confidence">
                        <span id="confidenceValue1h"></span>
                        <span id="confidenceText1h"></span>
                    </span>
                </div>
                <div class="price-details">
                    <span id="direction1h">Direction: --</span>
                    <span id="strength1h">Strength: --</span>
                </div>
            </div>
            
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">8 Hours Prediction</h3>
                    <span class="timeframe-badge badge-8h">8h</span>
                </div>
                <div class="price-container">
                    <span id="prediction8h" class="price-value">$--</span>
                    <span id="confidence8h" class="confidence">
                        <span id="confidenceValue8h"></span>
                        <span id="confidenceText8h"></span>
                    </span>
                </div>
                <div class="price-details">
                    <span id="direction8h">Direction: --</span>
                    <span id="strength8h">Strength: --</span>
                </div>
            </div>
            
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">24 Hours Prediction</h3>
                    <span class="timeframe-badge badge-24h">24h</span>
                </div>
                <div class="price-container">
                    <span id="prediction24h" class="price-value">$--</span>
                    <span id="confidence24h" class="confidence">
                        <span id="confidenceValue24h"></span>
                        <span id="confidenceText24h"></span>
                    </span>
                </div>
                <div class="price-details">
                    <span id="direction24h">Direction: --</span>
                    <span id="strength24h">Strength: --</span>
                </div>
            </div>
        </div>

        <!-- Main Chart -->
        <div class="chart-section">
            <div class="chart-header">
                <h2 class="section-title">Bitcoin Price with Predictions</h2>
                <select id="timeframe" class="timeframe-select">
                    <option value="1">1 hour</option>
                    <option value="4">4 hours</option>
                    <option value="8">8 hours</option>
                    <option value="24" selected>24 hours</option>
                    <option value="168">7 days</option>
                </select>
            </div>
            <div class="chart-container">
                <canvas id="priceChart"></canvas>
            </div>
        </div>

        <!-- Prediction History -->
        <div class="history-section">
            <div class="history-header">
                <h2 class="section-title">Prediction History</h2>
                <button id="exportBtn" class="export-btn">
                    <i class="fas fa-download"></i> Export JSON
                </button>
            </div>
            
            <div id="historyContainer" class="history-items">
                <!-- History items will be added here -->
                <div class="empty-history" style="color: #718096; text-align: center; padding: 20px;">
                    No prediction history yet.
                </div>
            </div>
        </div>

        <!-- Accuracy Statistics -->
        <div class="stats-section">
            <h2 class="section-title">Accuracy Statistics</h2>
            
            <div class="stats-container">
                <div class="stat-item">
                    <div class="gauge-container">
                        <canvas id="accuracyGauge"></canvas>
                    </div>
                    <div class="stat-info">
                        <div class="stat-label">Average Accuracy</div>
                        <div id="avgAccuracy" class="stat-value">--%</div>
                    </div>
                </div>
                
                <div class="stat-item">
                    <div class="stat-info">
                        <div class="stat-label">Correct Predictions</div>
                        <div id="correctPredictions" class="stat-value">--/--</div>
                        <div class="stat-subtext">Last 24 hours</div>
                    </div>
                </div>
                
                <div class="stat-item">
                    <div class="stat-info">
                        <div class="stat-label">Best Method</div>
                        <div id="bestMethod" class="stat-value">--</div>
                        <div id="methodAccuracy" class="stat-subtext">Accuracy: --%</div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Global variables
        let priceChart;
        let accuracyGauge;
        let autoRefreshInterval;
        let nextRefreshTime;
        let historicalData = [];
        let predictionHistory = [];
        let userData = null;
        
        // Initialize the app when DOM is loaded
        document.addEventListener('DOMContentLoaded', function() {
            initializeGoogleSignIn();
            loadUserData();
            fetchData();
            setupAutoRefresh();
            
            // Set up manual refresh button
            document.getElementById('refreshBtn').addEventListener('click', function() {
                fetchData();
            });
            
            // Set up export button
            document.getElementById('exportBtn').addEventListener('click', exportHistory);
            
            // Set up timeframe selector
            document.getElementById('timeframe').addEventListener('change', function() {
                fetchData();
            });
            
            // Set up logout button
            document.getElementById('logoutBtn').addEventListener('click', logout);
        });
        
        // Initialize Google Sign-In
        function initializeGoogleSignIn() {
            window.onload = function() {
                google.accounts.id.initialize({
                    client_id: 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com',
                    callback: handleCredentialResponse,
                    auto_select: false
                });
                
                google.accounts.id.renderButton(
                    document.getElementById('loginContainer'),
                    { theme: 'outline', size: 'large' }
                );
                
                google.accounts.id.prompt();
            };
        }
        
        // Handle Google Sign-In response
        function handleCredentialResponse(response) {
            const responsePayload = parseJwt(response.credential);
            
            userData = {
                id: responsePayload.sub,
                name: responsePayload.name,
                email: responsePayload.email,
                picture: responsePayload.picture,
                token: response.credential
            };
            
            // Save user data to localStorage
            localStorage.setItem('bitcoinPredictorUser', JSON.stringify(userData));
            
            // Update UI
            updateUserUI();
            
            // Load user-specific data
            loadUserData();
        }
        
        // Parse JWT token
        function parseJwt(token) {
            const base64Url = token.split('.')[1];
            const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
            const jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
                return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
            }).join(''));
            
            return JSON.parse(jsonPayload);
        }
        
        // Update user UI
        function updateUserUI() {
            if (userData) {
                document.getElementById('userInfo').style.display = 'flex';
                document.getElementById('loginContainer').style.display = 'none';
                document.getElementById('userAvatar').src = userData.picture;
                document.getElementById('userName').textContent = userData.name;
            } else {
                document.getElementById('userInfo').style.display = 'none';
                document.getElementById('loginContainer').style.display = 'block';
            }
        }
        
        // Load user data from localStorage
        function loadUserData() {
            const storedUser = localStorage.getItem('bitcoinPredictorUser');
            
            if (storedUser) {
                userData = JSON.parse(storedUser);
                updateUserUI();
                
                // Load user-specific prediction history
                const userHistory = localStorage.getItem(`bitcoinPredictorHistory_${userData.id}`);
                if (userHistory) {
                    predictionHistory = JSON.parse(userHistory);
                } else {
                    predictionHistory = [];
                }
            } else {
                // Load anonymous history
                const anonymousHistory = localStorage.getItem('bitcoinPredictorHistory');
                predictionHistory = anonymousHistory ? JSON.parse(anonymousHistory) : [];
            }
            
            renderHistory();
            updateAccuracyStats();
        }
        
        // Logout function
        function logout() {
            userData = null;
            localStorage.removeItem('bitcoinPredictorUser');
            updateUserUI();
            
            // Switch to anonymous storage
            loadUserData();
            
            // Google sign-out
            google.accounts.id.disableAutoSelect();
        }
        
        // Fetch data from CoinGecko API
        async function fetchData() {
            try {
                // Show loading state
                const refreshBtn = document.getElementById('refreshBtn');
                refreshBtn.disabled = true;
                refreshBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Refreshing...';
                
                // Get selected timeframe
                const timeframe = document.getElementById('timeframe').value;
                
                // Fetch price data
                const response = await axios.get(`https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=${timeframe}`);
                const prices = response.data.prices;
                
                // Process data
                historicalData = prices.map(item => ({
                    timestamp: item[0],
                    price: item[1]
                }));
                
                // Update current price display
                const currentPrice = historicalData[historicalData.length - 1].price;
                const previousPrice = historicalData[historicalData.length - 2].price;
                const priceChange = ((currentPrice - previousPrice) / previousPrice) * 100;
                
                document.getElementById('currentPrice').textContent = `$${currentPrice.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2})}`;
                
                const changeElement = document.getElementById('priceChange');
                const arrowElement = document.getElementById('changeArrow');
                const percentElement = document.getElementById('changePercent');
                
                if (priceChange >= 0) {
                    changeElement.style.color = '#38a169';
                    arrowElement.innerHTML = '<i class="fas fa-caret-up"></i>';
                } else {
                    changeElement.style.color = '#e53e3e';
                    arrowElement.innerHTML = '<i class="fas fa-caret-down"></i>';
                }
                percentElement.textContent = `${Math.abs(priceChange).toFixed(2)}%`;
                
                // Update market cap and volume (using the latest data)
                document.getElementById('marketCap').textContent = `Market Cap: $${(response.data.market_caps[response.data.market_caps.length - 1][1]).toLocaleString('en-US', {minimumFractionDigits: 0, maximumFractionDigits: 0})}`;
                document.getElementById('volume').textContent = `Volume: $${(response.data.total_volumes[response.data.total_volumes.length - 1][1]).toLocaleString('en-US', {minimumFractionDigits: 0, maximumFractionDigits: 0})}`;
                
                // Generate predictions for different timeframes
                generatePredictions(currentPrice);
                
                // Update chart with EMA 20 and EMA 50
                updateChart();
                
                // Update last updated time
                const now = new Date();
                
                // Schedule next refresh
                scheduleNextRefresh();
                
                // Update past predictions with actual prices
                updatePastPredictions(currentPrice);
                
            } catch (error) {
                console.error('Error fetching data:', error);
                alert('Error fetching data. Please try again.');
            } finally {
                // Reset button state
                const refreshBtn = document.getElementById('refreshBtn');
                refreshBtn.disabled = false;
                refreshBtn.innerHTML = '<i class="fas fa-sync-alt"></i> Refresh';
            }
        }
        
        // Generate predictions for different timeframes
        function generatePredictions(currentPrice) {
            // Generate predictions for 1h, 8h, and 24h
            const timeframes = ['1h', '8h', '24h'];
            
            timeframes.forEach(timeframe => {
                // Generate random but realistic predictions
                let prediction, confidence, direction, strength;
                
                // Different volatility based on timeframe
                if (timeframe === '1h') {
                    prediction = currentPrice * (1 + (Math.random() * 0.01 - 0.005));
                    confidence = 70 + Math.random() * 20;
                } else if (timeframe === '8h') {
                    prediction = currentPrice * (1 + (Math.random() * 0.02 - 0.01));
                    confidence = 65 + Math.random() * 20;
                } else { // 24h
                    prediction = currentPrice * (1 + (Math.random() * 0.03 - 0.015));
                    confidence = 60 + Math.random() * 20;
                }
                
                direction = prediction > currentPrice ? 'Bullish' : 'Bearish';
                
                const strengthValue = Math.abs((prediction - currentPrice) / currentPrice * 100);
                if (strengthValue < 0.5) strength = 'Weak';
                else if (strengthValue < 1.5) strength = 'Moderate';
                else strength = 'Strong';
                
                // Update UI
                document.getElementById(`prediction${timeframe.replace('h', '')}`).textContent = `$${prediction.toFixed(2)}`;
                
                const confidenceElement = document.getElementById(`confidence${timeframe.replace('h', '')}`);
                const confidenceValueElement = document.getElementById(`confidenceValue${timeframe.replace('h', '')}`);
                const confidenceTextElement = document.getElementById(`confidenceText${timeframe.replace('h', '')}`);
                
                confidenceValueElement.textContent = `${confidence.toFixed(0)}%`;
                confidenceTextElement.textContent = confidence >= 70 ? 'High' : 
                                                   confidence >= 50 ? 'Medium' : 'Low';
                
                // Set confidence class
                confidenceElement.className = 'confidence';
                if (confidence >= 70) {
                    confidenceElement.classList.add('high');
                } else if (confidence >= 50) {
                    confidenceElement.classList.add('medium');
                } else {
                    confidenceElement.classList.add('low');
                }
                
                document.getElementById(`direction${timeframe.replace('h', '')}`).textContent = `Direction: ${direction}`;
                document.getElementById(`strength${timeframe.replace('h', '')}`).textContent = `Strength: ${strength}`;
                
                // Save prediction to history
                savePredictionToHistory(currentPrice, prediction, confidence, direction, strength, timeframe);
            });
        }
        
        // Save prediction to history
        function savePredictionToHistory(currentPrice, prediction, confidence, direction, strength, timeframe) {
            const now = new Date();
            
            // Create new prediction entry
            const newPrediction = {
                id: Date.now(),
                timestamp: now.getTime(),
                date: now.toISOString(),
                timeframe: timeframe,
                currentPrice: currentPrice,
                prediction: prediction,
                confidence: confidence,
                direction: direction,
                strength: strength,
                actualPrice: null, // Will be updated later
                accuracy: null, // Will be calculated later
                directionCorrect: null // Will be calculated later
            };
            
            // Add to history
            predictionHistory.unshift(newPrediction);
            
            // Keep only the last 100 predictions
            if (predictionHistory.length > 100) {
                predictionHistory = predictionHistory.slice(0, 100);
            }
            
            // Save to appropriate storage
            if (userData) {
                localStorage.setItem(`bitcoinPredictorHistory_${userData.id}`, JSON.stringify(predictionHistory));
            } else {
                localStorage.setItem('bitcoinPredictorHistory', JSON.stringify(predictionHistory));
            }
            
            // Update history display
            renderHistory();
        }
        
        // Update actual prices for past predictions
        function updatePastPredictions(currentPrice) {
            const now = new Date();
            
            // We'll update predictions that are older than their timeframe
            let updated = false;
            
            predictionHistory.forEach(prediction => {
                const predictionTime = new Date(prediction.timestamp);
                const hoursPassed = (now - predictionTime) / (1000 * 60 * 60);
                
                // Check if enough time has passed to evaluate this prediction
                let shouldUpdate = false;
                let timeframeHours = 0;
                
                if (prediction.timeframe === '1h' && hoursPassed >= 1) {
                    shouldUpdate = true;
                    timeframeHours = 1;
                } else if (prediction.timeframe === '8h' && hoursPassed >= 8) {
                    shouldUpdate = true;
                    timeframeHours = 8;
                } else if (prediction.timeframe === '24h' && hoursPassed >= 24) {
                    shouldUpdate = true;
                    timeframeHours = 24;
                }
                
                if (shouldUpdate && prediction.actualPrice === null) {
                    prediction.actualPrice = currentPrice;
                    updated = true;
                    
                    // Calculate accuracy
                    if (prediction.prediction && prediction.actualPrice) {
                        const priceDifference = Math.abs(prediction.prediction - prediction.actualPrice);
                        const accuracy = 100 - (priceDifference / prediction.actualPrice * 100);
                        prediction.accuracy = Math.max(0, Math.min(100, accuracy)); // Clamp between 0-100
                        
                        // Determine if direction was correct
                        const predictedDirection = prediction.direction === 'Bullish' ? 1 : -1;
                        const actualDirection = prediction.actualPrice > prediction.currentPrice ? 1 : -1;
                        prediction.directionCorrect = predictedDirection === actualDirection;
                    }
                }
            });
            
            if (updated) {
                // Save updated history
                if (userData) {
                    localStorage.setItem(`bitcoinPredictorHistory_${userData.id}`, JSON.stringify(predictionHistory));
                } else {
                    localStorage.setItem('bitcoinPredictorHistory', JSON.stringify(predictionHistory));
                }
                
                // Update UI
                renderHistory();
                updateAccuracyStats();
            }
        }
        
        // Render prediction history
        function renderHistory() {
            const historyContainer = document.getElementById('historyContainer');
            historyContainer.innerHTML = '';
            
            if (predictionHistory.length === 0) {
                historyContainer.innerHTML = '<div class="empty-history" style="color: #718096; text-align: center; padding: 20px;">No prediction history yet.</div>';
                return;
            }
            
            predictionHistory.forEach(prediction => {
                const historyItem = document.createElement('div');
                historyItem.className = 'history-item';
                
                // Main prediction info
                const historyHeader = document.createElement('div');
                historyHeader.className = 'history-header-item';
                
                const timeframeBadge = document.createElement('span');
                timeframeBadge.className = 'timeframe-badge';
                
                if (prediction.timeframe === '1h') {
                    timeframeBadge.classList.add('badge-1h');
                } else if (prediction.timeframe === '8h') {
                    timeframeBadge.classList.add('badge-8h');
                } else {
                    timeframeBadge.classList.add('badge-24h');
                }
                
                timeframeBadge.textContent = prediction.timeframe;
                
                const dateInfo = document.createElement('span');
                dateInfo.className = 'text-sm';
                dateInfo.style.color = '#718096';
                dateInfo.textContent = new Date(prediction.timestamp).toLocaleString();
                
                historyHeader.appendChild(timeframeBadge);
                historyHeader.appendChild(dateInfo);
                
                // Prediction details
                const details = document.createElement('div');
                details.className = 'history-details';
                
                // Prediction vs Actual
                const predictionActual = document.createElement('div');
                predictionActual.className = 'history-detail';
                predictionActual.innerHTML = `
                    <div class="detail-label">Prediction/Actual</div>
                    <div class="detail-value">
                        $${prediction.prediction.toFixed(2)} / 
                        ${prediction.actualPrice ? `$${prediction.actualPrice.toFixed(2)}` : '--'}
                    </div>
                `;
                
                // Difference
                const differenceDiv = document.createElement('div');
                differenceDiv.className = 'history-detail';
                
                if (prediction.actualPrice !== null) {
                    const difference = prediction.actualPrice - prediction.prediction;
                    const absDifference = Math.abs(difference);
                    const differenceText = `$${absDifference.toFixed(2)} (${(absDifference / prediction.prediction * 100).toFixed(2)}%)`;
                    
                    differenceDiv.innerHTML = `
                        <div class="detail-label">Difference</div>
                        <div class="detail-value" style="color: ${
                            difference > 0 ? '#38a169' : 
                            difference < 0 ? '#e53e3e' : '#4a5568'
                        }">
                            ${difference > 0 ? '+' : difference < 0 ? '-' : ''}${differenceText}
                        </div>
                    `;
                } else {
                    differenceDiv.innerHTML = `
                        <div class="detail-label">Difference</div>
                        <div class="detail-value">--</div>
                    `;
                }
                
                // Accuracy
                const accuracyDiv = document.createElement('div');
                accuracyDiv.className = 'history-detail';
                
                if (prediction.accuracy !== null) {
                    let accuracyClass = '';
                    if (prediction.accuracy >= 80) {
                        accuracyClass = 'accuracy-high';
                    } else if (prediction.accuracy >= 60) {
                        accuracyClass = 'accuracy-medium';
                    } else {
                        accuracyClass = 'accuracy-low';
                    }
                    
                    accuracyDiv.innerHTML = `
                        <div class="detail-label">Accuracy</div>
                        <div class="detail-value ${accuracyClass}">
                            ${prediction.accuracy.toFixed(1)}%
                        </div>
                    `;
                } else {
                    accuracyDiv.innerHTML = `
                        <div class="detail-label">Accuracy</div>
                        <div class="detail-value">--</div>
                    `;
                }
                
                // Direction
                const directionDiv = document.createElement('div');
                directionDiv.className = 'history-detail';
                
                if (prediction.directionCorrect !== null) {
                    directionDiv.innerHTML = `
                        <div class="detail-label">Direction</div>
                        <div class="detail-value" style="color: ${
                            prediction.directionCorrect ? '#38a169' : '#e53e3e'
                        }">
                            ${prediction.directionCorrect ? 'Correct' : 'Incorrect'}
                        </div>
                    `;
                } else {
                    directionDiv.innerHTML = `
                        <div class="detail-label">Direction</div>
                        <div class="detail-value">--</div>
                    `;
                }
                
                // Append all details
                details.appendChild(predictionActual);
                details.appendChild(differenceDiv);
                details.appendChild(accuracyDiv);
                details.appendChild(directionDiv);
                
                // Append to history item
                historyItem.appendChild(historyHeader);
                historyItem.appendChild(details);
                
                // Append to container
                historyContainer.appendChild(historyItem);
            });
        }
        
        // Update accuracy statistics
        function updateAccuracyStats() {
            const completedPredictions = predictionHistory.filter(p => p.accuracy !== null);
            
            if (completedPredictions.length > 0) {
                const totalAccuracy = completedPredictions.reduce((sum, p) => sum + p.accuracy, 0);
                const avgAccuracy = totalAccuracy / completedPredictions.length;
                
                const correctDirections = completedPredictions.filter(p => p.directionCorrect).length;
                
                // Find best performing method
                const methodPerformance = {
                    '1h': { count: 0, totalAccuracy: 0 },
                    '8h': { count: 0, totalAccuracy: 0 },
                    '24h': { count: 0, totalAccuracy: 0 }
                };
                
                completedPredictions.forEach(p => {
                    if (methodPerformance[p.timeframe]) {
                        methodPerformance[p.timeframe].count++;
                        methodPerformance[p.timeframe].totalAccuracy += p.accuracy;
                    }
                });
                
                let bestMethod = '';
                let bestMethodAccuracy = 0;
                
                for (const [method, data] of Object.entries(methodPerformance)) {
                    if (data.count > 0) {
                        const methodAvg = data.totalAccuracy / data.count;
                        if (methodAvg > bestMethodAccuracy) {
                            bestMethod = method;
                            bestMethodAccuracy = methodAvg;
                        }
                    }
                }
                
                document.getElementById('avgAccuracy').textContent = `${avgAccuracy.toFixed(1)}%`;
                document.getElementById('correctPredictions').textContent = `${correctDirections}/${completedPredictions.length}`;
                document.getElementById('bestMethod').textContent = bestMethod ? `${bestMethod} prediction` : '--';
                document.getElementById('methodAccuracy').textContent = bestMethod ? `Accuracy: ${bestMethodAccuracy.toFixed(1)}%` : '--';
                
                // Update accuracy gauge
                updateAccuracyGauge(avgAccuracy);
            } else {
                document.getElementById('avgAccuracy').textContent = '--%';
                document.getElementById('correctPredictions').textContent = '--/--';
                document.getElementById('bestMethod').textContent = '--';
                document.getElementById('methodAccuracy').textContent = '--';
                
                // Reset accuracy gauge if it exists
                if (accuracyGauge) {
                    accuracyGauge.data.datasets[0].data = [0, 100];
                    accuracyGauge.update();
                }
            }
        }
        
        // Update accuracy gauge chart
        function updateAccuracyGauge(accuracy) {
            const ctx = document.getElementById('accuracyGauge').getContext('2d');
            
            if (!accuracyGauge) {
                accuracyGauge = new Chart(ctx, {
                    type: 'doughnut',
                    data: {
                        datasets: [{
                            data: [accuracy, 100 - accuracy],
                            backgroundColor: [
                                getAccuracyColor(accuracy),
                                '#f3f4f6'
                            ],
                            borderWidth: 0
                        }]
                    },
                    options: {
                        cutout: '70%',
                        rotation: -90,
                        circumference: 180,
                        plugins: {
                            legend: {
                                display: false
                            },
                            tooltip: {
                                enabled: false
                            }
                        }
                    }
                });
            } else {
                accuracyGauge.data.datasets[0].data = [accuracy, 100 - accuracy];
                accuracyGauge.data.datasets[0].backgroundColor[0] = getAccuracyColor(accuracy);
                accuracyGauge.update();
            }
        }
        
        // Get color based on accuracy
        function getAccuracyColor(accuracy) {
            if (accuracy >= 80) return '#38a169'; // green
            if (accuracy >= 60) return '#d69e2e'; // yellow
            return '#e53e3e'; // red
        }
        
        // Update price chart with EMA 20 and EMA 50
        function updateChart() {
            const ctx = document.getElementById('priceChart').getContext('2d');
            const timeframe = document.getElementById('timeframe').value;
            
            // Prepare data for chart
            const labels = historicalData.map(item => new Date(item.timestamp));
            const prices = historicalData.map(item => item.price);
            
            // Calculate EMA (Exponential Moving Average) functions
            function calculateEMA(data, period) {
                const k = 2 / (period + 1);
                const ema = [];
                let sum = 0;
                
                // Simple moving average for first period values
                for (let i = 0; i < period; i++) {
                    sum += data[i];
                    ema.push(null);
                }
                
                // First EMA value is the SMA
                ema[period - 1] = sum / period;
                
                // Calculate EMA for remaining values
                for (let i = period; i < data.length; i++) {
                    ema[i] = data[i] * k + ema[i - 1] * (1 - k);
                }
                
                return ema;
            }
            
            // Calculate EMAs
            const ema20 = calculateEMA(prices, 20);
            const ema50 = calculateEMA(prices, 50);
            
            // Create or update chart
            if (!priceChart) {
                priceChart = new Chart(ctx, {
                    type: 'line',
                    data: {
                        labels: labels,
                        datasets: [
                            {
                                label: 'BTC Price',
                                data: prices,
                                borderColor: '#3182ce',
                                backgroundColor: 'rgba(49, 130, 206, 0.05)',
                                borderWidth: 2,
                                fill: true,
                                tension: 0.4
                            },
                            {
                                label: 'EMA 20',
                                data: ema20,
                                borderColor: '#d69e2e',
                                borderWidth: 1.5,
                                pointRadius: 0,
                                tension: 0.4
                            },
                            {
                                label: 'EMA 50',
                                data: ema50,
                                borderColor: '#805ad5',
                                borderWidth: 1.5,
                                pointRadius: 0,
                                tension: 0.4
                            }
                        ]
                    },
                    options: {
                        responsive: true,
                        maintainAspectRatio: false,
                        scales: {
                            x: {
                                type: 'time',
                                time: {
                                    unit: timeframe <= 1 ? 'hour' : 
                                          timeframe <= 24 ? 'day' : 'week',
                                    displayFormats: {
                                        hour: 'HH:mm',
                                        day: 'MMM d',
                                        week: 'MMM d'
                                    }
                                },
                                grid: {
                                    display: false
                                }
                            },
                            y: {
                                beginAtZero: false,
                                grid: {
                                    color: 'rgba(0, 0, 0, 0.05)'
                                },
                                ticks: {
                                    callback: function(value) {
                                        return '$' + value.toLocaleString();
                                    }
                                }
                            }
                        },
                        plugins: {
                            tooltip: {
                                mode: 'index',
                                intersect: false,
                                callbacks: {
                                    label: function(context) {
                                        let label = context.dataset.label || '';
                                        if (label) {
                                            label += ': ';
                                        }
                                        if (context.parsed.y !== null) {
                                            label += '$' + context.parsed.y.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2});
                                        }
                                        return label;
                                    }
                                }
                            },
                            legend: {
                                position: 'top',
                                align: 'end'
                            }
                        },
                        interaction: {
                            mode: 'nearest',
                            axis: 'x',
                            intersect: false
                        }
                    }
                });
            } else {
                priceChart.data.labels = labels;
                priceChart.data.datasets[0].data = prices;
                priceChart.data.datasets[1].data = ema20;
                priceChart.data.datasets[2].data = ema50;
                
                // Update time unit based on timeframe
                priceChart.options.scales.x.time.unit = timeframe <= 1 ? 'hour' : 
                                                       timeframe <= 24 ? 'day' : 'week';
                
                priceChart.update();
            }
        }
        
        // Set up auto-refresh
        function setupAutoRefresh() {
            // Initial schedule
            scheduleNextRefresh();
        }
        
        // Schedule next refresh
        function scheduleNextRefresh() {
            clearTimeout(autoRefreshInterval);
            
            const now = new Date();
            const nextRefresh = new Date(now.getTime() + 15 * 60 * 1000); // 15 minutes from now
            
            autoRefreshInterval = setTimeout(() => {
                fetchData();
                scheduleNextRefresh();
            }, 15 * 60 * 1000);
        }
        
        // Export history as JSON
        function exportHistory() {
            const dataStr = JSON.stringify(predictionHistory, null, 2);
            const dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);
            
            const exportFileDefaultName = `bitcoin-predictions-${new Date().toISOString().slice(0, 10)}.json`;
            
            const linkElement = document.createElement('a');
            linkElement.setAttribute('href', dataUri);
            linkElement.setAttribute('download', exportFileDefaultName);
            linkElement.click();
        }
    </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=note6/btcpro6" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>