/* style.css - 修正版 v3 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'PingFang TC', 'Microsoft JhengHei', sans-serif;
    background: #fff;
    color: #222;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ===== 首頁 ===== */
#upload-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 95%;
    max-width: 850px;
    max-height: 98vh;
    overflow-y: auto;
    padding: 20px 10px;
}

#upload-screen h1 {
    font-size: 2.2rem;
    color: #222;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.section-label {
    width: 100%;
    font-size: 0.85rem;
    font-weight: bold;
    color: #999;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
    margin-top: 10px;
}

/* 拖曳區 */
.drop-zone {
    width: 100%;
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    background: #fafafa;
    transition: all 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over {
    background: #f0f0f0;
    border-color: #888;
}
.drop-zone .icon { font-size: 3rem; margin-bottom: 10px; }
.drop-zone .sub  { font-size: 0.85rem; color: #888; margin-top: 5px; }

#file-input { display: none; }

/* ★ Google 試算表網址列（加大） */
.url-row {
    display: flex;
    width: 100%;
    gap: 10px;
    align-items: stretch;
}

.url-row input {
    flex: 1;
    padding: 14px 16px;          /* ← 加大內距 */
    font-size: 1rem;             /* ← 字體放大 */
    border: 1.5px solid #ccc;
    border-radius: 8px;
    min-height: 52px;            /* ← 最小高度 */
    color: #333;
    background: #fff;
    transition: border-color 0.2s;
}
.url-row input:focus {
    outline: none;
    border-color: #222;
}
.url-row .btn {
    flex: 0 0 auto;
    padding: 14px 28px;
    white-space: nowrap;
    min-height: 52px;
}

/* 按鈕 */
.btn-row {
    display: flex;
    width: 100%;
    gap: 12px;
}

.btn {
    flex: 1;
    padding: 14px;
    border: 1.5px solid #ccc;
    border-radius: 8px;
    background: #fff;
    font-size: 1rem;
    font-weight: bold;
    color: #444;
    cursor: pointer;
    transition: all 0.2s;
}
.btn:hover  { background: #f4f4f4; border-color: #999; }
.btn.primary { background: #222; color: #fff; border-color: #222; }
.btn.primary:hover { background: #444; }
.btn.danger  { color: #d32f2f; border-color: #ffcdd2; background: #fff5f5; }
.btn.danger:hover { background: #ffebee; }

/* 題庫狀態 */
.bank-status {
    width: 100%;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 18px;
    text-align: center;
    font-size: 1rem;
    color: #555;
    border: 1px solid #e9ecef;
}

/* 範圍輸入 */
.range-row {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 15px;
}
.range-row input {
    width: 120px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    text-align: center;
    font-size: 1.1rem;
}

.format-hint {
    width: 100%;
    font-size: 0.9rem;
    color: #666;
    background: #f1f3f5;
    padding: 15px;
    border-radius: 8px;
    line-height: 1.6;
}

/* ===== 測驗畫面 ===== */
#quiz-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    position: relative;
    padding: 20px;
}

/* 右上：題號 */
.word-num {
    position: absolute;
    top: 20px;
    right: 40px;
    font-size: 5rem;
    font-weight: bold;
    color: #ddd;
    line-height: 1;
}

/* 左上：計時器 */
.timer-wrap {
    position: absolute;
    top: 30px;
    left: 40px;
}

.timer-circle {
    position: relative;
    width: 90px;
    height: 90px;
}
.timer-circle svg {
    transform: rotate(-90deg);
    width: 90px;
    height: 90px;
}
.bg-c {
    fill: none;
    stroke: #eee;
    stroke-width: 5;
}
.prog-c {
    fill: none;
    stroke: #222;
    stroke-width: 5;
    stroke-dasharray: 239;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.timer-num {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
    font-weight: bold;
    color: #222;
    line-height: 1;
    pointer-events: none;
    transition: color 0.3s;
}

/* 左下：進度 */
.progress-text {
    position: absolute;
    bottom: 35px;
    left: 45px;
    font-size: 1.3rem;
    color: #aaa;
    font-weight: bold;
}

/* 右下：按鈕群 */
.bottom-btns {
    position: absolute;
    bottom: 35px;
    right: 45px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-sm {
    padding: 12px 20px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    background: #fff;
    color: #555;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-sm:hover { background: #222; color: #fff; border-color: #222; }
.btn-sm.main  { background: #222; color: #fff; border-color: #222; min-width: 120px; }

/* 中央題目區 */
.card-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    padding: 0 20px;
}

.pos-text {
    font-size: clamp(1.4rem, 3vw, 2rem);
    color: #999;
    margin-bottom: 12px;
}

.zh-text {
    font-size: clamp(3.5rem, 11vw, 7.5rem);
    font-weight: bold;
    color: #111;
    margin-bottom: 50px;
    letter-spacing: 6px;
    white-space: nowrap;
    text-align: center;
}

/* 字母行 */
.letters-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 0;
    width: 96vw;
    max-width: 1400px;
    overflow: hidden;
}

.letter-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}

.letter-char {
    font-weight: bold;
    color: #111;
    line-height: 1;
    opacity: 0;                  /* 預設隱藏 */
    transition: opacity 0.4s;
    font-family: 'Courier New', monospace;
    display: block;
    text-align: center;
}
/* 第一個字母 & 已揭露 → 顯示 */
.letter-char.first-letter,
.letter-char.revealed { opacity: 1; }

/* ★ 底線：始終顯示 */
.letter-line {
    background: #111;
    border-radius: 2px;
    width: 100%;
    /* height 由 JS 動態設定 */
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 15px;
    width: 92%;
    max-width: 900px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.modal-content h3 { font-size: 1.6rem; color: #222; }

.modal-content textarea {
    width: 100%;
    height: 58vh;
    min-height: 350px;
    padding: 18px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 1.1rem;
    resize: vertical;
    line-height: 1.6;
    background: #fcfcfc;
}
.modal-content textarea:focus {
    outline: none;
    border-color: #222;
    background: #fff;
}

/* ===== Toast ===== */
#toast {
    visibility: hidden;
    min-width: 280px;
    background-color: #222;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 14px 24px;
    position: fixed;
    z-index: 9999;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
#toast.show {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== 完成畫面 ===== */
#complete-screen {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 25px;
    text-align: center;
    background: #fff;
}
#complete-screen h2 { font-size: 3.5rem; color: #222; }
#complete-screen p  { font-size: 1.4rem; color: #777; }

/* ===== RWD 手機 ===== */
@media (max-width: 600px) {
    .word-num { font-size: 2.5rem; top: 15px; right: 15px; }
    .timer-wrap { top: 15px; left: 15px; }
    .timer-circle { width: 70px; height: 70px; }
    .timer-circle svg { width: 70px; height: 70px; }
    .timer-num { font-size: 1.4rem; }
    .bottom-btns {
        right: 8px;
        bottom: 10px;
        gap: 6px;
        max-width: calc(100vw - 16px);
    }
    .btn-sm { padding: 9px 12px; font-size: 0.85rem; }
    .progress-text { left: 10px; bottom: 10px; font-size: 1rem; }
    .zh-text { font-size: clamp(2.2rem, 12vw, 4rem); margin-bottom: 30px; }
    .url-row { flex-direction: column; }
    .url-row .btn { width: 100%; }
}

/* ===== 音效開關按鈕 ===== */
.sound-toggle {
    margin-top: 10px;
    text-align: center;
    font-size: 1.5rem;
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s;
    line-height: 1;
}
.sound-toggle:hover {
    transform: scale(1.2);
}
