.ffModalScreen {
    width: 19.2rem;
    height: 9.23rem;

}

/* 遊戲特定樣式 */
.game-container {
    position: relative;
    overflow: hidden;
}

/* 添加左右邊界遮罩 */
.game-container::before,
.game-container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2rem;
    background: transparent;
    z-index: 15;
    pointer-events: none;
}

/* 左側邊界遮罩 */
.game-container::before {
    left: -2rem;
    background: linear-gradient(to right,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, 0) 100%);
}

/* 右側邊界遮罩 */
.game-container::after {
    right: -2rem;
    background: linear-gradient(to left,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, 0) 100%);
}

/* 確保障礙物層級正確 */
.obstacle-group {
    position: absolute;
    z-index: 5;
}

.game-bird {
    position: absolute;
    z-index: 10;
    transform: rotate(0deg);
    /* CSS中預設角度 */
    transform-origin: center center;
    transition: none;
    /* 預設關閉過渡 */

    /* 設定 Sprite 背景 */
    /* background-image: url('../img/pingu_ani.png');
    background-size: 3.6rem 1.5rem; */
    /* sprite 總尺寸：容器寬度×3幀, 容器高度×1 */
    background-repeat: no-repeat;

    /* 預設狀態：一般狀態 (第一幀) */
    background-position: 0rem 0rem;
}

/* 小鳥 Sprite 狀態 */
.game-bird.normal-state {
    background-position: 0rem 0rem;
    /* 第一幀：一般狀態 */
}

.game-bird.flying-state {
    background-position: -2.4rem 0rem;
    /* 第二幀：飛行狀態 */
}

.game-bird.collision-state {
    background-position: -2.4rem 0rem !important;
    /* 第三幀：撞擊狀態 (x=240) */
}

/* 確保碰撞狀態不會被翅膀揮動動畫覆蓋 */
.game-bird.collision-state.flapping {
    animation: none !important;
    background-position: -2.4rem 0rem !important;
}

/* 翅膀揮動動畫 - 使用 sprite 位置切換 */
.game-bird.flapping {
    animation: spriteWingFlap var(--wing-flap-speed, 0.2s) steps(2, end) infinite;
}

@keyframes spriteWingFlap {
    0% {
        background-position: 0rem 0rem;
        /* 第一幀：一般狀態 */
    }

    100% {
        background-position: -2.4rem 0rem;
        /* 第二幀：飛行狀態 */
    }
}

.obstacle,
.top-box,
.bottom-box {
    position: absolute;
    z-index: 5;
}

/* 重寫CSS以避免main.css中固定高度的影響 */
.game-container {
    overflow: visible !important;
    /* 確保底部內容不被隱藏 */
}

.game-container .top-box,
.game-container .bottom-box {
    width: auto !important;
    height: auto !important;
    position: absolute;
    z-index: 5;
}

.ff-box,
.ga-box {
    display: block;
    position: relative;
    z-index: 6;
}

/* 強化邊界控制 */
.ff-game-bg,
.ga-game-bg {
    overflow: hidden !important;
    position: relative;
}

/* 添加視覺邊界指示器（可選，除錯用） */
.game-container.debug-mode::before,
.game-container.debug-mode::after {
    background: rgba(255, 0, 0, 0.2);
    border: 1px solid red;
}

/* 更強力的邊界遮罩方案 */
.game-container-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 16;
    pointer-events: none;
   
}

.countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 2rem;
    color: rgb(255, 255, 255);
    z-index: 20;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    opacity: 0;
}

.countdown.show {
    opacity: 1;
    animation: countdownPulse 1.2s ease-in-out;
}

/* GO! 特殊樣式 */
.countdown.go {
    font-size: 2.2rem;
    color: #ffffff;
    /* 金色 */
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    animation: goAnimation 0.8s ease-in-out;
}

@keyframes goAnimation {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0;
    }
}

/* 遊戲結束遮罩 */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.75);
    z-index: 19;
    opacity: 0;
}

.game-over-overlay.show {
    animation: overlayFadeIn 0.6s ease-in-out forwards;
}

/* 遊戲結束文字 */
.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.6rem;
    color: rgb(5, 5, 5);
    z-index: 20;
    text-shadow: 2px 2px 4px rgba(234, 234, 234, 0.8);
    opacity: 0;
    letter-spacing: 0.05rem;
    
    /* 確保遊戲結束畫面有正確的佈局 */
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
   
}

.game-over.show {
    animation: gameOverTextFadeIn 0.4s ease-in-out 0.4s forwards;
}

/* 通用隱藏類別 */
.hidden {
    display: none !important;
    visibility: hidden !important;
}

@keyframes countdownPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* 遮罩淡入動畫 */
@keyframes overlayFadeIn {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

/* 文字淡入動畫（延遲0.4秒） */
@keyframes gameOverTextFadeIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 彈窗出現動畫 */
.modal-bg {
    opacity: 0.5;
    transform: scale(0.2);
    transition: none;
}

.modal-bg.show-modal {
    animation: modalAppear 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes modalAppear {
    0% {
        opacity: 0.5;
        transform: scale(0.2);
    }

    60% {
        opacity: 0.9;
        transform: scale(1.1);
    }

    80% {
        opacity: 1;
        transform: scale(0.95);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* @keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
} */

.game-container.collision-mode {
    filter: brightness(0.7) contrast(1.2);
    transition: filter 0.2s ease;
}

/* 小鳥掉落旋轉動畫 */
.game-bird.falling-rotation {
    animation: birdFallRotation var(--fall-rotation-speed, 0.9s) linear infinite !important;
}

/* 碰撞狀態 + 旋轉動畫的組合 */
.game-bird.collision-state.falling-rotation {
    background-position: -2.4rem 0rem !important;
    /* 保持撞擊圖片 */
    animation: birdFallRotation var(--fall-rotation-speed, 0.9s) linear infinite !important;
    /* 保持旋轉 */
}

@keyframes birdFallRotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 只在需要角度動畫時啟用過渡 */
.game-bird.angle-transition {
    transition: transform var(--bird-angle-transition, 0.3s) ease-out;
    /* 按需啟用 */
}

/* 禁用角度過渡（碰撞時使用） */
.game-bird.no-angle-transition {
    transition: none !important;
}

/* 載入畫面樣式 */
#loadingScreen {

    z-index: 9999;

}

/* 載入畫面隱藏狀態 */
#loadingScreen.hidden {
    display: none !important;
    visibility: hidden !important;
}

.loading-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
}

.loading-container .loading-text {
    position: relative;
    font-weight: 700;
    font-style: italic;
    color: #252628;
    text-align: center;
    animation: loadingPulse 2s ease-in-out infinite;
    font-family: 'Montserrat', sans-serif;
    transition: transform 0.1s ease-out, text-shadow 0.1s ease-out;
}

/* 數字變化時的脈動效果 */
.loading-container .loading-text.number-change {
    animation: numberChange 0.15s ease-out, loadingPulse 2s ease-in-out infinite;
    transform: scale(1.08);
    /* text-shadow: 0 0 8px rgba(37, 38, 40, 0.4); */
}

.loading-container .loading-text::after {
    content: '%';
    color: #252628;
    position: absolute;
    font-weight: 700;
    font-style: italic;
    opacity: 1;
}

/* 載入完成動畫 */
.loading-container.complete {
    animation: loadingComplete 0.8s ease-out forwards;
}

.loading-container.complete .loading-text {
    animation: completePulse 0.5s ease-out;
    color: #4CAF50;
    text-shadow: 2px 2px 4px rgba(76, 175, 80, 0.3);
}

.loading-container.complete .loading-text::after {
    color: #4CAF50;
    opacity: 1;
}

/* 載入文字脈動動畫 */
@keyframes loadingPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* 完成脈動 */
@keyframes completePulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* 數字變化動畫 */
@keyframes numberChange {
    0% {
        transform: scale(1);
    }
    
    50% {
        transform: scale(1.08);
    }
    
    100% {
        transform: scale(1);
    }
}

/* 載入完成淡出 */
@keyframes loadingComplete {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
}



/* 手機觸控優化 */
.main_start_btn,
.next_btn,
.finish_btn,
.goback_btn,
.restart_btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* 遊戲容器觸控優化 */
.game-container {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@media screen and (orientation: landscape) {
    .countdown.go {
        font-size: 2.2rem;
    }

    .loading-container .loading-text {
        font-size: 1.15rem;
    }

    .loading-container .loading-text::after {
        font-size: 0.5rem;
        right: -0.5rem;
        bottom: 0.1rem;
    }
}

@media screen and (orientation: portrait) {
    .countdown.go {
        font-size: 1.4rem;
    }

    .loading-container .loading-text {
        font-size: 1.15rem;
    }

    .loading-container .loading-text::after {
        font-size: 0.5rem;
        right: -0.5rem;
        bottom: 0.1rem;
    }
}