/* =========================================
   遊戲二：飛花令樣式
   - 全獨立樣式表，供 game2.js 相關功能使用
   ========================================= */

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

.hidden {
    display: none !important;
}

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

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

/* 主字選擇區 */
.game2-keyword-selector {
    padding-bottom: 10px;
    display: flex;
    justify-content: center;
    gap: 2px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.00);
    width: 100%;
}

.kw-btn {
    width: 50px;
    height: 50px;
    padding: 10px;
    margin: 2px;
    border-radius: 50%;
    border: 2px solid var(--fm-border, #d8c193);
    background: transparent;
    color: var(--fm-ink, #2e241b);
    font-size: 30px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kw-btn:hover {
    background: var(--fm-paper-card, #fbf5e6);
    color: var(--fm-ink, #2e241b);
    transform: scale(1.1);
    box-shadow: var(--fm-shadow-soft, 0 2px 6px rgba(120, 90, 40, 0.3));
}

.kw-btn.active {
    background: var(--fm-paper-card, #fbf5e6);
    color: var(--fm-ink, #2e241b);
    transform: scale(1.1);
    box-shadow: var(--fm-shadow-soft, 0 2px 6px rgba(120, 90, 40, 0.3));
    border-color: var(--fm-border-strong, #b98e50);
}

/* 問題展示區 */
/* 限定作用域：只在 game2 中生效 */
#game2-container .game2-question-area {
    text-align: center;
    width: 100%;
    margin: 0px 0;
    padding: 0px 20px;
    color: var(--fm-ink, #2e241b);

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

/* 限定作用域：只在 game2 中生效（宣紙墨字） */
#game2-container .game2-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;
}

#game2-container .game2-poem-lines .hidden-char {
    color: var(--fm-cinnabar-bright, #c94f3d);
    font-weight: bold;
}

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

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

/* 答案矩陣與計時器 */
.game2-answer-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    /* ⚠️ 水平置中保底：父層 .game2-area 為 flex column，align-items 預設 stretch，
       若本層有 max-width 限制會偏左，用 align-self:center 保證置中（同 game1）。 */
    align-self: center;
}

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

.game2-answer-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
   （紅→黃即時色由 game2.js updateTimerRing 逐格插值）。*/

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

}

.game2-ans-btn {
    width: 66px;
    height: 66px;
    background: var(--fm-paper-card, #fbf5e6);
    border: 4px solid var(--fm-border, #d8c193);
    border-radius: 12px;
    font-size: 44px;
    line-height: 1;
    margin: 6px;
    /* 答案按鍵之間的間距 */
    color: var(--fm-ink, #2e241b);
    cursor: pointer;
    box-shadow: var(--fm-shadow-btn, 0 4px 5px rgba(120, 90, 40, 0.22));
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
}

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

/* ⚠️ 答案卡出場動畫：以自身中心點整體 XY 放大（scale 0 → 1），每片動畫 0.5s。
   ⚠️ 動畫延遲由 JS 依「所有卡片啟動時機一律壓進 0~0.5 秒之間」規則設定，
   卡片再多也不會拖長整體出場時間。
   ⚠️ animation-fill-mode: both — 延遲期間即套用 from 狀態（scale 0），
   避免「先完整顯示 → 又縮回」的閃爍。 */
.game2-ans-btn.game2-ans-appear {
    transform-origin: center center;
    animation: game2-ans-grow 0.5s ease-out both;
}

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

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

.game2-ans-btn.disabled {
    background: hsl(45, 20%, 84%);
    color: hsl(40, 12%, 58%);
    cursor: default;
    box-shadow: none;
    pointer-events: none;
}

.game2-ans-btn.correct {
    background: var(--fm-correct-bg, #e4f0e2) !important;
    border-color: var(--fm-correct-border, #7cbf93) !important;
    color: var(--fm-correct-text, #245c3c) !important;
}

.game2-ans-btn.wrong {
    background: var(--fm-wrong-bg, #f9e3df) !important;
    border-color: var(--fm-wrong-border, #dd8a80) !important;
    color: var(--fm-wrong-text, #8a2b20) !important;
    animation: game4-shake 0.4s;
}

/* 過關與否訊息框：game2.js 已改用共用 GameMessage 元件
   （.common-game-message，樣式見 theme_xuanzhi.css）。原 .game2-message 已移除。*/



/* 響應式調整 */
@media (max-width: 240px) {
    #game2-container .game2-poem-lines {
        font-size: 50px;
    }

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

@keyframes shake {

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

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

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