From 29fefe94613e4ff8f63c7a1871af8fdf0cd4f656 Mon Sep 17 00:00:00 2001
From: Pinapelz <yukais@pinapelz.com>
Date: Thu, 16 Apr 2026 23:42:42 -0700
Subject: type: make bga opacity setting persist site-wide

---
 src/app/game/page.tsx | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

(limited to 'src/app/game/page.tsx')

diff --git a/src/app/game/page.tsx b/src/app/game/page.tsx
index 02ea319..dc0d93d 100644
--- a/src/app/game/page.tsx
+++ b/src/app/game/page.tsx
@@ -122,19 +122,18 @@ function GameInner() {
   const [clearShowing, setClearShowing] = useState(false);
   const [comboAnimKey, setComboAnimKey] = useState(0);
   const [countdown, setCountdown] = useState(0);
-  const [backgroundOpacity, setBackgroundOpacity] = useState(0);
+  const [backgroundOpacity, setBackgroundOpacity] = useState(() => {
+    if (typeof window === "undefined") return 0;
+    const stored = localStorage.getItem(BACKGROUND_OPACITY_KEY);
+    if (stored === null) return 0;
+    const parsed = Number(stored);
+    if (!Number.isFinite(parsed)) return 0;
+    return Math.min(100, Math.max(0, parsed));
+  });
   const [skipBacking, setSkipBacking] = useState(false);
   const isVideo = useMemo(() => isVideoUrl(audioUrl), [audioUrl]);
 
-  useEffect(() => {
-    const stored = localStorage.getItem(BACKGROUND_OPACITY_KEY);
-    if (stored === null) return;
-    const parsed = Number(stored);
-    if (Number.isFinite(parsed)) {
-      const clamped = Math.min(100, Math.max(0, parsed));
-      setBackgroundOpacity(clamped);
-    }
-  }, []);
+
 
   useEffect(() => {
     localStorage.setItem(BACKGROUND_OPACITY_KEY, String(backgroundOpacity));
-- 
cgit v1.2.3

