class StatMeter extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); document.addEventListener('state-update', () => this.update()); this.update(); } update() { const label = this.getAttribute('label'); const icon = this.getAttribute('icon'); const val = state.stats[label] || 0; // Color logic based on value - "Invisible Future Meter" logic let colorClass = '#22c55e'; // Green let glowClass = ''; if (val < 30) { colorClass = '#ef4444'; // Red - Danger glowClass = 'box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);'; } else if (val < 60) { colorClass = '#eab308'; // Yellow - Caution } else { colorClass = '#3b82f6'; // Blue - Good (using blue for high stat instead of green for money) } // Icon mapping const iconMap = { 'stability': 'shield', 'safety': 'activity', 'debt': 'arrow-down-circle', 'scamRisk': 'alert-triangle', 'wealth': 'trending-up' }; this.shadowRoot.innerHTML = `