File size: 48,600 Bytes
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5fc2e3a
 
 
 
 
 
f00e65a
5fc2e3a
 
f00e65a
 
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
5fc2e3a
 
 
 
f00e65a
 
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
 
 
 
 
 
 
 
 
 
 
 
 
5fc2e3a
f00e65a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5fc2e3a
 
 
f00e65a
 
 
 
5fc2e3a
 
f00e65a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5fc2e3a
 
 
f00e65a
 
 
 
 
 
 
 
 
 
 
5fc2e3a
 
f00e65a
 
 
 
 
 
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
5fc2e3a
f00e65a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5fc2e3a
f00e65a
 
5fc2e3a
f00e65a
 
 
 
 
 
 
5fc2e3a
f00e65a
 
5fc2e3a
f00e65a
 
 
 
 
 
 
5fc2e3a
 
 
 
 
 
 
 
 
 
f00e65a
5fc2e3a
 
 
 
 
 
 
f00e65a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5fc2e3a
 
 
 
 
 
 
 
 
f00e65a
 
5fc2e3a
 
f00e65a
 
 
5fc2e3a
f00e65a
 
 
 
5fc2e3a
f00e65a
 
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
 
 
 
 
 
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
 
 
5fc2e3a
f00e65a
 
 
 
5fc2e3a
f00e65a
5fc2e3a
 
 
 
 
f00e65a
5fc2e3a
f00e65a
 
 
 
 
 
 
 
 
 
 
 
5fc2e3a
 
f00e65a
5fc2e3a
f00e65a
 
 
 
 
 
 
 
 
 
 
 
5fc2e3a
 
 
 
f00e65a
 
 
 
 
 
 
 
 
 
 
 
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
 
 
5fc2e3a
f00e65a
 
 
 
 
 
5fc2e3a
 
 
 
 
 
 
 
 
f00e65a
5fc2e3a
 
f00e65a
 
 
5fc2e3a
f00e65a
 
 
 
5fc2e3a
f00e65a
5fc2e3a
 
 
 
f00e65a
 
 
5fc2e3a
f00e65a
 
 
 
 
 
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
5fc2e3a
 
f00e65a
5fc2e3a
f00e65a
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
 
5fc2e3a
 
f00e65a
 
 
5fc2e3a
f00e65a
 
 
 
5fc2e3a
f00e65a
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
 
 
5fc2e3a
f00e65a
 
 
 
 
 
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f00e65a
5fc2e3a
 
f00e65a
5fc2e3a
 
 
 
f00e65a
5fc2e3a
f00e65a
5fc2e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Soccer Prediction Neural Network</title>
  <script src="https://cdn.tailwindcss.com"></script>
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  <script src="https://unpkg.com/brain.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <style>
    .neuron {
      transition: all 0.3s ease;
    }
    .neuron:hover {
      transform: scale(1.1);
      box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
    }
    .connection {
      stroke-dasharray: 1000;
      stroke-dashoffset: 1000;
      animation: dash 2s linear forwards;
    }
    @keyframes dash {
      to {
        stroke-dashoffset: 0;
      }
    }
    .pulse {
      animation: pulse 1.5s infinite;
    }
    @keyframes pulse {
      0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
      }
      70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
      }
      100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
      }
    }
    .team-card {
      transition: all 0.3s ease;
    }
    .team-card:hover {
      transform: translateY(-5px);
      box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    }
    .progress-ring__circle {
      transition: stroke-dashoffset 0.5s;
      transform: rotate(-90deg);
      transform-origin: 50% 50%;
    }
    .stat-badge {
      font-size: 0.7rem;
      padding: 0.2rem 0.4rem;
      border-radius: 0.25rem;
    }
    .offensive-stat {
      background-color: #3B82F6;
      color: white;
    }
    .defensive-stat {
      background-color: #EF4444;
      color: white;
    }
    .teamwork-stat {
      background-color: #10B981;
      color: white;
    }
    .discipline-stat {
      background-color: #F59E0B;
      color: white;
    }
  </style>
</head>
<body class="bg-gray-50 min-h-screen">
  <div class="container mx-auto px-4 py-8">
    <header class="mb-12 text-center">
      <h1 class="text-4xl font-bold text-green-600 mb-2">
        <i class="fas fa-futbol mr-3"></i>Advanced Soccer Prediction Engine
      </h1>
      <p class="text-gray-600 max-w-3xl mx-auto">
        Comprehensive neural network analysis using 12 key performance metrics to predict match outcomes.
        The system learns from extensive soccer statistics to provide accurate loss probability predictions.
      </p>
    </header>

    <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
      <!-- Control Panel -->
      <div class="bg-white rounded-xl shadow-lg p-6 h-fit">
        <h2 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
          <i class="fas fa-sliders-h mr-2 text-green-500"></i>Network Configuration
        </h2>
        
        <div class="space-y-4">
          <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">Hidden Layers</label>
            <input type="range" id="hiddenLayers" min="1" max="5" value="3" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
            <div class="flex justify-between text-xs text-gray-500 mt-1">
              <span>1</span>
              <span>2</span>
              <span>3</span>
              <span>4</span>
              <span>5</span>
            </div>
          </div>
          
          <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">Neurons per Layer</label>
            <input type="range" id="neuronsPerLayer" min="2" max="20" value="12" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
            <div class="flex justify-between text-xs text-gray-500 mt-1">
              <span>2</span>
              <span>6</span>
              <span>12</span>
              <span>16</span>
              <span>20</span>
            </div>
          </div>
          
          <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">Learning Rate</label>
            <input type="range" id="learningRate" min="0.01" max="0.5" step="0.01" value="0.2" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
            <div class="flex justify-between text-xs text-gray-500 mt-1">
              <span>0.01</span>
              <span>0.25</span>
              <span>0.5</span>
            </div>
          </div>
          
          <div class="pt-2">
            <button id="trainBtn" class="w-full bg-green-600 hover:bg-green-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center justify-center">
              <i class="fas fa-brain mr-2"></i>
              Train Network
            </button>
          </div>
        </div>
        
        <div class="mt-6 pt-4 border-t border-gray-200">
          <h3 class="text-sm font-medium text-gray-700 mb-2 flex items-center">
            <i class="fas fa-database mr-2 text-green-500"></i>Training Data Parameters
          </h3>
          <div class="grid grid-cols-2 gap-3">
            <div>
              <label class="block text-xs font-medium text-gray-500 mb-1">Seasons</label>
              <select id="seasonRange" class="w-full text-sm border rounded px-2 py-1">
                <option value="5">Last 5 seasons</option>
                <option value="10" selected>Last 10 seasons</option>
                <option value="15">Last 15 seasons</option>
              </select>
            </div>
            <div>
              <label class="block text-xs font-medium text-gray-500 mb-1">Stat Weight</label>
              <select id="statWeight" class="w-full text-sm border rounded px-2 py-1">
                <option value="balanced">Balanced</option>
                <option value="offense">Offense-heavy</option>
                <option value="defense">Defense-heavy</option>
              </select>
            </div>
          </div>
        </div>
      </div>
      
      <!-- Network Visualization -->
      <div class="lg:col-span-2">
        <div class="bg-white rounded-xl shadow-lg p-6">
          <div class="flex justify-between items-center mb-4">
            <h2 class="text-xl font-semibold text-gray-800 flex items-center">
              <i class="fas fa-project-diagram mr-2 text-green-500"></i>Network Architecture
            </h2>
            <div class="flex space-x-2">
              <button id="resetBtn" class="text-sm bg-gray-200 hover:bg-gray-300 text-gray-800 py-1 px-3 rounded flex items-center">
                <i class="fas fa-redo mr-1 text-xs"></i> Reset
              </button>
            </div>
          </div>
          
          <div class="relative h-96 w-full bg-gray-50 rounded-lg overflow-hidden">
            <svg id="networkDiagram" class="w-full h-full">
              <!-- Network will be rendered here -->
            </svg>
            <div id="loadingOverlay" class="absolute inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
              <div class="bg-white p-4 rounded-lg flex items-center shadow-lg">
                <svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-green-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
                  <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
                  <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
                </svg>
                <span class="text-gray-800">Training network with soccer data...</span>
              </div>
            </div>
          </div>
          
          <div class="mt-6 grid grid-cols-1 md:grid-cols-2 gap-4">
            <div class="bg-gray-50 p-4 rounded-lg">
              <h3 class="text-sm font-medium text-gray-700 mb-2 flex items-center">
                <i class="fas fa-chart-line mr-2 text-green-500"></i>Team Performance Input
              </h3>
              <div class="grid grid-cols-2 gap-2">
                <!-- Offensive Stats -->
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge offensive-stat mr-1">OFF</span> Shots on Target
                  </label>
                  <input type="number" id="shotsOnTargetInput" min="100" max="300" step="1" value="180" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge offensive-stat mr-1">OFF</span> Goals Scored
                  </label>
                  <input type="number" id="goalsScoredInput" min="30" max="100" step="1" value="65" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge offensive-stat mr-1">OFF</span> Key Passes
                  </label>
                  <input type="number" id="keyPassesInput" min="200" max="600" step="1" value="400" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge offensive-stat mr-1">OFF</span> Dribbles
                  </label>
                  <input type="number" id="dribblesInput" min="100" max="500" step="1" value="300" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                
                <!-- Defensive Stats -->
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge defensive-stat mr-1">DEF</span> Goals Conceded
                  </label>
                  <input type="number" id="goalsConcededInput" min="20" max="80" step="1" value="40" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge defensive-stat mr-1">DEF</span> Tackles
                  </label>
                  <input type="number" id="tacklesInput" min="300" max="800" step="1" value="500" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge defensive-stat mr-1">DEF</span> Interceptions
                  </label>
                  <input type="number" id="interceptionsInput" min="200" max="600" step="1" value="400" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge defensive-stat mr-1">DEF</span> Clearances
                  </label>
                  <input type="number" id="clearancesInput" min="300" max="900" step="1" value="600" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                
                <!-- Teamwork Stats -->
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge teamwork-stat mr-1">TMW</span> Pass Accuracy %
                  </label>
                  <input type="number" id="passAccuracyInput" min="70" max="90" step="0.1" value="80" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge teamwork-stat mr-1">TMW</span> Cross Accuracy %
                  </label>
                  <input type="number" id="crossAccuracyInput" min="20" max="50" step="0.1" value="35" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                
                <!-- Discipline Stats -->
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge discipline-stat mr-1">DSC</span> Yellow Cards
                  </label>
                  <input type="number" id="yellowCardsInput" min="30" max="100" step="1" value="60" class="w-full px-2 py-1 border rounded text-sm">
                </div>
                <div>
                  <label class="block text-xs font-medium text-gray-500 mb-1 flex items-center">
                    <span class="stat-badge discipline-stat mr-1">DSC</span> Red Cards
                  </label>
                  <input type="number" id="redCardsInput" min="0" max="10" step="1" value="3" class="w-full px-2 py-1 border rounded text-sm">
                </div>
              </div>
            </div>
            
            <div class="bg-gray-50 p-4 rounded-lg">
              <h3 class="text-sm font-medium text-gray-700 mb-2 flex items-center">
                <i class="fas fa-percentage mr-2 text-green-500"></i>Loss Probability
              </h3>
              <div class="flex items-center">
                <div class="relative w-16 h-16 mr-4">
                  <svg class="w-full h-full" viewBox="0 0 36 36">
                    <path
                      d="M18 2.0845
                        a 15.9155 15.9155 0 0 1 0 31.831
                        a 15.9155 15.9155 0 0 1 0 -31.831"
                      fill="none"
                      stroke="#E5E7EB"
                      stroke-width="3"
                    />
                    <path
                      id="progressRing"
                      d="M18 2.0845
                        a 15.9155 15.9155 0 0 1 0 31.831
                        a 15.9155 15.9155 0 0 1 0 -31.831"
                      fill="none"
                      stroke="#EF4444"
                      stroke-width="3"
                      stroke-dasharray="100, 100"
                    />
                  </svg>
                  <div id="lossPercentage" class="absolute inset-0 flex items-center justify-center text-lg font-bold text-red-600">0%</div>
                </div>
                <div class="flex-1">
                  <div class="text-xs text-gray-500 mb-1">Prediction Confidence</div>
                  <div class="w-full bg-gray-200 rounded-full h-2">
                    <div id="confidenceBar" class="bg-green-600 h-2 rounded-full" style="width: 0%"></div>
                  </div>
                  <div id="predictionText" class="text-sm mt-2 font-medium text-gray-700">Enter team stats to predict</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <!-- Team Prediction Cards -->
    <div class="mt-8">
      <h2 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
        <i class="fas fa-table mr-2 text-green-500"></i>Team Loss Predictions
      </h2>
      <div id="teamPredictions" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
        <!-- Team cards will be dynamically inserted here -->
      </div>
    </div>
    
    <!-- Training Progress -->
    <div class="mt-8 bg-white rounded-xl shadow-lg p-6">
      <h2 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
        <i class="fas fa-chart-bar mr-2 text-green-500"></i>Training Progress
      </h2>
      <canvas id="errorChart" class="w-full h-64"></canvas>
    </div>
    
    <!-- Soccer Statistics Explanation -->
    <div class="mt-8 bg-white rounded-xl shadow-lg p-6">
      <h2 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
        <i class="fas fa-info-circle mr-2 text-green-500"></i>Key Soccer Metrics
      </h2>
      <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
        <!-- Offensive Stats -->
        <div class="bg-blue-50 p-4 rounded-lg">
          <h3 class="font-medium text-blue-800 mb-1 flex items-center">
            <span class="stat-badge offensive-stat mr-2">OFF</span> Offensive Metrics
          </h3>
          <ul class="text-sm text-blue-600 space-y-1">
            <li><strong>Shots on Target:</strong> Direct attempts on goal</li>
            <li><strong>Goals Scored:</strong> Total goals per season</li>
            <li><strong>Key Passes:</strong> Passes leading to shots</li>
            <li><strong>Dribbles:</strong> Successful player runs</li>
          </ul>
        </div>
        
        <!-- Defensive Stats -->
        <div class="bg-red-50 p-4 rounded-lg">
          <h3 class="font-medium text-red-800 mb-1 flex items-center">
            <span class="stat-badge defensive-stat mr-2">DEF</span> Defensive Metrics
          </h3>
          <ul class="text-sm text-red-600 space-y-1">
            <li><strong>Goals Conceded:</strong> Goals allowed</li>
            <li><strong>Tackles:</strong> Successful defensive challenges</li>
            <li><strong>Interceptions:</strong> Passes intercepted</li>
            <li><strong>Clearances:</strong> Defensive removals</li>
          </ul>
        </div>
        
        <!-- Teamwork Stats -->
        <div class="bg-green-50 p-4 rounded-lg">
          <h3 class="font-medium text-green-800 mb-1 flex items-center">
            <span class="stat-badge teamwork-stat mr-2">TMW</span> Teamwork Metrics
          </h3>
          <ul class="text-sm text-green-600 space-y-1">
            <li><strong>Pass Accuracy:</strong> Successful pass percentage</li>
            <li><strong>Cross Accuracy:</strong> Successful crosses</li>
          </ul>
        </div>
        
        <!-- Discipline Stats -->
        <div class="bg-yellow-50 p-4 rounded-lg">
          <h3 class="font-medium text-yellow-800 mb-1 flex items-center">
            <span class="stat-badge discipline-stat mr-2">DSC</span> Discipline Metrics
          </h3>
          <ul class="text-sm text-yellow-600 space-y-1">
            <li><strong>Yellow Cards:</strong> Cautions received</li>
            <li><strong>Red Cards:</strong> Ejections received</li>
          </ul>
        </div>
      </div>
    </div>
  </div>

  <script>
    document.addEventListener('DOMContentLoaded', function() {
      // Configuration
      const config = {
        hiddenLayers: 3,
        neuronsPerLayer: 12,
        learningRate: 0.2,
        iterations: 20000,
        errorThresh: 0.005
      };
      
      // Sample soccer team data (in a real app, this would come from an API)
      const soccerTeams = [
        { 
          name: "Manchester City", 
          logo: "⚽", 
          goalsConceded: 32, 
          shotsOnTarget: 280, 
          goalsScored: 85,
          keyPasses: 450,
          dribbles: 350,
          passAccuracy: 89.2, 
          crossAccuracy: 38.5,
          tackles: 520,
          interceptions: 480,
          clearances: 580,
          yellowCards: 45,
          redCards: 1
        },
        { 
          name: "Liverpool", 
          logo: "⚽", 
          goalsConceded: 38, 
          shotsOnTarget: 265, 
          goalsScored: 78,
          keyPasses: 420,
          dribbles: 320,
          passAccuracy: 85.7, 
          crossAccuracy: 36.2,
          tackles: 550,
          interceptions: 460,
          clearances: 620,
          yellowCards: 52,
          redCards: 2
        },
        { 
          name: "Chelsea", 
          logo: "⚽", 
          goalsConceded: 45, 
          shotsOnTarget: 240, 
          goalsScored: 70,
          keyPasses: 400,
          dribbles: 290,
          passAccuracy: 84.1, 
          crossAccuracy: 34.8,
          tackles: 580,
          interceptions: 440,
          clearances: 650,
          yellowCards: 58,
          redCards: 3
        },
        { 
          name: "Tottenham", 
          logo: "⚽", 
          goalsConceded: 48, 
          shotsOnTarget: 225, 
          goalsScored: 68,
          keyPasses: 380,
          dribbles: 270,
          passAccuracy: 82.3, 
          crossAccuracy: 33.5,
          tackles: 600,
          interceptions: 420,
          clearances: 680,
          yellowCards: 62,
          redCards: 4
        },
        { 
          name: "Arsenal", 
          logo: "⚽", 
          goalsConceded: 42, 
          shotsOnTarget: 235, 
          goalsScored: 72,
          keyPasses: 390,
          dribbles: 280,
          passAccuracy: 83.5, 
          crossAccuracy: 35.1,
          tackles: 570,
          interceptions: 430,
          clearances: 630,
          yellowCards: 55,
          redCards: 2
        },
        { 
          name: "Manchester Utd", 
          logo: "⚽", 
          goalsConceded: 51, 
          shotsOnTarget: 210, 
          goalsScored: 65,
          keyPasses: 370,
          dribbles: 260,
          passAccuracy: 81.8, 
          crossAccuracy: 32.7,
          tackles: 620,
          interceptions: 410,
          clearances: 700,
          yellowCards: 68,
          redCards: 5
        },
        { 
          name: "Leicester", 
          logo: "⚽", 
          goalsConceded: 54, 
          shotsOnTarget: 195, 
          goalsScored: 60,
          keyPasses: 350,
          dribbles: 240,
          passAccuracy: 79.6, 
          crossAccuracy: 31.2,
          tackles: 640,
          interceptions: 400,
          clearances: 720,
          yellowCards: 72,
          redCards: 6
        },
        { 
          name: "West Ham", 
          logo: "⚽", 
          goalsConceded: 58, 
          shotsOnTarget: 185, 
          goalsScored: 58,
          keyPasses: 340,
          dribbles: 230,
          passAccuracy: 78.2, 
          crossAccuracy: 30.5,
          tackles: 660,
          interceptions: 390,
          clearances: 750,
          yellowCards: 78,
          redCards: 7
        }
      ];
      
      // DOM Elements
      const diagram = document.getElementById('networkDiagram');
      const hiddenLayersInput = document.getElementById('hiddenLayers');
      const neuronsPerLayerInput = document.getElementById('neuronsPerLayer');
      const learningRateInput = document.getElementById('learningRate');
      const trainBtn = document.getElementById('trainBtn');
      const resetBtn = document.getElementById('resetBtn');
      
      // Input elements for all 12 stats
      const goalsConcededInput = document.getElementById('goalsConcededInput');
      const shotsOnTargetInput = document.getElementById('shotsOnTargetInput');
      const goalsScoredInput = document.getElementById('goalsScoredInput');
      const keyPassesInput = document.getElementById('keyPassesInput');
      const dribblesInput = document.getElementById('dribblesInput');
      const passAccuracyInput = document.getElementById('passAccuracyInput');
      const crossAccuracyInput = document.getElementById('crossAccuracyInput');
      const tacklesInput = document.getElementById('tacklesInput');
      const interceptionsInput = document.getElementById('interceptionsInput');
      const clearancesInput = document.getElementById('clearancesInput');
      const yellowCardsInput = document.getElementById('yellowCardsInput');
      const redCardsInput = document.getElementById('redCardsInput');
      
      const lossPercentage = document.getElementById('lossPercentage');
      const confidenceBar = document.getElementById('confidenceBar');
      const predictionText = document.getElementById('predictionText');
      const progressRing = document.getElementById('progressRing');
      const loadingOverlay = document.getElementById('loadingOverlay');
      const teamPredictions = document.getElementById('teamPredictions');
      const seasonRange = document.getElementById('seasonRange');
      const statWeight = document.getElementById('statWeight');
      
      // Initialize network
      let net = new brain.NeuralNetwork();
      let errorChart;
      
      // Initialize UI
      initUI();
      drawNetwork();
      initChart();
      renderTeamCards();
      
      // Event Listeners
      hiddenLayersInput.addEventListener('input', updateConfig);
      neuronsPerLayerInput.addEventListener('input', updateConfig);
      learningRateInput.addEventListener('input', updateConfig);
      trainBtn.addEventListener('click', trainNetwork);
      resetBtn.addEventListener('click', resetNetwork);
      
      // Add input event listeners for all stat inputs
      [
        goalsConcededInput, shotsOnTargetInput, goalsScoredInput, 
        keyPassesInput, dribblesInput, passAccuracyInput, 
        crossAccuracyInput, tacklesInput, interceptionsInput, 
        clearancesInput, yellowCardsInput, redCardsInput
      ].forEach(input => {
        input.addEventListener('input', () => {
          // Only predict if network is trained
          if (net.trainOpts) {
            predictLossProbability();
          }
        });
      });
      
      // Functions
      function initUI() {
        hiddenLayersInput.value = config.hiddenLayers;
        neuronsPerLayerInput.value = config.neuronsPerLayer;
        learningRateInput.value = config.learningRate;
      }
      
      function updateConfig() {
        config.hiddenLayers = parseInt(hiddenLayersInput.value);
        config.neuronsPerLayer = parseInt(neuronsPerLayerInput.value);
        config.learningRate = parseFloat(learningRateInput.value);
        drawNetwork();
      }
      
      function resetNetwork() {
        net = new brain.NeuralNetwork();
        drawNetwork();
        resetChart();
        lossPercentage.textContent = '0%';
        progressRing.setAttribute('stroke-dasharray', '0, 100');
        confidenceBar.style.width = '0%';
        predictionText.textContent = 'Enter team stats to predict';
      }
      
      function trainNetwork() {
        loadingOverlay.classList.remove('hidden');
        trainBtn.disabled = true;
        
        // Generate synthetic training data based on soccer stats
        const trainingData = generateTrainingData();
        
        // Configure network
        const networkConfig = {
          hiddenLayers: Array(config.hiddenLayers).fill(config.neuronsPerLayer),
          learningRate: config.learningRate,
          iterations: config.iterations,
          errorThresh: config.errorThresh,
          log: true,
          logPeriod: 1000,
          callback: function(info) {
            updateChart(info.iterations, info.error);
          },
          callbackPeriod: 1000
        };
        
        // Train in a timeout to allow UI to update
        setTimeout(() => {
          net.train(trainingData, networkConfig);
          loadingOverlay.classList.add('hidden');
          trainBtn.disabled = false;
          drawNetwork();
          
          // After training, update predictions for all teams
          updateAllTeamPredictions();
          
          // Also predict for the current input values
          predictLossProbability();
        }, 100);
      }
      
      function generateTrainingData() {
        // In a real application, this would be actual historical soccer data
        // For this demo, we generate synthetic data that follows general trends:
        // More goals conceded, fewer shots on target, lower pass accuracy, more yellow cards = more likely to lose
        
        const data = [];
        const seasons = parseInt(seasonRange.value);
        const weight = statWeight.value;
        
        // Generate data for multiple seasons
        for (let i = 0; i < seasons * 100; i++) {
          // Random stats within realistic ranges
          const goalsConceded = Math.floor(randomInRange(20, 80));
          const shotsOnTarget = Math.floor(randomInRange(100, 300));
          const goalsScored = Math.floor(randomInRange(30, 100));
          const keyPasses = Math.floor(randomInRange(200, 600));
          const dribbles = Math.floor(randomInRange(100, 500));
          const passAccuracy = randomInRange(70, 90);
          const crossAccuracy = randomInRange(20, 50);
          const tackles = Math.floor(randomInRange(300, 800));
          const interceptions = Math.floor(randomInRange(200, 600));
          const clearances = Math.floor(randomInRange(300, 900));
          const yellowCards = Math.floor(randomInRange(30, 100));
          const redCards = Math.floor(randomInRange(0, 10));
          
          // Calculate loss probability based on stats
          let lossProbability;
          
          if (weight === 'offense') {
            // More weight on offensive stats
            lossProbability = (
              (0.1 * normalize(goalsConceded, 20, 80)) + 
              (0.2 * (1 - normalize(shotsOnTarget, 100, 300))) + 
              (0.2 * (1 - normalize(goalsScored, 30, 100))) + 
              (0.15 * (1 - normalize(keyPasses, 200, 600))) +
              (0.15 * (1 - normalize(dribbles, 100, 500))) +
              (0.1 * (1 - normalize(passAccuracy, 70, 90))) + 
              (0.05 * (1 - normalize(crossAccuracy, 20, 50))) +
              (0.025 * normalize(tackles, 300, 800)) +
              (0.025 * normalize(interceptions, 200, 600)) +
              (0.025 * normalize(clearances, 300, 900)) +
              (0.025 * normalize(yellowCards, 30, 100)) +
              (0.025 * normalize(redCards, 0, 10))
            );
          } else if (weight === 'defense') {
            // More weight on defensive stats
            lossProbability = (
              (0.3 * normalize(goalsConceded, 20, 80)) + 
              (0.05 * (1 - normalize(shotsOnTarget, 100, 300))) + 
              (0.05 * (1 - normalize(goalsScored, 30, 100))) + 
              (0.05 * (1 - normalize(keyPasses, 200, 600))) +
              (0.05 * (1 - normalize(dribbles, 100, 500))) +
              (0.1 * (1 - normalize(passAccuracy, 70, 90))) + 
              (0.05 * (1 - normalize(crossAccuracy, 20, 50))) +
              (0.1 * normalize(tackles, 300, 800)) +
              (0.1 * normalize(interceptions, 200, 600)) +
              (0.1 * normalize(clearances, 300, 900)) +
              (0.05 * normalize(yellowCards, 30, 100)) +
              (0.05 * normalize(redCards, 0, 10))
            );
          } else {
            // Balanced approach
            lossProbability = (
              (0.15 * normalize(goalsConceded, 20, 80)) + 
              (0.1 * (1 - normalize(shotsOnTarget, 100, 300))) + 
              (0.1 * (1 - normalize(goalsScored, 30, 100))) + 
              (0.1 * (1 - normalize(keyPasses, 200, 600))) +
              (0.1 * (1 - normalize(dribbles, 100, 500))) +
              (0.1 * (1 - normalize(passAccuracy, 70, 90))) + 
              (0.05 * (1 - normalize(crossAccuracy, 20, 50))) +
              (0.1 * normalize(tackles, 300, 800)) +
              (0.1 * normalize(interceptions, 200, 600)) +
              (0.05 * normalize(clearances, 300, 900)) +
              (0.025 * normalize(yellowCards, 30, 100)) +
              (0.025 * normalize(redCards, 0, 10))
            );
          }
          
          // Add some randomness
          lossProbability += randomInRange(-0.1, 0.1);
          lossProbability = Math.max(0, Math.min(1, lossProbability));
          
          // Determine if this would be a loss (1) or win (0)
          const outcome = lossProbability > 0.5 ? 1 : 0;
          
          // Add to training data
          data.push({
            input: [
              normalize(goalsConceded, 20, 80),
              normalize(shotsOnTarget, 100, 300),
              normalize(goalsScored, 30, 100),
              normalize(keyPasses, 200, 600),
              normalize(dribbles, 100, 500),
              normalize(passAccuracy, 70, 90),
              normalize(crossAccuracy, 20, 50),
              normalize(tackles, 300, 800),
              normalize(interceptions, 200, 600),
              normalize(clearances, 300, 900),
              normalize(yellowCards, 30, 100),
              normalize(redCards, 0, 10)
            ],
            output: [outcome]
          });
        }
        
        return data;
      }
      
      function predictLossProbability() {
        // Get all 12 input values
        const goalsConceded = parseFloat(goalsConcededInput.value);
        const shotsOnTarget = parseFloat(shotsOnTargetInput.value);
        const goalsScored = parseFloat(goalsScoredInput.value);
        const keyPasses = parseFloat(keyPassesInput.value);
        const dribbles = parseFloat(dribblesInput.value);
        const passAccuracy = parseFloat(passAccuracyInput.value);
        const crossAccuracy = parseFloat(crossAccuracyInput.value);
        const tackles = parseFloat(tacklesInput.value);
        const interceptions = parseFloat(interceptionsInput.value);
        const clearances = parseFloat(clearancesInput.value);
        const yellowCards = parseFloat(yellowCardsInput.value);
        const redCards = parseFloat(redCardsInput.value);
        
        const input = [
          normalize(goalsConceded, 20, 80),
          normalize(shotsOnTarget, 100, 300),
          normalize(goalsScored, 30, 100),
          normalize(keyPasses, 200, 600),
          normalize(dribbles, 100, 500),
          normalize(passAccuracy, 70, 90),
          normalize(crossAccuracy, 20, 50),
          normalize(tackles, 300, 800),
          normalize(interceptions, 200, 600),
          normalize(clearances, 300, 900),
          normalize(yellowCards, 30, 100),
          normalize(redCards, 0, 10)
        ];
        
        const output = net.run(input);
        const lossProb = output[0];
        const lossPercent = Math.round(lossProb * 100);
        const confidence = Math.abs(lossProb - 0.5) * 2; // How far from 50%
        
        // Update UI
        lossPercentage.textContent = `${lossPercent}%`;
        progressRing.setAttribute('stroke-dasharray', `${lossPercent}, ${100 - lossPercent}`);
        confidenceBar.style.width = `${confidence * 100}%`;
        
        if (lossProb > 0.7) {
          predictionText.innerHTML = `<span class="text-red-600">High loss probability</span>`;
          progressRing.setAttribute('stroke', '#EF4444');
        } else if (lossProb > 0.55) {
          predictionText.innerHTML = `<span class="text-orange-500">Moderate loss probability</span>`;
          progressRing.setAttribute('stroke', '#F97316');
        } else if (lossProb > 0.45) {
          predictionText.textContent = "Neutral prediction";
          progressRing.setAttribute('stroke', '#6B7280');
        } else if (lossProb > 0.3) {
          predictionText.innerHTML = `<span class="text-green-500">Moderate win probability</span>`;
          progressRing.setAttribute('stroke', '#10B981');
        } else {
          predictionText.innerHTML = `<span class="text-green-600">High win probability</span>`;
          progressRing.setAttribute('stroke', '#059669');
        }
      }
      
      function renderTeamCards() {
        teamPredictions.innerHTML = '';
        
        soccerTeams.forEach(team => {
          const card = document.createElement('div');
          card.className = 'bg-white rounded-lg shadow-md p-4 team-card';
          card.innerHTML = `
            <div class="flex items-center mb-3">
              <div class="text-2xl mr-3">${team.logo}</div>
              <h3 class="font-semibold text-gray-800">${team.name}</h3>
            </div>
            <div class="grid grid-cols-2 gap-2 text-xs mb-3">
              <div><span class="text-gray-500">Conceded:</span> ${team.goalsConceded}</div>
              <div><span class="text-gray-500">Shots:</span> ${team.shotsOnTarget}</div>
              <div><span class="text-gray-500">Goals:</span> ${team.goalsScored}</div>
              <div><span class="text-gray-500">Pass %:</span> ${team.passAccuracy.toFixed(1)}</div>
              <div><span class="text-gray-500">Tackles:</span> ${team.tackles}</div>
              <div><span class="text-gray-500">Yellows:</span> ${team.yellowCards}</div>
            </div>
            <div class="flex items-center">
              <div class="relative w-10 h-10 mr-2">
                <svg class="w-full h-full" viewBox="0 0 36 36">
                  <path
                    d="M18 2.0845
                      a 15.9155 15.9155 0 0 1 0 31.831
                      a 15.9155 15.9155 0 0 1 0 -31.831"
                    fill="none"
                    stroke="#E5E7EB"
                    stroke-width="2"
                  />
                  <path
                    class="team-progress"
                    d="M18 2.0845
                      a 15.9155 15.9155 0 0 1 0 31.831
                      a 15.9155 15.9155 0 0 1 0 -31.831"
                    fill="none"
                    stroke="#EF4444"
                    stroke-width="2"
                    stroke-dasharray="0, 100"
                  />
                </svg>
                <div class="team-percentage absolute inset-0 flex items-center justify-center text-xs font-bold text-red-600">-</div>
              </div>
              <button class="text-xs bg-green-100 hover:bg-green-200 text-green-800 py-1 px-2 rounded flex items-center ml-auto predict-btn" data-team='${JSON.stringify(team)}'>
                <i class="fas fa-calculator mr-1 text-xs"></i> Predict
              </button>
            </div>
          `;
          teamPredictions.appendChild(card);
        });
        
        // Add event listeners to predict buttons
        document.querySelectorAll('.predict-btn').forEach(btn => {
          btn.addEventListener('click', function() {
            const team = JSON.parse(this.getAttribute('data-team'));
            
            // Set all 12 input values
            goalsConcededInput.value = team.goalsConceded;
            shotsOnTargetInput.value = team.shotsOnTarget;
            goalsScoredInput.value = team.goalsScored;
            keyPassesInput.value = team.keyPasses;
            dribblesInput.value = team.dribbles;
            passAccuracyInput.value = team.passAccuracy;
            crossAccuracyInput.value = team.crossAccuracy;
            tacklesInput.value = team.tackles;
            interceptionsInput.value = team.interceptions;
            clearancesInput.value = team.clearances;
            yellowCardsInput.value = team.yellowCards;
            redCardsInput.value = team.redCards;
            
            if (net.trainOpts) {
              predictLossProbability();
            } else {
              predictionText.textContent = "Train the network first";
            }
          });
        });
      }
      
      function updateAllTeamPredictions() {
        soccerTeams.forEach((team, index) => {
          const input = [
            normalize(team.goalsConceded, 20, 80),
            normalize(team.shotsOnTarget, 100, 300),
            normalize(team.goalsScored, 30, 100),
            normalize(team.keyPasses, 200, 600),
            normalize(team.dribbles, 100, 500),
            normalize(team.passAccuracy, 70, 90),
            normalize(team.crossAccuracy, 20, 50),
            normalize(team.tackles, 300, 800),
            normalize(team.interceptions, 200, 600),
            normalize(team.clearances, 300, 900),
            normalize(team.yellowCards, 30, 100),
            normalize(team.redCards, 0, 10)
          ];
          
          const output = net.run(input);
          const lossPercent = Math.round(output[0] * 100);
          
          // Update the corresponding team card
          const card = teamPredictions.children[index];
          const progress = card.querySelector('.team-progress');
          const percentage = card.querySelector('.team-percentage');
          
          progress.setAttribute('stroke-dasharray', `${lossPercent}, ${100 - lossPercent}`);
          percentage.textContent = `${lossPercent}%`;
          
          // Color based on probability
          if (lossPercent > 70) {
            progress.setAttribute('stroke', '#EF4444');
            percentage.classList.add('text-red-600');
            percentage.classList.remove('text-orange-500', 'text-gray-500', 'text-green-500', 'text-green-600');
          } else if (lossPercent > 55) {
            progress.setAttribute('stroke', '#F97316');
            percentage.classList.add('text-orange-500');
            percentage.classList.remove('text-red-600', 'text-gray-500', 'text-green-500', 'text-green-600');
          } else if (lossPercent > 45) {
            progress.setAttribute('stroke', '#6B7280');
            percentage.classList.add('text-gray-500');
            percentage.classList.remove('text-red-600', 'text-orange-500', 'text-green-500', 'text-green-600');
          } else if (lossPercent > 30) {
            progress.setAttribute('stroke', '#10B981');
            percentage.classList.add('text-green-500');
            percentage.classList.remove('text-red-600', 'text-orange-500', 'text-gray-500', 'text-green-600');
          } else {
            progress.setAttribute('stroke', '#059669');
            percentage.classList.add('text-green-600');
            percentage.classList.remove('text-red-600', 'text-orange-500', 'text-gray-500', 'text-green-500');
          }
        });
      }
      
      function drawNetwork() {
        // Clear diagram
        diagram.innerHTML = '';
        
        const width = diagram.clientWidth;
        const height = diagram.clientHeight;
        const padding = 50;
        
        // Calculate layer positions
        const layers = [
          { neurons: 12, label: 'Input', stats: ['Conceded', 'Shots', 'Goals', 'KeyP', 'Drib', 'Pass%', 'Cross%', 'Tack', 'Int', 'Clear', 'Yel', 'Red'] },
          ...Array(config.hiddenLayers).fill().map((_, i) => ({
            neurons: config.neuronsPerLayer,
            label: `Hidden ${i + 1}`
          })),
          { neurons: 1, label: 'Output', stats: ['Loss %'] }
        ];
        
        const layerCount = layers.length;
        const layerWidth = (width - 2 * padding) / (layerCount - 1);
        
        // Draw connections first (so they appear behind neurons)
        for (let l = 0; l < layerCount - 1; l++) {
          const currentLayer = layers[l];
          const nextLayer = layers[l + 1];
          
          for (let n1 = 0; n1 < currentLayer.neurons; n1++) {
            for (let n2 = 0; n2 < nextLayer.neurons; n2++) {
              const x1 = padding + l * layerWidth;
              const y1 = padding + (height - 2 * padding) * (n1 + 0.5) / currentLayer.neurons;
              const x2 = padding + (l + 1) * layerWidth;
              const y2 = padding + (height - 2 * padding) * (n2 + 0.5) / nextLayer.neurons;
              
              // Create connection
              const line = document.createElementNS('http://www.w3.org/2000/svg', 'line');
              line.setAttribute('x1', x1);
              line.setAttribute('y1', y1);
              line.setAttribute('x2', x2);
              line.setAttribute('y2', y2);
              line.setAttribute('stroke', '#9CA3AF');
              line.setAttribute('stroke-width', '1');
              line.setAttribute('class', 'connection');
              diagram.appendChild(line);
            }
          }
        }
        
        // Draw neurons
        for (let l = 0; l < layerCount; l++) {
          const layer = layers[l];
          const x = padding + l * layerWidth;
          
          for (let n = 0; n < layer.neurons; n++) {
            const y = padding + (height - 2 * padding) * (n + 0.5) / layer.neurons;
            
            // Create neuron circle
            const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
            circle.setAttribute('cx', x);
            circle.setAttribute('cy', y);
            circle.setAttribute('r', 15);
            
            // Color input/output layers differently
            if (l === 0) {
              circle.setAttribute('fill', '#10B981'); // Green for input
            } else if (l === layerCount - 1) {
              circle.setAttribute('fill', '#EF4444'); // Red for output
            } else {
              circle.setAttribute('fill', '#3B82F6'); // Blue for hidden
            }
            
            circle.setAttribute('class', 'neuron');
            diagram.appendChild(circle);
            
            // Create neuron text
            const text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
            text.setAttribute('x', x);
            text.setAttribute('y', y + 4);
            text.setAttribute('text-anchor', 'middle');
            text.setAttribute('fill', 'white');
            text.setAttribute('font-size', '8');
            text.setAttribute('font-weight', 'bold');
            
            // Show stat names for input layer
            if (l === 0 && layer.stats) {
              text.textContent = layer.stats[n];
            } else if (l === layerCount - 1 && layer.stats) {
              text.textContent = layer.stats[n];
            } else {
              text.textContent = `${layer.label[0]}${n + 1}`;
            }
            
            diagram.appendChild(text);
          }
          
          // Add layer label
          const label = document.createElementNS('http://www.w3.org/2000/svg', 'text');
          label.setAttribute('x', x);
          label.setAttribute('y', height - 20);
          label.setAttribute('text-anchor', 'middle');
          label.setAttribute('fill', '#4B5563');
          label.setAttribute('font-size', '12');
          label.textContent = layer.label;
          diagram.appendChild(label);
        }
      }
      
      function initChart() {
        const ctx = document.getElementById('errorChart').getContext('2d');
        errorChart = new Chart(ctx, {
          type: 'line',
          data: {
            labels: [],
            datasets: [{
              label: 'Training Error',
              data: [],
              borderColor: '#10B981',
              backgroundColor: 'rgba(16, 185, 129, 0.1)',
              borderWidth: 2,
              fill: true,
              tension: 0.4
            }]
          },
          options: {
            responsive: true,
            plugins: {
              title: {
                display: true,
                text: 'Neural Network Learning Progress',
                font: {
                  size: 16
                }
              },
              tooltip: {
                callbacks: {
                  label: function(context) {
                    return `Error: ${context.parsed.y.toFixed(5)}`;
                  }
                }
              }
            },
            scales: {
              y: {
                beginAtZero: true,
                title: {
                  display: true,
                  text: 'Error Rate'
                }
              },
              x: {
                title: {
                  display: true,
                  text: 'Training Iterations'
                }
              }
            }
          }
        });
      }
      
      function updateChart(iteration, error) {
        errorChart.data.labels.push(iteration);
        errorChart.data.datasets[0].data.push(error);
        errorChart.update();
      }
      
      function resetChart() {
        errorChart.data.labels = [];
        errorChart.data.datasets[0].data = [];
        errorChart.update();
      }
      
      // Helper functions
      function randomInRange(min, max) {
        return Math.random() * (max - min) + min;
      }
      
      function normalize(value, min, max) {
        return (value - min) / (max - min);
      }
    });
  </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=MarcRyan/spe" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>