/* soccerarena.ai — shared app shell. Exports useCountdown, AppHeader, AppFooter. */ const { useState: useStateS, useEffect: useEffectS } = React; const SA_HOME = 'index.html'; function useCountdown() { const KEY = 'sa-next-match-target'; const read = () => { let target = 0; try { target = parseInt(localStorage.getItem(KEY) || '0', 10); } catch (e) { target = 0; } const now = Date.now(); if (!target || target <= now) { target = now + ARENA.tournament.nextMatchSeconds * 1000; try { localStorage.setItem(KEY, String(target)); } catch (e) { /* no-op */ } } return Math.max(0, Math.round((target - now) / 1000)); }; const start = read(); const [s, setS] = useStateS(start); useEffectS(() => { let cur = start; const id = setInterval(() => { cur = cur > 0 ? cur - 1 : 0; setS(cur); }, 1000); return () => clearInterval(id); }, []); const h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60), sec = s % 60; if (h >= 24) { const days = Math.floor(h / 24); return `${days}d ${h % 24}h ${String(m).padStart(2, '0')}m`; } return `${h}h ${String(m).padStart(2, '0')}m ${String(sec).padStart(2, '0')}s`; } function LiveStat({ countdown }) { const t = ARENA.tournament; return (