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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Minimalist 3D Dice Roller</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #e74c3c;
            --background-color: #f5f6fa;
            --dice-color: #ffffff;
            --shadow-color: rgba(0, 0, 0, 0.2);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background-color: var(--background-color);
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            color: var(--primary-color);
            overflow-x: hidden;
        }

        .container {
            text-align: center;
            max-width: 800px;
            padding: 2rem;
        }

        h1 {
            font-weight: 300;
            margin-bottom: 2rem;
            font-size: 2.5rem;
            letter-spacing: 1px;
        }

        .controls {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-bottom: 2rem;
            gap: 1rem;
            flex-wrap: wrap;
        }

        .dice-count {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        label {
            font-size: 1.1rem;
        }

        input[type="number"] {
            width: 60px;
            padding: 0.5rem;
            border: 1px solid #ddd;
            border-radius: 4px;
            text-align: center;
            font-size: 1rem;
            outline: none;
            transition: border 0.3s;
        }

        input[type="number"]:focus {
            border-color: var(--secondary-color);
        }

        input[type="number"]::-webkit-inner-spin-button,
        input[type="number"]::-webkit-outer-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }

        .btn {
            background-color: var(--secondary-color);
            color: white;
            border: none;
            padding: 0.75rem 1.5rem;
            border-radius: 4px;
            cursor: pointer;
            font-size: 1rem;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .btn:hover {
            background-color: #c0392b;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        .btn:active {
            transform: translateY(0);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .dice-container {
            display: flex;
            justify-content: center;
            flex-wrap: wrap;
            gap: 2rem;
            margin: 2rem 0;
            min-height: 200px;
            perspective: 1000px;
        }

        .dice {
            width: 80px;
            height: 80px;
            position: relative;
            transform-style: preserve-3d;
            transition: transform 1s ease-in-out;
            cursor: pointer;
        }

        @media (max-width: 768px) {
            .dice {
                width: 60px;
                height: 60px;
            }
        }

        .dice-face {
            position: absolute;
            width: 100%;
            height: 100%;
            background-color: var(--dice-color);
            border-radius: 8px;
            display: flex;
            justify-content: center;
            align-items: center;
            box-shadow: inset 0 0 10px var(--shadow-color);
            border: 1px solid #eee;
        }

        .dot {
            width: 12px;
            height: 12px;
            background-color: var(--primary-color);
            border-radius: 50%;
            position: absolute;
        }

        @media (max-width: 768px) {
            .dot {
                width: 10px;
                height: 10px;
            }
        }

        /* Dice face positions */
        .front { transform: translateZ(40px); }
        .back { transform: rotateY(180deg) translateZ(40px); }
        .right { transform: rotateY(90deg) translateZ(40px); }
        .left { transform: rotateY(-90deg) translateZ(40px); }
        .top { transform: rotateX(90deg) translateZ(40px); }
        .bottom { transform: rotateX(-90deg) translateZ(40px); }

        /* Media query for smaller dice on mobile */
        @media (max-width: 768px) {
            .front { transform: translateZ(30px); }
            .back { transform: rotateY(180deg) translateZ(30px); }
            .right { transform: rotateY(90deg) translateZ(30px); }
            .left { transform: rotateY(-90deg) translateZ(30px); }
            .top { transform: rotateX(90deg) translateZ(30px); }
            .bottom { transform: rotateX(-90deg) translateZ(30px); }
        }

        /* Dot positions for each face */
        /* All faces use these positions and visibility is controlled by JavaScript */
        .dot-center { transform: translate(0, 0); }

        .dot-top-left { 
            top: 20%; 
            left: 20%; 
        }
        .dot-top-right { 
            top: 20%; 
            right: 20%; 
        }
        .dot-middle-left { 
            left: 20%; 
        }
        .dot-middle-right { 
            right: 20%; 
        }
        .dot-bottom-left { 
            bottom: 20%; 
            left: 20%; 
        }
        .dot-bottom-right { 
            bottom: 20%; 
            right: 20%; 
        }

        /* Dice roll animations */
        @keyframes roll-twist {
            0% { transform: rotateX(0) rotateY(0) rotateZ(0); }
            20% { transform: rotateX(180deg) rotateY(360deg) rotateZ(45deg); }
            40% { transform: rotateX(360deg) rotateY(180deg) rotateZ(90deg); }
            60% { transform: rotateX(540deg) rotateY(360deg) rotateZ(135deg); }
            80% { transform: rotateX(720deg) rotateY(540deg) rotateZ(180deg); }
            100% { transform: rotateX(900deg) rotateY(720deg) rotateZ(225deg); }
        }

        @keyframes roll-flip {
            0% { transform: rotateX(0) rotateY(0); }
            30% { transform: rotateX(360deg) rotateY(180deg); }
            70% { transform: rotateX(720deg) rotateY(540deg); }
            100% { transform: rotateX(1080deg) rotateY(720deg); }
        }

        @keyframes roll-spiral {
            0% { transform: rotateX(0) rotateY(0) rotateZ(0) translateY(0); }
            20% { transform: rotateX(180deg) rotateY(90deg) rotateZ(90deg) translateY(-50px); }
            40% { transform: rotateX(360deg) rotateY(180deg) rotateZ(180deg) translateY(0); }
            60% { transform: rotateX(540deg) rotateY(270deg) rotateZ(270deg) translateY(30px); }
            80% { transform: rotateX(720deg) rotateY(360deg) rotateZ(360deg) translateY(-20px); }
            100% { transform: rotateX(900deg) rotateY(450deg) rotateZ(450deg) translateY(0); }
        }

        @keyframes roll-bounce {
            0% { transform: rotateX(0) rotateY(0) translateY(0); }
            10% { transform: rotateX(180deg) rotateY(90deg) translateY(-40px); }
            25% { transform: rotateX(360deg) rotateY(180deg) translateY(0); }
            35% { transform: rotateX(540deg) rotateY(270deg) translateY(-30px); }
            45% { transform: rotateX(720deg) rotateY(360deg) translateY(0); }
            55% { transform: rotateX(900deg) rotateY(450deg) translateY(-15px); }
            65% { transform: rotateX(1080deg) rotateY(540deg) translateY(0); }
            75% { transform: rotateX(1260deg) rotateY(630deg) translateY(-5px); }
            85% { transform: rotateX(1440deg) rotateY(720deg) translateY(0); }
            100% { transform: rotateX(1620deg) rotateY(810deg) translateY(0); }
        }

        .rolling-twist {
            animation: roll-twist 1.5s cubic-bezier(0.17, 0.67, 0.83, 0.67) forwards;
        }

        .rolling-flip {
            animation: roll-flip 1.5s cubic-bezier(0.17, 0.67, 0.83, 0.67) forwards;
        }

        .rolling-spiral {
            animation: roll-spiral 1.5s cubic-bezier(0.17, 0.67, 0.83, 0.67) forwards;
        }

        .rolling-bounce {
            animation: roll-bounce 2s cubic-bezier(0.17, 0.67, 0.83, 0.67) forwards;
        }

        .total-display {
            margin-top: 2rem;
            font-size: 1.5rem;
            opacity: 0;
            transition: opacity 0.5s;
        }

        .show-total {
            opacity: 1;
        }

        footer {
            margin-top: 3rem;
            font-size: 0.9rem;
            color: #7f8c8d;
        }

        /* Responsive adjustments */
        @media (max-width: 600px) {
            h1 {
                font-size: 2rem;
            }
            .controls {
                flex-direction: column;
            }
            .dice-count {
                margin-bottom: 1rem;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Minimalist Dice Roller</h1>
        
        <div class="controls">
            <div class="dice-count">
                <label for="dice-number">Number of dice:</label>
                <input type="number" id="dice-number" min="1" max="10" value="3">
            </div>
            <button id="roll-btn" class="btn">
                <i class="fas fa-dice"></i> Roll Dice
            </button>
        </div>
        
        <div id="dice-container" class="dice-container"></div>
        
        <div id="total-display" class="total-display"></div>
        
        <footer>
            Click any die to roll it individually
        </footer>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const diceContainer = document.getElementById('dice-container');
            const rollBtn = document.getElementById('roll-btn');
            const diceNumberInput = document.getElementById('dice-number');
            const totalDisplay = document.getElementById('total-display');
            
            let diceCount = 3;
            let diceElements = [];
            
            // Possible roll animations
            const rollAnimations = [
                'rolling-twist', 
                'rolling-flip', 
                'rolling-spiral', 
                'rolling-bounce'
            ];
            
            // Create initial dice
            initializeDice();
            
            // Update dice count when input changes
            diceNumberInput.addEventListener('change', function() {
                const value = parseInt(this.value);
                if (isNaN(value) || value < 1) {
                    this.value = 1;
                    diceCount = 1;
                } else if (value > 10) {
                    this.value = 10;
                    diceCount = 10;
                } else {
                    diceCount = value;
                }
                initializeDice();
            });
            
            // Roll all dice
            rollBtn.addEventListener('click', function() {
                rollAllDice();
            });
            
            function initializeDice() {
                // Clear existing dice
                diceContainer.innerHTML = '';
                diceElements = [];
                
                // Create new dice
                for (let i = 0; i < diceCount; i++) {
                    const dice = createDiceElement();
                    diceContainer.appendChild(dice);
                    diceElements.push(dice);
                }
            }
            
            function createDiceElement() {
                const dice = document.createElement('div');
                dice.className = 'dice';
                
                // Create all 6 faces of the dice with ALL possible dots
                const faces = [
                    { class: 'front', value: 1 },
                    { class: 'back', value: 2 },
                    { class: 'right', value: 3 },
                    { class: 'left', value: 4 },
                    { class: 'top', value: 5 },
                    { class: 'bottom', value: 6 }
                ];
                
                faces.forEach((face) => {
                    const faceElement = document.createElement('div');
                    faceElement.className = `dice-face ${face.class}`;
                    
                    // Create all possible dots (they will be shown/hidden based on value)
                    const dotPositions = [
                        'dot-center',
                        'dot-top-left',
                        'dot-top-right',
                        'dot-middle-left',
                        'dot-middle-right',
                        'dot-bottom-left',
                        'dot-bottom-right'
                    ];
                    
                    // Create all dots (visibility will be controlled by JS)
                    dotPositions.forEach(pos => {
                        const dot = document.createElement('div');
                        dot.className = `dot ${pos}`;
                        faceElement.appendChild(dot);
                    });
                    
                    dice.appendChild(faceElement);
                });
                
                // Show random face initially
                rollSingleDice(dice, false);
                
                // Add click event to roll single die
                dice.addEventListener('click', function() {
                    rollSingleDice(this, true);
                    updateTotal();
                });
                
                return dice;
            }
            
            function rollSingleDice(diceElement, withAnimation = true) {
                // Remove any existing animation classes
                rollAnimations.forEach(anim => {
                    diceElement.classList.remove(anim);
                });
                
                if (withAnimation) {
                    // Randomly select an animation
                    const randomAnim = rollAnimations[Math.floor(Math.random() * rollAnimations.length)];
                    diceElement.classList.add(randomAnim);
                    
                    // Remove animation class after animation completes
                    setTimeout(() => {
                        diceElement.className = 'dice'; // Reset all classes
                        showRandomFace(diceElement);
                    }, 2000);
                } else {
                    showRandomFace(diceElement);
                }
            }
            
            function showRandomFace(diceElement) {
                // Generate random number between 1 and 6
                const randomValue = Math.floor(Math.random() * 6) + 1;
                
                // Calculate rotation to show the correct face
                const rotations = [
                    { x: 0, y: 0 },       // 1 (front)
                    { x: 0, y: 180 },     // 2 (back)
                    { x: 0, y: 90 },      // 3 (right)
                    { x: 0, y: 270 },     // 4 (left)
                    { x: 270, y: 0 },     // 5 (top)
                    { x: 90, y: 0 }       // 6 (bottom)
                ];
                
                const rotation = rotations[randomValue - 1];
                diceElement.style.transform = `rotateX(${rotation.x}deg) rotateY(${rotation.y}deg)`;
                diceElement.setAttribute('data-value', randomValue);
                
                // Update dots visibility for all faces based on their values
                const faces = diceElement.querySelectorAll('.dice-face');
                faces.forEach((face, idx) => {
                    const value = idx + 1; // faces are in order 1-6
                    const dots = face.querySelectorAll('.dot');
                    
                    // Hide all dots first
                    dots.forEach(dot => dot.style.display = 'none');
                    
                    // Show dots based on face value
                    switch(value) {
                        case 1: // Center
                            dots[0].style.display = 'block';
                            break;
                        case 2: // Top-left, Bottom-right
                            dots[1].style.display = 'block';
                            dots[6].style.display = 'block';
                            break;
                        case 3: // Center + case 2
                            dots[0].style.display = 'block';
                            dots[1].style.display = 'block';
                            dots[6].style.display = 'block';
                            break;
                        case 4: // All corners
                            dots[1].style.display = 'block';
                            dots[2].style.display = 'block';
                            dots[5].style.display = 'block';
                            dots[6].style.display = 'block';
                            break;
                        case 5: // Center + case 4
                            dots[0].style.display = 'block';
                            dots[1].style.display = 'block';
                            dots[2].style.display = 'block';
                            dots[5].style.display = 'block';
                            dots[6].style.display = 'block';
                            break;
                        case 6: // All corners + middle
                            dots[1].style.display = 'block';
                            dots[2].style.display = 'block';
                            dots[3].style.display = 'block';
                            dots[4].style.display = 'block';
                            dots[5].style.display = 'block';
                            dots[6].style.display = 'block';
                            break;
                    }
                });
            }
            
            function rollAllDice() {
                // Hide total display during roll
                totalDisplay.classList.remove('show-total');
                
                // Roll each die with a slight delay between them
                diceElements.forEach((dice, index) => {
                    setTimeout(() => {
                        rollSingleDice(dice, true);
                    }, index * 150);
                });
                
                // Show total after all dice finish rolling
                setTimeout(() => {
                    updateTotal();
                    totalDisplay.classList.add('show-total');
                }, 2500);
            }
            
            function updateTotal() {
                let total = 0;
                let allRolled = true;
                
                diceElements.forEach(dice => {
                    const value = dice.getAttribute('data-value');
                    if (value) {
                        total += parseInt(value);
                    } else {
                        allRolled = false;
                    }
                });
                
                if (allRolled) {
                    totalDisplay.textContent = `Total: ${total}`;
                } else {
                    totalDisplay.textContent = '';
                }
            }
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <a href="https://enzostvs-deepsite.hf.space" style="color: #fff;" target="_blank" >DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
</html>