/* =========================================
   遊戲四：眾裡尋他千百度樣式
   - 全獨立樣式表，供 game4.js 相關功能使用
   ========================================= */

/* ⚠️ 介面「上半部」（overlay 背景、頂列、分數、控制鈕、難度標籤、
   紅心副標、詩詞出處連結）之樣式已抽至 theme_xuanzhi.css 的 .fm-* 共用區塊。
   本檔僅保留 .game4-area 及以下的遊戲區私有樣式。 */

/* 通用隱藏用 class：強制不顯示元素 */
.hidden {
    display: none !important;
}

/* 遊戲主區域 */
.game4-area {
    display: flex;
    flex: 1;
    flex-direction: column;
    position: relative;
    padding: 10px;
    width: 100%;
}

/* 難度標籤樣式已上移至 theme_xuanzhi.css 的 .fm-difficulty-tag */

/* 問題展示區 */
.game4-question-area {
    text-align: center;
    width: 100%;
    margin: 0 0;
    padding: 0px 20px;
    color: var(--fm-ink, #2e241b);

    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

/* 詩句（宣紙墨字；狀態色沿用 game1 一致的朱砂/青碧語意）*/
.game4-poem-lines {
    font-size: 50px;
    /*根據字數自動調整，請參考game1.js 動態縮小字體程式碼*/
    font-weight: bold;
    line-height: 1.2;
    margin-bottom: 6px;
    letter-spacing: 6px;
    color: var(--fm-ink, #2e241b);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
}

.game4-poem-lines span.hidden-char {
    color: var(--fm-cinnabar-bright, #c94f3d);
    border-radius: 2px;
    padding: 0 2px;
}

.game4-poem-lines span.correct-char {
    color: var(--fm-celadon, #3a7d5c);
    font-weight: bold;
}

.game4-poem-lines span.char-typing {
    color: var(--fm-ink-faint, #8a6a3e);
    font-weight: normal;
}

.game4-poem-lines span.char-wrong-pos {
    color: hsl(220, 55%, 45%);
    font-weight: bold;
}

.game4-poem-lines span.char-wrong {
    color: var(--fm-cinnabar, #c0392b);
    font-weight: bold;
}

/* 題目句子的延遲顯示樣式 */
.game4-poem-lines.game4-hidden-line {
    opacity: 0;
}

.game4-poem-lines.game4-hidden-line.revealed {
    opacity: 1;
    transition: opacity 3s ease;
}

/* 詩詞出處連結：樣式已上移至 theme_xuanzhi.css 的 .fm-poem-info（位於 fm-sub-header 右側）*/

/* 答案矩陣與計時器 */
.game4-answer-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    /* ⚠️ 水平置中保底：見 game1 同款修正說明 */
    align-self: center;
}

/* ⚠️ 三層同心圓結構（同 game1）：
   ① 最外圈：紅色 SVG timer path（10px stroke）
   ② 5px 間隔（由本層 padding 提供）
   ③ 中間圈：3px 邊框 + 徑向漸層底 + border-radius 20px（.game4-grid-inner-ring）
   ④ 20px 間隔（由中間圈 padding 提供）
   ⑤ 內圈：答案卡（.game4-answer-grid） */
.game4-grid-container {
    position: relative;
    display: inline-block;
    padding: 15px;
    background: transparent;
    border-radius: 0;
}

.game4-grid-inner-ring {
    background: radial-gradient(hsla(0, 0%, 100%, 0.0) 60%, rgba(0, 0, 0, 0.1)) 100%;
    border: 3px solid var(--fm-border, #d8c193);
    border-radius: 20px;
    padding: 20px;
}

/* 計時器外環／計時框：樣式已移至 theme_xuanzhi.css 的 .fm-timer-ring / .fm-timer-path
   （紅→黃即時色由 game4.js updateTimerRing 逐格插值）。*/

.game4-answer-grid {
    display: grid;
    margin: 0;
    /* ⚠️ 邊距改由 .game4-grid-inner-ring 統一提供 20px */
    padding: 0;
    gap: 1px;
    /* 答案按鍵之間的間距，請設定0，讓按鍵ans-btn的 margin 自行設定即可 */
    justify-content: center;
    justify-items: center;
    align-items: center;

}

/* ⚠️ 答案卡出場動畫：中心點整體 XY 放大（scale 0→1），每片 0.5s；
   延遲由 JS 依「所有卡片啟動時機壓進 0~0.5 秒」規則設定（同 game1/game2）。 */
.game4-ans-btn.game4-ans-appear {
    transform-origin: center center;
    animation: game4-ans-grow 0.5s ease-out both;
}

@keyframes game4-ans-grow {
    from {
        filter: brightness(0.66);
        transform: scale(0);
    }

    to {
        filter: brightness(1);
        transform: scale(1);
    }
}

/* 答案矩陣中單一按鍵（可點選字）的預設樣式 */
.game4-ans-btn {
    width: 66px;
    height: 66px;
    background: hsl(40, 50%, 88%);
    border: none;
    border-radius: 12px;
    font-size: 44px;
    line-height: 1;
    margin: 6px;
    /* 答案按鍵之間的間距 */
    color: hsl(210, 30%, 24%);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
}

.game4-ans-btn:active {
    transform: scale(0.9);
}

.game4-ans-btn.disabled {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.3);
    cursor: default;
    box-shadow: none;
    pointer-events: none;
}

.game4-ans-btn.correct {
    background: hsl(145, 68%, 36%) !important;
    color: white !important;
}

.game4-ans-btn.wrong {
    background: hsl(0, 80%, 60%) !important;
    color: white !important;
    animation: game4-shake 0.4s;
}

/* .game4-message 樣式已移除，改用統一的 GameMessage 元件 */

@keyframes game4-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

@media (max-width: 240px) {
    .game4-poem-lines {
        font-size: 50px;
    }

    .game4-ans-btn {
        width: 66px;
        height: 66px;
        font-size: 44px;
    }
}

/* 飛行星星 .flying-star：樣式已移至 theme_xuanzhi.css（結算共用樣式）。*/