-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
685 lines (610 loc) · 25.9 KB
/
App.tsx
File metadata and controls
685 lines (610 loc) · 25.9 KB
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
import React, { useState, useCallback, useRef, useEffect } from 'react';
import { Player } from './types';
import { INITIAL_PLAYERS, WHEEL_COLORS, PRESET_PLAYERS } from './constants';
import Wheel from './components/Wheel';
import Controls from './components/Controls';
import WinRipple from './components/WinRipple';
import WinnerModal from './components/WinnerModal';
import Confetti from './components/Confetti';
import { Play, Zap, History, Trophy } from 'lucide-react';
import { ensureAudio, playTick, playWin, playSpinStart } from './utils/audio';
// Helper for cubic-bezier(0.1, 0, 0.18, 1) approximation
// We need this to calculate where the wheel IS during the JS loop to play sounds correctly
function cubicBezier(t: number): number {
const p0 = 0, p1 = 0, p2 = 0.18, p3 = 1; // Simplified for the specific curve
// Since x1=0.1, y1=0 and x2=0.18, y2=1.
// This is a custom approximation for performance:
// It starts very fast and decays exponentially.
// 1 - (1-t)^4 is a standard EaseOutQuart which is close to the CSS look
return 1 - Math.pow(1 - t, 4);
}
const PLAYERS_STORAGE_KEY = 'asmodeus_players';
const HISTORY_STORAGE_KEY = 'asmodeus_history';
const CONFETTI_DURATION = 2200;
const SOUND_STORAGE_KEY = 'asmodeus_sound';
const MODE_STORAGE_KEY = 'asmodeus_elimination';
const DEMO_STORAGE_KEY = 'asmodeus_demo';
const STREAMER_STORAGE_KEY = 'asmodeus_streamer';
const normalizePlayers = (raw: any[], colorOffset = 0): Player[] => {
if (!Array.isArray(raw)) return [];
return raw
.filter((item) => item && typeof item.name === 'string')
.map((item, index) => ({
id: typeof item.id === 'string' ? item.id : crypto.randomUUID(),
name: item.name,
color:
typeof item.color === 'string'
? item.color
: WHEEL_COLORS[(index + colorOffset) % WHEEL_COLORS.length],
}));
};
const App: React.FC = () => {
const [players, setPlayers] = useState<Player[]>(() => {
if (typeof window !== 'undefined') {
const saved = localStorage.getItem(PLAYERS_STORAGE_KEY);
if (saved) {
try {
const parsed = JSON.parse(saved);
const normalized = normalizePlayers(parsed);
if (normalized.length) {
return normalized;
}
} catch (err) {
console.warn('Could not read players from localStorage', err);
}
}
}
return INITIAL_PLAYERS.map((name, i) => ({
id: crypto.randomUUID(),
name,
color: WHEEL_COLORS[i % WHEEL_COLORS.length],
}));
});
const [rotation, setRotation] = useState(0);
const [isSpinning, setIsSpinning] = useState(false);
const [winner, setWinner] = useState<Player | null>(null);
const [history, setHistory] = useState<Player[]>(() => {
if (typeof window !== 'undefined') {
const saved = localStorage.getItem(HISTORY_STORAGE_KEY);
if (saved) {
try {
const parsed = JSON.parse(saved);
return normalizePlayers(parsed).slice(0, 5);
} catch (err) {
console.warn('Could not read history from localStorage', err);
}
}
}
return [];
});
const [eliminationMode, setEliminationMode] = useState(() => {
if (typeof window !== 'undefined') {
const saved = localStorage.getItem(MODE_STORAGE_KEY);
if (saved) return saved === 'true';
}
return false;
});
const [soundEnabled, setSoundEnabled] = useState(() => {
if (typeof window !== 'undefined') {
const saved = localStorage.getItem(SOUND_STORAGE_KEY);
if (saved) return saved === 'true';
}
return true;
});
const [demoMode, setDemoMode] = useState(() => {
if (typeof window !== 'undefined') {
const saved = localStorage.getItem(DEMO_STORAGE_KEY);
if (saved) return saved === 'true';
}
return false;
});
const [confettiTrigger, setConfettiTrigger] = useState(0);
const [highlightId, setHighlightId] = useState<string | null>(null);
const [sparkBurst, setSparkBurst] = useState(0);
const [beamTrigger, setBeamTrigger] = useState(0);
const [liveMessage, setLiveMessage] = useState('');
const [rippleTrigger, setRippleTrigger] = useState(0);
const [streamerMode, setStreamerMode] = useState(() => {
if (typeof window !== 'undefined') {
const saved = localStorage.getItem(STREAMER_STORAGE_KEY);
if (saved) return saved === 'true';
}
return false;
});
const [countdown, setCountdown] = useState(10);
const [isReady, setIsReady] = useState(false);
// Audio state refs
const lastTickRef = useRef<number>(0);
const animationFrameRef = useRef<number>(0);
const beamTimeoutRef = useRef<number>(0);
const wheelContainerRef = useRef<HTMLDivElement>(null);
const [wheelSize, setWheelSize] = useState(300);
useEffect(() => {
const handleResize = () => {
if (wheelContainerRef.current) {
const { width, height } = wheelContainerRef.current.getBoundingClientRect();
const isMobile = window.innerWidth < 1024;
const dimension = isMobile ? width : Math.min(width, height);
const padding = isMobile ? 40 : 40;
setWheelSize((dimension / 2) - padding);
}
};
const debouncedResize = () => requestAnimationFrame(handleResize);
window.addEventListener('resize', debouncedResize);
handleResize();
return () => window.removeEventListener('resize', debouncedResize);
}, []);
const handleSpin = useCallback(() => {
if (isSpinning || players.length < 2) return;
setWinner(null);
setHighlightId(null);
setIsSpinning(true);
window.clearTimeout(beamTimeoutRef.current);
if (window.innerWidth < 1024) {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
// CSS Animation Duration
const duration = 10000;
const spinCount = 8; // More spins for dramatic effect
const randomDegree = Math.floor(Math.random() * 360);
const startRotation = rotation;
const targetRotation = startRotation + (360 * spinCount) + randomDegree;
setRotation(targetRotation);
if (soundEnabled) {
ensureAudio();
playSpinStart();
}
// Light beam near final turns
beamTimeoutRef.current = window.setTimeout(() => {
setBeamTrigger((prev) => prev + 1);
}, duration * 0.7);
// Audio Sync Loop
// We simulate the rotation in JS to trigger sounds when passing pegs
const startTime = performance.now();
const segmentSize = 360 / players.length;
const tick = () => {
const now = performance.now();
const elapsed = now - startTime;
const progress = Math.min(elapsed / duration, 1);
// Calculate current virtual rotation based on easing
const easedProgress = cubicBezier(progress);
const currentRotation = startRotation + (targetRotation - startRotation) * easedProgress;
// Check if we passed a segment boundary (peg)
// We check if the integer division of segment size changed
// Offset by -90 because the pointer is at the top
const currentTickIndex = Math.floor((currentRotation) / segmentSize);
if (currentTickIndex > lastTickRef.current) {
// Only play if moving fast enough (don't click on the very last slow creep)
if (progress < 0.98) {
if (soundEnabled) {
playTick();
}
setSparkBurst((prev) => prev + 1);
}
lastTickRef.current = currentTickIndex;
}
if (progress < 1) {
animationFrameRef.current = requestAnimationFrame(tick);
}
};
lastTickRef.current = Math.floor(startRotation / segmentSize);
cancelAnimationFrame(animationFrameRef.current);
animationFrameRef.current = requestAnimationFrame(tick);
}, [rotation, isSpinning, players.length, soundEnabled]);
// Keyboard support (Spacebar to spin)
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
const target = e.target as HTMLElement | null;
const isInput = target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA');
if (e.code === 'Space' && !isSpinning && !winner && players.length >= 2) {
// Prevent scrolling down
e.preventDefault();
handleSpin();
return;
}
if (isInput) return;
if (e.code === 'KeyS') {
e.preventDefault();
handleToggleSound();
return;
}
if (e.code === 'KeyD') {
e.preventDefault();
setDemoMode((prev) => !prev);
return;
}
};
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [isSpinning, winner, players, handleSpin]);
useEffect(() => {
if (typeof window === 'undefined') return;
localStorage.setItem(PLAYERS_STORAGE_KEY, JSON.stringify(players));
}, [players]);
useEffect(() => {
if (typeof window === 'undefined') return;
localStorage.setItem(HISTORY_STORAGE_KEY, JSON.stringify(history));
}, [history]);
useEffect(() => {
if (soundEnabled) {
ensureAudio();
}
if (typeof window !== 'undefined') {
localStorage.setItem(SOUND_STORAGE_KEY, String(soundEnabled));
}
}, [soundEnabled]);
useEffect(() => {
if (typeof window !== 'undefined') {
localStorage.setItem(MODE_STORAGE_KEY, String(eliminationMode));
}
}, [eliminationMode]);
useEffect(() => {
if (typeof window !== 'undefined') {
localStorage.setItem(DEMO_STORAGE_KEY, String(demoMode));
}
}, [demoMode]);
useEffect(() => {
if (typeof window !== 'undefined') {
localStorage.setItem(STREAMER_STORAGE_KEY, String(streamerMode));
}
}, [streamerMode]);
// Demo mode auto-spin
useEffect(() => {
if (!demoMode) return;
if (isSpinning) return;
if (winner) return;
if (players.length < 2) return;
const delay = 8000 + Math.random() * 4000;
const timer = window.setTimeout(() => {
handleSpin();
}, delay);
return () => window.clearTimeout(timer);
}, [demoMode, isSpinning, winner, players.length, handleSpin]);
// Auto add players for demo
useEffect(() => {
if (!demoMode) return;
if (players.length >= 2) return;
setPlayers((prev) => {
if (prev.length >= 2) return prev;
const startIndex = prev.length;
const additions = PRESET_PLAYERS.slice(0, 6 - startIndex).map((name, i) => ({
id: crypto.randomUUID(),
name,
color: WHEEL_COLORS[(startIndex + i) % WHEEL_COLORS.length],
}));
return [...prev, ...additions];
});
}, [demoMode, players.length]);
useEffect(() => {
return () => {
window.clearTimeout(beamTimeoutRef.current);
};
}, []);
// Streamer mode countdown
useEffect(() => {
if (!streamerMode) return;
if (isSpinning) return;
const interval = window.setInterval(() => {
setCountdown((prev) => {
if (prev <= 1) {
handleSpin();
return 10;
}
return prev - 1;
});
}, 1000);
return () => window.clearInterval(interval);
}, [streamerMode, isSpinning, handleSpin]);
useEffect(() => {
const timer = window.setTimeout(() => setIsReady(true), 400);
return () => window.clearTimeout(timer);
}, []);
const handleAddPlayer = (name: string, color: string) => {
const trimmed = name.trim();
if (!trimmed) return;
const exists = players.some((p) => p.name.toLowerCase() === trimmed.toLowerCase());
if (exists) {
alert('Name already exists');
setLiveMessage(`${trimmed} is already in the list`);
return;
}
setPlayers((prev) => [...prev, { id: crypto.randomUUID(), name: trimmed, color }]);
setLiveMessage(`Added player ${trimmed}`);
};
const handleRemovePlayer = (id: string) => {
const removed = players.find((p) => p.id === id);
setPlayers((prev) => prev.filter((p) => p.id !== id));
if (removed) {
setLiveMessage(`Removed player ${removed.name}`);
}
};
const handleReorderPlayers = (from: number, to: number) => {
setPlayers((prev) => {
const next = [...prev];
const [moved] = next.splice(from, 1);
next.splice(to, 0, moved);
return next;
});
};
const handleAddPreset = () => {
setPlayers((prev) => {
const lower = new Set(prev.map((p) => p.name.toLowerCase()));
const additions = PRESET_PLAYERS.filter((n) => !lower.has(n.toLowerCase()));
if (!additions.length) return prev;
const startIndex = prev.length;
const newPlayers = additions.map((name, i) => ({
id: crypto.randomUUID(),
name,
color: WHEEL_COLORS[(startIndex + i) % WHEEL_COLORS.length],
}));
return [...prev, ...newPlayers];
});
};
const handleReset = () => {
if (confirm("Reset all players?")) {
setPlayers(
INITIAL_PLAYERS.map((name, i) => ({
id: crypto.randomUUID(),
name,
color: WHEEL_COLORS[i % WHEEL_COLORS.length],
}))
);
setHistory([]);
setWinner(null);
setLiveMessage('Player list reset');
}
};
const handleSpinEnd = () => {
setIsSpinning(false);
cancelAnimationFrame(animationFrameRef.current);
const actualRotation = rotation % 360;
const sliceAngle = 360 / players.length;
const winningIndex = Math.floor((players.length - (actualRotation / sliceAngle) % players.length)) % players.length;
const winPlayer = players[winningIndex];
setWinner(winPlayer);
setHighlightId(winPlayer.id);
setHistory(prev => [winPlayer, ...prev].slice(0, 5));
setLiveMessage(`${winPlayer.name} won`);
setRippleTrigger((prev) => prev + 1);
if (soundEnabled) {
playWin();
}
setConfettiTrigger((prev) => prev + 1);
};
const handleModalClose = () => {
setWinner(null);
if (eliminationMode && winner) {
handleRemovePlayer(winner.id);
}
};
const handleToggleSound = () => {
setSoundEnabled((prev) => {
const next = !prev;
if (!prev) {
ensureAudio();
}
return next;
});
};
return (
<div className="min-h-screen lg:h-screen bg-[#020617] text-slate-200 flex flex-col lg:flex-row lg:overflow-hidden font-sans selection:bg-red-500 selection:text-white relative">
{!isReady && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur">
<div className="flex flex-col items-center gap-4 text-center">
<div className="w-24 h-24 rounded-full border-4 border-fuchsia-500/40 border-t-transparent animate-spin"></div>
<div className="text-sm font-mono text-slate-300">Initializing systems...</div>
</div>
</div>
)}
<div className="floating-stripes"></div>
<div className="noise-overlay"></div>
<div className="grid-overlay"></div>
<div className="scanlines"></div>
<div className="fixed inset-0 z-0 opacity-10 pointer-events-none"
style={{ backgroundImage: 'radial-gradient(#475569 1px, transparent 1px)', backgroundSize: '40px 40px' }}>
</div>
{/* Ambient layers */}
<div className="floating-particles" aria-hidden>
{Array.from({ length: 32 }).map((_, i) => (
<span
key={i}
className={`dot ${i % 3 === 0 ? 'alt' : ''}`}
style={{
left: `${Math.random() * 100}%`,
top: `${Math.random() * 100}%`,
animationDelay: `${Math.random() * 6}s`,
}}
/>
))}
</div>
{/* LEFT PANEL */}
<div
className="relative w-full h-auto lg:h-full lg:flex-1 bg-gradient-to-br from-slate-950 via-[#050b1d] to-slate-950 flex flex-col items-center justify-start lg:justify-center p-0 lg:p-0 order-1 lg:order-1 shrink-0"
>
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[600px] bg-fuchsia-900/10 rounded-full blur-[100px] pointer-events-none fixed lg:absolute"></div>
<div className="lg:hidden w-full text-center pt-10 pb-2 z-20 relative">
<h1 className="text-4xl font-display font-black text-white tracking-tight neon-text italic">ASMODEUS</h1>
</div>
<div ref={wheelContainerRef} className="w-full flex items-center justify-center relative z-10 py-8 lg:py-0 lg:h-full min-h-[350px]">
<Wheel
players={players}
rotation={rotation}
radius={Math.max(100, wheelSize)}
onSpinEnd={handleSpinEnd}
isSpinning={isSpinning}
highlightId={highlightId}
sparkBurst={sparkBurst}
beamTrigger={beamTrigger}
/>
</div>
<div className="absolute bottom-2 left-4 text-[10px] font-mono text-slate-700 hidden lg:block">
SYS.VER.2.1.0 // AUDIO_ENABLED
</div>
</div>
{/* RIGHT PANEL */}
<div
className="w-full h-auto lg:h-full lg:w-[450px] glass-panel bg-slate-900/80 border-t lg:border-t-0 lg:border-l border-slate-800/70 flex flex-col z-20 shadow-2xl order-2 lg:order-2 relative overflow-hidden"
>
<div className="absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-white/5 to-transparent pointer-events-none"></div>
<div className="p-3 lg:p-6 border-b border-slate-800/70 bg-slate-950/40 hidden lg:block">
<div className="flex items-center gap-3 mb-2">
<div className="w-2 h-2 bg-red-500 rounded-full animate-pulse shadow-[0_0_10px_red]"></div>
<h2 className="text-xs font-mono text-red-500 tracking-[0.3em]">COMMAND CENTER</h2>
</div>
<h1 className="text-4xl font-display font-black text-white tracking-tight neon-text italic">
ASMODEUS
</h1>
<div className="flex flex-wrap items-center gap-2 mt-3">
<span className="chip chip-red">Game Mode</span>
<span className="chip chip-cyan">Elimination {eliminationMode ? 'On' : 'Off'}</span>
<span className="chip chip-amber">Sound {soundEnabled ? 'On' : 'Off'}</span>
</div>
<div className="hud-line mt-4"></div>
</div>
<div className="flex-none lg:flex-1 lg:overflow-y-auto custom-scrollbar flex flex-col p-4 lg:p-6 gap-4">
<div className="w-full glass-panel holo-card rounded-xl border border-slate-800/60 shadow-xl relative overflow-hidden p-4 lg:p-5">
<div className="hud-line absolute top-0 left-0 right-0" aria-hidden></div>
<Controls
players={players}
onAddPlayer={handleAddPlayer}
onRemovePlayer={handleRemovePlayer}
onReorderPlayers={handleReorderPlayers}
onAddPreset={handleAddPreset}
onReset={handleReset}
isSpinning={isSpinning}
eliminationMode={eliminationMode}
setEliminationMode={setEliminationMode}
highlightId={highlightId}
/>
<div className="grid grid-cols-2 gap-2 mt-4 text-[11px] font-mono text-slate-400 uppercase tracking-tight">
<div className="bg-slate-900/70 border border-slate-800/60 rounded-lg px-3 py-2 flex items-center justify-between">
<span>Players</span>
<span className="text-cyan-400 font-bold">{players.length}</span>
</div>
<div className="bg-slate-900/70 border border-slate-800/60 rounded-lg px-3 py-2 flex items-center justify-between">
<span>Mode</span>
<span className="text-amber-300 font-bold">{eliminationMode ? 'Eliminate' : 'Classic'}</span>
</div>
<div className="bg-slate-900/70 border border-slate-800/60 rounded-lg px-3 py-2 flex items-center justify-between">
<span>Sound</span>
<span className="text-emerald-300 font-bold">{soundEnabled ? 'Enabled' : 'Muted'}</span>
</div>
<div className="bg-slate-900/70 border border-slate-800/60 rounded-lg px-3 py-2 flex items-center justify-between">
<span>History</span>
<span className="text-fuchsia-300 font-bold">{history.length}</span>
</div>
</div>
</div>
{history.length > 0 && (
<div className="hidden lg:block glass-panel holo-card rounded-xl p-4 border border-slate-800/70 shrink-0 shadow-xl relative overflow-hidden">
<div className="absolute inset-x-0 top-0 h-1 hud-line" aria-hidden></div>
<div className="flex items-center gap-2 mb-3 text-slate-400">
<History className="w-4 h-4" />
<span className="text-xs font-bold uppercase tracking-wider">Recent Victories</span>
</div>
<div className="space-y-2">
{history.map((h, i) => (
<div
key={`${h.id}-${i}`}
className={`flex items-center justify-between text-sm px-2 py-1 rounded ${
highlightId === h.id && i === 0 ? 'bg-fuchsia-500/10 border border-fuchsia-400/40 shadow-[0_0_12px_rgba(236,72,153,0.3)]' : ''
}`}
>
<span className="text-slate-300 font-display">{h.name}</span>
{i === 0 && <Trophy className="w-3 h-3 text-yellow-500" />}
</div>
))}
</div>
</div>
)}
</div>
<div className="p-4 lg:p-6 bg-slate-950/90 border-t border-slate-800 shrink-0 pb-safe-area sticky bottom-0 lg:relative z-30">
<div className="accent-bar mb-4" aria-hidden></div>
<button
onClick={handleSpin}
disabled={isSpinning || players.length < 2}
aria-label={isSpinning ? 'Wheel is spinning' : `Spin the wheel. Players: ${players.length}`}
className={`w-full relative overflow-hidden group py-4 lg:py-5 rounded-md font-display font-black text-lg lg:text-xl tracking-widest transition-all ${
isSpinning || players.length < 2
? 'bg-slate-800 text-slate-600 cursor-not-allowed border border-slate-700'
: 'bg-red-600 text-white hover:bg-red-500 shadow-[0_0_20px_rgba(220,38,38,0.4)] hover:shadow-[0_0_30px_rgba(220,38,38,0.6)] border border-red-500'
}`}
>
<div className="flex items-center justify-center gap-3 relative z-10">
{isSpinning ? (
<>
<Zap className="w-5 h-5 animate-spin" /> <span className="text-sm lg:text-xl">PROCESSING</span>
</>
) : (
<>
<Play fill="currentColor" className="w-5 h-5" /> <span className="text-sm lg:text-xl">INITIATE SPIN (SPACE)</span>
</>
)}
</div>
{!isSpinning && players.length >= 2 && (
<div className="absolute inset-0 bg-white/20 translate-y-full group-hover:translate-y-0 transition-transform duration-300"></div>
)}
</button>
<div className="mt-2 lg:mt-3 flex justify-between items-center text-[10px] text-slate-600 font-mono uppercase gap-3">
<span>Status: {isSpinning ? 'ACTIVE' : 'READY'}</span>
<div className="flex items-center gap-2">
<button
onClick={handleToggleSound}
className={`px-2 py-1 rounded border transition-colors ${
soundEnabled
? 'border-cyan-500 text-cyan-400 bg-cyan-500/10'
: 'border-slate-700 text-slate-500 hover:text-slate-300 hover:border-slate-500'
}`}
title="Toggle sound"
>
Sound: {soundEnabled ? 'On' : 'Off'}
</button>
<button
onClick={() => setDemoMode((prev) => !prev)}
className={`px-2 py-1 rounded border transition-colors ${
demoMode
? 'border-amber-400 text-amber-300 bg-amber-400/10'
: 'border-slate-700 text-slate-500 hover:text-slate-300 hover:border-slate-500'
}`}
title="Demo mode: auto-spin"
>
Demo: {demoMode ? 'On' : 'Off'}
</button>
<button
onClick={() => setStreamerMode((prev) => !prev)}
className={`px-2 py-1 rounded border transition-colors ${
streamerMode
? 'border-green-400 text-green-300 bg-green-400/10'
: 'border-slate-700 text-slate-500 hover:text-slate-300 hover:border-slate-500'
}`}
title="Streamer mode: fullscreen + auto-spin timer"
>
Streamer: {streamerMode ? 'On' : 'Off'}
</button>
<span>{players.length} SOULS LOADED</span>
</div>
</div>
<div className="mt-1 text-[10px] text-slate-500 font-mono uppercase">Space — Spin, S — Sound, D — Demo</div>
{streamerMode && !isSpinning && (
<div className="mt-3 text-xs text-emerald-300 font-mono flex items-center justify-between">
<span>Auto-spin in {countdown}s</span>
<button
onClick={handleSpin}
className="px-3 py-2 rounded-md bg-emerald-600 text-white font-semibold tracking-wide text-xs hover:bg-emerald-500 shadow-[0_0_15px_rgba(16,185,129,0.35)]"
>
Next spin now
</button>
</div>
)}
</div>
</div>
<WinnerModal winner={winner} onClose={handleModalClose} />
<Confetti trigger={confettiTrigger} duration={CONFETTI_DURATION} />
<WinRipple trigger={rippleTrigger} color={winner?.color || '#ef4444'} />
<div className="sr-only" aria-live="polite">
{(winner ? `${winner.name} won` : isSpinning ? 'Wheel is spinning' : 'Ready') + '. ' + (liveMessage || '')}
</div>
</div>
);
};
export default App;