:root {
            --yang-color: #2c3e50;
            --yin-color: #c0392b;
            --bg-color: #f0f2f5;
            --primary: #1A535C; 
            --success: #27ae60;
            --danger: #e74c3c;
            --accent: #f1c40f;
            --text-dark: #2c2c2c;
        }
        
        body { 
            font-family: 'Georgia', "PingFang TC", "Microsoft JhengHei", serif; 
            background: var(--bg-color); 
            margin: 0; 
            display: flex; 
            flex-direction: column; /* 修正：設定為垂直排列 */
            min-height: 100vh; 
            overflow: auto; /* 修正：避免吃掉 Footer，改為 auto */
            color: var(--text-dark); 
        }

        /* 通用狀態容器 */
        .state-container { 
            display: none; 
            width: 100%; 
            flex-grow: 1; /* 修正：讓內容自動填滿剩餘高度 */
            justify-content: center; 
            align-items: center; 
            transition: opacity 0.5s ease-in-out; 
            flex-direction: column; 
            padding: 20px 0; /* 修正：增加上下緩衝，避免太擠 */
        }
        
        .active-state { display: flex; opacity: 1; }

        /* ==================== 首頁 (太極旋轉) ==================== */
        #home-state-container {
            gap: 40px;
        }
        #home-state-container h1 {
            color: var(--primary);
            text-shadow: 0 2px 4px rgba(0,0,0,0.1);;
            font-size: 2.5em;
            margin: 0;
            letter-spacing: 2px;
            text-align: center;
        }

        #taiji-animator {
            width: 280px;  
            height: 280px; 
            cursor: pointer;
            background-image: url('taiji_sprite.jpg');
            background-size: 1400px 280px; 
            background-position: 0 0;
            animation: playTaijiSprite 1.5s steps(5) infinite;
            border-radius: 12px; 
            box-shadow: 0 0 30px rgba(241, 196, 15, 0.3);
            transition: box-shadow 0.3s ease, transform 0.3s ease;
        }
        
        #taiji-animator:hover {
            box-shadow: 0 0 50px rgba(241, 196, 15, 0.8);
            transform: scale(1.05); 
            animation-duration: 0.8s; 
        }

        @keyframes playTaijiSprite {
            from { background-position: 0 0; }
            to { background-position: -1400px 0; }
        }

        .start-hint {
            color: #666;
            font-size: 1.2em;
            margin: 0;
            animation: pulseText 2s infinite;
        }
        @keyframes pulseText {
            0%, 100% { opacity: 0.6; }
            50% { opacity: 1; }
        }

        /* ==================== 遊戲頁面 ==================== */
        .game-card { background: white; width: 95%; max-width: 500px; padding: 30px; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.1); text-align: center; }
        
        .header-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; font-size: 0.9em; color: #666; }
        .level-indicator { font-weight: bold; color: var(--primary); font-size: 1.2em; }
        .streak-bar { display: flex; justify-content: center; gap: 8px; margin: 15px 0 25px; min-height: 20px; }
        .dot { width: 14px; height: 14px; border-radius: 50%; background: #ddd; transition: 0.3s; }
        .dot.active { background: var(--success); transform: scale(1.2); }

        .hint-box { background: #f9fbfb; border-left: 5px solid var(--primary); padding: 15px; text-align: left; font-size: 0.95em; margin-bottom: 25px; color: #444; border-radius: 0 8px 8px 0; min-height: 50px; line-height: 1.5; }

        .stage-area { min-height: 220px; display: flex; flex-direction: column-reverse; justify-content: center; align-items: center; gap: 15px; margin: 25px 0; }
        .yao { width: 220px; height: 35px; position: relative; border-radius: 4px; }
        .yao-label { position: absolute; left: -65px; top: 8px; font-size: 0.85em; color: #888; width: 60px; text-align: right; }
        .yang { background: var(--yang-color); }
        .yin { display: flex; justify-content: space-between; }
        .yin::before, .yin::after { content: ""; width: 44%; height: 100%; background: var(--yin-color); border-radius: 4px; }
        .hidden-yao { opacity: 0.08; }

        .btn-group { display: flex; gap: 15px; justify-content: center; margin-top: 15px; }
        button { padding: 14px 0; font-size: 1.1em; cursor: pointer; border: none; border-radius: 4px; background: var(--primary); color: white; transition: 0.3s; min-width: 130px; font-weight: bold; letter-spacing: 1px; }
        button:hover { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.15); }
        button.btn-alt { background: #7f8c8d; }

        #final-screen { display: none; }
        .score { font-size: 4.5em; color: var(--success); font-weight: bold; margin: 10px 0; }
        .time-result { font-size: 1.2em; color: #555; margin-bottom: 30px; }

        /* ==================== 自定義居中彈窗 ==================== */
        .modal-overlay {
            display: none; 
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0, 0, 0, 0.6);
            z-index: 1000;
            justify-content: center;
            align-items: center;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        .modal-overlay.show {
            display: flex;
            opacity: 1;
        }
        .modal-box {
            background: white;
            padding: 30px 40px;
            border-radius: 12px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.3);
            text-align: center;
            max-width: 80%;
            transform: scale(0.8);
            transition: transform 0.3s ease;
        }
        .modal-overlay.show .modal-box {
            transform: scale(1);
        }
        .modal-box p {
            font-size: 1.2em;
            color: var(--text-dark);
            margin: 0 0 25px 0;
            font-weight: bold;
            line-height: 1.5;
        }
        .modal-box button {
            min-width: 120px;
            padding: 12px 0;
        }