:root {
    /* --- 深色模式 (預設) --- */
    --bg-main: #081023;
    --bg-gradient: linear-gradient(180deg, var(--bg-main), #050613);
    
    /* 介面背景 */
    --bg-panel: linear-gradient(180deg, rgba(8, 16, 35, 0.95), rgba(5, 8, 20, 0.95));
    --bg-card: linear-gradient(145deg, rgba(30, 40, 60, 0.8), rgba(10, 15, 30, 0.9));
    --bg-key: #2b2e3b;
    --bg-key-special: #3e4252;
    --border-color: rgba(74, 170, 255, 0.15);
    --shadow-color: rgba(0, 0, 0, 0.8);

    /* 文字顏色 */
    --text-main: #dfe9ff;        
    --text-sub: #aaaaaa;         
    --text-heading: #9ff8ff;     
    --text-highlight: #ffffff;   
    
    /* 遊戲狀態顏色 */
    --color-correct: #4affaa;    
    --color-wrong: #ff4a6e;      
    --color-current: #00f7ff;    
    --color-combo: #ffd700;      
    --color-accent: #4af;        
    
    /* 軌道與方塊 */
    --lane-border: rgba(74, 170, 255, 0.12);
    --lane-bg: linear-gradient(90deg, rgba(255, 255, 255, 0.01) 0%, rgba(74, 170, 255, 0.05) 66.66%, rgba(74, 170, 255, 0.15) 100%);
    --tile-bg: rgba(255, 255, 255, 0.95);
    --tile-text: #0a0a0a;
    
    /* 統計與熱力圖 */
    --stat-bar-bg: rgba(255,255,255,0.1);
    --hm-bg: rgba(0, 0, 0, 0.2);
    --hm-key-bg: rgba(255,255,255,0.05);
    --hm-text: #ccc;

    --expand-row-bg: rgba(0, 0, 0, 0.2);

    --practice-font-size: 24px; /* [新增] 預設字體大小 */
}

/* === 淺色模式覆蓋 === */
body.light-mode {
    --bg-main: #f0f2f5;
    --bg-gradient: #f0f2f5;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-key: #f0f0f0;
    --bg-key-special: #e0e0e0;
    --border-color: #cccccc;
    --shadow-color: rgba(0, 0, 0, 0.15);

    --text-main: #333333;        
    --text-sub: #666666;         
    --text-heading: #0056b3;     
    --text-highlight: #000000;   
    
    --color-correct: #008a2e;    
    --color-wrong: #d32f2f;      
    --color-current: #0056b3;    
    --color-combo: #e65100;      
    --color-accent: #0056b3;     
    
    --lane-border: rgba(0, 0, 0, 0.1);
    --lane-bg: linear-gradient(90deg, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0.05) 66%, rgba(0, 86, 179, 0.1) 100%);
    --tile-bg: #ffffff;
    --tile-text: #333333;
    
    --stat-bar-bg: rgba(0,0,0,0.1);
    --hm-bg: #e0e0e0;
    --hm-key-bg: #ffffff;
    --hm-text: #000000;

    --expand-row-bg: rgba(0, 0, 0, 0.05);
}

html, body {
    height: 100%; margin: 0; 
    background: var(--bg-gradient);
    font-family: 'Roboto Mono', 'Fira Code', Consolas, monospace;
    color: var(--text-main); 
    overflow: hidden; 
    transition: background 0.3s, color 0.3s;
}

/* 文字顏色工具類別 */
.text-correct { color: var(--color-correct) !important; }
.text-warn { color: var(--color-combo) !important; }
.text-danger { color: var(--color-wrong) !important; }
.text-current { color: var(--color-current) !important; }
.label-bold { font-weight: bold; }
.settings-subtitle { color: var(--text-heading); font-size: 14px; margin-bottom: 8px; font-weight: bold; }

/* === 全螢幕遮罩 (保持置中) === */
.full-page-mask { 
    position: fixed; inset: 0; 
    padding: 50px;
    display: flex; justify-content: center; 
    background: var(--bg-gradient); 
    z-index: 10000; overflow-y: auto; 
}

/* === [修正] 通用對話框 (回復原本的置中 Card 樣式) === */
.dialog-box { 
    width: min(880px, 92%); max-width: 980px; 
    height: fit-content;
    background: var(--bg-panel); 
    border-radius: 12px; padding: 28px; 
    box-shadow: 0 12px 40px var(--shadow-color); 
    border: 1px solid var(--border-color); 
    color: var(--text-main); text-align: left; 
    
    /* 關鍵：限制最大高度並允許內部捲動，保持視窗置中 */
    display: flex; flex-direction: column; 
    transition: background 0.3s, color 0.3s; 
}

/* 確保特定選單不會強制全螢幕 */
#mainMenu .dialog-box, 
#textSelectionMenu .dialog-box, 
#keyPracticeSettings .dialog-box {
    /* 移除之前的 width: 100%; height: 100%; */
    align-items: center; /* 讓內容水平置中 */
}

/* 標題樣式 */
.dialog-box h1, .dialog-box h2 { 
    margin: 0 0 20px; font-size: 42px; font-weight: 900;
    color: var(--text-heading); 
    text-shadow: 0 0 15px rgba(0,0,0,0.1); 
    text-align: center; letter-spacing: 2px;
}
body.light-mode .dialog-box h1, body.light-mode .dialog-box h2 { text-shadow: none; }

.menu-box p, .dialog-box p { 
    color: var(--text-sub); 
    font-size: 18px; 
    margin-bottom: 25px; 
    text-align: center;
}

/* === 自訂結束條件框樣式 === */
.custom-conditions {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    margin-bottom: 30px; 
    width: 90%; max-width: 650px;
}
body.light-mode .custom-conditions { background: #fff; border-color: #ccc; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }

.custom-conditions .settings-subtitle {
    margin: 0 0 15px 0 !important;
    text-align: left;
}

.condition-inputs {
    display: flex; gap: 20px; justify-content: space-between; flex-wrap: wrap;
}
.input-group { flex: 1; display: flex; flex-direction: column; min-width: 140px; }
.input-group label {
    font-size: 14px; color: var(--text-sub); margin-bottom: 8px; text-align: left;
}
.custom-input {
    background: var(--bg-key);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    font-family: 'Roboto Mono', monospace; font-size: 18px;
    outline: none; transition: border-color 0.2s;
}
.custom-input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 2px rgba(74, 170, 255, 0.2); }
body.light-mode .custom-input { background: #fff; border-color: #aaa; color: #000; }

/* 模式卡片 */
.mode-cards { 
    display: flex; justify-content: center; gap: 40px; flex-wrap: wrap; 
    margin-top: 10px;
}
.mode-card {
    background: var(--bg-card);
    border: 2px solid var(--color-accent); border-radius: 20px; padding: 50px 30px;
    width: 300px; cursor: pointer; transition: all 0.2s ease;
    box-shadow: 0 0 20px rgba(0,0,0,0.1); user-select: none; position: relative; z-index: 10001;
}
.mode-card:hover { transform: translateY(-10px); box-shadow: 0 0 40px var(--color-accent); }
.mode-card:active { transform: scale(0.95); }
.mode-card h3 { color: var(--color-accent); margin-bottom: 15px; font-size: 28px; }
.mode-card p { color: var(--text-main); font-size: 16px; line-height: 1.6; opacity: 0.9; text-align: left; }

/* 結算分數 */
#finalScore { text-align: center; font-size: 24px; margin: 0 0 10px; font-weight: bold; }

/* 設定按鈕 */
#settings-btn {
    position: fixed; top: auto; bottom: 30px; right: 30px; z-index: 10001;
    font-size: 24px; 
    background: rgba(128, 128, 128, 0.2); color: var(--text-main);
    border: 1px solid var(--border-color); border-radius: 50%;
    cursor: pointer; width: 40px; height: 40px; display: flex;
    align-items: center; justify-content: center;
    transition: all 0.2s; backdrop-filter: blur(5px);
}
#settings-btn:hover { background: var(--color-accent); color: #fff; transform: rotate(90deg); }

/* 設定面板 */
#settings-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center;
    z-index: 20000; backdrop-filter: blur(5px);
}
.settings-content {
    background: var(--bg-panel); 
    padding: 30px; border-radius: 12px; width: 400px;
    box-shadow: 0 10px 40px var(--shadow-color); 
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.settings-content h3 { margin-top: 0; color: var(--text-heading); text-align: center; margin-bottom: 20px; }
.setting-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-wrap: wrap; }
.settings-content #close-settings {
    margin: 10px auto;
    width: 100%; text-align: center;
}

/* Switch Toggle */
.switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .4s; border-radius: 24px;
}
.slider:before {
    position: absolute; content: ""; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--color-accent); }
input:checked + .slider:before { transform: translateX(22px); }
input:disabled + .slider { background-color: #555; cursor: not-allowed; opacity: 0.5; }

/* 隱藏類別 */
.hide-keyboard #virtualKeyboard { display: none !important; }
.hide-hearts #heartFX { display: none !important; }
.hide-hands #hands-overlay { display: none !important; }
.hidden { display: none !important; }

/* === 文本練習區 === */
#textPracticeArea {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; 
    justify-content: flex-start;
    background: inherit; z-index: 50; 
}
.text-hud {
    position: absolute; top: 0; left: 0; right: 0; height: 60px;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 30px; background: rgba(0,0,0,0.6); border-bottom: 1px solid rgba(255,255,255,0.1);
    color: #fff; backdrop-filter: blur(5px); z-index: 100;
}
body.light-mode .text-hud { background: rgba(255,255,255,0.9); color: #333; border-bottom: 1px solid #ccc; }

.text-title { font-size: 22px; font-weight: bold; color: var(--color-current); }
.text-stats { font-size: 18px; font-family: 'Roboto Mono', monospace; }

#textComboContainer {
    position: absolute; top: 70px; left: 0; right: 0;
    text-align: center; height: 40px; pointer-events: none; z-index: 55;
}
#textComboText {
    font-size: 28px; font-weight: bold; color: var(--color-combo); 
    transition: opacity 0.2s; display: inline-block;
}
.text-combo-pop { animation: textPop 0.15s ease-out; }
@keyframes textPop { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }

.text-cursor-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 52; }

#textContainer {
    width: 85%; max-width: 1200px;
    height: calc(90vh - 400px); min-height: 200px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px; padding: 40px;
    font-size: var(--practice-font-size); line-height: 1.6; color: var(--text-sub);
    overflow-y: auto; position: relative;
    font-family: 'Consolas', 'Monaco', monospace; tab-size: 4;
    margin: 80px auto 0 auto;
    text-align: left; transition: background 0.3s, color 0.3s;
}
body.hide-keyboard #textContainer {
    height: calc(100vh - 190px) !important;
    margin-bottom: 50px;
}
.wrap-on { white-space: pre-wrap; word-break: break-word; }
.wrap-off { white-space: pre; overflow-x: auto; }
#textContainer::-webkit-scrollbar { width: 8px; height: 8px; }
#textContainer::-webkit-scrollbar-thumb { background: #555; border-radius: 4px; }

/* 文本字元顏色 */
.t-char { border-bottom: 2px solid transparent; transition: background-color 0.1s; }
.t-char.correct { color: var(--color-correct); }
.t-char.wrong { color: var(--color-wrong); background: rgba(255, 0, 0, 0.1); border-bottom-color: var(--color-wrong); }
.t-char.current { background: rgba(0, 120, 255, 0.15); color: var(--text-highlight); border-bottom: 2px solid var(--color-current); }
@keyframes errorFlash { 0% { background-color: var(--color-wrong); color: #fff; } 100% { background-color: transparent; color: var(--color-wrong); } }
.t-char.wrong-flash { animation: errorFlash 0.3s ease-out; }

/* === 倒數與暫停 === */
#countdownOverlay, #pauseOverlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.85);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 100; backdrop-filter: blur(5px);
}
#countdownNum {
    font-size: 150px; font-weight: 900; color: var(--color-current);
    text-shadow: 0 0 50px var(--color-current); opacity: 0; transform: scale(0.5); 
}
@keyframes pulseNum { 0% { transform: scale(0.5); opacity: 0; } 50% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
.animate-count { animation: pulseNum 0.9s ease-out forwards; }
#pauseOverlay h2 { font-size: 60px; color: var(--color-combo); margin-bottom: 10px; }
#pauseOverlay p { color: #fff; font-size: 20px; margin-bottom: 30px; }

/* === 鍵位模式 UI === */
.wrap-lanes { 
    display: flex; flex-direction: column; 
    justify-content: center; gap: 15px; 
    padding-top: 130px; 
    width: 95%; max-width: 1000px; margin: 0 auto;
}
.hud { position: fixed; left: 20px; top: 18px; color: var(--text-main); z-index: 60; font-size: 18px; width: auto; }
.hud-row { 
    display: flex; gap: 30px; align-items: center; 
    background: var(--bg-panel); 
    padding: 10px 20px; border-radius: 8px; 
    border: 1px solid var(--border-color); 
}
.hud .val { font-weight: 700; margin-left: 8px; color: var(--text-highlight); text-shadow: 0 0 5px var(--color-accent); }
body.light-mode .hud .val { text-shadow: none; color: var(--color-accent); }

#comboHUD { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); text-align: center; z-index: 55; pointer-events: none; transition: transform 0.1s; opacity: 0; }
#comboCount { font-size: 64px; font-weight: 900; line-height: 1; margin: 0; color: var(--text-highlight); }
#comboLabel { font-size: 16px; font-weight: 700; letter-spacing: 4px; color: var(--text-sub); text-transform: uppercase; }
#comboMultiplier { font-size: 14px; color: var(--color-combo); font-weight: bold; margin-top: 4px; opacity: 0; }
.combo-pop { animation: comboPop 0.15s forwards; }
@keyframes comboPop { 0% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.3); } 100% { transform: translateX(-50%) scale(1); } }
.combo-break { animation: comboShake 0.4s forwards; }
@keyframes comboShake { 0% { transform: translateX(-50%) translateX(0); color: var(--color-wrong); } 25% { transform: translateX(-50%) translateX(-10px); } 75% { transform: translateX(-50%) translateX(-10px); } 100% { transform: translateX(-50%) translateX(0); opacity: 0; } }

.combo-lv1 { color: var(--color-correct) !important; }
.combo-lv2 { color: var(--color-combo) !important; }
.combo-lv3 { color: var(--color-wrong) !important; text-shadow: 0 0 10px var(--color-wrong) !important; }
body.light-mode .combo-lv3 { text-shadow: none !important; }

/* 軌道 */
.lane { 
    position: relative; width: 100%; height: 90px;
    border-radius: 12px; overflow: hidden; 
    border: 2px solid var(--lane-border); 
    box-shadow: 0 0 30px rgba(0,0,0,0.05); 
    background: var(--lane-bg);
    display: flex; align-items: center; justify-content: flex-start; padding-top: 0;
    transition: border-color 0.3s; 
}
@keyframes techPulse { 0%, 100% { border-color: var(--border-color); } 50% { border-color: var(--color-accent); } }
.lane.active-lane { animation: techPulse 3s ease-in-out infinite; }
.lane.glow { border-color: var(--color-accent) !important; box-shadow: 0 0 20px var(--color-accent) !important; animation: none; transition: all 0.1s ease-out; }
.lane.err { border-color: var(--color-wrong) !important; background: rgba(255, 74, 110, 0.15); animation: none; transition: all 0.1s ease-out; }

/* 提示線 */
.lane .hint-line { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, 0.15); pointer-events: none; z-index: 5; }
body.light-mode .lane .hint-line { background: rgba(0, 0, 0, 0.1); }
.hint-perfect { left: 66.66%; background: var(--color-correct) !important; opacity: 0.3; }
.hint-good { left: 33.33%; background: var(--color-combo) !important; opacity: 0.3; }

/* 方塊 */
.tile {
    position: absolute; width: 80px; height: 80px; 
    top: 50%; transform: translateY(-50%);
    background: var(--tile-bg); border-radius: 10px; 
    font-size: calc(var(--practice-font-size) * 1.6); font-weight: 700; color: var(--tile-text);
    display: flex; justify-content: center; align-items: center; z-index: 10;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); user-select: none;
    border: 2px solid transparent;
}
.tile.space-tile { border-color: var(--color-accent); color: var(--color-accent); font-size: 30px; }

/* 尾巴 */
.tile-tail {
    position: absolute; top: 10px; bottom: 10px; left: 100%; right: auto; width: 0; 
    background: var(--color-accent); opacity: 0.5;
    border-radius: 0 8px 8px 0; pointer-events: none; z-index: -1;
}
.tile.holding { background: #fff; border-color: var(--color-correct); transform: translateY(-50%) scale(1.05); }
.tile.holding .tile-tail { background: var(--color-correct); }

.message { position: fixed; right: 20px; top: 18px; font-size: 14px; color: var(--text-sub); opacity: 0.9; z-index: 60; }
.footer { text-align: center; color: var(--text-sub); font-size: 12px; opacity: 0.5; z-index: 100000; background-color: var(--bg-gradient); }

.fx-text { position: fixed; left: 15%; top: 50%; transform: translate(-50%, -50%); font-size: 68px; font-weight: 900; pointer-events: none; opacity: 0; animation: fx-pop 0.9s cubic-bezier(.2, .9, .2, 1) forwards; z-index: 9999; }
.fx-perfect { color: var(--color-current); text-shadow: 0 0 20px var(--color-current); }
.fx-good { color: var(--color-correct); text-shadow: 0 0 20px var(--color-correct); }
body.light-mode .fx-text { text-shadow: none; }
@keyframes fx-pop { 0% { transform: translate(-50%, -50%) scale(0.7); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(-50%, -100%) scale(1.2); opacity: 0; } }

#heartFX { 
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.6); 
    font-size: 160px; color: var(--color-wrong); opacity: 0; pointer-events: none; z-index: 9998; 
}
#heartFX.show { animation: heartBreak 0.6s ease-out forwards; }
@keyframes heartBreak { 0% { opacity: 1; transform: translate(-50%, -50%) scale(0.8); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; } }

/* 統計圖表 */
#statsList { margin: 10px 0; padding: 10px; background: rgba(0, 0, 0, 0.2); border-radius: 8px; overflow-y: auto; max-height: 150px; border: 1px solid var(--border-color); }
.stat-item { display: flex; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--border-color); font-family: 'Roboto Mono', monospace; font-size: 13px; }
.stat-item:last-child { border-bottom: none; }
.stat-char { font-size: 16px; font-weight: bold; color: var(--text-highlight); width: 40px; text-align: center; margin-right: 15px; text-transform: uppercase; }
.stat-bar-container { flex: 1; height: 8px; background: var(--stat-bar-bg); border-radius: 4px; overflow: hidden; margin-right: 15px; }
.stat-bar { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.bar-high { background: var(--color-wrong); }
.bar-mid { background: var(--color-combo); }
.bar-low { background: var(--color-correct); }
.stat-info { font-size: 12px; color: var(--text-sub); width: 120px; text-align: right; }
.stats-title { color: var(--color-wrong); margin: 20px 0 5px; }
.empty-stats { text-align:center; padding:20px; color:var(--text-sub); }

#heatmapKeyboard { margin-top: 15px; padding: 15px; background: var(--hm-bg); border-radius: 8px; border: 1px solid var(--border-color); display: flex; flex-direction: column; align-items: center; }
.hm-row { display: flex; justify-content: center; margin: 3px 0; }
.hm-key { width: 32px; height: 32px; margin: 2px; border-radius: 4px; border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; color: var(--hm-text); background: var(--hm-key-bg); }
.hm-key.hm-space { width: 200px; }
.hm-none { opacity: 0.5; }
.hm-clean { background: var(--color-correct) !important; color: #fff !important; } 
.hm-low { background: var(--color-combo) !important; color: #000 !important; } 
.hm-high { background: var(--color-wrong) !important; color: #fff !important; } 
.legend { display: flex; gap: 15px; justify-content: center; margin-bottom: 10px; font-size: 12px; color: var(--text-sub); }
.dot { width: 10px; height: 10px; display: inline-block; border-radius: 50%; margin-right: 5px; }

/* 按鈕 */
.btn { display: inline-block; padding: 12px 24px; border-radius: 8px; background: linear-gradient(90deg, #4af, #78f); color: #021022; font-weight: 700; font-size: 18px; cursor: pointer; border: none; margin: 10px; transition: transform 0.1s; }
.btn:active { transform: scale(0.96); }
.btn.secondary { background: linear-gradient(90deg, #ff6f91, #ff4a6e); color: white; }
#startControls, #gameOverControls { text-align: center; margin-top: 10px; }
#rules { background: rgba(128,128,128,0.1); border: 1px solid var(--border-color); padding: 15px; border-radius: 8px; color: var(--text-main); font-size: 15px; line-height: 1.6; margin-bottom: 20px; }

/* === 虛擬鍵盤 === */
#virtualKeyboard {
    display: none; /* 預設隱藏 */
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    padding: 10px; 
    background: var(--bg-key);
    border-radius: 10px; border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px var(--shadow-color); z-index: 99;
    flex-direction: column; gap: 6px; user-select: none; transition: filter 0.2s;
}
.vk-row { display: flex; gap: 6px; justify-content: center; }
.vk-key {
    width: 40px; height: 40px; background: var(--bg-key-special); color: var(--text-sub);
    border-radius: 4px; border-bottom: 3px solid rgba(0,0,0,0.2);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    font-size: 14px; font-weight: bold; position: relative; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: all 0.1s; font-family: 'Roboto Mono', monospace;
}
.vk-dual { justify-content: space-between; padding: 3px 0; font-size: 11px; }
.vk-dual span:first-child { opacity: 0.7; }
.vk-dual span:last-child { color: var(--text-highlight); font-size: 13px; }

.vk-special { background: #2b2e3b; font-size: 12px; }
body.light-mode .vk-special { background: #e0e0e0; }

.w-125 { width: 50px; } .w-150 { width: 60px; } .w-175 { width: 70px; } .w-200 { width: 80px; } .w-225 { width: 90px; } .w-275 { width: 110px; } .w-625 { width: 250px; }

.vk-key.glow { 
    background: var(--color-accent); color: #fff !important; 
    border-bottom-color: #000; transform: translateY(2px); box-shadow: 0 0 15px var(--color-accent); 
}
body.light-mode .vk-key.glow { color: #fff !important; box-shadow: none; }
.vk-key.glow span { color: #fff !important; opacity: 1; }
.vk-key[data-key="Shift"].glow { background: var(--color-combo); box-shadow: 0 0 15px var(--color-combo); }

/* 雙手 */
#hands-overlay {
    display: none; /* 預設隱藏 */
    position: fixed; bottom: 230px; left: 50%; transform: translateX(-50%);
    width: 520px; height: 220px; 
    justify-content: space-between;
    pointer-events: none; z-index: 55; opacity: 0.8; transition: opacity 0.3s;
}
.hand-svg { width: 200px; height: auto; }
.finger { fill: transparent; stroke: rgba(255, 255, 255, 0.2); stroke-width: 3; transition: all 0.1s; }
body.light-mode .finger { stroke: rgba(0, 0, 0, 0.2); }
.palm { fill: rgba(255, 255, 255, 0.05); }
body.light-mode .palm { fill: rgba(0, 0, 0, 0.05); }

.finger.active { fill: var(--color-correct); stroke: var(--color-correct); stroke-width: 4; opacity: 0.5; }
#f-l-pinky.active { fill: var(--color-wrong); stroke: var(--color-wrong); }
#f-l-index.active, #f-r-index.active { fill: var(--color-current); stroke: var(--color-current); }

/* 管理員模式專用 */
body.admin-enabled #pauseOverlay.admin-transparent {
    background: rgba(0, 0, 0, 0.2); /* 變為極淡的遮罩 */
    backdrop-filter: none;         /* 移除模糊效果 */
}

body.admin-enabled .t-char {
    cursor: pointer;
}

body.admin-enabled .t-char:hover {
    background: rgba(0, 247, 255, 0.2);
    border-radius: 4px;
}
#btnKeyPause, #btnTextPause {
    transition: background 0.3s ease, transform 0.1s;
    /* min-width: 80px; 固定寬度防止文字更換時按鈕跳動 */
}

/* 表格樣式 */
#historyTable th, #historyTable td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

#historyTable tbody tr:hover {
    background: rgba(74, 170, 255, 0.05);
}

#historyBody tr:last-child td {
    border-bottom: none;
}

.history-empty {
    text-align: center;
    padding: 40px !important;
    color: var(--text-sub);
}

.history-btn {
    width: fit-content;
    border-radius: 40px; padding: 15px 30px;
    margin: 10px 0;
}
.history-btn p {
    margin: 0;
}

/* 歷史紀錄頁籤 */
.history-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-sub);
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--color-current);
    color: var(--bg-main);
    font-weight: bold;
    border-color: var(--color-current);
}

/* 展開區域樣式 */
.expand-row {
    background: var(--expand-row-bg);
    display: none; /* 預設隱藏 */
}

.detail-container {
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    text-align: center;
    font-size: 13px;
}

.detail-item:not(:last-child){
    border-right: 1px solid var(--border-color);
}

.detail-item:not(:first-child){
    border-left: 1px solid var(--border-color);
}

.detail-item span {
    display: block;
    font-size: 18px;
    font-weight: bold;
    margin-top: 5px;
}

/* 讓紀錄列看起來可以點擊 */
.key-record-row { cursor: pointer; }
.key-record-row:hover { background: rgba(74, 170, 255, 0.1) !important; }

/* 最佳紀錄顯示 */
.pb-display {
    margin-top: 15px;
    padding: 5px 10px;
    background: rgba(0, 247, 255, 0.1);
    border-radius: 4px;
    font-size: 13px;
    color: var(--color-current);
    border: 1px dashed var(--color-current);
    display: inline-block;
}

/* 確保卡片內的 PB 顯示不會擠在一起 */
.mode-card .pb-display {
    display: block; /* 改為區塊元素讓它自成一行 */
    width: fit-content;
}

/* 文本選擇清單中的進度標籤 */
.text-progress-tag {
    font-size: 12px;
    padding: 3px 8px;
    border-style: solid; /* 實線邊框與主頁區分 */
}

/* 新紀錄標籤 */
.new-record-tag {
    background: var(--color-combo);
    color: #000;
    font-weight: 900;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 18px;
    margin: 10px auto;
    width: fit-content;
    animation: pb-glow 1s infinite alternate;
}

@keyframes pb-glow {
    from { box-shadow: 0 0 5px var(--color-combo); transform: scale(1); }
    to { box-shadow: 0 0 20px var(--color-combo); transform: scale(1.1); }
}

/* 結算數值高亮 */
.pb-highlight {
    color: var(--color-combo) !important;
    text-shadow: 0 0 10px var(--color-combo);
    font-weight: bold;
}

/* 文本選定後的發光標記 */
#textSelectionMenu .mode-card.selected-card {
    border-color: var(--color-current);
    box-shadow: 0 0 25px var(--color-current);
    background: rgba(0, 247, 255, 0.1); /* 淡淡的選定底色 */
    transform: translateY(-5px);
}

/* 讓選定的標題也發光 */
#textSelectionMenu .mode-card.selected-card h3 {
    text-shadow: 0 0 10px var(--color-current);
}

#btnTextRandom.selected-card {
    border-color: #a259ff;
    box-shadow: 0 0 25px #a259ff;
    background: rgba(162, 89, 255, 0.1);
}

#btnTextRandom h3 {
    color: #a259ff;
}

/* 全局分析內的表格 */
#globalStatsBody td { padding: 12px; border-bottom: 1px solid var(--border-color); }
#globalStatsBody tr:hover { background: rgba(255, 74, 110, 0.05); }

/* 統計框格樣式 */
.stat-box {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0,0,0,0.1);
}

/* 成就徽章樣式 */
.achievement-badge {
    margin: 10px auto;
    padding: 8px 20px;
    border-radius: 4px;
    font-size: 24px;
    font-weight: 900;
    text-align: center;
    letter-spacing: 2px;
    width: fit-content;
    text-transform: uppercase;
    animation: achievement-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Full Combo: 金黃色 */
.fc-badge {
    background: rgba(255, 215, 0, 0.2);
    color: #ffd700;
    border: 2px solid #ffd700;
    text-shadow: 0 0 15px #ffd700;
}

/* All Perfect: 青藍色強力發光 */
.ap-badge {
    background: rgba(0, 247, 255, 0.2);
    color: #00f7ff;
    border: 2px solid #00f7ff;
    text-shadow: 0 0 20px #00f7ff;
    animation: ap-glow 1s infinite alternate;
}

@keyframes achievement-pop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes ap-glow {
    from { box-shadow: 0 0 5px #00f7ff; }
    to { box-shadow: 0 0 20px #00f7ff; }
}

/* 成就面板項目 */
/* 調整成就項目容器，適配多枚勳章 */
.achievement-item {
    padding: 15px 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: 15px;
}

.achievement-item.locked {
    filter: grayscale(1);
    opacity: 0.5;
}

.achievement-item.unlocked {
    border-color: var(--color-combo);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

/* 修改 medal-icon 讓他在並排時不要太大 */
.achievement-item .medal-icon {
    font-size: 32px; /* 從 40px 微調為 32px */
    margin-bottom: 5px;
    display: block;
    text-align: center;
}

.achievement-item h4 {
    margin: 10px 0 5px;
    color: var(--text-heading);
    text-align: center;
}

.achievement-item .fc-count-tag {
    background: var(--color-combo);
    color: #000;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}

/* 讓鍵位成就在解鎖時有青藍色的光芒 */
.achievement-item.unlocked h4[style*="var(--color-current)"] {
    text-shadow: 0 0 10px var(--color-current);
}

/* 增加成就網格的最小高度，防止彈窗太扁 */
#achievementListGrid {
    min-height: 250px;
}

/* 成就區域分組標題 */
.ach-section-header {
    grid-column: 1 / -1;
    padding: 15px 0;
    border-bottom: 2px solid var(--color-current);
}

.ach-section-header h3 {
    margin-top: 0;
    margin-bottom: 5px;
}

.ach-section-header p {
    text-align: left;
    margin: 2px 0;
}

.ach-speed-group {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 5px;
}

.speed-label {
    min-width: 70px;
    font-weight: bold;
    color: var(--text-sub);
    font-size: 13px;
}

.ach-badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

/* 極簡徽章樣式 */
.mini-badge {
    width: 38px;
    height: 38px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 9px;
    position: relative;
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.1s;
}

.mini-badge.locked { opacity: 0.15; background: #000; color: #fff; }
.mini-badge.unlocked { opacity: 1; transform: scale(1.05); }

.mini-badge.fc.unlocked { background: rgba(255, 215, 0, 0.2); border-color: #ffd700; color: #ffd700; }
.mini-badge.ap.unlocked { background: rgba(0, 247, 255, 0.2); border-color: #00f7ff; color: #00f7ff; box-shadow: 0 0 5px var(--color-current); }

.mini-badge .icon { font-size: 12px; }
.mini-badge .cnt {
    position: absolute; top: -2px; right: -2px;
    background: var(--color-wrong); color: #fff;
    padding: 1px 3px; border-radius: 5px; font-size: 8px; font-weight: bold;
}

/* 勳章槽樣式 */
.medal-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 45px;
    transition: transform 0.2s;
}

.medal-slot.locked-medal {
    filter: grayscale(1);
    opacity: 0.2;
}

.medal-slot:not(.locked-medal):hover {
    transform: scale(1.2);
}

.medal-count {
    font-size: 10px;
    color: var(--color-combo);
    font-weight: bold;
    margin-top: -2px;
}

/* 特殊方塊樣式 */
.tile.special {
    background: linear-gradient(135deg, #ffea00, #ffaa00);
    border-color: #ffffff;
    box-shadow: 0 0 20px #ffea00, inset 0 0 10px #ffffff;
    color: #000 !important; /* 金色底配黑字較清楚 */
    font-weight: 900;
    z-index: 10;
}

/* 擊中特殊方塊時的文字提示顏色 */
.fx-text.special-hit {
    color: #ffea00;
    text-shadow: 0 0 15px #ffea00;
    font-size: 28px;
}

/* 鍵位精準度徽章解鎖樣式 (青藍色主題) */
.mini-badge.accuracy.unlocked {
    background: rgba(74, 170, 255, 0.2);
    border-color: var(--color-accent);
    color: var(--color-accent);
    box-shadow: 0 0 8px rgba(74, 170, 255, 0.4);
}

.mini-badge.accuracy .icon {
    font-size: 11px;
}

/* === [新增] 超越紀錄特效樣式 === */
.record-break-fx {
    position: fixed;
    left: 50%;
    top: 40%;
    transform: translate(-50%, -50%);
    font-size: 42px;
    font-weight: 900;
    font-style: italic;
    pointer-events: none;
    z-index: 10000;
    white-space: nowrap;
    text-transform: uppercase;
    animation: record-break-pop 1.2s ease-out forwards;
}

.fx-score-break {
    color: #4affaa; /* 綠色代表分數突破 */
    text-shadow: 0 0 20px #4affaa, 0 0 40px #4affaa;
}

.fx-combo-break {
    color: #ffd700; /* 金色代表 Combo 突破 */
    text-shadow: 0 0 20px #ffd700, 0 0 40px #ffd700;
}

@keyframes record-break-pop {
    0% { transform: translate(-50%, -20%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    40% { transform: translate(-50%, -55%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -100%) scale(1.1); opacity: 0; }
}

/* === [新增] 單一文本重置按鈕樣式 === */
.mode-card {
    position: relative; /* 確保按鈕能定位在卡片內 */
}

.reset-single-text {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 74, 110, 0.1);
    color: var(--color-wrong);
    border: 1px solid var(--color-wrong);
    font-size: 16px;
    line-height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0; /* 平時隱藏 */
    transition: all 0.2s ease;
    z-index: 10;
}

.mode-card:hover .reset-single-text {
    opacity: 1; /* 游標移入時顯現 */
}

.reset-single-text:hover {
    background: var(--color-wrong);
    color: #fff;
    box-shadow: 0 0 10px var(--color-wrong);
}
/* === [新增] 玩法說明專屬樣式 === */
.instruction-sections {
    display: grid;
    gap: 15px;
    text-align: left;
}

.info-card {
    background: var(--bg-card);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #555;
}

.info-card.newbie { border-left-color: var(--color-correct); }
.info-card.entry { border-left-color: var(--color-current); }
.info-card.expert { border-left-color: var(--color-wrong); }

.info-card h3 { margin-bottom: 8px; font-size: 18px; text-align: center; }
.info-card p { margin-bottom: 5px; color: var(--text-highlight); text-align: left; }
.info-card ul { padding-left: 20px; color: var(--text-sub); font-size: 14px; line-height: 1.6; }