const canvas = document.getElementById('matrix-rain'); if (canvas && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) { const ctx = canvas.getContext('2d'); const chars = 'アカサタナハマヤラワ0123456789ABCDEFcacto$#@%&*'.split(''); const fontSize = 15; const bg = getComputedStyle(document.documentElement).getPropertyValue('--color-bg').trim(); let columns = 0; let drops = []; function setup() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; columns = Math.floor(canvas.width / fontSize); drops = new Array(columns).fill(0).map(() => Math.floor((Math.random() * canvas.height) / fontSize)); } function draw() { ctx.fillStyle = `${bg}cc`; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.font = `${fontSize}px monospace`; for (let i = 0; i < columns; i++) { const char = chars[Math.floor(Math.random() * chars.length)]; const x = i * fontSize; const y = drops[i] * fontSize; // «голова» капли — редкая, чуть ярче, со свечением const isHead = Math.random() > 0.94; ctx.shadowColor = 'rgba(100, 255, 160, 0.9)'; ctx.shadowBlur = isHead ? 10 : 0; ctx.fillStyle = isHead ? '#d2ffe1' : Math.random() > 0.98 ? '#9fa3a0' : '#00ff41'; ctx.fillText(char, x, y); if (y > canvas.height && Math.random() > 0.975) { drops[i] = 0; } else { drops[i]++; } } ctx.shadowBlur = 0; } setup(); window.addEventListener('resize', setup); setInterval(draw, 50); }