/* ═══════════════════════════════════════════════════════
   exam.css — 考試（考棚）遊戲樣式
   依 screen_adaptive.js 規範：
     - 500×850 邏輯尺寸
     - stage 內用 px（不用 rem/em，避免系統字級縮放影響）
     - overlay 位置與縮放由 registerOverlayResize 於 JS 動態套用
   ═══════════════════════════════════════════════════════ */

/* ─── 主遊戲 overlay（對齊 500×850 舞台） ─── */
#examOverlay {
    position: absolute;
    width: 500px;
    height: 850px;
    background: hsl(30, 30%, 12%);
    color: #f4e4a0;
    font-family: 'Noto Serif TC', serif;
    display: none;
    /* 由 JS 切換 block */
    z-index: 6000;
    overflow: hidden;
}

/* ─── 頁首列：文位標籤 + 題號 ─── */
.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    background: rgba(0, 0, 0, 0.35);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.exam-diff-tag {
    padding: 4px 20px;
    border-radius: 22px;
    font-size: 20px;
    font-weight: bold;
    color: #fff;
    /* 底色由 JS 依 rank 動態設定 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.exam-q-progress {
    font-size: 22px;
    font-weight: bold;
    color: hsl(45, 70%, 75%);
}

/* ─── 心（10 題共用） ─── */
.exam-hearts {
    display: flex;
    justify-content: center;
    gap: 0px;
    padding: 0px 10px;
    background: rgba(0, 0, 0, 0.15);
}

.exam-heart {
    font-size: 30px;
    color: hsl(0, 80%, 60%);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s, transform 0.3s;
}

.exam-heart.empty {
    opacity: 0.5;
    color: hsl(0, 83%, 30%);
    transform: scale(0.85);
}

/* ─── 主體：詩詞資訊 + 題目 + 倒數 + 選項 ─── */
.exam-body {
    padding: 10px 20px;
    height: calc(100% - 80px);
    display: flex;
    flex-direction: column;
}

/*詩詞資訊*/
.exam-poem-info {
    text-align: center;
    font-size: 20px;
    color: hsl(45, 45%, 68%);
    margin-bottom: 4px;
    opacity: 0.75;
}

/* ─── 題目容器（依格式可能是 2/3/3 行） ─── */
.exam-question {
    text-align: center;
    line-height: 1.2;
    letter-spacing: 4px;
    color: hsl(40, 50%, 80%);
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.66);
    margin: 3px 0 22px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

/* 單句可見詩句（字級由 JS 動態設定，避免長句超版） */
.exam-poem-line {
    font-weight: bold;
    margin: 2px 0;
    letter-spacing: 4px;
    white-space: nowrap;
    overflow: hidden;
    color: #fff8dc;
}

/* 可見句中的遮罩字 ◎（金黃色，突顯難度） */
.exam-poem-line .hidden-char {
    color: hsl(36, 80%, 55%);
    border-radius: 2px;
    padding: 0 1px;
}

/* 答對後揭曉遮罩字：改綠色高亮，與答案按鈕的綠色呼應 */
.exam-poem-line .hidden-char.exam-revealed-char {
    color: hsl(120, 68%, 55%);
    font-weight: bold;
    text-shadow: 0 0 8px hsla(120, 68%, 45%, 0.55);
    animation: exam-reveal-pop 0.4s ease-out;
}

@keyframes exam-reveal-pop {
    0% {
        transform: scale(0.8);
        opacity: 0.3;
    }

    60% {
        transform: scale(1.1);
    }

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

/* ─── 隱藏句佔位欄（灰色虛線框 + 呼吸動畫 + 方向提示） ─── */
.exam-hidden-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 48px;
    margin: 6px auto;
    padding: 4px 12px;
    width: 90%;
    border: 2px dashed hsla(0, 0%, 70%, 0.5);
    border-radius: 8px;
    background: hsla(0, 0%, 100%, 0.04);
    animation: exam-slot-pulse 1.6s ease-in-out infinite;
}

/* 答對後：佔位欄改為顯示正解（實線綠色框、綠色文字） */
.exam-hidden-slot.exam-slot-revealed {
    border: 2px solid hsl(120, 68%, 55%);
    background: hsla(120, 68%, 45%, 0.15);
    animation: none;
    box-shadow: 0 0 12px hsla(120, 68%, 55%, 0.5);
}

.exam-slot-answer {
    color: hsl(120, 68%, 65%);
    font-size: 38px;
    font-weight: bold;
    letter-spacing: 4px;
    text-shadow: 0 0 10px hsla(120, 68%, 45%, 0.6);
    animation: exam-reveal-pop 0.5s ease-out;
}

.exam-slot-hint {
    color: hsla(0, 0%, 100%, 0.8);
    font-size: 34px;
    letter-spacing: 2px;
}

@keyframes exam-slot-pulse {

    0%,
    100% {
        border-color: hsla(0, 0%, 70%, 0.5);
        box-shadow: 0 0 6px hsla(0, 0%, 70%, 0.15);
    }

    50% {
        border-color: hsla(45, 90%, 60%, 0.85);
        box-shadow: 0 0 10px hsla(45, 90%, 60%, 0.35);
    }
}

.exam-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    /* margin-top:auto 已移到 .exam-options-container；此處由父容器決定位置 */
}

.exam-option {
    padding: 0px 18px;
    border-radius: 12px;
    background: hsl(30, 20%, 22%);
    color: #f4e4a0;
    border: 1.5px solid hsla(45, 40%, 60%, 0.35);
    border-left: 6px solid hsla(45, 40%, 60%, 0.7);
    font-size: 50px;
    font-weight: bold;
    letter-spacing: 2px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    text-align: center;
    font-family: inherit;
}

.exam-option:hover {
    background: hsl(30, 30%, 30%);
}

.exam-option:active {
    transform: scale(0.98);
}

.exam-option.correct {
    background: hsl(120, 45%, 32%);
    border-color: hsl(120, 60%, 55%);
    color: #fff;
}

.exam-option.wrong {
    background: hsl(0, 50%, 32%);
    border-color: hsl(0, 60%, 55%);
    color: #fff;
}

.exam-option:disabled {
    cursor: default;
    opacity: 0.9;
}

/* ─── 選項區容器（含 SVG 邊框倒數計時） ─── */
.exam-options-container {
    position: relative;
    /* SVG 以此為定位基準 */
    padding: 12px;
    /* 與內部按鈕的間距，讓邊框有呼吸空間 */
    /* 上下 auto → 於題目與底部之間垂直置中，隨選項數量自動調整位置 */
    margin-top: auto;
    margin-bottom: auto;
    border-radius: 12px;
}

/* SVG 倒數框（覆蓋整個 options-container 邊緣，順時針縮短） */
#examTimerRing {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* 不干擾按鈕點擊 */
}

#examTimerPath {
    fill: none;
    stroke: hsl(0, 50%, 22%);
    /* 初始暗紅，JS 依 ratio 插值到鮮紅 */
    stroke-width: 8px;
    stroke-linecap: round;
    stroke-dasharray: 10000;
    /* 預設隱藏；JS 於 _startTimer 首次呼叫時計算 */
    stroke-dashoffset: 10000;
}

.exam-hidden-slot-row {
    margin-top: 10px;
    /* 缺句佔位與上一句之間的間距 */
}

/* ═══════════════════════════════════════════════════════
   考試結束結果彈窗（金榜題名 / 落榜）
   覆蓋於 examOverlay 之內
   ═══════════════════════════════════════════════════════ */

.exam-result-mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.exam-result-box {
    background: hsl(42, 38%, 86%);
    color: #333;
    border-radius: 14px;
    padding: 24px 26px;
    width: 80%;
    max-width: 400px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
    text-align: center;
    font-family: 'Noto Serif TC', serif;
}

.exam-result-title {
    font-size: 28px;
    font-weight: bold;
    color: hsl(0, 60%, 30%);
    margin-bottom: 14px;
    letter-spacing: 3px;
}

.exam-result-line {
    font-size: 18px;
    line-height: 1.6;
    margin: 6px 0;
    color: #5a3010;
}

.exam-result-btn {
    margin-top: 16px;
    padding: 10px 26px;
    font-size: 19px;
    font-weight: bold;
    background: hsl(0, 60%, 35%);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
}

.exam-result-btn:hover {
    background: hsl(0, 60%, 42%);
}

.exam-result-btn:active {
    transform: scale(0.97);
}

/* ═══════════════════════════════════════════════════════
   Alt+E 測試模式：文位選擇彈窗
   對齊 500×850 舞台，位置與縮放由 JS 套用
   ═══════════════════════════════════════════════════════ */

#examTestPicker {
    position: absolute;
    width: 500px;
    height: 850px;
    background: rgba(0, 0, 0, 0.85);
    z-index: 50000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-family: 'Noto Serif TC', serif;
}

.exam-test-picker-title {
    color: hsl(45, 80%, 70%);
    font-size: 26px;
    font-weight: bold;
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.exam-test-picker-sub {
    color: #fff;
    font-size: 16px;
    margin-bottom: 16px;
}

.exam-test-picker-btn {
    width: 220px;
    padding: 4px 0;
    font-size: 28px;
    font-weight: bold;
    background: hsl(30, 20%, 22%);
    color: #f4e4a0;
    border: 1.5px solid hsl(45, 50%, 50%);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 2px;
    transition: background 0.15s;
}

.exam-test-picker-btn:hover {
    background: hsl(30, 30%, 30%);
}

.exam-test-picker-btn:active {
    transform: scale(0.98);
}

.exam-test-picker-cancel {
    margin-top: 14px;
    padding: 8px 26px;
    font-size: 18px;
    background: hsl(0, 50%, 35%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.exam-test-picker-cancel:hover {
    background: hsl(0, 60%, 42%);
}