/* 宜蘭手寫基本功（原名生字筆順練習）：國小學生用（Chromebook kiosk，1366×768 為主），字型「ZhuyinKai」會自動帶注音 */
:root {
    --kid-bg: #fff7e6;
    --kid-card: #ffffff;
    --kid-border: #fed7aa;
    --kid-primary: #f97316;
    --kid-primary-dark: #c2410c;
    --kid-green: #16a34a;
    --kid-blue: #2563eb;
    --kid-red: #dc2626;
    --kid-text: #1f2937;
    --kid-muted: #6b7280;
    --zhuyin-font: "ZhuyinKai", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    --plain-font: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

html {
    font-size: 19px;
}

html, body {
    overscroll-behavior: none;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--zhuyin-font);
    line-height: 1.75;
    color: var(--kid-text);
    background-color: var(--kid-bg);
    background-image: radial-gradient(circle at 12% 18%, #ffedd5 0, transparent 28%),
                      radial-gradient(circle at 88% 82%, #fef3c7 0, transparent 30%);
    -webkit-user-select: none;
    user-select: none;
}

/* Bootstrap 元件也要用注音字型 */
.btn, .form-select, .modal-content {
    font-family: var(--zhuyin-font);
}

/* 放在 .btn 規則之後，頁尾與教師說明頁的按鈕、表單也不帶注音 */
.no-zhuyin, .no-zhuyin * {
    font-family: var(--plain-font);
}

/* ---------- 版面 ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .2rem 1rem;
    background: #ffedd5;
    border-bottom: 3px solid var(--kid-border);
}

.app-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--kid-primary-dark);
    text-decoration: none;
}

.header-lesson {
    font-size: 1.05rem;
    color: var(--kid-primary-dark);
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1340px;
    margin: 0 auto;
    padding: .6rem .8rem 1rem;
}

.app-footer {
    padding: .4rem 1rem;
    font-size: .62rem;
    line-height: 1.5;
    color: var(--kid-muted);
    text-align: center;
    border-top: 1px solid var(--kid-border);
    background: #fffaf0;
}

.app-footer a {
    color: var(--kid-muted);
}

.card-kid {
    background: var(--kid-card);
    border: 3px solid var(--kid-border);
    border-radius: 18px;
    padding: .6rem 1rem;
    box-shadow: 0 4px 0 rgba(249, 115, 22, .15);
}

/* ---------- 按鈕 ---------- */
.btn-kid, .btn-kid-sm {
    border-radius: 16px;
    border: 3px solid var(--kid-primary);
    background: #fff;
    color: var(--kid-primary-dark);
    font-weight: bold;
}

.btn-kid {
    font-size: 1.35rem;
    padding: .35rem 1.4rem;
}

.btn-kid-sm {
    font-size: 1.05rem;
    padding: .1rem .9rem;
}

.btn-kid:hover, .btn-kid-sm:hover {
    background: #fff7ed;
    color: var(--kid-primary-dark);
    border-color: var(--kid-primary-dark);
}

.btn-yes {
    background: var(--kid-green);
    border-color: var(--kid-green);
    color: #fff;
}

.btn-yes:hover {
    background: #15803d;
    border-color: #15803d;
    color: #fff;
}

.btn-no {
    border-color: #9ca3af;
    color: #374151;
}

.btn-no:hover {
    border-color: #6b7280;
    color: #111827;
    background: #f3f4f6;
}

.btn-start {
    background: var(--kid-primary);
    color: #fff;
    font-size: 1.6rem;
    padding: .35rem 2.4rem;
}

.btn-start:hover {
    background: var(--kid-primary-dark);
    color: #fff;
}

.btn-start:disabled {
    background: #fdba74;
    border-color: #fdba74;
    color: #fff;
}

/* ---------- 選擇頁 ---------- */
.welcome {
    font-size: 1.1rem;
    margin-bottom: .6rem;
}

.welcome p {
    margin: 0;
}

.welcome-title {
    font-size: 1.9rem;
    font-weight: bold;
    color: var(--kid-primary-dark);
    margin: 0 0 .3rem;
}

.welcome-hello {
    font-size: 1.35rem;
    font-weight: bold;
    color: var(--kid-primary-dark);
}

.welcome-note {
    color: var(--kid-muted);
}

/* 體驗模式（校外連線，不留紀錄、不計點）的說明 */
.welcome .visitor-banner {
    margin: 0 0 .3rem;
    padding: .15rem .8rem;
    border: 2px solid #bfdbfe;
    border-radius: 12px;
    background: #eff6ff;
    color: #1e3a8a;
    font-weight: bold;
}

/* 選擇頁最下面：依 IP 判斷的連線來源（學校被當成校外時照這一行回報） */
.network-source {
    margin: .5rem 0 0;
    font-size: .8rem;
    color: var(--kid-muted);
    text-align: right;
}

.point-text {
    color: var(--kid-red);
    font-size: 1.3rem;
}

/* 選擇頁「接著練習」：從練習頁按「返回選單」回來，同一個人要換別的練習（index-page.js）。
   上面的說明與學校、班級、座號三步收起來（body.continuing），只留這一塊（現在是誰＋「換人」）和版本課次 */
.continue-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: .6rem;
}

.continue-card[hidden] {
    display: none;
}

.continue-text {
    flex: 1 1 auto;
    min-width: 0;
}

.continue-who {
    margin: 0;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--kid-primary-dark);
}

.continue-note {
    margin: 0;
    font-size: 1.05rem;
    color: var(--kid-muted);
}

/* 恢復成完整的選擇頁時放在最上面的說明（.kid-alert 的 margin 寫在後面，所以這裡要兩個 class 才蓋得過） */
.kid-alert.top-message {
    margin: 0 0 .6rem;
}

body.continuing .welcome,
body.continuing #step-school,
body.continuing #step-class,
body.continuing #step-seat,
body.continuing #step-lesson .step-no {
    display: none;
}

.step-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
}

.step-wide {
    grid-column: span 2;
}

.step-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin: 0 0 .3rem;
    color: var(--kid-primary-dark);
}

.step-note {
    font-size: .9rem;
    font-weight: normal;
    color: var(--kid-muted);
}

.confirm-note {
    margin: .4rem 0 0;
    font-size: 1.1rem;
    color: var(--kid-primary-dark);
}

.step-no {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    margin-right: .5rem;
    border-radius: 50%;
    background: var(--kid-primary);
    color: #fff;
    text-align: center;
    line-height: 2rem;
    font-family: var(--plain-font);
}

.kid-select {
    font-size: 1.35rem;
    padding: .3rem .8rem;
    border: 3px solid var(--kid-border);
    border-radius: 14px;
}

.hint {
    margin: 0;
    color: var(--kid-muted);
}

.seat-grid > .hint, .lesson-grid > .hint {
    grid-column: 1 / -1;
}

.choice-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.choice-btn, .seat-btn, .lesson-btn {
    border: 3px solid var(--kid-border);
    border-radius: 14px;
    background: #fff;
    color: var(--kid-text);
}

.choice-btn {
    font-size: 1.25rem;
    padding: .1rem .9rem;
}

.choice-btn.active, .seat-btn.active, .lesson-btn.active {
    background: var(--kid-primary);
    border-color: var(--kid-primary-dark);
    color: #fff;
}

/* 選擇頁先分科目（2026-11-14）：老師開的活動（神祕寫字板、競賽，綠色，排前面）、國語、英語、數學各一顆大按鈕，
   選了才列那一科的版本（#publisher-list；只有一個版本時收起來） */
/* 層次（2026-11-15 使用者：三排按鈕長得太像，層次不夠清楚）：
   第一層 科目＝分頁（大、上面圓角），選中的那一顆坐在下面那個框（.subject-panel）的上緣，框的外框和它同一個顏色；
   第二層 版本＝框裡最上面一排小一號的膠囊，下面一條虛線；
   第三層 分類（.lesson-cats：國語小練習的改錯字、成語…，國中英文的課本、單字王…）＝左邊一條色線、淡色底的小膠囊；
   課次照舊是卡片（白底，在淡色的框裡最顯眼） */
.subject-list {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .5rem;
}

.subject-list:empty {
    display: none;
}

.choice-btn.subject-btn {
    flex: 1 1 8.5rem;
    max-width: 16rem;
    font-size: 1.5rem;
    font-weight: bold;
    padding: .35rem 1rem .3rem;
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    color: var(--kid-primary-dark);
}

.choice-btn.subject-btn.active {
    background: var(--kid-primary);
    border-color: var(--kid-primary);
    color: #fff;
}

.choice-btn.subject-now {
    border-color: #6fbf73;
    background: #f1faf1;
    color: #237a3c;
}

.choice-btn.subject-now.active {
    background: #2e9e4f;
    border-color: #2e9e4f;
    color: #fff;
}

.subject-panel {
    border: 3px solid var(--kid-primary);
    border-radius: 0 16px 16px 16px;
    background: #fffaf3;
    background: color-mix(in srgb, var(--kid-primary) 7%, #fff);
    padding: .55rem .65rem .65rem;
}

/* 老師開的活動（神祕寫字板、競賽）選著的時候，框跟著是綠色 */
.subject-list:has(.subject-now.active) + .subject-panel {
    border-color: #2e9e4f;
    background: #f4fbf4;
}

/* 還沒有科目（還沒選班級、讀取中）：只是一行說明，不畫框 */
.subject-list:empty + .subject-panel {
    border: 0;
    border-radius: 0;
    background: none;
    padding: 0;
}

.subject-panel > .lesson-grid {
    margin-top: 0;
}

#publisher-list[hidden] {
    display: none;
}

#publisher-list:not(:empty) {
    margin-bottom: .55rem;
    padding-bottom: .55rem;
    border-bottom: 2px dashed var(--kid-border);
}

.choice-btn.publisher-btn {
    font-size: 1.1rem;
    padding: .05rem 1rem;
    border-width: 2px;
    border-radius: 999px;
}

.seat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    gap: .35rem;
}

.seat-btn {
    height: 3.3rem;
    font-size: 1.35rem;
    font-family: var(--plain-font);
    font-weight: bold;
    padding: 0;
    line-height: 1.1;
}

.seat-btn.busy, .seat-btn.busy:disabled {
    background: #e5e7eb;
    border-color: #d1d5db;
    color: #9ca3af;
    opacity: 1;
}

.busy-tag {
    display: block;
    font-size: .62rem;
    font-weight: normal;
    font-family: var(--zhuyin-font);
}

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .4rem;
    margin-top: .4rem;
}

.lesson-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .2rem .4rem;
    line-height: 1.5;
}

/* 名稱比較長的課別（數學的題型，例如「除以一位數（有餘數）」）：按鈕寬一點、字小一點，名稱排成一列
   （1366 寬一列 4 個） */
.lesson-grid.wide {
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
}

.lesson-grid.wide .lesson-title {
    font-size: 1rem;
    white-space: nowrap;
}

.lesson-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.lesson-chars {
    font-size: .95rem;
    letter-spacing: .05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* 次要的一顆（2026-11-15：國語小練習各種的「答錯過的題目」，排在各組後面）：自己一排、虛線的小膠囊，名稱和說明排成一行 */
.lesson-btn.lesson-minor {
    grid-column: 1 / -1;
    justify-self: start;
    flex-direction: row;
    align-items: baseline;
    gap: .6rem;
    margin-top: .2rem;
    padding: .05rem 1rem;
    border-width: 2px;
    border-style: dashed;
    border-radius: 999px;
}

.lesson-minor .lesson-title {
    font-size: 1rem;
    font-weight: normal;
}

.lesson-minor .lesson-chars {
    font-size: .85rem;
}

/* 數學依學校教學計畫列出時的分段小標題（這學期的單元／全部題型），和還沒有練習的單元（灰色、不能按） */
.lesson-group {
    grid-column: 1 / -1;
    margin-top: .3rem;
    font-weight: bold;
    color: var(--kid-muted);
}

/* 「競賽」按活動整理（2026-10-23）：每一場單字限時賽、每個小組積分賽活動一張卡片，練習、考試、看名次的按鈕都在卡片上 */
.compete-card {
    grid-column: 1 / -1;
    padding: .4rem .6rem .5rem;
    border: 2px solid var(--kid-border);
    border-radius: 14px;
    background: var(--kid-bg);
}

.compete-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .2rem .8rem;
    margin-bottom: .35rem;
}

.compete-card-title {
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--kid-primary-dark);
}

.compete-card-note {
    color: var(--kid-muted);
}

.compete-card-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: .5rem;
}

/* 國中英文單字自己練習（2026-10-24）：課本、單字王、自訂題庫用分類選（一次只顯示一類），選了題庫下面出現選範圍那一塊 */
/* 第三層（2026-11-15）：版本裡面再分的種類，左邊一條色線、淡色底，按鈕比版本再小一號 */
.lesson-cats {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    padding: .35rem .6rem;
    border-left: 5px solid var(--kid-primary);
    border-radius: 0 12px 12px 0;
    background: #fdeedd;
    background: color-mix(in srgb, var(--kid-primary) 16%, #fff);
}

.lesson-cat {
    padding: 0 .8rem;
    border: 2px solid var(--kid-border);
    border-radius: 999px;
    background: #fff;
    color: var(--kid-text);
    font-size: .95rem;
}

.lesson-cat.active {
    background: var(--kid-primary-dark);
    border-color: var(--kid-primary-dark);
    color: #fff;
}

.lesson-cat-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: inherit;
    gap: inherit;
}

.lesson-cat-panel[hidden] {
    display: none;
}

.range-picker {
    grid-column: 1 / -1;
    padding: .4rem .6rem .5rem;
    border: 2px dashed var(--kid-border);
    border-radius: 14px;
    background: var(--kid-bg);
}

.range-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem .8rem;
}

.range-name {
    font-weight: bold;
    color: var(--kid-primary-dark);
}

.range-modes {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.range-mode {
    padding: .05rem .8rem;
    border: 2px solid var(--kid-border);
    border-radius: 10px;
    background: #fff;
    color: var(--kid-text);
}

.range-mode.active {
    background: var(--kid-primary);
    border-color: var(--kid-primary-dark);
    color: #fff;
}

.range-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem .5rem;
    margin-top: .4rem;
}

.range-body[hidden] {
    display: none;
}

.range-select {
    width: auto;
    min-width: 6rem;
}

.range-number {
    width: 6.5rem;
}

.range-msg {
    margin-top: .25rem;
    color: var(--kid-muted);
}

.range-msg:empty {
    display: none;
}

/* 選字母（2026-11-11，單字王依字母練）：一個字母一格——字母、幾個字（登入的學生是「學會／全部」和一條進度條） */
.range-letter-box {
    flex: 1 1 100%;
    min-width: 0;
}

.range-letters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(4.1rem, 1fr));
    gap: .35rem;
}

.range-letter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .05rem;
    min-width: 0;
    padding: .1rem .15rem .3rem;
    border: 2px solid var(--kid-border);
    border-radius: 10px;
    background: #fff;
    color: var(--kid-text);
    line-height: 1.2;
    touch-action: manipulation;
}

.range-letter-name {
    font-size: 1.35rem;
    font-weight: bold;
}

.range-letter-count {
    font-size: .8rem;
    color: var(--kid-muted);
    white-space: nowrap;
}

.range-letter-bar {
    display: block;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: #e5e7eb;
    overflow: hidden;
}

.range-letter-bar[hidden] {
    display: none;
}

.range-letter-bar > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 3px;
    background: #22c55e;
}

.range-letter.active {
    border-color: var(--kid-primary-dark);
    background: var(--kid-primary);
    color: #fff;
}

.range-letter.active .range-letter-count {
    color: #fff;
}

.range-letter.active .range-letter-bar {
    background: rgba(255, 255, 255, .45);
}

.range-letter.active .range-letter-bar > span {
    background: #fff;
}

.range-letter.all-learned:not(.active) {
    border-color: #86efac;
    background: #f0fdf4;
}

.range-letter-hint {
    margin-top: .3rem;
    font-size: .9rem;
    color: var(--kid-muted);
}

.lesson-btn.lesson-none, .lesson-btn.lesson-none:disabled {
    background: #f3f4f6;
    border-color: #e5e7eb;
    border-style: dashed;
    color: #9ca3af;
    opacity: 1;
}

/* 「這週學什麼」：學校教學計畫的本週國語課、數學單元（按一項＝選好那個版本和課別） */
/* 今天的任務（2026-11-17）：畫在「這週學什麼」的位置，做完的那一項淡一點 */
.today-item.completed {
    opacity: .6;
}

.today-item:disabled {
    opacity: .6;
}

/* 注音「容易混的」：聽聽看是哪一個（2026-11-17） */
.which-board {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.4rem;
    height: 100%;
}

.which-speaker {
    font-size: 2.6rem;
    width: 7rem;
    height: 5.4rem;
}

.which-options {
    display: flex;
    gap: 1.2rem;
    justify-content: center;
}

.which-option {
    font-size: 4rem;
    width: 8rem;
    height: 8rem;
    line-height: 1;
}

.which-option.miss {
    opacity: .35;
}

.this-week {
    margin-bottom: .6rem;
    padding: .5rem .7rem .6rem;
    border: 3px solid var(--kid-primary);
    border-radius: 16px;
    background: #fffbeb;
}

.this-week-head {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: .35rem;
}

.this-week-items {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.this-week-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    border: 3px solid var(--kid-border);
    border-radius: 14px;
    background: #fff;
    color: var(--kid-text);
    padding: .25rem .8rem;
    text-align: left;
}

.this-week-item.active {
    background: var(--kid-primary);
    border-color: var(--kid-primary-dark);
    color: #fff;
}

.this-week-subject {
    flex: none;
    font-size: .9rem;
    font-weight: bold;
    padding: 0 .5rem;
    border-radius: 999px;
    background: var(--kid-primary);
    color: #fff;
}

.this-week-item.active .this-week-subject {
    background: #fff;
    color: var(--kid-primary-dark);
}

.this-week-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.this-week-detail {
    font-size: .95rem;
}

.start-bar {
    position: sticky;
    bottom: .4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: .6rem;
}

.selection-summary {
    font-size: 1.15rem;
}

.kid-alert {
    margin: .5rem 0 0;
    padding: .4rem .8rem;
    border-radius: 12px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 1.15rem;
}

/* ---------- 確認視窗 ---------- */
.kid-modal {
    border: 4px solid var(--kid-border);
    border-radius: 24px;
}

.confirm-question {
    font-size: 1.5rem;
    margin: 0;
}

.confirm-who {
    font-size: 2.1rem;
    font-weight: bold;
    color: var(--kid-blue);
    margin: .2rem 0;
}

.celebrate-emoji {
    font-size: 4rem;
    margin: 0;
    line-height: 1.2;
}

.celebrate-title {
    font-size: 2.4rem;
    font-weight: bold;
    color: var(--kid-red);
    margin: 0;
}

.celebrate-text {
    font-size: 1.5rem;
    margin: 0;
}

.celebrate-note {
    color: var(--kid-muted);
    margin: .4rem 0 0;
}

/* ---------- 練習頁 ---------- */
/* 1366×768 不必捲動（到分解列／部件區為止，頁尾在畫面外）：田字格 430（practice-page.js 的 computeSize）時，
   頁首 50＋資訊列 55＋主區 510＋分解列 121＋間距 27，分解列底端在 763。改這幾塊的高度、留白或根字級後要重量。
   這個配置的前提是資訊列與分解列都只有一列：資訊列不換行（校名太長就截斷）、分解列的小格子在筆畫多時縮小 */
.practice-page .app-title {
    line-height: 1.4;
}

.practice-top {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: .4rem .7rem;
    padding: .25rem .7rem;
    font-size: 1.1rem;
}

/* 資訊列各段不換行、不縮小；真實校名是「鄉鎮市＋簡稱」（7～10 個字），放不下時只有校名用「…」截斷
   （頁首右上角有完整的校名、班級、座號） */
.practice-top > * {
    flex: none;
    white-space: nowrap;
}

.practice-top > .top-who {
    flex: 0 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .3rem;
}

.top-school {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1rem;
}

.top-who strong {
    flex: none;
}

.top-lesson {
    font-weight: bold;
    color: var(--kid-primary-dark);
}

/* 英文單字只練一段（2026-10-23：單字限時賽、小組積分賽的範圍、學校指定的課、照教學進度） */
.top-range {
    display: inline-block;
    margin-left: .3rem;
    padding: 0 .5rem;
    border: 1px solid var(--kid-border);
    border-radius: 999px;
    background: var(--kid-bg);
    font-size: .85rem;
    font-weight: normal;
    white-space: nowrap;
}

.top-points {
    color: var(--kid-red);
    font-weight: bold;
}

.top-actions {
    margin-left: auto;
    display: flex;
    gap: .4rem;
}

.practice-main {
    display: grid;
    grid-template-columns: 170px 1fr 290px;
    gap: .6rem;
    margin-top: .4rem;
}

.panel-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0 0 .2rem;
    color: var(--kid-primary-dark);
}

.char-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .35rem;
    max-height: 58vh;
    overflow-y: auto;
}

.char-tile {
    position: relative;
    font-size: 1.9rem;
    line-height: 1.5;
    padding: .1rem 0;
    border: 3px solid var(--kid-border);
    border-radius: 14px;
    background: #fff;
    color: var(--kid-text);
    font-family: var(--zhuyin-font);
}

/* 英文字母：字卡矮一點（一課 13 個、7 列不必捲動）；字母由 practice-page.js 用筆順資料畫成 svg */
.char-list-letters .char-tile {
    height: 54px;
    padding: 0;
    line-height: 1.2;
}

.char-tile .tile-glyph {
    display: block;
    height: 42px;
    width: auto;
    margin: 0 auto;
    fill: var(--kid-text);
}

/* 注音的拼音（拼讀）：一課 10 個音節（2 欄 5 列），字卡用筆順資料畫（直排加聲調，practice-page.js 的 drawSyllableTiles）。
   拼讀示範念到哪一個符號，那一組筆畫變成紅色（spell-on）；念代表字的時候整個字變紅（spell-all） */
.char-list-syllables .char-tile {
    min-width: 0;
    height: 80px;
    font-size: 1rem;
    padding: 0;
    line-height: 1.2;
}

.char-tile .tile-syllable {
    width: 100%;
    height: 72px;
}

.char-tile .tile-syllable [data-part] {
    transition: fill .15s;
}

.char-tile .tile-syllable .spell-on,
.char-tile.spell-all .tile-syllable {
    fill: var(--kid-red);
}

/* 數字練習的兩、三位數：字小一點，不和右上角的 ✔ 疊在一起（列高維持和一位數相同） */
/* 生字課：有部首筆畫的字卡用筆順資料畫（practice-page.js 的 drawRadicalTiles），部首那幾筆用部首的顏色。
   高度和原本的一行字相同（1.5em），字卡的大小不變 */
:root {
    --radical-color: #dc2626;
}

.char-tile .tile-hanzi {
    height: 1.2em;
    margin: .15em auto;
}

.char-tile .tile-radical {
    fill: var(--radical-color);
}

/* 「部首：言」：接在寫字區下面那一行的後面 */
.radical-info {
    margin-left: 1.2em;
    white-space: nowrap;
}

.radical-name {
    color: var(--radical-color);
    font-weight: 700;
}

/* 拼拼看：部首那一塊 */
.puzzle-slot.radical {
    position: relative;
    border: 3px solid var(--radical-color);
}

.puzzle-radical-tag {
    position: absolute;
    left: 50%;
    bottom: -1px;
    transform: translate(-50%, 50%);
    padding: 0 .3rem;
    border-radius: 8px;
    background: var(--radical-color);
    color: #fff;
    font-size: .7rem;
    line-height: 1.5;
    white-space: nowrap;
    pointer-events: none;
}

.puzzle-board.complete .puzzle-piece.radical path {
    fill: var(--radical-color);
}

.char-tile[data-len="2"] {
    font-size: 1.6rem;
    line-height: 1.78;
}

.char-tile[data-len="3"] {
    font-size: 1.3rem;
    line-height: 2.19;
}

.char-tile.current {
    border-color: var(--kid-blue);
    background: #eff6ff;
}

.char-tile.done::after {
    content: "✔";
    position: absolute;
    top: -.2rem;
    right: .1rem;
    font-size: 1rem;
    color: var(--kid-green);
    font-family: var(--plain-font);
}

.char-tile.done {
    background: #f0fdf4;
}

/* 兩、三位數與英文字母的 ✔ 小一點、貼近右上角 */
.char-tile[data-len="2"].done::after,
.char-tile[data-len="3"].done::after,
.char-list-letters .char-tile.done::after {
    top: -.1rem;
    right: .05rem;
    font-size: .7rem;
}

.char-tile.nodata {
    opacity: .45;
}

/* 按了「先寫下一個字」、還沒寫好的字：左上角橘點（practice-page.js 的 skipChar） */
.char-tile.skipped::before {
    content: "";
    position: absolute;
    top: .2rem;
    left: .2rem;
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    background: #f97316;
}

/* 看注音寫（2026-11-02；practice-page.js 的「看注音寫」）。只露出注音的做法：注音字型每個字寬 1.5em，
   國字在左邊（字型的 x 0～1010，字框 1024）、注音在右邊（1021～1505）。所以用一個寬 .49em、overflow hidden 的框，
   裡面的字往左移 .995em，就只看得到那一條注音（直排、聲調在右、輕聲的點在上，和課本一樣；是字型的預設讀音）。
   新的生字國字部分超過 1010 的話會露出一條細邊（字型目前的生字都沒有） */
.zy-clip {
    display: inline-block;
    width: .49em;
    height: 1em;
    overflow: hidden;
    line-height: 1;
    vertical-align: top;
    font-family: var(--zhuyin-font);
    user-select: none;
}

.zy-clip > span {
    display: inline-block;
    margin-left: -.995em;
    white-space: nowrap;
}

.char-tile .tile-face {
    display: block;
}

.char-tile .tile-zy {
    display: none;
}

/* 看注音寫的時候：還沒寫好的字只露出注音（字卡的高度不變：一行 1.9rem × 1.5） */
.char-list.dict .char-tile:not(.dict-done):not(.no-reading) .tile-face {
    display: none;
}

.char-list.dict .char-tile:not(.dict-done):not(.no-reading) .tile-zy {
    display: block;
    height: 2.85rem;
    font-size: 2.6rem;
    line-height: 1;
    padding-top: .12rem;
}

/* 看注音寫的時候不顯示全課的 ✔（上面的「進度」照舊是全課的），改顯示這一輪的：自己寫對 ✔、按過「忘記了」💡 */
.char-list.dict .char-tile.done {
    background: #fff;
}

.char-list.dict .char-tile.done::after {
    content: none;
}

.char-list.dict .char-tile.dict-done {
    background: #f0fdf4;
}

.char-list.dict .char-tile.dict-done::after {
    content: "✔";
    position: absolute;
    top: -.2rem;
    right: .1rem;
    font-size: 1rem;
    color: var(--kid-green);
    font-family: var(--plain-font);
}

.char-list.dict .char-tile.dict-hint::after {
    content: "💡";
    font-size: .85rem;
    top: 0;
}

.char-list.dict .char-tile.no-reading {
    opacity: .45;
}

/* 取代「筆順」那一列（高度不超過那一列，整頁才不必捲動） */
.dict-panel {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: .4rem;
    padding: .3rem 1rem;
    min-height: 3.4rem;
}

.dict-panel .panel-title {
    margin: 0;
    white-space: nowrap;
}

.dict-prompt {
    flex: none;
    font-size: 5.2rem;
    line-height: 1;
    min-width: .6em;
    text-align: center;
}

.dict-prompt .dict-answer {
    font-family: var(--zhuyin-font);
    font-size: 4rem;
    color: var(--kid-primary-dark);
}

.dict-help {
    margin: 0;
    font-size: 1.15rem;
}

.dict-actions {
    display: flex;
    gap: .4rem;
    margin-left: auto;
}

.btn-dict-hint {
    font-size: 1.2rem;
    background: #fef9c3;
    border: 2px solid #eab308;
    color: #854d0e;
    white-space: nowrap;
}

.btn-dict-hint:hover {
    background: #fef08a;
    color: #713f12;
}

.btn-dict-again {
    font-size: 1.05rem;
    white-space: nowrap;
}

/* 寫錯時閃一下這一筆正確的起筆點（practice-page.js 的 flashStartDot；字元座標，半徑 34） */
.start-dot {
    fill: #f97316;
    stroke: #fff;
    stroke-width: 10;
    animation: start-dot-blink .5s ease-in-out 5 alternate;
    pointer-events: none;
}

@keyframes start-dot-blink {
    from { opacity: 1; }
    to { opacity: .2; }
}

/* 「⏭ 先寫下一個字」：和「再看一次」同一個位置（寫寫看、自己寫的時候「再看一次」是收起來的） */
.btn-skip {
    font-size: 1.05rem;
    white-space: nowrap;
    padding-left: .4rem;
    padding-right: .4rem;
    background: #fff7ed;
    border: 2px solid #f97316;
    color: #c2410c;
}

.btn-skip:hover {
    background: #ffedd5;
    color: #9a3412;
}

.writer-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .5rem;
}

/* 紅框放在外層：若畫在 svg 本身，觸控座標會偏移框線寬度 */
.writer-box {
    position: relative;
    line-height: 0;
    border: 3px solid #ef4444;
    border-radius: 6px;
}

#writer {
    background: #fff;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#writer .grid-line {
    stroke: #fca5a5;
    stroke-width: 1.5;
    stroke-dasharray: 8 6;
}

/* 英文字母的四線格（取代田字格的十字線）：第三條是基線，用紅色 */
#writer .guide-line {
    stroke: #93c5fd;
    stroke-width: 1.5;
}

#writer .guide-base {
    stroke: #ef4444;
    stroke-width: 2;
}

/* 英文字母的筆順動畫：Hanzi Writer 沿著中心線畫的粗線（屬性寫的是 200，用外框裁切）往筆的兩邊各蓋 100 單位，
   小寫字母的圓半徑才 112～123、筆畫才 44 粗：筆走在圓的一邊時幾乎蓋到另一邊，播起來是一整塊冒出來、不是跟著筆走。
   改成和筆畫差不多粗：筆畫是 44（tools/build-letter-strokes.py 的 HALF_WIDTH × 2），60 是兩邊各多 8。
   多的這 8 單位要蓋得住：粗線的路線是折線（圓弧每 26 單位取一點，最彎的地方——小寫 s——折線離真正的弧 2 單位）、
   折返的地方被 practice-page.js 的 keepSharpTurns 移開 1 單位。接角用圓的（和筆順腳本畫外框的圓頭筆一樣）。
   前提是粗線的路線真的走到每一個轉角、而且從起筆點開始：practice-page.js 的 fitBrush 把路線換成筆順檔的 brush
   （build-letter-strokes.py 的 brush_points）；換不成的時候它會把 letter-brush 拿掉，退回程式庫原來的粗線。
   數字的筆順檔沒有 brush，所以數字不能用這條規則。
   只有粗線有 clip-path（學生寫的筆跡沒有）。改筆畫粗細、取點的方式或這個數字以後要跑 tools/writer-coverage-test.js
   （用 run({ step: 2 })），52 個字母都要是 0（48 以上才全部完整） */
#writer.letter-brush path[clip-path] {
    stroke-width: 60px;
    stroke-linejoin: round;
}

/* 注音的拼音（拼讀）：同樣的做法（tools/build-syllable-strokes.py 的 brush＝教育部的運筆路線）。
   符號縮小以後筆畫約 25～35 粗；教育部的運筆路線是折線、不在筆畫的正中間，所以粗線要寬一點才蓋得滿
   （2026-10-16 量的：60 有幾處缺一兩點、90 剩三個字各缺一兩點、100 五課全部是 0；輕聲的點另外繞一圈，見 dot_brush）。
   改這個數字以後用 tools/writer-coverage-test.js（run({ step: 2 })）量五課拼音，要全部是 0 */
#writer.syllable-brush path[clip-path] {
    stroke-width: 100px;
    stroke-linejoin: round;
}

.writer-message {
    position: absolute;
    inset: 30% 8% auto;
    padding: .6rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, .95);
    border: 3px solid var(--kid-border);
    font-size: 1.3rem;
    line-height: 1.6;
    text-align: center;
}

.cheer {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: .3rem 1.2rem;
    border-radius: 20px;
    background: var(--kid-green);
    color: #fff;
    font-size: 2rem;
    line-height: 1.6;
    box-shadow: 0 6px 0 rgba(0, 0, 0, .15);
    pointer-events: none;
}

/* 比較長的一句鼓勵（2026-11-18：上次沒寫完，這次寫完了）：放在字的上面一點，不蓋住剛寫好的字的中間 */
.cheer.long {
    top: 12%;
    width: max-content;
    max-width: 96%;
    padding: .3rem .8rem;
    font-size: .95rem;
    text-align: center;
}

.stroke-info {
    margin-top: .3rem;
    font-size: 1.3rem;
    min-height: 2.2rem;
    text-align: center;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.mode-buttons {
    display: grid;
    gap: .35rem;
}

.btn-mode, .btn-nav {
    white-space: nowrap;
}

.btn-mode {
    font-size: 1.25rem;
    border: 3px solid var(--kid-border);
    border-radius: 14px;
    background: #fff;
    color: var(--kid-text);
    padding: .1rem .5rem;
}

.btn-mode.active {
    background: var(--kid-blue);
    border-color: #1d4ed8;
    color: #fff;
}

.btn-action {
    font-size: 1.3rem;
    background: var(--kid-green);
    border-color: var(--kid-green);
    color: #fff;
}

.btn-action:hover {
    background: #15803d;
    color: #fff;
}

/* 注音符號發音 */
.btn-sound {
    font-size: 1.3rem;
    background: #7c3aed;
    border-color: #6d28d9;
    color: #fff;
}

.btn-sound:hover,
.btn-sound:active {
    background: #6d28d9;
    color: #fff;
}

/* 英文單字：聽的按鈕上現在念的速度（很慢／慢／中等／快，跟著學生調；word-common.js 的 attachLevel），升降時閃一下 */
.speech-level {
    display: inline-block;
    margin-left: .25em;
    padding: 0 .45em;
    border-radius: 999px;
    background: rgba(255, 255, 255, .25);
    font-size: .62em;
    line-height: 1.6;
    vertical-align: middle;
    white-space: nowrap;
}

.speech-level.changed-up {
    animation: speech-level-up 1.6s ease-out;
}

.speech-level.changed-down {
    animation: speech-level-down 1.6s ease-out;
}

@keyframes speech-level-up {
    0%, 40% { background: #fde047; color: #713f12; }
    100% { background: rgba(255, 255, 255, .25); color: inherit; }
}

@keyframes speech-level-down {
    0%, 40% { background: #bae6fd; color: #0c4a6e; }
    100% { background: rgba(255, 255, 255, .25); color: inherit; }
}

/* 發音那一列：「聽聽看」＋聲音開關（換字的時候要不要自己念；practice-page.js） */
.sound-row {
    display: flex;
    gap: .35rem;
}

.sound-row[hidden] {
    display: none;
}

/* 這一列裡面只有 246px（右邊那一塊寬 290）：注音字型一個字寬 1.5em，兩顆按鈕的字加起來要放得下，
   所以字比其他按鈕小一點（1.3rem 時「聽聽看」會比按鈕寬 12px、壓到開關；改字級或文字後要重量） */
.sound-row .btn-sound {
    flex: 1 1 auto;
    min-width: 0;
    padding-left: .3rem;
    padding-right: .3rem;
    font-size: 1.1rem;
    white-space: nowrap;
}

.btn-sound-auto {
    flex: 0 0 auto;
    padding-left: .35rem;
    padding-right: .35rem;
    font-size: 1.1rem;
    white-space: nowrap;
    border-color: #6d28d9;
    color: #5b21b6;
}

/* 關掉：灰色 */
.btn-sound-auto.off {
    border-color: #9ca3af;
    background: #f3f4f6;
    color: #4b5563;
}

/* 數學頁面資訊列上的聲音開關（Math.cshtml、MathActivity.cshtml 的 #btn-voice）：和旁邊的「換人」「返回選單」一樣高，
   資訊列的高度不可以變（下面的版面是照它算的）。左右留白比別的按鈕小：再寬 8px，10 個字的校名配 10 個字的題型名稱
   就會被截掉最後一個字（1366 寬；2026-10-08 量過） */
.top-actions .btn-sound-auto {
    padding: .1rem .25rem;
    font-size: 1.05rem;
}

.speed-buttons {
    display: flex;
    align-items: center;
    gap: .3rem;
}

.speed-label {
    font-size: 1rem;
    margin-right: .2rem;
    white-space: nowrap;
}

.btn-speed {
    font-size: 1.1rem;
    border: 2px solid var(--kid-border);
    border-radius: 12px;
    background: #fff;
    padding: 0 .6rem;
}

.btn-speed.active {
    background: var(--kid-primary);
    border-color: var(--kid-primary-dark);
    color: #fff;
}

.nav-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: .35rem;
}

.btn-nav {
    font-size: 1rem;
    border: 2px solid var(--kid-border);
    border-radius: 12px;
    background: #fff;
    padding: .1rem .2rem;
}

.breakdown-panel {
    margin-top: .4rem;
    padding: .3rem 1rem;
}

/* 分解列固定一列：一列放得下 19 格，20 畫以上的字（聽、讀、體…最多「鬱」29 畫）小格子等比縮小 */
.breakdown-row {
    display: flex;
    flex-wrap: nowrap;
    gap: .35rem;
}

/* 數字 10 以上的位值提示：接在「筆順」標題後面，不另外占一列 */
.number-tip {
    margin-left: 1rem;
    font-weight: normal;
    color: var(--kid-text);
}

.breakdown-item {
    flex: 0 1 58px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.breakdown-item svg {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    background: #fff;
    border: 2px solid #fca5a5;
    border-radius: 4px;
}

.breakdown-item.active svg {
    border-color: var(--kid-blue);
    box-shadow: 0 0 0 3px #bfdbfe;
}

/* 自己寫完「比一比」：錯最多次的那一筆（practice-page.js 的 showCompare） */
.breakdown-item.missed svg {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px #fecaca;
}

/* 自己寫完「比一比」：寫字區上藍色細線是學生寫對的那幾筆（字元座標，線寬不跟著縮放） */
#writer .compare-stroke,
#writer .compare-halo {
    fill: none;
    stroke: #2563eb;
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

#writer .compare-halo {
    stroke: #fff;
    stroke-width: 7px;
}

.breakdown-num {
    font-size: .8rem;
    font-family: var(--plain-font);
    color: var(--kid-muted);
    margin-top: .1rem;
}

.bd-grid {
    stroke: #fecaca;
    stroke-width: 10;
    stroke-dasharray: 36 28;
    fill: none;
}

/* 分解列小格子裡的四線格（英文字母） */
.bd-guide {
    stroke: #bfdbfe;
    stroke-width: 12;
    fill: none;
}

.bd-guide-base {
    stroke: #fca5a5;
}

.bd-done {
    fill: #1f2937;
}

.bd-current {
    fill: var(--kid-red);
}

.bd-todo {
    fill: #e5e7eb;
}

/* ---------- 部件拼拼看 ---------- */
.puzzle-board {
    position: absolute;
    inset: 0;
    background: #fff;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.puzzle-board .grid-line {
    stroke: #fca5a5;
    stroke-width: 1.5;
    stroke-dasharray: 8 6;
}

.puzzle-ghost {
    fill: #eef2f7;
}

.puzzle-measure {
    position: absolute;
    left: -10000px;
    top: 0;
    visibility: hidden;
}

/* 部件區一列排開（標題在左），1366×768 不必捲動就能拖 */
.puzzle-panel {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin-top: .4rem;
    padding: .3rem 1rem;
}

.puzzle-panel .panel-title {
    margin: 0;
    white-space: nowrap;
}

.puzzle-tray {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    min-height: 84px;
}

.puzzle-slot {
    width: 84px;
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--kid-border);
    border-radius: 14px;
    background: #fffbeb;
}

.puzzle-slot.empty {
    opacity: .35;
}

.puzzle-piece {
    line-height: 0;
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.puzzle-piece svg {
    display: block;
    overflow: visible;
}

.puzzle-piece.dragging {
    position: fixed;
    z-index: 2000;
    cursor: grabbing;
    filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .25));
}

.puzzle-piece.animating {
    transition: left .18s ease, top .18s ease, width .18s ease, height .18s ease;
}

.puzzle-piece.placed {
    position: absolute;
    cursor: default;
    pointer-events: none;
}

.puzzle-board.complete .puzzle-piece path {
    fill: var(--kid-text);
    transition: fill .5s;
}

/* ---------- 練習頁的配對（注音符號、數字；practice-page.js） ---------- */
/* 配對的時候取代寫字區：寬度用到中間這一塊的大部分，高度由程式設成和寫字區相同，所以整頁的高度不變。
   卡片沿用英文單字配對的樣式（.match-side、.match-card 與 picked／miss／matched） */
.pair-board {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.4rem;
    width: 100%;
    max-width: 720px;
}

/* 題目卡（左邊）：阿拉伯數字或喇叭 */
.pair-card.pair-ask {
    border-color: #93c5fd;
    font-family: var(--plain-font);
    font-size: 2.6rem;
    font-weight: bold;
    line-height: 1.2;
}

.pair-card.pair-ask.pair-sound {
    border-color: #c4b5fd;
    background: #f5f3ff;
    font-size: 2.4rem;
    font-weight: normal;
}

/* 答案卡（右邊）：國字、點點或注音符號 */
.pair-card.pair-answer {
    border-color: #fdba74;
    background: #fffbeb;
    font-size: 1.7rem;
    line-height: 1.5;
}

.pair-card.pair-answer.pair-sound {
    font-size: 2.6rem;
}

/* 國字的答案卡不換行；三個字的（二十一～九十九）在比 1366 窄的畫面（例如 1024 寬的平板）卡片只有一百多 px 寬，
   用小一點的字才放得下（2026-10-07 審查：1024 寬時第三個字被切掉） */
.pair-card.pair-answer.pair-word {
    white-space: nowrap;
}

@media (max-width: 1250px) {
    .pair-card.pair-answer.pair-word[data-len="3"] {
        padding-left: .1rem;
        padding-right: .1rem;
        font-size: 1.15rem;
    }
}

/* 選起來的、配錯的、配對了的樣子要蓋過上面的底色與框線 */
.pair-card.picked {
    border-color: var(--kid-blue);
}

.pair-card.miss {
    border-color: var(--kid-red);
    background: #fee2e2;
}

.pair-card.matched, .pair-card.matched:disabled {
    border-color: #86efac;
    background: #dcfce7;
}

/* 十格的框和圓點（數字配點點）。名稱不可以叫 .pair-dots：那是「配點點」這種配法每一張卡片都有的 class（pair-＋配法） */
.pair-dots-figure {
    display: block;
    width: 100%;
    max-width: 150px;
    height: auto;
    margin: 0 auto;
}

.pair-dots-cell {
    fill: #fff;
    stroke: #d6d3d1;
    stroke-width: 1.5;
}

.pair-dots-dot {
    fill: var(--kid-red);
}

.pair-board .cheer {
    top: 50%;
    z-index: 3;
}

/* 找拼音（拼音的課）：答案卡是用筆順資料畫的拼音 */
.pair-syllable-figure {
    display: block;
    height: 100%;
    max-height: 120px;
    width: auto;
    margin: 0 auto;
    fill: var(--kid-text);
}

.pair-card.pair-answer.pair-say {
    padding: .2rem;
}

/* 英文字母的配對（2026-11-03）：卡片上的字母用筆順資料畫（單層的 a、g，和字卡一樣），有淡淡的四線格看得出高矮。
   「順序」的題目卡是「C ➜ ？」：旁邊的字母、箭頭、問號排一列 */
.pair-card.pair-letter {
    padding: .2rem;
    font-family: var(--plain-font);
}

.pair-letter-figure {
    display: block;
    height: 100%;
    max-height: 110px;
    width: auto;
    margin: 0 auto;
    fill: var(--kid-text);
}

.pair-letter-figure .letter-line {
    stroke: #cbd5e1;
    stroke-width: 8;
}

.pair-letter-figure .letter-line.base {
    stroke: #94a3b8;
}

.letter-clue {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    height: 100%;
}

.letter-clue-near {
    display: flex;
    align-items: center;
    height: 100%;
    max-height: 90px;
}

.letter-clue-near .pair-letter-figure {
    max-height: 90px;
}

.letter-clue-arrow {
    font-size: 1.6rem;
    font-weight: normal;
    color: #64748b;
}

.letter-clue-blank {
    font-size: 2.2rem;
    color: var(--kid-blue);
}

/* 1250px 以下卡片只有一百多 px 寬：「C ➜ ？」三樣都縮小才排得下（1024 寬量過） */
@media (max-width: 1250px) {
    .letter-clue {
        gap: .1rem;
    }

    .letter-clue-near,
    .letter-clue-near .pair-letter-figure {
        max-height: 52px;
    }

    .letter-clue-arrow {
        font-size: 1.1rem;
    }

    .letter-clue-blank {
        font-size: 1.6rem;
    }
}

/* 聽音拼拼看（拼音的課）：左邊是「再聽一次」和要填的格子（符號直排，聲調一格在右邊），右邊是符號卡、聲調卡和「好了」。
   整塊和寫字區一樣高（pair-board 的高度由程式設定），1366×768 不會超出 */
.pair-board:has(.build-board) {
    display: block;
}

.build-board {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 1rem;
    height: 100%;
}

.build-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    min-height: 0;
}

.build-target {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex: 1;
    min-height: 0;
}

.build-column {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.build-slot {
    width: 74px;
    height: 74px;
    border: 3px dashed #a8a29e;
    border-radius: 12px;
    background: #fff;
    color: var(--kid-text);
    font-family: var(--zhuyin-font);
    font-size: 2.6rem;
    line-height: 1;
    touch-action: manipulation;
}

.build-tone-slot {
    width: 56px;
    height: 56px;
    font-size: 2.2rem;
}

.build-slot.first, .build-card.first {
    font-size: 1.1rem;
}

.build-slot:not(:empty) {
    border-style: solid;
    border-color: var(--kid-blue);
}

.build-slot.right {
    border-color: #22c55e;
    background: #dcfce7;
}

.build-slot.wrong {
    border-color: var(--kid-red);
    background: #fee2e2;
}

.build-right {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    justify-content: center;
}

.build-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .4rem;
}

.build-tones {
    grid-template-columns: repeat(5, 1fr);
}

.build-card {
    min-width: 0;
    height: 64px;
    padding: 0;
    border: 3px solid #fdba74;
    border-radius: 12px;
    background: #fffbeb;
    color: var(--kid-text);
    font-family: var(--zhuyin-font);
    font-size: 2.3rem;
    line-height: 1;
    touch-action: manipulation;
}

.build-tone {
    height: 54px;
    border-color: #c4b5fd;
    background: #f5f3ff;
}

/* 比 1366 窄的畫面（1024 寬的平板、900px 以下的單欄）：五張聲調卡一列放不下「一聲」，改成三欄兩列 */
@media (max-width: 1100px) {
    .build-tones {
        grid-template-columns: repeat(3, 1fr);
    }

    .build-card.first {
        font-size: .95rem;
    }
}

/* 配對的說明：取代下面「筆順」那一列（標題在左，數字 0～10 的兩種配法在右） */
.pair-panel {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin-top: .4rem;
    padding: .3rem 1rem;
    min-height: 3.4rem;
}

.pair-panel .panel-title {
    margin: 0;
    white-space: nowrap;
}

.pair-help {
    margin: 0;
    font-size: 1.15rem;
}

.pair-kinds {
    display: flex;
    gap: .4rem;
    margin-left: auto;
}

/* 有「配對」按鈕的頁面（注音符號、數字）：模式按鈕多一顆，「上一個／下一個」排成一列，右邊這一塊才不會超過主區的高度 */
.control-panel.compact-nav .nav-buttons {
    grid-template-columns: 1fr 1fr;
}

/* 一般生字課的聲音開關（看筆順念第幾筆）：放在「筆順」這一塊的右上角。
   用絕對位置，標題列和下面整塊的高度都不變（這一塊的底端要留在 764 以內，見「練習頁」開頭的說明）；
   按鈕的底端不可以碰到下面那一列小格子（筆畫多的字，小格子會排到最右邊） */
.breakdown-panel {
    position: relative;
}

.count-switch {
    position: absolute;
    top: .15rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .95rem;
    font-weight: normal;
    color: var(--kid-text);
}

/* 高度寫死：注音字型的行高比字級高很多，照字級算的話按鈕會碰到下面的小格子 */
.count-switch .btn-sound-auto {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 .6rem;
    font-size: .9rem;
    line-height: 1;
}

/* ---------- 數學手寫測試（/MathLab，原型） ---------- */
.mathlab-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem 1rem;
}

/* 年級、題型、換一題盡量排成一列，留高度給手寫區 */
.mathlab-top .choice-btn {
    font-size: 1.05rem;
    padding: 0 .6rem;
}

.mathlab-main {
    display: grid;
    grid-template-columns: 1fr 180px;
    gap: .75rem;
    margin-top: .75rem;
}

.mathlab-question {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem 1rem;
    margin: 0 .25rem .2rem;
}

/* 答案格：接在「題目 =」後面，寫在這裡的數字由 Chromebook 內建手寫辨識讀出來 */
.mathlab-answer-pad {
    width: 320px;
    height: 92px;
    touch-action: none;
    border: 3px solid var(--kid-primary);
    border-radius: 12px;
    background: #fffdf5;
    cursor: crosshair;
}

.mathlab-recognized {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
}

.mathlab-badge {
    color: var(--kid-muted);
    font-size: .95rem;
}

.mathlab-badge.active {
    color: var(--kid-primary-dark);
    font-weight: bold;
}

.mathlab-recognized-text {
    min-height: 2.4rem;
    font-family: var(--plain-font);
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--kid-primary-dark);
    line-height: 1.1;
}

.mathlab-hint {
    margin: 0 .25rem .3rem;
    font-size: .95rem;
}

/* 算式用一般字型（數字不需要注音，字寬較窄，四位數的題目也排得下） */
.mathlab-text {
    font-size: 2.6rem;
    font-weight: bold;
    white-space: nowrap;
}

.mathlab-board {
    padding: .5rem;
}

/* 方格只是畫面上的對齊輔助（CSS 背景），送給 AI 的手寫圖只有筆跡 */
.mathlab-pad {
    display: block;
    width: 100%;
    height: 340px;   /* mathlab-page.js 依畫面剩下的高度調整 */
    touch-action: none;
    border: 2px solid var(--kid-border);
    border-radius: 12px;
    background-color: #fff;
    background-image: linear-gradient(#eef2f7 1px, transparent 1px), linear-gradient(90deg, #eef2f7 1px, transparent 1px);
    background-size: 48px 48px;
    cursor: crosshair;
}

.mathlab-actions {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    justify-content: center;
}

.mathlab-actions .btn {
    width: 100%;
    white-space: nowrap;
}

.mathlab-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.mathlab-display {
    min-height: 3.2rem;
    font-size: 2.2rem;
    font-weight: bold;
    border-bottom: 3px solid var(--kid-border);
    margin: 0 auto .75rem;
    max-width: 260px;
}

.mathlab-keypad {
    display: grid;
    grid-template-columns: repeat(3, 76px);
    gap: .45rem;
    justify-content: center;
    margin-bottom: .9rem;
}

.mathlab-key {
    font-size: 1.6rem;
    height: 58px;
}

.mathlab-ai-note {
    color: var(--kid-muted);
    font-size: .95rem;
}

/* 結果視窗放寬一點，提示大多能排成一列 */
.mathlab-page #result-modal .modal-dialog {
    max-width: 680px;
}

/* 答錯時：學生的答案和正確答案一位一位比對（學生錯的那幾位紅色，正確答案對應的位數綠色） */
.mathlab-compare-wrap {
    overflow-x: auto;
    margin: .2rem 0;
}

.mathlab-compare {
    margin: 0 auto;
    border-collapse: separate;
    border-spacing: 5px 4px;
}

.mathlab-compare th {
    padding: 0 .4rem 0 0;
    font-size: 1.1rem;
    font-weight: normal;
    color: var(--kid-muted);
    text-align: right;
    white-space: nowrap;
}

.mathlab-compare th.mathlab-compare-name {
    padding: 0;
    text-align: center;
}

.mathlab-compare td {
    width: 44px;
    min-width: 44px;
    height: 48px;
    border: 2px solid var(--kid-border);
    border-radius: 8px;
    background: #fff;
    font-family: var(--plain-font);
    font-size: 1.7rem;
    font-weight: bold;
    line-height: 1;
}

.mathlab-compare td.mathlab-compare-gap {
    width: auto;
    min-width: 0;
    border: 0;
    background: none;
    color: var(--kid-muted);
}

.mathlab-compare td.blank {
    border-color: transparent;
    background: none;
}

.mathlab-compare-yours td.wrong {
    border-color: var(--kid-red);
    background: #fee2e2;
    color: #b91c1c;
}

.mathlab-compare-correct td.wrong {
    border-color: var(--kid-green);
    background: #dcfce7;
    color: #166534;
}

.mathlab-tip {
    margin: .3rem 0 .6rem;
    padding: .2rem .8rem;
    border: 3px solid var(--kid-border);
    border-radius: 14px;
    background: #fffbeb;
    font-size: 1.25rem;
}

/* 提示的一段（到逗號或冒號為止）：整段一起換行 */
.mathlab-tip-part {
    display: inline-block;
}

.mathlab-math {
    font-family: var(--plain-font);
    font-weight: bold;
}

.mathlab-results-title {
    font-size: 1.4rem;
    font-weight: bold;
}

.mathlab-stats {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin: .75rem 0;
}

.mathlab-stats > div {
    border: 2px solid var(--kid-border);
    border-radius: 12px;
    padding: .4rem .8rem;
    background: #fff;
}

.mathlab-stats span {
    display: block;
    color: var(--kid-muted);
    font-size: .85rem;
}

.mathlab-table {
    background: #fff;
    font-size: .9rem;
}

.mathlab-table th {
    white-space: nowrap;
}

/* 結果頁「錯在哪裡」：說明文字較長，給固定寬度避免把表格撐得太寬 */
.mathlab-diagnosis {
    min-width: 220px;
    max-width: 320px;
}

.mathlab-thumb {
    display: block;
    width: 160px;
    border: 1px solid var(--kid-border);
    margin-bottom: .25rem;
}

.mathlab-replay-canvas {
    max-width: 100%;
    border: 1px solid var(--kid-border);
}

/* ---------- 數學練習（/Math，正式版；手寫板與結果視窗沿用上面測試頁的樣式） ---------- */
/* 1366×768 不必捲動：頁首 50＋資訊列 55＋主區（計算區的高度由 math-page.js 依畫面剩下的高度計算），頁尾在畫面外 */
.math-page .mathlab-main {
    grid-template-columns: 1fr 200px;
    margin-top: .4rem;
}

.math-page .mathlab-answer-pad[hidden] {
    display: none;
}

/* 右邊的操作區：上面是這一回合第幾題、答對幾題，「清除」「送出」靠下（靠近寫字的手） */
.math-page .mathlab-actions {
    justify-content: flex-start;
}

.math-round {
    margin-bottom: auto;
    padding: .3rem .2rem;
    border: 3px solid var(--kid-border);
    border-radius: 14px;
    background: #fffbeb;
    text-align: center;
    line-height: 1.6;
    white-space: nowrap;
}

.math-round span {
    font-family: var(--plain-font);
    font-weight: bold;
}

.math-round-no {
    font-size: 1.05rem;
    color: var(--kid-primary-dark);
}

.math-round-correct {
    font-size: 1rem;
    color: var(--kid-green);
}

/* ---------- 英文單字（/Spelling）：拼字、填空，與闖關的第 2、3 關 ---------- */
/* 1366×768 不必捲動：頁首 50＋資訊列 55＋練習方式按鈕列 40＋單字編號列 40＋主區（手寫區的高度由 spelling-page.js 依畫面剩下的高度計算；
   單字卡、選擇題、配對的主區由 word-common.js 的 fitHeight 計算，樣式在後面「英文單字的其他練習方式」）。
   答錯時的逐個字母比對沿用數學手寫測試的 .mathlab-compare、提示沿用 .mathlab-tip */
.spell-tiles {
    display: flex;
    flex-wrap: nowrap;
    gap: .3rem;
    margin-top: .4rem;
}

/* 一組 20 個：按鈕上是題庫的編號（不顯示單字） */
.spell-tile {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 2.1rem;
    padding: 0;
    border: 3px solid var(--kid-border);
    border-radius: 12px;
    background: #fff;
    color: var(--kid-text);
    font-family: var(--plain-font);
    font-size: 1.05rem;
    font-weight: bold;
    line-height: 1;
}

.spell-tile.current {
    border-color: var(--kid-blue);
    background: #eff6ff;
}

.spell-tile.tried {
    background: #fff7ed;
    border-color: var(--kid-primary);
}

.spell-tile.done {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.spell-tile.done.current {
    border-color: var(--kid-blue);
}

.spell-tile.done::after {
    content: "✔";
    position: absolute;
    top: -.35rem;
    right: 0;
    font-size: .7rem;
    color: var(--kid-green);
}

.spell-main {
    display: grid;
    grid-template-columns: 1fr 210px;
    gap: .6rem;
    margin-top: .4rem;
}

.spell-card {
    min-width: 0;
    padding: .4rem .7rem;
}

.spell-prompt {
    display: flex;
    align-items: center;
    gap: .9rem;
    min-height: 3.6rem;
}

.spell-prompt > * {
    flex: none;
}

.spell-no {
    font-size: 1.1rem;
    color: var(--kid-muted);
    white-space: nowrap;
}

.spell-no span {
    font-family: var(--plain-font);
    font-weight: bold;
}

/* 中文解釋：太長就自己換行，其他項目不縮 */
.spell-prompt > .spell-zh {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 1.9rem;
    font-weight: bold;
    line-height: 1.5;
    color: var(--kid-primary-dark);
}

/* 很長的中文解釋（國中英語單字王，word-common.js 的 sizeZh）：字小一點，不把寫字的地方擠掉 */
.spell-prompt > .spell-zh.long {
    font-size: 1.4rem;
    line-height: 1.35;
}

.spell-prompt > .spell-zh.xlong {
    font-size: 1.1rem;
    line-height: 1.3;
}

/* 多義的單字（國中英語單字王、課本：「n. 書、書本　v. 預訂；預約」）一個詞性一行（word-common.js 的 fillZh，2026-10-29）；
   詞性用一般字型、淡一點。四段以上（right、back、close…）排成兩欄，不然太高 */
.zh-multi .zh-sense {
    display: block;
}

.zh-pos {
    margin-right: .35em;
    font-family: var(--plain-font);
    font-size: .8em;
    font-weight: normal;
    color: var(--kid-muted);
}

.zh-multi.zh-many {
    display: grid;
    grid-template-columns: repeat(2, auto);
    column-gap: 1.2em;
    justify-content: start;
}

/* 答完下面那一行說明（選擇題、闖關第 1 關；上面的題目已經一行一行列過）：每個詞性還是分開的一段，但接著排、放不下才換行，
   不然 right 這種六個詞性的字加上闖關的「過關」那一句會超出畫面 */
.spell-note .zh-multi.zh-many {
    display: inline;
}

.spell-note .zh-multi .zh-sense {
    display: inline-block;
    margin-right: 1em;
}

/* 結果視窗是置中的：兩欄也置中 */
.spell-result-zh.zh-many {
    justify-content: center;
}

/* 句子填空（2026-11-10，只給國中）：題目上面一行英文句子，要寫的字是一條空格；中文（.spell-zh）是整句的中文 */
.spell-sentence {
    margin: .1rem 0 0;
    font-family: var(--plain-font);
    font-size: 1.6rem;
    font-weight: bold;
    line-height: 1.45;
    color: var(--kid-text, #1f2937);
}

.spell-blank {
    display: inline-block;
    height: 1.1em;
    margin: 0 .2em;
    border-bottom: 3px solid var(--kid-primary);
    vertical-align: baseline;
}

.spell-result-sentence {
    margin: .3rem 0 0;
    font-family: var(--plain-font);
    font-size: 1.45rem;
}

.spell-sentence-word {
    color: var(--kid-blue);
    text-decoration: underline;
    text-underline-offset: .2em;
}

.spell-basic {
    padding: 0 .5rem;
    border-radius: 10px;
    background: #fef3c7;
    color: #92400e;
    font-size: .85rem;
    white-space: nowrap;
}

/* 手寫區：方格排在中間，上面蓋一張透明的畫布（筆畫可以稍微寫出格子） */
.spell-stage {
    position: relative;
    height: 300px;   /* spelling-page.js 依畫面剩下的高度調整 */
    --box-w: 120px;
    --box-h: 160px;
}

.spell-rows {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.spell-row {
    display: flex;
    align-items: flex-start;
    gap: 28px;
}

.spell-word {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.spell-box {
    width: var(--box-w);
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.spell-ink {
    position: relative;
    box-sizing: border-box;
    height: var(--box-h);
    border: 2px solid #fca5a5;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

/* 四線格：第三條是基線，用紅色（和英文字母練習相同） */
.spell-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 1.5px solid #bfdbfe;
}

.spell-line-base {
    border-top: 2px solid #fca5a5;
}

/* 按鍵輸入的字母印在方格裡：固定用 Arial（各裝置的字型高度一致，基線才對得上第三條線） */
.spell-text, .spell-chip, .spell-key, .spell-answer, .spell-letter, .spell-fixed, .spell-compare td {
    font-family: Arial, "Liberation Sans", Arimo, Helvetica, sans-serif;
}

.spell-text {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 35.5%;
    margin-bottom: -.153em;
    font-size: calc(var(--box-h) * .6);
    line-height: 1;
    text-align: center;
    color: var(--kid-text);
    pointer-events: none;
}

.spell-box.cursor .spell-ink {
    border-color: var(--kid-blue);
    box-shadow: 0 0 0 3px #bfdbfe;
}

.spell-box.unknown .spell-ink {
    border-color: var(--kid-red);
    background: #fef2f2;
}

/* 英文填空：題目給的字母印在灰色方格裡（不能寫），白色方格才是學生要寫的 */
.spell-box.given .spell-ink {
    border-color: #cbd5e1;
    background: #eef2f6;
}

.spell-box.given .spell-text {
    color: #64748b;
}

/* 撇號、連字號：不用寫，印在方格之間。字級和方格裡的字母相同，上方留白讓基線落在第三條線
   （Arial 的基線在行高 1 的 0.8465em 處：0.645 − 0.8465 × 0.6 = 0.137） */
.spell-fixed {
    box-sizing: border-box;
    width: calc(var(--box-w) * .3);
    height: var(--box-h);
    padding-top: calc(var(--box-h) * .137);
    font-size: calc(var(--box-h) * .6);
    font-weight: bold;
    line-height: 1;
    text-align: center;
    color: var(--kid-muted);
}

.spell-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

.spell-canvas[hidden] {
    display: none;
}

/* 方格下面的字母：手寫辨識讀到的結果，點它可以用按鍵更正（要蓋在畫布上面才點得到） */
.spell-chip {
    position: relative;
    z-index: 2;
    height: 40px;
    margin-top: 6px;
    padding: 0;
    border: 2px solid var(--kid-border);
    border-radius: 10px;
    background: #fffbeb;
    color: var(--kid-primary-dark);
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1;
}

.spell-chip.typed {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
}

.spell-box.unknown .spell-chip {
    border-color: var(--kid-red);
    background: #fee2e2;
    color: #b91c1c;
}

/* 畫面上的字母按鍵（沒有手寫辨識的裝置）：26 個字母排兩列 */
.spell-keys {
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    gap: .25rem;
    margin-top: .4rem;
}

.spell-keys[hidden] {
    display: none;
}

.spell-key {
    height: 2.6rem;
    padding: 0;
    border: 2px solid var(--kid-border);
    border-radius: 10px;
    background: #fff;
    color: var(--kid-text);
    font-size: 1.4rem;
    font-weight: bold;
    line-height: 1;
}

.spell-key:active {
    background: #ffedd5;
}

/* 大寫、刪除：各占最右邊一欄（第一列、第二列） */
.spell-key-wide {
    grid-column: 14;
    font-family: var(--zhuyin-font);
    font-size: .8rem;
    white-space: nowrap;
}

.spell-key-wide:nth-last-child(2) {
    grid-row: 1;
}

.spell-key-wide:last-child {
    grid-row: 2;
    font-family: var(--plain-font);
    font-size: 1.3rem;
}

.spell-key-wide.active {
    background: var(--kid-blue);
    border-color: #1d4ed8;
    color: #fff;
}

/* 說明列：平常是操作說明，有問題時換成紅色的提醒（固定一列的高度，方格不會跳動） */
.spell-note {
    margin: .3rem 0 0;
    min-height: 2.1rem;
    padding: 0 .6rem;
    border-radius: 10px;
    color: var(--kid-muted);
    font-size: 1rem;
    line-height: 2.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spell-note.alert-note {
    background: #fee2e2;
    color: #991b1b;
    font-size: 1.1rem;
}

.spell-actions {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: .5rem .6rem;
}

.spell-actions .btn-kid {
    width: 100%;
    padding: .2rem .3rem;
    font-size: 1.25rem;
    white-space: nowrap;
}

.spell-actions .btn-yes {
    font-size: 1.5rem;
}

.spell-actions [hidden] {
    display: none;
}

.spell-badge {
    color: var(--kid-muted);
    font-size: .9rem;
    line-height: 1.5;
    text-align: center;
}

.spell-badge.active {
    color: var(--kid-primary-dark);
    font-weight: bold;
}

.spell-actions .nav-buttons {
    margin-top: auto;
}

/* 結果視窗 */
.spell-answer {
    margin: .2rem 0;
    font-size: 3.2rem;
    font-weight: bold;
    line-height: 1.2;
    letter-spacing: .06em;
    color: var(--kid-blue);
}

.spell-result-zh {
    margin: .2rem 0;
    font-size: 1.5rem;
    color: var(--kid-primary-dark);
}

.spell-letter {
    font-weight: bold;
    font-size: 1.15em;
}

/* 逐個字母比對：片語最多 15 個字母，格子比數學的窄一點才排得下 */
.spell-compare td {
    width: 40px;
    min-width: 40px;
}

.spell-picker {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: .35rem;
    margin: .5rem 0 .8rem;
}

.spell-picker .spell-key {
    height: 3rem;
    font-size: 1.6rem;
}

/* ---------- 英文單字的其他練習方式：按鈕列、單字卡、選擇題、配對、闖關 ---------- */
/* 練習方式：一列六顆，換方式是換網址重新載入（不釋放座號） */
.word-modes {
    display: flex;
    gap: .35rem;
    margin-top: .35rem;
}

.word-modes .btn-mode {
    flex: 1 1 0;
    min-width: 0;
    height: 2.1rem;
    padding: 0 .2rem;
    overflow: hidden;
    font-size: 1.15rem;
    line-height: 1.75rem;
}

/* 國中：整份題庫的統計（學會幾個、該複習幾個）與「換一批單字」，排在練習方式的右邊 */
.word-modes .word-bank {
    flex: 0 0 auto;
    align-self: center;
    padding: 0 .3rem;
    font-size: .8rem;
    line-height: 1.05rem;
    text-align: right;
    white-space: nowrap;
    color: var(--kid-muted, #6b7280);
}

.word-modes .word-bank-due {
    color: #b45309;
    font-weight: 600;
}

/* 下一批／換一批、照順序／隨機（2026-11-12）：排在練習方式那一列的最右邊。字比練習方式的按鈕小一點——
   國小的頁面有注音（一個字 1.5em 寬），不然七顆練習方式的按鈕會被擠到字放不下 */
.word-modes .btn-redraw,
.word-modes .btn-order {
    flex: 0 0 auto;
    padding: 0 .4rem;
    font-size: .95rem;
}

/* 國小、右邊有統計＋下一批＋照順序：練習方式的字小一點，寬度照字數分（三個字的「單字卡」「選擇題」比兩個字的寬） */
.word-modes.tight a.btn-mode {
    flex: 1 1 auto;
    font-size: 1.05rem;
}

/* 題目由程式安排的方式（選擇題、配對、闖關）：上面的編號只顯示進度，不能點 */
/* 不能點的編號：闖關已經學會的字（樣子就是打勾的綠色），與配對的整列 */
.spell-tile.static {
    pointer-events: none;
}

/* 配對：一局 6 個字由程式發牌，上面的編號只顯示進度。樣子不要像按鈕（沒有外框、灰底、細字）——
   使用者 2026-10-06 回報：看起來能點、點了沒反應，以為只能練第一題。其他五種方式的編號都可以點 */
.spell-tiles.readonly .spell-tile {
    border-color: transparent;
    border-radius: 6px;
    background: #f1f5f9;
    color: #64748b;
    font-weight: normal;
}

.spell-tiles.readonly .spell-tile.tried {
    background: #ffedd5;
    color: #9a3412;
}

.spell-tiles.readonly .spell-tile.done {
    background: #dcfce7;
    color: #166534;
}

/* 闖關：底色是這個單字過到第幾關（第 3 關過了就是 done，綠色打勾） */
.spell-tile[data-level="1"] {
    background: #fef9c3;
    border-color: #fde047;
}

.spell-tile[data-level="2"] {
    background: #dbeafe;
    border-color: #93c5fd;
}

/* 現在這一題：藍框加一圈。要排在 .tried 與 data-level 的後面才蓋得過它們的框色（同樣的優先順序，後面的贏）——
   2026-10-06 以前這條只給不能點的編號（.static.current）；開放選擇題、闖關點編號以後它們不再是 .static，
   闖關第 2、3 關與選擇題答錯過的字就看不出現在是哪一題了（審查發現） */
.spell-tile.current {
    border-color: var(--kid-blue);
    box-shadow: 0 0 0 3px #bfdbfe;
}

.word-main {
    display: grid;
    grid-template-columns: 1fr 210px;
    gap: .6rem;
    margin-top: .4rem;
}

.word-main[hidden], .spell-main[hidden] {
    display: none;
}

/* 主區塊：高度由 word-common.js 的 fitHeight 依畫面剩下的高度設定 */
.word-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    min-width: 0;
    height: 520px;
    padding: .5rem .7rem;
}

.word-panel .spell-note {
    margin: 0;
    flex: none;
}

/* 答對時說明列變成綠色 */
.spell-note.good-note {
    background: #dcfce7;
    color: #166534;
    font-size: 1.1rem;
}

/* 右邊操作欄裡的數字（第幾題、時間、配錯幾次…） */
.word-stat {
    font-size: 1.05rem;
    line-height: 1.7;
    text-align: center;
    white-space: nowrap;
}

.word-stat span {
    font-family: var(--plain-font);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--kid-primary-dark);
}

.word-stat-note {
    font-size: .9rem;
    color: var(--kid-muted);
}

/* 比較長的說明：可以換行 */
.word-stat-note.wrap {
    white-space: normal;
    text-align: left;
    line-height: 1.9;
}

/* 闖關：這一題是第幾關 */
.learn-stage {
    padding: 0 .6rem;
    border-radius: 10px;
    background: #dbeafe;
    color: #1e40af;
    font-size: 1rem;
    white-space: nowrap;
}

/* 英文都用 Arial（和拼字的方格相同） */
.pick-question.english, .pick-option.english, .flash-en, .match-card.en {
    font-family: Arial, "Liberation Sans", Arimo, Helvetica, sans-serif;
}

/* 選擇題：題目一列，下面四個大選項（2×2） */
.pick-prompt {
    display: flex;
    align-items: center;
    gap: .9rem;
    flex: none;
    min-height: 4.6rem;
}

.pick-prompt > * {
    flex: none;
}

.pick-prompt > .pick-question {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 2.3rem;
    font-weight: bold;
    line-height: 1.5;
    color: var(--kid-primary-dark);
}

.pick-prompt > .pick-question.long {
    font-size: 1.6rem;
    line-height: 1.35;
}

.pick-prompt > .pick-question.xlong {
    font-size: 1.2rem;
    line-height: 1.3;
}

.pick-prompt > .pick-question.english {
    font-size: 3.2rem;
    line-height: 1.2;
    letter-spacing: .04em;
    color: var(--kid-blue);
}

.pick-listen {
    padding: .3rem 2rem;
    font-size: 1.9rem;
}

/* 看句子選單字（2026-11-11，國中）：題目上面一行英文句子（要選的字是一條空格），題目那一列是整句的中文 */
.pick-sentence {
    flex: none;
    margin: 0;
    font-size: 1.9rem;
}

.pick-sentence:not([hidden]) + .pick-prompt {
    min-height: 2.6rem;
}

.pick-prompt > .pick-question.sentence-zh {
    font-size: 1.3rem;
    font-weight: normal;
    line-height: 1.4;
    color: var(--kid-muted);
}

.pick-options {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 1fr;
    gap: .6rem;
}

.pick-option {
    min-width: 0;
    padding: .2rem .6rem;
    overflow: hidden;
    border: 3px solid var(--kid-border);
    border-radius: 18px;
    background: #fff;
    color: var(--kid-text);
    font-size: 1.8rem;
    line-height: 1.6;
    touch-action: manipulation;
}

.pick-option.english {
    font-size: 2.4rem;
    font-weight: bold;
    line-height: 1.25;
}

.pick-option.long {
    font-size: 1.35rem;
}

.pick-option.english.long {
    font-size: 1.9rem;
}

/* 選了以後按鈕都停用，顏色照舊（Bootstrap 會把停用的按鈕變淡） */
.pick-option:disabled {
    opacity: 1;
    color: var(--kid-text);
    border-color: var(--kid-border);
    background: #fff;
}

.pick-option.dim:disabled {
    opacity: .45;
}

.pick-option.right:disabled {
    border-color: var(--kid-green);
    background: #dcfce7;
    color: #166534;
}

.pick-option.wrong:disabled {
    border-color: var(--kid-red);
    background: #fee2e2;
    color: #991b1b;
}

.pick-kinds {
    display: grid;
    gap: .35rem;
}

/* 最長的「聽聲音選單字」六個字要放得進 210px 的操作欄 */
.pick-kinds .btn-mode {
    min-width: 0;
    padding: .1rem 0;
    font-size: .95rem;
}

.pick-kinds [hidden] {
    display: none;
}

/* 單字卡：一張大卡片，點一下翻面 */
.flash-card {
    flex: 1 1 0;
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
    perspective: 1400px;
    touch-action: manipulation;
}

.flash-card[hidden], .card-end[hidden], .card-buttons[hidden] {
    display: none;
}

.flash-inner {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    transition: transform .35s;
    transform-style: preserve-3d;
}

.flash-card.flipped .flash-inner {
    transform: rotateY(180deg);
}

/* 換下一張時不要有翻回去的動畫（不然會先瞄到下一張的背面） */
.flash-card.no-flip .flash-inner {
    transition: none;
}

.flash-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .6rem 1rem;
    overflow: hidden;
    border: 4px solid #93c5fd;
    border-radius: 24px;
    background: #fff;
    backface-visibility: hidden;
}

.flash-back {
    transform: rotateY(180deg);
    border-color: #fdba74;
    background: #fffbeb;
}

.flash-en {
    font-size: 5rem;
    font-weight: bold;
    line-height: 1.15;
    letter-spacing: .03em;
    text-align: center;
    color: var(--kid-blue);
}

.flash-en.long {
    font-size: 3.4rem;
}

.flash-zh {
    font-size: 3rem;
    font-weight: bold;
    line-height: 1.5;
    text-align: center;
    color: var(--kid-primary-dark);
}

.flash-zh.long {
    font-size: 2.1rem;
}

.flash-zh.xlong {
    font-size: 1.5rem;
    line-height: 1.4;
}

/* 多義的單字一個詞性一行：整塊置中，每一行靠左對齊（不然長短不一的行各自置中，看起來亂） */
.flash-zh.zh-multi {
    text-align: left;
}

.flash-tip {
    font-size: 1rem;
    color: var(--kid-muted);
}

/* 單字卡背面的例句（2026-11-11，國中、這個字有句子才有）：一條虛線下面是英文句子（那個字標顏色）和整句的中文。
   有例句的那一面，上面的單字或中文解釋小一點，1366×768 才放得下 */
.flash-sentence {
    max-width: 100%;
    margin-top: .1rem;
    padding-top: .55rem;
    border-top: 2px dashed #c7d2fe;
    font-family: var(--plain-font);
    font-size: 1.8rem;
    font-weight: bold;
    line-height: 1.35;
    text-align: center;
    color: var(--kid-text, #1f2937);
}

.flash-sentence-zh {
    max-width: 100%;
    font-size: 1.3rem;
    line-height: 1.4;
    text-align: center;
    color: var(--kid-muted);
}

.flash-face.has-sentence {
    gap: .3rem;
}

.flash-face.has-sentence .flash-en {
    font-size: 3.6rem;
}

.flash-face.has-sentence .flash-en.long {
    font-size: 2.8rem;
}

.flash-face.has-sentence .flash-zh {
    font-size: 2.4rem;
    line-height: 1.35;
}

.flash-face.has-sentence .flash-zh.long {
    font-size: 1.9rem;
}

.flash-face.has-sentence .flash-zh.xlong {
    font-size: 1.3rem;
    line-height: 1.3;
}

.card-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .8rem;
    flex: none;
}

.card-buttons .btn-kid {
    padding: .25rem;
    font-size: 1.6rem;
}

/* 還沒翻面以前兩顆按鈕不能按 */
.card-buttons .btn-kid:disabled {
    opacity: .4;
}

.card-end {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.card-end-text {
    margin: 0;
    font-size: 1.8rem;
    line-height: 1.8;
    text-align: center;
}

.card-end .btn-kid {
    padding: .3rem 2rem;
    font-size: 1.6rem;
}

/* 配對：左邊兩欄英文卡、右邊兩欄中文卡，各 3 列 */
.match-board {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.6rem;
}

.match-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 1fr;
    gap: .5rem;
    min-width: 0;
    min-height: 0;
}

.match-card {
    min-width: 0;
    padding: .2rem .4rem;
    overflow: hidden;
    border: 3px solid var(--kid-border);
    border-radius: 16px;
    background: #fff;
    color: var(--kid-text);
    touch-action: manipulation;
}

.match-card.en {
    border-color: #93c5fd;
    font-size: 1.9rem;
    font-weight: bold;
    line-height: 1.25;
}

.match-card.zh {
    border-color: #fdba74;
    background: #fffbeb;
    font-size: 1.5rem;
    line-height: 1.6;
}

.match-card.en.long {
    font-size: 1.45rem;
}

.match-card.zh.long {
    font-size: 1.15rem;
}

.match-card.picked {
    border-color: var(--kid-blue);
    box-shadow: 0 0 0 4px #bfdbfe;
}

.match-card.miss {
    border-color: var(--kid-red);
    background: #fee2e2;
    animation: match-shake .4s;
}

/* 配對成功：留在原位變淡（其他卡片不會跑位置） */
.match-card.matched, .match-card.matched:disabled {
    border-color: #86efac;
    background: #dcfce7;
    opacity: .3;
}

@keyframes match-shake {
    25% { transform: translateX(-7px); }
    75% { transform: translateX(7px); }
}

/* 開始以前、玩完以後蓋在卡片上面：說明或成績，加一顆「開始／再玩一次」 */
.match-cover {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    border-radius: inherit;
    background: rgba(255, 255, 255, .97);
}

.match-cover[hidden] {
    display: none;
}

.match-cover-text {
    margin: 0;
    font-size: 1.7rem;
    line-height: 1.9;
    text-align: center;
    white-space: pre-line;
}

.match-cover .btn-kid {
    padding: .3rem 2.4rem;
    font-size: 1.8rem;
}

/* ---------- 英文單字的數字題庫（one～ten）：另一面是阿拉伯數字；字卡不顯示編號 ---------- */
/* 阿拉伯數字用一般字型、大一點的字（word-common.js 的 isNumeral；注音字型的數字比較細小） */
.numeral {
    font-family: var(--plain-font);
    font-weight: bold;
    letter-spacing: .02em;
}

.flash-zh.numeral {
    font-size: 7rem;
    line-height: 1.1;
}

.match-card.zh.numeral {
    font-size: 2.6rem;
    line-height: 1.2;
}

.pick-prompt > .pick-question.numeral {
    font-size: 3.4rem;
    line-height: 1.2;
}

.pick-option.numeral {
    font-size: 2.6rem;
    line-height: 1.3;
}

.spell-prompt > .spell-zh.numeral {
    font-size: 2.8rem;
    line-height: 1.2;
}

/* 字卡不顯示單字的編號（編號就是那個數字，顯示出來等於把答案告訴學生）：中間放一個圓點；
   現在這一題的外框、做完的打勾、答錯過的底色照舊 */
.spell-tiles.plain .spell-tile::before {
    content: "●";
    font-size: .7rem;
    color: #cbd5e1;
}

.spell-tiles.plain .spell-tile.current::before {
    color: var(--kid-blue);
}

/* ---------- 手寫辨識能力統計（/HwCheck） ---------- */
.hwcheck-subtitle {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 1rem 0 .4rem;
}

.hwcheck-table {
    background: #fff;
    font-size: .9rem;
}

/* 窄螢幕（平板直放）時改成上下排列 */
@media (max-width: 900px) {
    .step-grid {
        grid-template-columns: 1fr;
    }

    .step-wide {
        grid-column: auto;
    }

    .practice-main {
        grid-template-columns: 1fr;
    }

    .spell-main, .word-main {
        grid-template-columns: 1fr;
    }

    .word-modes {
        flex-wrap: wrap;
    }

    .word-modes .btn-mode {
        flex: 1 1 30%;
    }

    .spell-tiles {
        flex-wrap: wrap;
    }

    .spell-tile {
        flex: 0 0 calc(10% - .3rem);
    }

    /* 窄螢幕一列放不下：資訊列照舊換行 */
    .practice-top {
        flex-wrap: wrap;
    }

    .char-list {
        grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
        max-height: none;
    }
}

/* 國字隔幾天再寫一次（2026-11-02）：選擇頁「該複習的字」卡片（樣子照「這週學什麼」，綠色）、練習頁一次寫對（綠）、明天再寫（橘）的字卡 */
.this-week.review-card {
    border-color: #16a34a;
    background: #f0fdf4;
}

.review-card .this-week-subject {
    background: #16a34a;
}

.review-card .this-week-item.active {
    background: #16a34a;
    border-color: #15803d;
}

.review-card .this-week-item.active .this-week-subject {
    background: #fff;
    color: #15803d;
}

.char-tile.review-pass {
    box-shadow: inset 0 0 0 3px #22c55e;
}

.char-tile.review-again {
    box-shadow: inset 0 0 0 3px #fb923c;
}

/* ---------- 筆畫練習（控筆與基本筆畫，2026-11-14） ----------
   第一、二層：每個項目是一筆（或幾條線）的「字」。字卡排成一欄：左邊畫出那一筆、右邊是名稱（practice-page.js 的 drawStrokeTiles），
   控筆寫完的星星在右下角；一課最多 8 個（8 × 50px，不必捲動）。
   下面「筆順」那一列換成這一筆的名稱、說明、例字（stroke-panel；高度和原本那一列差不多，整頁的底端不變） */
.char-list-strokes {
    grid-template-columns: 1fr;
}

/* 字卡裡面只有 114px 寬（左邊那一塊 170px）：圖 34px，名稱兩個字 1.2rem、三個字 .85rem 排成一行，四個字以上排成兩行（一行兩個字）。
   注音字型一個字寬 1.5em；改名稱的長度或字級要重量（字卡的 scrollWidth 不可以大於 clientWidth） */
.char-list-strokes .char-tile[data-len] {
    display: flex;
    align-items: center;
    gap: .2rem;
    height: 48px;
    padding: 0 .15rem;
    font-size: .85rem;
    line-height: 1.15;
    text-align: left;
    overflow: hidden;
}

.char-list-strokes .char-tile[data-len="1"],
.char-list-strokes .char-tile[data-len="2"] {
    font-size: 1.2rem;
}

.char-tile .tile-stroke {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    margin: 0;
    border: 1px solid #fecaca;
    border-radius: 4px;
    background: #fff;
}

.char-tile .tile-name {
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
}

.char-list-strokes .char-tile[data-len="4"] .tile-name,
.char-list-strokes .char-tile[data-len="5"] .tile-name {
    width: 3.2em;
    white-space: normal;
    word-break: break-all;
}

.char-tile .tile-stars {
    position: absolute;
    right: .2rem;
    bottom: 0;
    font-size: .55rem;
    line-height: 1.3;
    font-family: var(--plain-font);
}

.char-list-strokes .char-tile.done::after {
    top: -.1rem;
    right: .1rem;
    font-size: .7rem;
}

body.stroke-items #breakdown-panel {
    display: none !important;
}

.stroke-panel {
    margin-top: .4rem;
    padding: .3rem 1rem;
}

.stroke-panel .stroke-name {
    margin-right: 1rem;
}

.stroke-panel .stroke-tip {
    font-weight: normal;
    color: var(--kid-text);
}

.stroke-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    height: 74px;
}

.stroke-examples-label {
    font-weight: bold;
    color: var(--kid-muted);
}

.stroke-examples {
    display: flex;
    gap: .5rem;
}

.stroke-example {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 66px;
    height: 66px;
    border: 2px solid #fca5a5;
    border-radius: 6px;
    background: #fff;
    font-size: 2rem;
    line-height: 1;
}

.stroke-example-glyph {
    width: 100%;
    height: 100%;
    fill: var(--kid-text);
}

.stroke-example-glyph .tile-radical {
    fill: var(--radical-color);
}

.stroke-stars {
    margin-left: 1rem;
    font-size: 1.15rem;
}

/* 第三層（筆畫的變化）：標題後面那一句說明（變了的那一筆在寫字區與字卡上是紅色） */
.focus-note::before {
    content: "";
    display: inline-block;
    width: .6em;
    height: .6em;
    margin-right: .35rem;
    border-radius: 50%;
    background: var(--radical-color);
}

/* ---------- 國中英文「📖 句子」底下的三種（2026-11-17）：重組句子、看中文寫整句（word-sentence.js） ---------- */
.word-modes.sentence-kinds {
    margin-top: -.25rem;
}

.word-modes.sentence-kinds .btn-mode {
    font-size: .95rem;
    padding: .2rem .8rem;
}

.sentence-card .sentence-zh {
    font-size: 1.5rem;
}

.sen-slots,
.sen-cards {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-content: flex-start;
    margin: .6rem 0;
}

.sen-slots {
    min-height: 4.2rem;
    padding: .5rem;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
}

.sen-slot-hint {
    color: #94a3b8;
    align-self: center;
}

.sen-card {
    font-size: 1.6rem;
    font-weight: 600;
    padding: .25rem .9rem;
    border: 2px solid var(--kid-primary, #f97316);
    border-radius: 10px;
    background: #fff;
    color: #1e293b;
    touch-action: manipulation;
}

.sen-card.placed {
    background: #eef2ff;
}

.sen-card.ok {
    border-color: #16a34a;
    background: #f0fdf4;
}

.sen-card.ng {
    border-color: #dc2626;
    background: #fef2f2;
}

.sen-write {
    position: relative;
    margin: .5rem 0;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
}

.sen-canvas {
    display: block;
    touch-action: none;
}

.sen-read {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    font-size: 1.3rem;
}

.sen-text {
    flex: 1;
    font-size: 1.5rem;
    font-weight: 600;
    word-break: break-word;
}

.sen-text.empty {
    color: #94a3b8;
    font-weight: normal;
}

.sen-keys {
    margin-top: .4rem;
}

.sen-key-row {
    display: flex;
    justify-content: center;
    gap: .3rem;
    margin-bottom: .3rem;
}

.sen-key {
    min-width: 2.6rem;
    font-size: 1.2rem;
    padding: .2rem .4rem;
    border: 1px solid #94a3b8;
    background: #fff;
}

.sen-key.wide {
    min-width: 5rem;
}

.sen-key.space {
    min-width: 12rem;
}

.sen-result {
    margin-top: .5rem;
    font-size: 1.4rem;
}

.sen-result-head {
    font-weight: bold;
    margin-bottom: .2rem;
}

.sen-result-head.ok {
    color: #16a34a;
}

.sen-result-head.ng {
    color: #dc2626;
}

.sen-result-line {
    margin: .1rem 0;
}

.sen-word.ng {
    color: #dc2626;
    text-decoration: line-through;
}

.sen-word.fix {
    color: #15803d;
    font-weight: bold;
}
