File size: 27,316 Bytes
37ca6fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PurpleHoop - Basketball Training</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/hotkeys-js/dist/hotkeys.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .heatmap {
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><rect width="100%" height="100%" fill="black"/></svg>');
            position: relative;
        }
        
        .heat-point {
            position: absolute;
            border-radius: 50%;
            transform: translate(-50%, -50%);
            opacity: 0.7;
            transition: all 0.3s ease;
        }
        
        .court {
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="300" height="280" viewBox="0 0 300 280"><rect x="0" y="0" width="300" height="280" fill="none" stroke="%23a855f7" stroke-width="2"/><circle cx="150" cy="140" r="60" fill="none" stroke="%23a855f7" stroke-width="2"/><line x1="0" y1="140" x2="300" y2="140" stroke="%23a855f7" stroke-width="2"/><rect x="0" y="100" width="60" height="80" fill="none" stroke="%23a855f7" stroke-width="2"/><rect x="240" y="100" width="60" height="80" fill="none" stroke="%23a855f7" stroke-width="2"/></svg>');
            background-repeat: no-repeat;
            background-position: center;
            background-size: contain;
        }
        
        .gradient-bg {
            background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
        }
        
        .pulse-animation {
            animation: pulse 2s infinite;
        }
        
        @keyframes pulse {
            0% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.7); }
            70% { box-shadow: 0 0 0 10px rgba(168, 85, 247, 0); }
            100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); }
        }
        
        .shot-trail {
            position: absolute;
            background: #a855f7;
            height: 2px;
            transform-origin: left center;
            z-index: 10;
        }
    </style>
</head>
<body class="gradient-bg text-white min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="flex justify-between items-center mb-8">
            <div class="flex items-center">
                <i class="fas fa-basketball-ball text-4xl text-purple-500 mr-3"></i>
                <h1 class="text-3xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-purple-400 to-purple-600">
                    PurpleHoop
                </h1>
            </div>
            <div class="flex space-x-4">
                <button class="bg-purple-600 hover:bg-purple-700 px-4 py-2 rounded-lg flex items-center">
                    <i class="fas fa-user mr-2"></i> Profile
                </button>
                <button class="bg-gray-800 hover:bg-gray-700 px-4 py-2 rounded-lg flex items-center">
                    <i class="fas fa-cog mr-2"></i> Settings
                </button>
            </div>
        </header>

        <!-- Main Content -->
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
            <!-- Camera Feed and Tracking -->
            <div class="lg:col-span-2 space-y-6">
                <div class="bg-black rounded-xl overflow-hidden shadow-2xl">
                    <div class="p-4 bg-gray-900 flex justify-between items-center">
                        <h2 class="text-xl font-semibold text-purple-400">
                            <i class="fas fa-video mr-2"></i> Shot Tracking
                        </h2>
                        <div class="flex space-x-2">
                            <button id="startTracking" class="bg-purple-600 hover:bg-purple-700 px-3 py-1 rounded-lg flex items-center pulse-animation">
                                <i class="fas fa-play mr-2"></i> Start Session
                            </button>
                            <button id="toggleCamera" class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded-lg flex items-center">
                                <i class="fas fa-camera mr-2"></i> Switch Camera
                            </button>
                        </div>
                    </div>
                    
                    <div class="relative" style="padding-bottom: 56.25%;">
                        <!-- Camera Feed Placeholder -->
                        <div id="cameraFeed" class="absolute inset-0 bg-gray-800 flex items-center justify-center">
                            <div class="text-center">
                                <i class="fas fa-basketball-ball text-6xl text-gray-600 mb-4"></i>
                                <p class="text-gray-400">Camera feed will appear here</p>
                                <button id="enableCamera" class="mt-4 bg-purple-600 hover:bg-purple-700 px-4 py-2 rounded-lg">
                                    Enable Camera
                                </button>
                            </div>
                        </div>
                        
                        <!-- Overlay for computer vision tracking -->
                        <canvas id="trackingOverlay" class="absolute inset-0 w-full h-full pointer-events-none" style="display: none;"></canvas>
                        
                        <!-- Shot trails container -->
                        <div id="shotTrails" class="absolute inset-0 w-full h-full pointer-events-none"></div>
                    </div>
                    
                    <div class="p-4 bg-gray-900 flex justify-between items-center">
                        <div class="text-sm text-gray-400">
                            <span id="shotCount">0</span> shots tracked
                        </div>
                        <div class="flex space-x-2">
                            <button id="showHeatmap" class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded-lg flex items-center">
                                <i class="fas fa-fire mr-2"></i> Heatmap
                            </button>
                            <button id="showTrajectory" class="bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded-lg flex items-center">
                                <i class="fas fa-project-diagram mr-2"></i> Trajectories
                            </button>
                        </div>
                    </div>
                </div>
                
                <!-- Session Stats -->
                <div class="bg-gray-900 rounded-xl p-6 shadow-2xl">
                    <h2 class="text-xl font-semibold text-purple-400 mb-4">
                        <i class="fas fa-chart-line mr-2"></i> Session Statistics
                    </h2>
                    <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
                        <div class="bg-gray-800 p-4 rounded-lg">
                            <div class="text-sm text-gray-400">Made Shots</div>
                            <div class="text-2xl font-bold text-purple-400">12</div>
                            <div class="text-xs text-gray-500">+2 from last</div>
                        </div>
                        <div class="bg-gray-800 p-4 rounded-lg">
                            <div class="text-sm text-gray-400">Shot %</div>
                            <div class="text-2xl font-bold text-purple-400">48%</div>
                            <div class="text-xs text-gray-500">3% improvement</div>
                        </div>
                        <div class="bg-gray-800 p-4 rounded-lg">
                            <div class="text-sm text-gray-400">Avg Arc</div>
                            <div class="text-2xl font-bold text-purple-400">47°</div>
                            <div class="text-xs text-gray-500">Ideal: 45-50°</div>
                        </div>
                        <div class="bg-gray-800 p-4 rounded-lg">
                            <div class="text-sm text-gray-400">Release Time</div>
                            <div class="text-2xl font-bold text-purple-400">0.8s</div>
                            <div class="text-xs text-gray-500">Consistent</div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Sidebar with Heatmap and Analytics -->
            <div class="space-y-6">
                <!-- Heatmap Visualization -->
                <div class="bg-gray-900 rounded-xl p-6 shadow-2xl">
                    <h2 class="text-xl font-semibold text-purple-400 mb-4">
                        <i class="fas fa-fire mr-2"></i> Shot Heatmap
                    </h2>
                    <div class="heatmap court relative" style="height: 280px; width: 100%;">
                        <!-- Heatmap points will be added here by JavaScript -->
                    </div>
                    <div class="mt-4 flex justify-between text-xs text-gray-400">
                        <span>Fewer shots</span>
                        <span>More shots</span>
                    </div>
                    <div class="h-2 mt-1 rounded-full bg-gradient-to-r from-gray-800 via-purple-600 to-purple-400"></div>
                </div>
                
                <!-- Shot Chart -->
                <div class="bg-gray-900 rounded-xl p-6 shadow-2xl">
                    <h2 class="text-xl font-semibold text-purple-400 mb-4">
                        <i class="fas fa-bullseye mr-2"></i> Shot Accuracy
                    </h2>
                    <canvas id="shotChart" height="200"></canvas>
                </div>
                
                <!-- Shot Types -->
                <div class="bg-gray-900 rounded-xl p-6 shadow-2xl">
                    <h2 class="text-xl font-semibold text-purple-400 mb-4">
                        <i class="fas fa-tags mr-2"></i> Shot Types
                    </h2>
                    <div class="space-y-3">
                        <div>
                            <div class="flex justify-between text-sm mb-1">
                                <span>3-Pointers</span>
                                <span>8/20 (40%)</span>
                            </div>
                            <div class="w-full bg-gray-800 rounded-full h-2">
                                <div class="bg-purple-500 h-2 rounded-full" style="width: 40%"></div>
                            </div>
                        </div>
                        <div>
                            <div class="flex justify-between text-sm mb-1">
                                <span>Mid-Range</span>
                                <span>12/15 (80%)</span>
                            </div>
                            <div class="w-full bg-gray-800 rounded-full h-2">
                                <div class="bg-purple-500 h-2 rounded-full" style="width: 80%"></div>
                            </div>
                        </div>
                        <div>
                            <div class="flex justify-between text-sm mb-1">
                                <span>Layups</span>
                                <span>10/12 (83%)</span>
                            </div>
                            <div class="w-full bg-gray-800 rounded-full h-2">
                                <div class="bg-purple-500 h-2 rounded-full" style="width: 83%"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- Session History -->
        <div class="mt-12 bg-gray-900 rounded-xl p-6 shadow-2xl">
            <h2 class="text-xl font-semibold text-purple-400 mb-4">
                <i class="fas fa-history mr-2"></i> Recent Sessions
            </h2>
            <div class="overflow-x-auto">
                <table class="min-w-full divide-y divide-gray-800">
                    <thead>
                        <tr>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Date</th>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Duration</th>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Shots</th>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Accuracy</th>
                            <th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider">Trend</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-800">
                        <tr>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">Today</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">45 min</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">120</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">68%</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm text-green-400"><i class="fas fa-arrow-up mr-1"></i> 5%</td>
                        </tr>
                        <tr>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">Yesterday</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">30 min</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">85</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">63%</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm text-red-400"><i class="fas fa-arrow-down mr-1"></i> 2%</td>
                        </tr>
                        <tr>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">May 15</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">60 min</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">150</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm">65%</td>
                            <td class="px-4 py-3 whitespace-nowrap text-sm text-green-400"><i class="fas fa-arrow-up mr-1"></i> 8%</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <script>
        // Simulate computer vision tracking
        document.addEventListener('DOMContentLoaded', function() {
            // Initialize shot chart
            const shotCtx = document.getElementById('shotChart').getContext('2d');
            const shotChart = new Chart(shotCtx, {
                type: 'line',
                data: {
                    labels: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
                    datasets: [
                        {
                            label: 'Made',
                            data: [3, 5, 7, 8, 10, 12, 14, 15, 17, 20],
                            borderColor: '#a855f7',
                            backgroundColor: 'rgba(168, 85, 247, 0.1)',
                            tension: 0.3,
                            fill: true
                        },
                        {
                            label: 'Missed',
                            data: [2, 3, 3, 4, 5, 5, 6, 6, 7, 8],
                            borderColor: '#6b7280',
                            backgroundColor: 'rgba(107, 114, 128, 0.1)',
                            tension: 0.3,
                            fill: true
                        }
                    ]
                },
                options: {
                    responsive: true,
                    plugins: {
                        legend: {
                            position: 'top',
                            labels: {
                                color: '#e5e7eb'
                            }
                        }
                    },
                    scales: {
                        y: {
                            beginAtZero: true,
                            grid: {
                                color: 'rgba(255, 255, 255, 0.1)'
                            },
                            ticks: {
                                color: '#9ca3af'
                            }
                        },
                        x: {
                            grid: {
                                color: 'rgba(255, 255, 255, 0.1)'
                            },
                            ticks: {
                                color: '#9ca3af'
                            }
                        }
                    }
                }
            });

            // Generate heatmap points
            const heatmap = document.querySelector('.heatmap');
            const heatmapWidth = heatmap.offsetWidth;
            const heatmapHeight = heatmap.offsetHeight;
            
            // Common shooting spots with different intensities
            const shootingSpots = [
                { x: 0.2, y: 0.7, intensity: 8 },  // Left corner
                { x: 0.8, y: 0.7, intensity: 7 },  // Right corner
                { x: 0.5, y: 0.6, intensity: 15 }, // Top of the key
                { x: 0.3, y: 0.5, intensity: 5 },  // Left wing
                { x: 0.7, y: 0.5, intensity: 6 },  // Right wing
                { x: 0.5, y: 0.8, intensity: 10 }, // Free throw
                { x: 0.15, y: 0.9, intensity: 3 }, // Left baseline
                { x: 0.85, y: 0.9, intensity: 4 }  // Right baseline
            ];
            
            shootingSpots.forEach(spot => {
                for (let i = 0; i < spot.intensity; i++) {
                    // Add some randomness to the position
                    const xVar = (Math.random() * 0.1) - 0.05;
                    const yVar = (Math.random() * 0.1) - 0.05;
                    
                    const point = document.createElement('div');
                    point.className = 'heat-point';
                    
                    // Position the point
                    const xPos = (spot.x + xVar) * 100;
                    const yPos = (spot.y + yVar) * 100;
                    
                    point.style.left = `${xPos}%`;
                    point.style.top = `${yPos}%`;
                    
                    // Size and color based on intensity
                    const size = 10 + (Math.random() * 10);
                    const opacity = 0.3 + (Math.random() * 0.5);
                    const hue = 270 + (Math.random() * 20 - 10); // Purple variations
                    
                    point.style.width = `${size}px`;
                    point.style.height = `${size}px`;
                    point.style.backgroundColor = `hsla(${hue}, 80%, 60%, ${opacity})`;
                    
                    heatmap.appendChild(point);
                }
            });

            // Simulate camera feed and tracking
            const enableCameraBtn = document.getElementById('enableCamera');
            const startTrackingBtn = document.getElementById('startTracking');
            const cameraFeed = document.getElementById('cameraFeed');
            const trackingOverlay = document.getElementById('trackingOverlay');
            const shotTrails = document.getElementById('shotTrails');
            const shotCount = document.getElementById('shotCount');
            
            let shotCounter = 0;
            let trackingInterval;
            
            enableCameraBtn.addEventListener('click', function() {
                // Simulate camera activation
                cameraFeed.innerHTML = `
                    <div class="absolute inset-0 bg-gray-900 flex items-center justify-center">
                        <div class="text-center">
                            <div class="court w-full h-full"></div>
                        </div>
                    </div>
                `;
                trackingOverlay.style.display = 'block';
                enableCameraBtn.style.display = 'none';
                startTrackingBtn.disabled = false;
                
                // Initialize tracking overlay
                trackingOverlay.width = trackingOverlay.offsetWidth;
                trackingOverlay.height = trackingOverlay.offsetHeight;
                const ctx = trackingOverlay.getContext('2d');
                
                // Draw some initial tracking markers
                ctx.strokeStyle = '#a855f7';
                ctx.lineWidth = 2;
                
                // Court lines
                ctx.beginPath();
                ctx.arc(trackingOverlay.width/2, trackingOverlay.height/2, trackingOverlay.width/5, 0, Math.PI * 2);
                ctx.stroke();
                
                ctx.beginPath();
                ctx.moveTo(0, trackingOverlay.height/2);
                ctx.lineTo(trackingOverlay.width, trackingOverlay.height/2);
                ctx.stroke();
            });
            
            startTrackingBtn.addEventListener('click', function() {
                if (startTrackingBtn.textContent.includes('Start')) {
                    startTrackingBtn.innerHTML = '<i class="fas fa-stop mr-2"></i> Stop Session';
                    startTrackingBtn.classList.remove('bg-purple-600');
                    startTrackingBtn.classList.add('bg-red-600');
                    startTrackingBtn.classList.remove('pulse-animation');
                    
                    // Start simulated tracking
                    trackingInterval = setInterval(simulateShotTracking, 3000);
                } else {
                    startTrackingBtn.innerHTML = '<i class="fas fa-play mr-2"></i> Start Session';
                    startTrackingBtn.classList.add('bg-purple-600');
                    startTrackingBtn.classList.remove('bg-red-600');
                    clearInterval(trackingInterval);
                }
            });
            
            function simulateShotTracking() {
                shotCounter++;
                shotCount.textContent = shotCounter;
                
                // Random shot result (60% make rate)
                const madeShot = Math.random() < 0.6;
                
                // Random shot position
                const startX = 50 + (Math.random() * 40 - 20);
                const startY = 80 + (Math.random() * 10);
                const endX = 45 + (Math.random() * 10);
                const endY = 40 + (Math.random() * 10);
                
                // Create shot trail
                const trail = document.createElement('div');
                trail.className = 'shot-trail';
                
                // Position the trail
                const startPosX = (startX / 100) * trackingOverlay.offsetWidth;
                const startPosY = (startY / 100) * trackingOverlay.offsetHeight;
                const endPosX = (endX / 100) * trackingOverlay.offsetWidth;
                const endPosY = (endY / 100) * trackingOverlay.offsetHeight;
                
                trail.style.left = `${startPosX}px`;
                trail.style.top = `${startPosY}px`;
                
                // Calculate length and angle
                const dx = endPosX - startPosX;
                const dy = endPosY - startPosY;
                const length = Math.sqrt(dx * dx + dy * dy);
                const angle = Math.atan2(dy, dx) * 180 / Math.PI;
                
                trail.style.width = `${length}px`;
                trail.style.transform = `rotate(${angle}deg)`;
                
                // Add to DOM
                shotTrails.appendChild(trail);
                
                // Animate the shot
                setTimeout(() => {
                    trail.style.width = '0';
                    trail.style.opacity = '0';
                    trail.style.transition = 'width 0.5s ease-out, opacity 0.5s ease-out';
                    
                    // Add shot marker
                    setTimeout(() => {
                        const marker = document.createElement('div');
                        marker.className = 'absolute w-4 h-4 rounded-full';
                        marker.style.left = `${endPosX}px`;
                        marker.style.top = `${endPosY}px`;
                        marker.style.backgroundColor = madeShot ? '#a855f7' : '#6b7280';
                        marker.style.transform = 'translate(-50%, -50%)';
                        marker.style.boxShadow = '0 0 10px ' + (madeShot ? '#a855f7' : '#6b7280');
                        
                        shotTrails.appendChild(marker);
                        
                        // Remove elements after animation
                        setTimeout(() => {
                            trail.remove();
                            marker.remove();
                        }, 3000);
                    }, 500);
                }, 100);
                
                // Update chart data periodically
                if (shotCounter % 5 === 0) {
                    const madeData = shotChart.data.datasets[0].data;
                    const missedData = shotChart.data.datasets[1].data;
                    
                    madeData.push(madeData[madeData.length-1] + (madeShot ? 1 : 0));
                    missedData.push(missedData[missedData.length-1] + (madeShot ? 0 : 1));
                    
                    if (madeData.length > 10) {
                        madeData.shift();
                        missedData.shift();
                    }
                    
                    shotChart.update();
                }
            }
            
            // Toggle heatmap visibility
            const showHeatmapBtn = document.getElementById('showHeatmap');
            const showTrajectoryBtn = document.getElementById('showTrajectory');
            
            showHeatmapBtn.addEventListener('click', function() {
                heatmap.style.display = heatmap.style.display === 'none' ? 'block' : 'none';
            });
            
            showTrajectoryBtn.addEventListener('click', function() {
                shotTrails.style.display = shotTrails.style.display === 'none' ? 'block' : 'none';
            });
        });
    </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=Deflook/defapp" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>