/* ==================== 字體與CSS變量 ==================== */
:root {
    --bg-deep: #0a0415;
    --bg-purple: #1a0a2e;
    --gold-primary: #ffd700;
    --gold-secondary: #c9a84c;
    --gold-dark: #8b6914;
    --gold-light: #ffe44d;
    --amber: #f0a500;
    --crimson: #c41e3a;
    --crimson-glow: #ff3355;
    --sapphire: #1a3a5c;
    --emerald: #0d5c3a;
    --text-light: #e8dcc8;
    --text-muted: #a89878;
    --surface-dark: rgba(20, 8, 40, 0.85);
    --surface-card: rgba(30, 15, 55, 0.7);
    --font-display: 'Cinzel Decorative', 'Cinzel', 'Noto Serif JP', serif;
    --font-heading: 'Cinzel', 'Noto Serif JP', serif;
    --font-body: 'Zen Kaku Gothic New', 'Noto Serif JP', sans-serif;
    --font-magic: 'Cinzel Decorative', serif;
    --transition-smooth: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-bounce: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --transition-elastic: 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --shadow-gold: 0 0 20px rgba(255, 215, 0, 0.4), 0 0 60px rgba(255, 215, 0, 0.15);
    --shadow-crimson: 0 0 20px rgba(196, 30, 58, 0.5), 0 0 60px rgba(196, 30, 58, 0.2);
    --shadow-magic: 0 0 30px rgba(180, 140, 220, 0.5), 0 0 80px rgba(160, 100, 200, 0.25);
}

/* ==================== 全局重置 ==================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-y: auto;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-overflow-scrolling: touch;
    cursor: none;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-overflow-scrolling: touch;
    cursor: none !important;
    position: relative;
}

button,
a,
[role="button"],
.letter-orb,
.word-slot,
.chapter-btn,
.help-icon-btn,
.scroll-close,
.alchemy-btn {
    cursor: none !important;
}

/* 當自定義光標不可用時的回退 */
body.custom-cursor-fallback {
    cursor: auto !important;
}

body.custom-cursor-fallback .custom-cursor {
    display: none;
}

/* ==================== 自定義光標 ==================== */
.custom-cursor {
    position: fixed;
    pointer-events: none;
    z-index: 99999;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    transition: transform 0.08s ease-out;
    will-change: transform;
}

.cursor-core {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: var(--gold-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 12px var(--gold-primary), 0 0 24px var(--gold-light);
    transition: all 0.2s ease;
}

.cursor-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--gold-secondary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: cursorRingPulse 2s ease-in-out infinite;
    transition: all 0.3s ease;
}

.cursor-sparkle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--gold-light);
    border-radius: 50%;
    opacity: 0;
    animation: cursorSparkle 1.5s ease-in-out infinite;
}

.sparkle-1 {
    top: 2px;
    left: 50%;
    animation-delay: 0s;
}

.sparkle-2 {
    top: 50%;
    right: 2px;
    animation-delay: 0.5s;
}

.sparkle-3 {
    bottom: 2px;
    left: 50%;
    animation-delay: 1s;
}

/* 光標懸停狀態 */
.custom-cursor.hovering {
    transform: translate(-50%, -50%) scale(1.6);
}

.custom-cursor.hovering .cursor-ring {
    width: 36px;
    height: 36px;
    border-color: var(--gold-primary);
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.6);
    border-width: 2px;
}

.custom-cursor.hovering .cursor-core {
    width: 12px;
    height: 12px;
    box-shadow: 0 0 20px var(--gold-primary), 0 0 40px var(--gold-light);
}

/* 光標點擊狀態 */
.custom-cursor.clicking {
    transform: translate(-50%, -50%) scale(0.7);
}

.custom-cursor.clicking .cursor-ring {
    width: 20px;
    height: 20px;
    border-color: #fff;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.9);
}

@keyframes cursorRingPulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

@keyframes cursorSparkle {

    0%,
    100% {
        opacity: 0;
        transform: scale(1);
    }

    50% {
        opacity: 0.9;
        transform: scale(1.8);
    }
}

/* ==================== 粒子背景畫布 ==================== */
.particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.7;
}

/* ==================== 粒子爆發層 ==================== */
.particle-burst-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    pointer-events: none;
}

.burst-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: burstFly 1.2s ease-out forwards;
}

@keyframes burstFly {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--bx), var(--by)) scale(0);
        opacity: 0;
    }
}

/* ==================== 主容器 ==================== */
.main-container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 16px 20px 20px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* ==================== 頂部狀態欄 ==================== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--surface-dark);
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: 16px;
    margin-bottom: 28px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.score-display,
.combo-display,
.level-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
}

.score-icon,
.combo-flame,
.level-icon {
    font-size: 1.4rem;
    animation: iconFloat 3s ease-in-out infinite;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold-primary);
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
    font-family: var(--font-display);
    min-width: 50px;
    text-align: center;
    transition: all 0.3s ease;
}

.score-value.pulse {
    animation: scorePulse 0.5s ease-out;
}

@keyframes scorePulse {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.5);
        color: #fff;
    }

    100% {
        transform: scale(1);
    }
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.combo-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--amber);
    text-shadow: 0 0 16px rgba(240, 165, 0, 0.6);
    font-family: var(--font-display);
    transition: all 0.3s ease;
}

.combo-value.super-combo {
    color: #ff6b35;
    text-shadow: 0 0 24px rgba(255, 107, 53, 0.8);
    animation: comboShake 0.3s ease-in-out;
}

@keyframes comboShake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px) rotate(-5deg);
    }

    75% {
        transform: translateX(4px) rotate(5deg);
    }
}

.level-name {
    font-size: 0.9rem;
    color: var(--text-light);
    letter-spacing: 0.06em;
}

@keyframes iconFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* ==================== 遊戲主區域 ==================== */
.game-area {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
    padding: 10px 0;
}

/* ==================== 魔法陣容器 ==================== */
.alchemy-circle-container {
    position: relative;
    width: min(360px, 90vw);
    height: min(360px, 90vw);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    height: min(360px, 90vw);
}

/* 魔法陣環 */
.magic-ring {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.magic-ring-outer {
    width: 340px;
    height: 340px;
    border: 2.5px solid rgba(201, 168, 76, 0.5);
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.2), inset 0 0 25px rgba(255, 215, 0, 0.08);
    animation: ringRotate 20s linear infinite;
}

.magic-ring-middle {
    width: 280px;
    height: 280px;
    border: 1.5px dashed rgba(201, 168, 76, 0.4);
    animation: ringRotateReverse 16s linear infinite;
}

.magic-ring-inner {
    width: 210px;
    height: 210px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.12), inset 0 0 18px rgba(255, 215, 0, 0.05);
    animation: ringRotate 12s linear infinite;
}

/* 魔法陣上的符文點 */
.magic-ring-outer::before,
.magic-ring-outer::after,
.magic-ring-middle::before,
.magic-ring-middle::after,
.magic-ring-inner::before,
.magic-ring-inner::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--gold-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--gold-primary);
}

.magic-ring-outer::before {
    top: -3px;
    left: 50%;
    margin-left: -3px;
}

.magic-ring-outer::after {
    bottom: -3px;
    left: 50%;
    margin-left: -3px;
}

.magic-ring-middle::before {
    top: 50%;
    right: -3px;
    margin-top: -3px;
}

.magic-ring-middle::after {
    top: 50%;
    left: -3px;
    margin-top: -3px;
}

.magic-ring-inner::before {
    top: -3px;
    left: 50%;
    margin-left: -3px;
    width: 4px;
    height: 4px;
}

.magic-ring-inner::after {
    bottom: -3px;
    left: 50%;
    margin-left: -3px;
    width: 4px;
    height: 4px;
}

@keyframes ringRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes ringRotateReverse {
    from {
        transform: rotate(360deg);
    }

    to {
        transform: rotate(0deg);
    }
}

/* ==================== 魔法陣核心 ==================== */
.alchemy-core {
    position: relative;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(20, 8, 45, 0.95) 40%, rgba(10, 4, 25, 0.98) 100%);
    border: 2px solid rgba(255, 215, 0, 0.5);
    box-shadow: var(--shadow-magic), inset 0 0 40px rgba(100, 60, 180, 0.2);
    transition: all 0.5s ease;
}

.alchemy-core.success {
    border-color: var(--gold-primary);
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.7), 0 0 100px rgba(255, 200, 0, 0.4), inset 0 0 60px rgba(255, 215, 0, 0.3);
    animation: coreSuccess 0.8s ease-out;
}

.alchemy-core.error {
    border-color: var(--crimson);
    box-shadow: var(--shadow-crimson), inset 0 0 40px rgba(200, 30, 50, 0.3);
    animation: coreShake 0.5s ease-out;
}

@keyframes coreSuccess {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.12);
    }

    60% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes coreShake {

    0%,
    100% {
        transform: translateX(0);
    }

    10% {
        transform: translateX(-8px);
    }

    20% {
        transform: translateX(8px);
    }

    30% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    50% {
        transform: translateX(-4px);
    }

    60% {
        transform: translateX(4px);
    }

    70% {
        transform: translateX(-2px);
    }

    80% {
        transform: translateX(2px);
    }
}

.core-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 55%, rgba(180, 140, 220, 0.3) 100%);
    pointer-events: none;
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.9;
    }
}

.chinese-meaning {
    text-align: center;
    z-index: 2;
    padding: 8px 16px;
    transition: all 0.4s ease;
}

.meaning-text {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold-primary);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    letter-spacing: 0.08em;
    display: block;
    transition: all 0.3s ease;
}

/* 單字槽位 */
.word-slots {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    z-index: 2;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 44px;
    align-items: center;
}

.word-slot {
    width: 38px;
    height: 44px;
    border: 2px solid rgba(201, 168, 76, 0.5);
    border-radius: 10px;
    background: rgba(20, 8, 40, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold-primary);
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 長單字槽位緊湊模式 */
.word-slots.compact .word-slot {
    width: 28px;
    height: 34px;
    font-size: 1rem;
    gap: 4px;
}

.word-slots.compact {
    gap: 4px;
    flex-wrap: nowrap;
}

.word-slot:hover {
    border-color: var(--gold-primary);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.4);
    transform: translateY(-3px);
}

.word-slot.filled {
    border-color: var(--gold-primary);
    background: rgba(40, 20, 60, 0.8);
    animation: slotFillPop 0.4s var(--transition-elastic);
}

.word-slot.hint-glow {
    border-color: #ff6bff;
    box-shadow: 0 0 20px rgba(255, 107, 255, 0.6);
    animation: hintPulse 0.6s ease-in-out infinite;
}

@keyframes slotFillPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    60% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes hintPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(255, 107, 255, 0.6);
    }

    50% {
        box-shadow: 0 0 35px rgba(255, 107, 255, 1);
    }
}

/* ==================== 字母元素球軌道 ==================== */
.letter-orbit {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10;
}

.letter-orb {
    position: absolute;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    transition: transform 0.35s var(--transition-elastic), box-shadow 0.35s ease,
        opacity 0.4s ease;
    z-index: 10;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
    animation: orbFloat 3.5s ease-in-out infinite;
    user-select: none;
    -webkit-user-select: none;
}

.letter-orb:nth-child(odd) {
    animation-delay: -1.5s;
}

.letter-orb:nth-child(3n) {
    animation-delay: -2.5s;
}

.letter-orb:hover {
    transform: scale(1.25);
    z-index: 20;
    box-shadow: 0 0 30px var(--orb-glow, rgba(255, 215, 0, 0.8)) !important;
}

.letter-orb:active {
    transform: scale(0.85);
    transition: transform 0.1s ease;
}

.letter-orb.used {
    opacity: 0.3;
    pointer-events: none;
    transform: scale(0.7);
    filter: grayscale(0.6);
    transition: all 0.5s ease;
}

.letter-orb.returning {
    animation: orbReturn 0.5s var(--transition-elastic);
}

@keyframes orbFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-9px);
    }

    60% {
        transform: translateY(-3px);
    }

    85% {
        transform: translateY(-7px);
    }
}

@keyframes orbReturn {
    0% {
        transform: scale(0.7);
        opacity: 0.3;
    }

    60% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 元素球顏色變體 */
.orb-fire {
    background: radial-gradient(circle at 35% 30%, #ff6b35, #c41e3a 70%, #6b1020 100%);
    --orb-glow: rgba(255, 107, 53, 0.7);
    box-shadow: 0 6px 20px rgba(255, 80, 30, 0.5), inset 0 -3px 6px rgba(0, 0, 0, 0.3);
}

.orb-water {
    background: radial-gradient(circle at 35% 30%, #5bcefa, #1a6fa0 70%, #0a3d5c 100%);
    --orb-glow: rgba(91, 206, 250, 0.7);
    box-shadow: 0 6px 20px rgba(70, 180, 240, 0.5), inset 0 -3px 6px rgba(0, 0, 0, 0.3);
}

.orb-earth {
    background: radial-gradient(circle at 35% 30%, #8bc34a, #4a7c20 70%, #2d4a10 100%);
    --orb-glow: rgba(139, 195, 74, 0.7);
    box-shadow: 0 6px 20px rgba(100, 180, 50, 0.5), inset 0 -3px 6px rgba(0, 0, 0, 0.3);
}

.orb-wind {
    background: radial-gradient(circle at 35% 30%, #e8dcc8, #b8a080 70%, #6b5d40 100%);
    --orb-glow: rgba(232, 220, 200, 0.7);
    box-shadow: 0 6px 20px rgba(200, 180, 150, 0.5), inset 0 -3px 6px rgba(0, 0, 0, 0.3);
}

.orb-void {
    background: radial-gradient(circle at 35% 30%, #c8a0e0, #6b3fa0 70%, #3a1060 100%);
    --orb-glow: rgba(180, 130, 220, 0.7);
    box-shadow: 0 6px 20px rgba(150, 100, 200, 0.5), inset 0 -3px 6px rgba(0, 0, 0, 0.3);
}

/* 說明按鈕 */
.help-icon-btn {
    background: none;
    border: 1px solid rgba(201, 168, 76, 0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.4rem;
    color: var(--gold-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-smooth);
    background: var(--surface-card);
    backdrop-filter: blur(8px);
}

.help-icon-btn:hover {
    border-color: var(--gold-primary);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    color: var(--gold-primary);
    transform: scale(1.1);
}

/* ==================== 控制按鈕 ==================== */
.control-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 60px;
    justify-content: center;
    width: 100%;
}

.alchemy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1.5px solid rgba(201, 168, 76, 0.5);
    border-radius: 25px;
    background: var(--surface-card);
    color: var(--text-light);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-smooth);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    letter-spacing: 0.04em;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.alchemy-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.15), transparent);
    transition: left 0.6s ease;
}

.alchemy-btn:hover::before {
    left: 100%;
}

.alchemy-btn:hover {
    border-color: var(--gold-primary);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    transform: translateY(-2px);
    color: #fff;
}

.alchemy-btn:active {
    transform: scale(0.94);
    transition: transform 0.1s ease;
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-cost {
    font-size: 0.7rem;
    color: var(--crimson-glow);
    font-weight: 600;
    opacity: 0.8;
}

.start-btn {
    padding: 14px 32px;
    font-size: 1.1rem;
    border-color: var(--gold-primary);
    background: linear-gradient(135deg, rgba(40, 20, 60, 0.9), rgba(25, 8, 45, 0.95));
    box-shadow: 0 0 28px rgba(255, 215, 0, 0.3);
    letter-spacing: 0.08em;
    margin-left: auto;
    margin-right: auto;
}

.start-btn:hover {
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.55);
    border-color: #fff;
}

/* ==================== 進度條 ==================== */
.progress-area {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 10px 18px;
    background: var(--surface-dark);
    border-radius: 20px;
    border: 1px solid rgba(201, 168, 76, 0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.progress-bar-container {
    flex: 1;
    height: 10px;
    background: rgba(30, 15, 50, 0.6);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-primary), var(--gold-light));
    border-radius: 10px;
    transition: width 0.6s var(--transition-elastic);
    position: relative;
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.4);
}

.progress-glow {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5));
    border-radius: 10px;
    animation: progressGlowMove 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes progressGlowMove {

    0%,
    100% {
        transform: translateX(-40px);
        opacity: 0;
    }

    50% {
        opacity: 0.7;
    }
}

.progress-text {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 50px;
    text-align: right;
    letter-spacing: 0.04em;
}

/* ==================== 覆蓋層 ==================== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 2, 15, 0.92);
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 20px;
    padding-bottom: 20px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: overlayFadeIn 0.5s ease-out;
}

.overlay-content,
.scroll-container,
.success-burst,
.finale-scroll {
    margin-top: 0;
    margin-bottom: 0;
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 卷軸覆蓋層 */
.scroll-overlay {
    background: rgba(5, 2, 15, 0.9);
    z-index: 110;
}

.scroll-container {
    background: linear-gradient(180deg, #3b2a1a 0%, #5a4028 5%, #f4e4c1 10%, #faf0dc 50%, #f4e4c1 90%, #5a4028 95%, #3b2a1a 100%);
    border: 8px solid #3b2a1a;
    border-radius: 8px;
    max-width: 480px;
    width: 90%;
    padding: 30px 20px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), inset 0 0 30px rgba(0, 0, 0, 0.4);
    font-family: var(--font-heading);
    color: #2d1c0a;
    animation: scrollUnroll 0.7s ease-out;
    background-image: repeating-linear-gradient(transparent, transparent 28px, rgba(139, 105, 20, 0.15) 28px, rgba(139, 105, 20, 0.15) 29px);
    margin-left: auto;
    margin-right: auto;
    margin-top: 20px;
    margin-bottom: 20px;
}

@keyframes scrollUnroll {
    from {
        transform: scaleY(0);
        opacity: 0;
    }

    to {
        transform: scaleY(1);
        opacity: 1;
    }
}

.scroll-content {
    position: relative;
}

.scroll-close {
    position: absolute;
    top: -15px;
    right: -10px;
    font-size: 1.8rem;
    cursor: pointer;
    color: #a7774a;
    transition: 0.2s;
    z-index: 5;
}

.scroll-close:hover {
    color: #c41e3a;
    transform: scale(1.2);
}

.scroll-title {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: #b98452;
    margin-bottom: 10px;
}

.scroll-divider {
    width: 60%;
    height: 2px;
    background: #8b6914;
    margin: 0 auto 20px;
}

.scroll-body h3 {
    color: #af6f20;
    margin: 14px 0 4px;
    font-size: 1.1rem;
}

.scroll-body p {
    font-size: 1.1rem;
    margin: 0 0 8px 10px;
    line-height: 1.6;
    color: #aa5200;
}

.scroll-body kbd {
    background: #3b2a1a;
    color: #f4e4c1;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

/* 結局畫面 */
.overlay-finale {
    background: radial-gradient(circle, #1a0a2e, #000);
    z-index: 120;
}

.finale-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.finale-fireworks {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.finale-scroll {
    background: linear-gradient(180deg, #5a4028, #f4e4c1 15%, #faf0dc 50%, #f4e4c1 85%, #5a4028);
    border: 6px solid #3b2a1a;
    border-radius: 12px;
    padding: 40px 30px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0 80px rgba(255, 215, 0, 0.6);
    animation: finaleAppear 1s ease-out;
    position: relative;
    z-index: 2;
}

@keyframes finaleAppear {
    from {
        transform: scale(0.5) rotate(-10deg);
        opacity: 0;
    }

    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.finale-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    color: #3b2a1a;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    margin-bottom: 8px;
}

.finale-subtitle {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: #5c3a10;
    margin-bottom: 20px;
}

.finale-stats {
    font-family: var(--font-heading);
    color: #2d1c0a;
    font-size: 1.1rem;
    line-height: 2;
    margin-bottom: 24px;
}

.overlay-content {
    text-align: center;
    padding: 30px 20px;
    max-width: 520px;
    width: 90%;
    background: var(--surface-dark);
    border: 1.5px solid rgba(201, 168, 76, 0.4);
    border-radius: 24px;
    box-shadow: 0 0 60px rgba(100, 50, 180, 0.3), 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: contentSlideUp 0.6s var(--transition-elastic);
    margin: 10px auto;
}

@keyframes contentSlideUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.overlay-symbol {
    font-size: 4rem;
    animation: symbolFloat 2s ease-in-out infinite;
    display: block;
    margin-bottom: 8px;
}

@keyframes symbolFloat {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-10px) rotate(-5deg);
    }

    75% {
        transform: translateY(-5px) rotate(5deg);
    }
}

.overlay-title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--gold-primary);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
    letter-spacing: 0.1em;
    margin-bottom: 4px;
}

.overlay-subtitle {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--gold-secondary);
    letter-spacing: 0.15em;
    margin-bottom: 16px;
}

.overlay-divider {
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-secondary), transparent);
    margin: 16px auto;
}

.overlay-description {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-light);
    line-height: 1.8;
    margin-bottom: 16px;
}

.overlay-instructions {
    text-align: left;
    margin: 16px auto;
    display: inline-block;
}

.overlay-instructions p {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 6px 0;
    letter-spacing: 0.03em;
}

.overlay-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 16px;
    margin-bottom: 8px;
    letter-spacing: 0.04em;
}

.chapter-select {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
    margin-bottom: 8px;
}

.chapter-btn {
    padding: 8px 12px;
    border: 1.5px solid rgba(201, 168, 76, 0.4);
    border-radius: 20px;
    background: rgba(30, 15, 50, 0.6);
    color: var(--text-light);
    font-family: var(--font-heading);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all var(--transition-smooth);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.chapter-btn:hover {
    border-color: var(--gold-primary);
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.35);
    background: rgba(50, 25, 70, 0.8);
    transform: translateY(-2px);
}

.chapter-btn.selected {
    border-color: var(--gold-primary);
    background: rgba(60, 30, 80, 0.8);
    box-shadow: 0 0 22px rgba(255, 215, 0, 0.5);
    color: #fff;
}

/* 成功覆蓋層 */
.overlay-success {
    background: rgba(5, 2, 15, 0.75);
    pointer-events: none;
    z-index: 90;
    justify-content: center;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
}

.success-burst {
    text-align: center;
    animation: successPopIn 0.5s var(--transition-elastic);
}

@keyframes successPopIn {
    from {
        transform: scale(0.3);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.success-text {
    font-family: var(--font-display);
    font-size: 2.5rem;
    color: var(--gold-primary);
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.8);
    letter-spacing: 0.1em;
    animation: successGlow 0.8s ease-in-out infinite alternate;
}

@keyframes successGlow {
    from {
        text-shadow: 0 0 40px rgba(255, 215, 0, 0.8);
    }

    to {
        text-shadow: 0 0 70px rgba(255, 255, 200, 1), 0 0 120px rgba(255, 215, 0, 0.6);
    }
}

.success-word {
    font-family: var(--font-display);
    font-size: 2rem;
    color: #fff;
    margin-top: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* ==================== 響應式設計 ==================== */
@media (max-width: 600px) {
    .alchemy-circle-container {
        width: 280px;
        height: 280px;
    }

    .magic-ring-outer {
        width: 260px;
        height: 260px;
    }

    .magic-ring-middle {
        width: 210px;
        height: 210px;
    }

    .magic-ring-inner {
        width: 155px;
        height: 155px;
    }

    .alchemy-core {
        width: 120px;
        height: 120px;
    }

    .meaning-text {
        font-size: 1.3rem;
    }

    .word-slot {
        width: 30px;
        height: 36px;
        font-size: 1rem;
    }

    .letter-orb {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .overlay-title {
        font-size: 1.6rem;
    }

    .overlay-content {
        padding-top: 40px;
    }

    .top-bar {
        padding: 10px 14px;
        gap: 6px;
    }

    .score-value {
        font-size: 1.2rem;
    }

    .control-buttons {
        margin-top: 15px;
    }

    .alchemy-btn {
        padding: 8px 14px;
        font-size: 0.75rem;
    }

    .custom-cursor {
        display: none;
    }

    body {
        cursor: auto !important;
    }

    html {
        cursor: auto;
    }
}

@media (max-width: 380px) {
    .alchemy-circle-container {
        width: 240px;
        height: 240px;
    }

    .magic-ring-outer {
        width: 220px;
        height: 220px;
    }

    .magic-ring-middle {
        width: 175px;
        height: 175px;
    }

    .magic-ring-inner {
        width: 130px;
        height: 130px;
    }

    .alchemy-core {
        width: 100px;
        height: 100px;
    }

    .meaning-text {
        font-size: 1.1rem;
    }

    .letter-orb {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
    }

    .word-slot {
        width: 26px;
        height: 32px;
        font-size: 0.85rem;
    }
}

@media (max-width: 600px) {
    .main-container {
        padding: 10px 12px 15px;
    }

    .game-area {
        min-height: 0;
    }
}

@media (max-width: 600px) {
    .overlay {
        padding-top: 30px;
    }
}

/* 確保 Font Awesome 圖標對齊與繼承動畫 */
.score-icon i,
.combo-flame i,
.help-icon-btn i,
.btn-icon i,
.overlay-symbol i,
.scroll-title i,
.scroll-close i,
.success-text i {
    display: inline-block;
    vertical-align: middle;
}

/* 修正成功文字中圖標的間距 */
.success-text i:first-child {
    margin-right: 8px;
}

.success-text i:last-child {
    margin-left: 8px;
}

.success-burst {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ---------- Font Awesome 強制覆蓋（確保所有圖示正常顯示） ---------- */
.fas,
.far,
.fab,
.fa-solid,
.fa-regular,
.fa-brands {
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Brands' !important;
    font-weight: 900 !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    display: inline-block;
    line-height: 1;
}

/* Regular 風格的權重調整 */
.far,
.fa-regular {
    font-weight: 400 !important;
}

/* Brands 風格的權重調整 */
.fab,
.fa-brands {
    font-weight: 400 !important;
}

/* 讓圖標垂直對齊更美觀 */
.fas,
.far,
.fab,
.fa-solid,
.fa-regular,
.fa-brands {
    vertical-align: -0.125em;
}

#overlay-complete,
#overlay-success {
    justify-content: center;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
}

/* 音樂控制按鈕 */
.music-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-dark);
    border: 1.5px solid var(--gold-secondary);
    color: var(--gold-primary);
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(255,215,0,0.3);
    transition: all var(--transition-smooth);
    backdrop-filter: blur(8px);
}
.music-toggle-btn:hover {
    border-color: var(--gold-primary);
    box-shadow: 0 0 20px rgba(255,215,0,0.6);
    transform: scale(1.1);
}
.music-toggle-btn.muted {
    color: #777;
    border-color: #555;
}
.music-toggle-btn.muted i::before {
    content: "\f6a9"; /* fa-volume-mute */
}