/* ============================================================================
 * style-1.css   —   Lõi phần 1 — nền, khung, biến, header, menu
 * ----------------------------------------------------------------------------
 * 🔴 LÁT CẮT CỦA style.css. 11 lát PHẢI nạp ĐÚNG THỨ TỰ trong index.html.
 *    Đổi thứ tự = đổi kết quả đè = lệch giao diện, KHÔNG có lỗi nào báo.
 *    Nối cả 11 lát (bỏ banner này) = style.css gốc TỪNG BYTE.
 *    Kiểm:  node scripts/cut-css.js --verify
 *
 * MỤC LỤC — 2717 dòng · 358 rule · 68.4 KB
 *   dòng    55–96     Nền & còn lại           (2 rule)
 *   dòng   112–148    Nền & còn lại           (4 rule)
 *   dòng   210–270    Thành phần dùng chung   (6 rule)
 *   dòng   282–312    Bài thi                 (5 rule)
 *   dòng   375–406    Thành phần dùng chung   (2 rule)
 *   dòng   428–496    Nền & còn lại           (10 rule)
 *   dòng   499–565    Lịch sử                 (9 rule)
 *   dòng   598–631    Lịch sử                 (7 rule)
 *   dòng   681–732    Điều hướng & khung      (6 rule)
 *   dòng   781–816    Học sinh & huy hiệu     (6 rule)
 *   dòng   872–904    Bài thi                 (6 rule)
 *   dòng   954–1093   Vòng quay may mắn       (11 rule)
 *   dòng  1114–1176   Nền & còn lại           (16 rule)
 *   dòng  1178–1242   Vòng quay may mắn       (10 rule)
 *   dòng  1353–1390   Học sinh & huy hiệu     (4 rule)
 *   dòng  1436–1466   Tổng quan & biểu đồ     (5 rule)
 *   dòng  1474–1515   Học sinh & huy hiệu     (8 rule)
 *   dòng  1519–1566   Nền & còn lại           (9 rule)
 *   dòng  1618–1674   Học sinh & huy hiệu     (7 rule)
 *   dòng  1699–1742   Nền & còn lại           (3 rule)
 *   dòng  1755–1805   Cửa hàng & phần thưởng  (7 rule)
 *   dòng  2042–2081   Vòng quay may mắn       (7 rule)
 *   dòng  2187–2221   Bài thi                 (6 rule)
 *   dòng  2305–2395   Nền & còn lại           (8 rule)
 *   dòng  2492–2522   Điều hướng & khung      (2 rule)
 *   dòng  2600–2714   Cửa hàng & phần thưởng  (13 rule)
 *
 * Bảng tra đầy đủ mọi miền:      docs/BANDO-CSS.md
 * Vì sao cắt kiểu này:           docs/kien-truc/K6-1-so-do-tach-css.md
 * ========================================================================== */
/* =========================================================
   🔘 TOKEN BUTTON DÙNG CHUNG (chỉnh một chỗ — đồng bộ toàn app)

   [ĐỢT 5 · M3.4b] Khối này là BẢNG TOKEN THỨ HAI, chạy song song với tokens.css
   và áp lên selector `button` TRẦN (xem rule ngay dưới) — tức MỌI thẻ <button>
   của app, lan sang cả garden.css và memory-game.css. Tổng 42 điểm dùng.
   Hệ quả trước khi hợp nhất: đổi --radius-md trong tokens.css xong, nút vẫn bo
   theo bảng này. Nay đã NỐI DÂY 11/16 biến về thang chung.

   ⚠️ GIỮ NGUYÊN TÊN BIẾN — 42 điểm dùng đang bám vào, đổi tên là vỡ hàng loạt.
   ⚠️ Chỉ nối khi có token ĐÚNG VAI TRÒ và CÙNG GIÁ TRỊ → 0 đổi diện mạo.
      Không nối bừa theo con số: `--btn-font: 14px` trùng số với `--space-7`
      nhưng một cái là CỠ CHỮ, một cái là KHOẢNG CÁCH — nối vào là sai nghĩa,
      tới M4.1 đổi thang khoảng cách thì cỡ chữ nút đổi theo.
   ========================================================= */
:root {
    --btn-radius: var(--radius-md);          /* 10px */
    --btn-pad-y: var(--space-5);             /* 10px */
    --btn-pad-x: var(--space-8);             /* 18px */
    --btn-font-weight: var(--weight-bold);   /* 700 */
    --btn-gap: var(--space-3);               /* 6px */
    --btn-transition: var(--transition-btn); /* all .15s ease */
    /* Nhỏ (sm ~32px) */
    --btn-pad-y-sm: var(--space-3);          /* 6px */
    --btn-pad-x-sm: var(--space-6);          /* 12px */
    --btn-font-sm: var(--text-sm);           /* 13px */
    /* Lớn (lg ~52px) */
    --btn-pad-y-lg: var(--space-7);          /* 14px */
    --btn-font-lg: var(--text-lg);           /* 18px */

    /* ---- 5 biến CHƯA nối được, cố ý giữ số cứng ----
       Thang chung không có giá trị tương ứng ĐÚNG VAI, nối bừa là đổi diện mạo.
       ⚠️ 3 biến chiều cao đang DƯỚI chuẩn chạm 44px (--touch-min) của hướng A.
          Nâng chúng lên là ĐỔI DIỆN MẠO → việc của M4.2, KHÔNG làm ở M3.
          Riêng --btn-min-h áp cho `button` trần nên nâng nó là đụng TOÀN APP:
          phải rà lại màn Cài đặt (94 nút) và các hàng bảng ở khu quản trị. */
    /* ✅ [M4.2 lô 3] ĐÃ NÂNG lên chuẩn chạm. Ba biến này áp cho selector `button` TRẦN
       nên phủ MỌI nút của app, kể cả nút chưa gắn class `.btn`. Đặc tả M2-3 §4.3:
       “Vùng chạm ≥ --touch-min (44px) — KHÔNG NGOẠI LỆ”.
       Nhóm `sm` nhảy nhiều nhất: 32 → 44px (+12px). */
    --btn-min-h: var(--touch-min);      /* cũ 40px */
    --btn-min-h-sm: var(--touch-min);   /* cũ 32px */
    --btn-min-h-lg: 56px;               /* cũ 52px */
    --btn-font: 14px;       /* thang chữ nhảy 13→15, không có 14 */
    --btn-pad-x-lg: 28px;   /* thang --space nhảy 24→32, không có 28 */
}

body {
    font-family: 'Nunito', 'Segoe UI', Arial, sans-serif;
    margin: 0;
    padding: 8px;
    color: var(--text-body);

    /* [REDESIGN ĐỢT 1] Nối dây token — giá trị Y HỆT gradient cũ, nay tinh chỉnh 1 chỗ ở tokens.css. */
    background: var(--page-bg);
    background-attachment: fixed;
}

/* Các ô form không tự kế thừa font → ép kế thừa để đồng nhất với toàn hệ thống */
input,
select,
button,
textarea {
    font-family: inherit;
}

/* =========================================================
   🧩 KHUNG NỘI DUNG CHUNG (.main-panel)
   Đồng bộ khung của mọi màn (lấy "Cửa hàng đổi thưởng" làm gốc):
   cùng chiều rộng, min-height, nền, bo góc, padding, viền mảnh, bóng nhẹ.
   Hành vi lấp đầy/cuộn nội bộ trên desktop do các rule riêng từng màn đảm nhiệm.
   ========================================================= */
.main-panel {
    width: 100%;
    box-sizing: border-box;
    min-height: 585px;
    padding: var(--space-8);
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-md);
    margin: 0;
}

/* Mobile: không ép chiều cao tối thiểu (tôn trọng cuộn trang tự nhiên) */
@media (max-width: 900px) {
    .main-panel {
        min-height: auto;
    }
}

.app {
    max-width: 1600px;
    margin: auto;
    /* [ĐỢT 5 · M3.4] Nối dây --surface-app. Dòng này thực tế ĐÃ CHẾT trong cascade
       (rule .app ở cuối file đè hoàn toàn) — nối vào chỉ để không còn màu viết cứng,
       diện mạo không đổi một pixel. */
    background: var(--surface-app, #ffffff);
    padding: 10px 20px;
    border-radius: var(--radius-md);
}

h1 {
    text-align: center;
    color: var(--text-strong);
    margin: 6px 0 10px;
    font-size: 36px;
    letter-spacing: 1px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    background: #e2efda;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    font-weight: bold;
}

.control-area {
    /* [1B.3] Giãn nhịp: nhiều chỗ thở quanh hàng công cụ (10px → 18px). */
    margin: var(--space-8) 0;
}

.main-control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.left-controls,
.right-controls,
.admin-buttons-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.left-controls {
    justify-content: flex-start;
}

.right-controls,
.admin-buttons-row {
    justify-content: flex-end;
}

.admin-buttons-row {
    margin-top: 6px;
}

.password-input {
    width: 150px;
    padding: 6px 10px;
    margin: 3px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-field);
    font-weight: bold;
    font-size: var(--text-md);
}

.hidden-keep-space {
    visibility: hidden;
}

.hidden-admin-row {
    display: none !important;
}

button {
    margin: 3px;
    border: none;
    background: var(--accent-secondary);
    color: white;
    cursor: pointer;
    white-space: nowrap;
    /* Khung CHUNG (token) — màu giữ theo từng class */
    padding: var(--btn-pad-y) var(--btn-pad-x);
    min-height: var(--btn-min-h);
    border-radius: var(--btn-radius);
    font-weight: var(--btn-font-weight);
    font-size: var(--btn-font);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--btn-gap);
    line-height: 1;
    transition: var(--btn-transition);
}

button:hover {
    background: var(--blue-800);
}

/* Trạng thái CHUNG cho mọi button */
/* ⚠️ [ĐỢT 5 · M4.2 lô 1e] BỌC @media (hover: hover) — sửa lỗi HOVER DÍNH trên điện thoại.
   Rule này áp cho MỌI thẻ <button> của app và trước đây nằm NGOÀI mọi media query.
   Trên màn CẢM ỨNG, trạng thái :hover "dính" lại sau khi trẻ chạm → nút bị nhấc lên
   rồi KẸT nguyên như vậy cho tới khi chạm chỗ khác. Bọc lại là màn cảm ứng không còn
   nhận hiệu ứng rê nữa; máy tính giữ nguyên y hệt, không đổi một pixel.

   📌 Đây cũng là chỗ khiến hàng rào (hover: hover) của hệ `.btn` vô tác dụng: hệ `.btn`
      tự bọc media query rồi, nhưng rule TRẦN này ở ngoài nên vẫn lọt xuống điện thoại.
      Vá ở đây là vá đúng gốc, thay vì vá từng họ nút.

   ⚠️ CỐ Ý KHÔNG bọc `button:active` bên dưới: :active là lúc NGÓN TAY ĐANG ẤN, cần
      chạy trên cả màn cảm ứng. Chỉ :hover mới là thứ điện thoại không có thật. */
@media (hover: hover) {
    button:hover:not(:disabled) {
        transform: translateY(-1px);
    }
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled,
button[disabled] {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button:focus-visible {
    outline: 2px solid var(--accent-secondary);
    outline-offset: 2px;
}

.student-select {
    padding: 6px 10px;
    margin: 3px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-field);
    font-weight: bold;
    font-size: var(--text-md);
}

/* [CỠ CHỮ BÀI TẬP] Khối thiết định 5 lớp trong Cài đặt (admin-only) */
.exam-font-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
}
.exam-font-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.exam-font-label {
    font-weight: var(--weight-bold);
    color: var(--text-body);
    font-size: var(--text-base);
}
.exam-font-input {
    width: 96px;
    min-height: 44px;
    font-size: 16px; /* ≥16px chống zoom iOS */
    text-align: center;
    font-weight: var(--weight-bold);
    color: var(--text-strong);
    padding: 6px 10px;
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface-white);
    box-sizing: border-box;
}
.exam-font-input:focus { outline: none; border-color: var(--accent-secondary); }
.exam-font-status {
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
}
.exam-font-status.is-ok { color: var(--accent-primary-hover); }
.exam-font-status.is-err { color: var(--accent-danger); }
.exam-font-status.is-saving { color: var(--text-muted); }

.col-no {
    width: 55px;
    text-align: center;
}

.col-question {
    width: 40%;
}

.col-answer {
    width: 95px;
    background: var(--surface-answer);
    /* Làm mềm màu vàng nền ô nhập dữ liệu */
    text-align: center;
}

.col-result {
    width: 75px;
    text-align: center;
}

.col-correct {
    width: 110px;
    text-align: center;
}

.col-choice {
    width: 125px;
    text-align: center;
}

.answer-input {
    width: 100%;
    padding: 4px;
    /* Đã thu nhỏ padding để ô không bị cao */
    box-sizing: border-box;
    /* [ĐỢT 5 · M7.1→M7.2] Viền ô gõ đáp án. M7.1 nâng riêng ô này lên --blue-500;
       M7.2 gom lại thành token chung --border-field cho MỌI ô nhập (xem tokens.css).
       Giá trị y hệt, chỉ khác ở chỗ nay chỉ còn MỘT nơi quyết định. */
    border: 1px solid var(--border-field);
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: bold;
    color: var(--text-strong);
    background-color: var(--surface-white);
    transition: border-color 0.15s ease-in-out;
}

.answer-input:focus {
    border-color: var(--accent-secondary);
    outline: none;
    box-shadow: var(--shadow-focus);
}

.choice-btn {
    width: 100%;
    padding: 4px 6px;
    min-height: 0;
    /* Nút đáp án MCQ giữ chiều cao thấp như cũ (không theo --btn-min-h 40px) */
    margin: 0;
    background: var(--surface-tint-blue);
    color: var(--text-strong);
    border: 1px solid var(--border-card);
    /* [M4.4] CHỐT món M4.1 để lại: --radius-xl đã ĐỔI VAI TRÒ thành "khối hành động
       cực lớn" (24px), nên nút trắc nghiệm phải về --radius-md (16px) đúng đặc tả
       §4.1. Trước đó nút này 24px trên PC nhưng 14px trên điện thoại — cùng một nút
       hai hình dáng. */
    border-radius: var(--radius-md);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    line-height: 18px;
    cursor: pointer;
    /* Thêm hiệu ứng chuyển động mượt mà khi tương tác */
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* [M4.2 lô 1e] bọc chống HOVER DÍNH trên màn cảm ứng */
@media (hover: hover) {
.choice-btn:hover {
    background: var(--surface-hover);
    border-color: var(--accent-secondary);
    transform: translateY(-1px);
    /* Nhấc nhẹ nút lên khi di chuột vào */
}
}

/* Gộp 4 nút lựa chọn trong ô "Trả lời" của khu Tính nhanh (khi hình thức là Trắc nghiệm) */
.compact-choice-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.choice-btn.selected {
    background: var(--accent-secondary);
    color: white;
    border-color: var(--accent-secondary);
    box-shadow: 0 4px 10px rgba(var(--accent-secondary-rgb), 0.3);
    /* Tạo bóng đổ sâu rõ rệt */
    transform: scale(1.04);
    /* Phóng to nút lên 4% để con biết rõ mình đang chọn nút này */
}

/* Hàng nút bấm nhanh ký tự cho câu VIẾT điền dấu (> < = hoặc + -).
   Vùng chạm to, dễ bấm trên điện thoại cho trẻ. */
.symbol-key-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.symbol-key {
    min-width: 44px;
    min-height: 44px;
    padding: 6px 14px;
    background: var(--surface-tint-blue);
    color: var(--text-strong);
    border: 2px solid var(--border-card);
    border-radius: 14px;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
}

/* [M4.2 lô 1e] bọc chống HOVER DÍNH trên màn cảm ứng */
@media (hover: hover) {
.symbol-key:hover {
    background: var(--surface-hover);
    border-color: var(--accent-secondary);
    transform: translateY(-1px);
}
}

.symbol-key:active {
    background: var(--accent-secondary);
    color: var(--text-inverse);
    border-color: var(--accent-secondary);
    transform: scale(0.96);
}

.symbol-key:disabled {
    opacity: 0.5;
    cursor: default;
}

.correct {
    color: var(--text-success);
    font-weight: bold;
}

.wrong {
    color: var(--red-550);
    font-weight: bold;
}

h2 {
    /* [1B.3] Tách tiêu đề mục rõ hơn (thang --space-*). */
    margin: var(--space-7) 0 var(--space-3);
    font-size: 16px;
}

table {
    border-collapse: collapse;
}

.main-layout {
    display: grid;
    grid-template-columns: minmax(1200px, 1fr) 420px;
    gap: 10px;
    align-items: start;
}

/* ===== LÀM ĐẸP LỊCH SỬ THEO NGÀY (HISTORY PANEL) ===== */
.history-panel {
    /* Khung do .main-panel đảm nhiệm; chỉ giữ hành vi nội dung */
    overflow: hidden;
}

.history-title {
    background: var(--surface-subtle);
    color: var(--text-strong);
    font-weight: bold;
    text-align: center;
    padding: 8px;
    font-size: 17px;
    border-bottom: 2px solid var(--border-card);
}

.history-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.history-table th {
    /* Header đồng bộ với các bảng khác (xanh gradient, padding 11x12) */
    background: linear-gradient(180deg, var(--blue-50) 0%, #e1edfa 100%);
    color: var(--text-strong);
    font-weight: 800;
    padding: 11px 12px;
    border-bottom: 2px solid var(--border-card);
    text-align: center;
}

.history-table th,
.history-table td {
    border-bottom: 1px solid var(--border-faint);
    border-right: none;
    border-left: none;
    padding: 6px 11px;
    text-align: center;
    height: auto;
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-table tbody tr:nth-child(even) td {
    background-color: var(--surface-tint-blue);
}

/* Badge điểm trong ngày */
.history-score-badge {
    display: inline-block;
    min-width: 56px;
    padding: 4px 14px;
    border-radius: var(--radius-pill);
    background: var(--surface-subtle);
    color: var(--text-strong);
    font-weight: 800;
    font-size: 14px;
}

/* Điểm cao (>= 1000): nổi bật màu xanh lá kèm 🔥 */
.history-score-high {
    background: var(--surface-success);
    color: var(--text-success);
}

@media (max-width: 1250px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

.blank-answer-space {
    height: 29px;
}

.score-display {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
}

.total-score-input {
    width: 110px;
    padding: 4px 8px;
    border: 1px solid var(--border-field);
    border-radius: 5px;
    font-weight: bold;
    text-align: right;
    font-size: var(--text-md);
}

.hidden-score-input {
    display: none;
}

.history-table {
    table-layout: fixed;
}

.history-table th,
.history-table td {
    box-sizing: border-box;
}

.history-table th:nth-child(1),
.history-table td:nth-child(1) {
    width: 32%;
}

.history-table th:nth-child(2),
.history-table td:nth-child(2) {
    width: 32%;
}

.history-table th:nth-child(3),
.history-table td:nth-child(3) {
    width: 36%;
}

.history-scroll-area {
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
}

.history-table-header {
    padding-right: 16px;
    box-sizing: border-box;
}

.left-main-area {
    width: 100%;
}

.reward-section {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.reward-title {
    font-size: 22px;
    font-weight: bold;
    color: var(--text-strong);
    margin-bottom: 8px;
}

.reward-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-field);
    padding: 4px;
    font-size: var(--text-md);
}

.exchange-title {
    font-size: 22px;
    font-weight: bold;
    color: var(--text-strong);
    margin: 18px 0 8px;
}

.exchange-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-field);
    padding: 4px;
    font-size: var(--text-md);
}

.app-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 12px;
    align-items: start;
}

.side-menu {
    min-height: 720px;
    background: var(--surface-tint-blue);
    padding: 18px 10px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-menu);
    display: flex;
    flex-direction: column;
}

/* Menu điều hướng: ẩn thanh cuộn (vẫn cuộn được nếu nội dung tràn), tránh hiện
   thanh cuộn thừa ở một số màn như Cài đặt. */
.side-menu {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.side-menu::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.menu-title {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 22px;
    color: var(--text-strong);
}

.menu-link {
    display: block;
    width: 100%;
    margin: 0;
    padding: 5px 10px;
    min-height: 34px;
    /* Thu hẹp nhẹ chiều cao mỗi dòng menu (giảm so với min-height 40px mặc định của button) */
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-strong);
    text-align: left;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
}

.menu-link:hover {
    background: var(--surface-hover);
    color: var(--text-strong);
}

.menu-link.active-student {
    background: #d9ead3;
    color: var(--green-800);
}

.menu-link.active-section {
    background: var(--blue-100);
    color: var(--text-strong);
}

.hidden-section {
    display: none;
}

.today-score-message {
    margin-top: 6px;
    text-align: center;
    color: var(--text-success);
    /* Đổi từ màu đỏ sang xanh lá cây truyền cảm hứng */
    font-weight: bold;
    min-height: 22px;
}

.settings-panel {
    /* Khung do .main-panel đảm nhiệm. Bỏ max-width/margin auto để trải đủ bề rộng
       như màn gốc (không còn thu hẹp + căn giữa cả khung). */
    width: 100%;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
}

@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .side-menu {
        min-height: auto;
    }
}

.student-menu-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

/* [VIỆC 2] Nút "➕ Thêm học sinh" trong tab "Thông tin học sinh" (sau cổng mật khẩu). */
.student-info-add-btn {
    border: 2px dashed var(--green-500) !important;
    color: var(--text-success) !important;
    background: #f1faf1 !important;
    font-weight: 700;
}

.student-info-add-btn:hover {
    background: #e3f5e4 !important;
}

.student-badge {
    font-size: 11px;
    padding: 3px 6px;
    border-radius: var(--radius-pill);
    background: #e2efda;
    color: var(--green-800);
    white-space: nowrap;
}

.student-badge:empty {
    display: none;
}

.student-badge.graded {
    background: var(--blue-100);
    color: var(--text-strong);
}

.menu-link {
    transition: background 0.15s ease, color 0.15s ease;
}

.main-control-row {
    justify-content: center;
}

.control-area {
    width: 100%;
}

.content-area {
    width: 100%;
    margin: 0;
    padding-left: 0;
    overflow-x: auto;
    text-align: left;
}

.exam-header-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 56px;
    margin-bottom: 10px;
}

.exam-action-wrapper {
    grid-column: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin: 0;
}

.exam-btn {
    width: 260px;
    height: 44px;
    font-size: 16px;
    font-weight: bold;
    border-radius: var(--btn-radius);
}

.exam-btn:active {
    transform: scale(0.97);
}

/* Header 3 ô: trái - giữa - phải, không viền */
.main-control-row {
    width: 100%;
}

.exam-header-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 10px 0;
    border: none !important;
}

.exam-header-table tr,
.exam-header-table td {
    border: none !important;
}

.exam-header-table td {
    padding: 0;
    vertical-align: middle;
}

.exam-header-left {
    width: 30%;
    text-align: left;
}

.exam-header-center {
    width: 40%;
    text-align: center;
    white-space: nowrap;
}

.exam-header-right {
    width: 30%;
    text-align: right;
}

.hello-text {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-strong);
    /* Đổi từ màu đỏ sang xanh dương lịch sự */
    white-space: nowrap;
    margin: 0;
    padding: 0;
}

.exam-btn {
    width: 190px;
    height: 44px;
    font-size: 16px;
    font-weight: bold;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

#answerAdminButton {
    width: 130px;
    /* bằng 1/2 nút 260px */
}

.exam-header-center .exam-btn {
    margin: 0 10px;
}

.exam-header-right .exam-btn {
    margin-right: 0;
}

.settings-panel {
    text-align: center;
}

.settings-panel h2 {
    text-align: center;
    font-size: 26px;
    margin: 0 0 18px;
    color: var(--text-strong);
}

.admin-buttons-row {
    justify-content: center;
    gap: 10px;
}

.lucky-section {
    /* Khung do .main-panel đảm nhiệm; giữ canh giữa nội dung + cắt tràn */
    text-align: center;
    overflow: hidden;
}

.lucky-main-layout {
    display: grid;
    /* [LÔ 2] minmax(0,...) chống cột phình theo min-content (vòng quay rộng CỨNG 410px nên cột
       trái không chịu co, đẩy cột phải tràn khỏi khung — đo được +65px ở iPad Pro dọc). */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 36px;
    width: 100%;
    max-width: 1120px;
    margin: 16px auto 0;
    align-items: start;
}

.lucky-left,
.lucky-right {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lucky-right {
    flex-direction: column;
    gap: 20px;
}

.wheel-wrapper {
    position: relative;
    width: 410px;
    height: 410px;
    margin: 0 auto;
}

.lucky-wheel {
    width: 410px;
    height: 410px;
    box-sizing: border-box;
    border-radius: var(--radius-circle);
    border: 12px solid var(--yellow-400);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
    transition: transform 4.2s cubic-bezier(0.08, 0.82, 0.16, 1);
    /* [M5.1b] 8 nan nay khai TRỌN GÓI ở tokens.css (--wheel-bg) để theme đổi được.
       Bản mặc định giữ ĐÚNG bộ màu cũ, không lệch một mã. */
    background: var(--wheel-bg);
    cursor: pointer;
    will-change: transform;
}

.lucky-wheel::before {
    content: "QUAY";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 96px;
    height: 96px;
    transform: translate(-50%, -50%);
    border-radius: var(--radius-circle);
    background: var(--red-500);
    color: var(--text-inverse);
    border: 8px solid var(--yellow-400);
    font-size: 22px;
    font-weight: bold;
    line-height: 96px;
    text-align: center;
    z-index: 5;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
}

.lucky-wheel::after {
    content: "";
    position: absolute;
    inset: 125px;
    border-radius: var(--radius-circle);
    background: rgba(255, 255, 255, 0.35);
    border: 8px solid rgba(255, 214, 90, 0.9);
    z-index: 2;
}

.wheel-pointer {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    width: 0;
    height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-top: 38px solid var(--text-warning);
    filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.35));
}

.wheel-label {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
    transform-origin: 0 0;
    z-index: 4;
    pointer-events: none;
}

.wheel-label span {
    position: absolute;
    left: -45px;
    /* Dịch lùi sang trái để bù cho width được mở rộng */
    top: -155px;
    /* Kéo lùi chữ vào gần tâm vòng quay 5px để tránh viền cong */
    width: 90px;
    /* Nới rộng hộp chứa chữ để không bị cắt xén */
    height: 24px;
    line-height: 24px;
    text-align: center;
    /* [ĐỢT 5 · M5.7] NHÃN VÒNG QUAY — đổi CHỮ, KHÔNG đụng màu nan.
       Trước đây nhãn là chữ TRẮNG trên 8 nan màu hội chợ: chỉ 1/8 nan đạt 4,5:1,
       tệ nhất là nan vàng 1,73:1 (gần như không đọc được). M4 bỏ sót chỗ này vì nền
       là conic-gradient nên máy không đo được tương phản.
       Đã cân hai đường:
         · làm TỐI 8 nan cho chữ trắng đọc được → lệch màu trung bình ΔE 15,4,
           vòng quay TRẦM hẳn đi. BỎ — vòng quay là vật trang trí kiểu hội chợ.
         · GIỮ NGUYÊN 8 nan, đổi CHỮ sang ĐEN → 7/8 nan đạt (4,80 đến 12,16).
       Chọn đường thứ hai: KHÔNG một mã màu nan nào bị đụng.
       Nan 3 là nan DUY NHẤT tối màu (nó mang màu thương hiệu, đổi theo theme) nên
       giữ chữ TRẮNG riêng cho nó — xem .label-3 span bên dưới. Kết quả 8/8 đạt.
       Quầng chữ đổi từ tối sang SÁNG cho hợp với chữ đen. */
    color: #000000;
    font-size: 15px;
    /* Giảm nhẹ font chữ từ 17px xuống 15px */
    font-weight: bold;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.55);
}

/* [ĐỢT 5 · M5.7] Nan 3 luôn là nan TỐI MÀU ở mọi theme (nó mang màu thương hiệu:
   #3867d6 mặc định, #801E5F Kẹo Dâu, #5F00C3 Trò Chơi…) nên chữ đen sẽ chìm.
   Giữ chữ TRẮNG + quầng tối cho riêng nan này. Đo chữ trắng trên nan 3 ở cả 8 theme:
   thấp nhất 5,15:1 (theme mặc định), cao nhất 9,26:1. */
.label-3 span {
    color: var(--text-inverse);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

/* Phóng to icon mặt buồn 😢 ("không được quà") lên 1.5 lần trên nhãn vòng quay.
   QUAN TRỌNG: đặt font-size ngay trên CHÍNH ô nhãn .wheel-label span, KHÔNG bọc
   emoji trong <span> con — vì trong ngữ cảnh ô nhãn (position:absolute + xoay),
   trình duyệt không vẽ emoji màu nằm trong span con (icon sẽ biến mất). Nội dung
   phải là con TRỰC TIẾP của .wheel-label span. Cỡ chữ chỉnh thêm trong media query
   để vẫn co theo responsive (gốc 15 → 13 → 11px). */
.wheel-label span.lucky-spin-15x {
    font-size: 22px;
}

.label-1 {
    transform: rotate(0deg);
}

.label-2 {
    transform: rotate(45deg);
}

.label-3 {
    transform: rotate(90deg);
}

.label-4 {
    transform: rotate(135deg);
}

.label-5 {
    transform: rotate(180deg);
}

.label-6 {
    transform: rotate(225deg);
}

.label-7 {
    transform: rotate(270deg);
}

.label-8 {
    transform: rotate(315deg);
}

.label-1 span {
    transform: rotate(0deg);
}

.label-2 span {
    transform: rotate(-45deg);
}

.label-3 span {
    transform: rotate(-90deg);
}

.label-4 span {
    transform: rotate(-135deg);
}

.label-5 span {
    transform: rotate(-180deg);
}

.label-6 span {
    transform: rotate(-225deg);
}

.label-7 span {
    transform: rotate(-270deg);
}

.label-8 span {
    transform: rotate(-315deg);
}

.lucky-info {
    width: 100%;
    max-width: 520px;
    box-sizing: border-box;
    background: var(--surface-white);
    border: 2px solid var(--yellow-500);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    font-size: 16px;
    text-align: center;
}

.lucky-result {
    min-height: 34px;
    margin: 8px auto 0;
    font-size: 24px;
    font-weight: bold;
    color: var(--red-500);
    /* Nằm GIỮA dưới vòng quay; gói gọn trong bề rộng vòng quay để không tràn/vỡ. */
    width: 100%;
    max-width: 410px;
    text-align: center;
}

.lucky-result:empty {
    display: none;
}

.lucky-wheel.wheel-disabled {
    cursor: not-allowed;
    filter: grayscale(0.25);
    opacity: 0.85;
}

.lucky-wheel.wheel-disabled::before {
    background: var(--surface-disabled);
}

/* [LÔ 2] Nới 1000px → 1100px cho khớp mốc tablet của vùng làm bài: iPad Pro DỌC (1024px) trước đây
   lọt lưới nên vẫn cố xếp 2 cột (vòng quay 410px + cột phải) trong khung chỉ còn ~586px sau khi trừ
   menu bên → tràn. Từ 1101px trở lên (iPad NGANG, PC) giữ nguyên 2 cột như cũ. */
@media (max-width: 1100px) {
    .lucky-main-layout {
        grid-template-columns: minmax(0, 1fr);
        max-width: 520px;
    }

    .wheel-wrapper,
    .lucky-wheel {
        width: 330px;
        height: 330px;
    }

    .lucky-wheel::after {
        inset: 98px;
    }

    .wheel-label span {
        top: -128px;
        font-size: 13px;
    }

    .wheel-label span.lucky-spin-15x {
        font-size: 19px;
    }
}

.exam-header-right {
    text-align: right;
}

.exam-header-right-inner {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    width: 100%;
}

#answerAdminButton {
    margin-right: 0;
}

/* [ĐỢT 5 · M7.4] Đã gỡ `#finishAdminButton,` khỏi selector này. Nút "Thoát Cài đặt"
   nay nằm CỐ ĐỊNH trong `.settings-title-row` (index.html), mà rule
   `.settings-title-row #finishAdminButton` đặt `width:auto !important` → dòng này
   KHÔNG BAO GIỜ tới được nó. Giữ nguyên phần cho #answerAdminButton. */
#answerAdminButton {
    width: 130px;
}

.lucky-wheel {
    animation: wheelIdleGlow 2.2s ease-in-out infinite;
}

.lucky-wheel.spinning {
    animation: none;
    box-shadow:
        0 0 0 8px rgba(255, 214, 90, 0.35),
        0 16px 34px rgba(0, 0, 0, 0.32);
}

.lucky-wheel.spin-finished {
    animation: wheelStopBounce 0.45s ease;
}

.lucky-wheel::before {
    animation: quayPulse 1.4s ease-in-out infinite;
}

.lucky-result {
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.lucky-result.result-pop {
    animation: resultPop 0.55s ease;
}

@keyframes wheelIdleGlow {

    0%,
    100% {
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    }

    50% {
        box-shadow:
            0 0 0 5px rgba(255, 214, 90, 0.22),
            0 12px 30px rgba(0, 0, 0, 0.28);
    }
}

@keyframes quayPulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.06);
    }
}

@keyframes wheelStopBounce {
    0% {
        transform: rotate(var(--final-rotation)) scale(1);
    }

    45% {
        transform: rotate(var(--final-rotation)) scale(1.035);
    }

    100% {
        transform: rotate(var(--final-rotation)) scale(1);
    }
}

@keyframes resultPop {
    0% {
        transform: scale(0.85);
        opacity: 0;
    }

    60% {
        transform: scale(1.12);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.student-photo-box {
    margin-top: auto;
    padding-top: 18px;
    width: 100%;
}

.student-photo-frame-box {
    position: relative;
    width: 260px;
    height: 260px;
    margin: 0 auto;
}

.student-photo {
    position: absolute;
    left: 50%;
    top: 50%;
    /* 70% khớp với "ô kính" trong các frame PNG (bronze/silver/gold/diamond/
       legend). Dùng tỉ lệ % để mọi breakpoint cùng 1 ratio → không lệch giữa
       avatar sidebar và preview "Thông tin học sinh". */
    width: 70%;
    height: 70%;
    transform: translate(-50%, -50%);
    object-fit: cover;
    object-position: center;
    border-radius: var(--radius-md);
    z-index: 1;
}

.student-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 2;
    pointer-events: none;
}

.admin-bonus-spin-row {
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.admin-bonus-spin-row button {
    min-width: 220px;
}

.admin-bonus-spin-row:not(.hidden-admin-row) {
    display: flex;
}

.history-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 8px;
    background: var(--surface-tint-blue);
    border-bottom: 1px solid #b7b7b7;
}

.summary-box {
    border: 1px solid var(--border-card);
    border-radius: 14px;
    padding: 9px 14px;
    background: linear-gradient(160deg, var(--surface-white) 0%, var(--surface-subtle) 100%);
    box-shadow: 0 6px 16px rgba(var(--shadow-rgb), 0.07);
    font-size: 14px;
}

.summary-title {
    font-weight: 800;
    color: var(--text-strong);
    font-size: 15px;
    margin-bottom: 5px;
    padding-bottom: 5px;
    text-align: center;
    border-bottom: 2px dashed var(--border-card);
}

/* Mỗi chỉ số là 1 hàng dashboard: nhãn (kèm icon) bên trái, số to đậm bên phải */
.stat-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 4px;
}

.stat-metric+.stat-metric {
    border-top: 1px solid var(--blue-50);
}

.stat-label {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
}

.stat-value {
    color: var(--text-strong);
    font-weight: 800;
    font-size: 18px;
    line-height: 1.1;
    white-space: nowrap;
}

/* Giá trị "ngày học tốt nhất" là chuỗi ngày nên để nhỏ hơn cho cân đối */
.stat-value-day {
    font-size: 13px;
    color: var(--text-warning);
}

@media (max-width: 700px) {
    .history-summary {
        grid-template-columns: 1fr;
    }
}

.level-label {
    margin-left: 10px;
}

.student-level {
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-weight: bold;
    font-size: 13px;
    white-space: nowrap;
}

.level-bronze {
    background: var(--medal-bronze-bg);
    color: var(--medal-bronze-text);
}

.level-silver {
    background: var(--medal-silver-bg);
    color: var(--medal-silver-text);
}

.level-gold {
    background: var(--medal-gold-bg);
    color: var(--medal-gold-text);
}

.level-platinum {
    /* Bạch Kim: trắng bạc ánh xanh/tím nhạt — sang hơn Vàng, dưới Kim Cương */
    background: linear-gradient(135deg, var(--medal-platinum-bg) 0%, var(--medal-platinum-bg2) 100%);
    color: var(--medal-platinum-text);
}

.level-diamond {
    background: var(--medal-diamond-bg);
    color: var(--medal-diamond-text);
}

.level-legend {
    background: var(--medal-legend-bg);
    color: var(--medal-legend-text);
}

/* ===== [DANH HIỆU QUÂN HÀM] Sao + bố cục viên badge danh hiệu ===== */
/* Sao vẽ bằng ký tự ★ (U+2605) + CSS color (KHÔNG dùng emoji ⭐ vì không tô màu được). */
.rank-stars {
    font-weight: 800;
    letter-spacing: 0.5px;
    line-height: 1.1;
    white-space: nowrap;
    /* ★ luôn nằm 1 cụm, không tách dòng/cắt ngọn trên mobile hẹp. */
}

.rank-star-ico {
    margin-left: 1px;
}

.rank-star-bronze {
    color: var(--medal-bronze-star);
}

.rank-star-silver {
    color: var(--medal-silver-star);
}

.rank-star-gold {
    color: var(--medal-gold-star);
}

.rank-star-platinum {
    color: var(--medal-platinum-star);
}

.rank-star-diamond {
    color: var(--medal-diamond-star);
}

/* Huyền Thoại: gradient áp lên chữ + phát sáng nhẹ (chữ trong suốt → dùng drop-shadow). */
.rank-star-legend {
    background: var(--medal-legend-star-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 3px rgba(155, 93, 229, .55));
}

/* Trình duyệt cũ không hỗ trợ background-clip:text → tránh sao bị "tàng hình". */
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
    .rank-star-legend {
        background: none;
        color: #9b5de5;
        filter: none;
    }
}

/* Viên badge khi mang danh hiệu: danh hiệu · huy hiệu + sao trên cùng một cụm (PC). */
.student-level.has-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
}

.student-level.has-rank .rank-name {
    white-space: nowrap;
}

.student-level.has-rank .rank-badge-name {
    white-space: nowrap;
}

.student-level.has-rank .rank-sep {
    opacity: 0.7;
}

/* [DASHBOARD] Dòng tóm tắt danh hiệu trong màn chi tiết một con. */
.dash-rank-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 4px 0 12px;
}

.dash-rank-summary .dash-rank-badge {
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}

.dash-rank-summary .dash-rank-score {
    font-weight: 800;
    color: var(--text-strong);
    font-size: 14px;
}

.dash-rank-summary .dash-rank-next {
    color: var(--text-muted);
    font-size: 12.5px;
}

.student-photo {
    transition: border 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.photo-frame-bronze {
    border-color: var(--text-warning);
    box-shadow: 0 4px 14px rgba(180, 95, 6, 0.28);
}

.photo-frame-silver {
    border-color: #a6a6a6;
    box-shadow:
        0 0 0 4px rgba(217, 217, 217, 0.7),
        0 6px 18px rgba(120, 120, 120, 0.35);
}

.photo-frame-gold {
    border-color: var(--yellow-500);
    box-shadow:
        0 0 0 4px rgba(255, 242, 204, 0.9),
        0 0 18px rgba(241, 194, 50, 0.75),
        0 8px 22px rgba(191, 144, 0, 0.35);
    /* Căn chỉnh ảnh dùng chung rule .student-photo (top: 50%, scale 1, 70%).
       Không override top/transform riêng cho từng tier nữa. */
}

.photo-frame-platinum {
    /* Bạch Kim: viền trắng bạc ánh xanh/tím, hào quang nhẹ hơn Kim Cương */
    border-color: #aab0d6;
    box-shadow:
        0 0 0 4px rgba(232, 234, 244, 0.92),
        0 0 20px rgba(170, 176, 214, 0.8),
        0 9px 24px rgba(90, 91, 140, 0.38);
}

.photo-frame-diamond {
    /* [ĐỢT 5 · M5.1b] 🔴 GHIM CỨNG như 5 khung kia — ĐỪNG trả về var().
       Trước đây viền dùng var(--blue-400) và bóng dùng var(--shadow-rgb) → sang theme
       “Kẹo Dâu” thì khung KIM CƯƠNG hoá HỒNG, trong khi đồng/bạc/vàng/bạch kim/huyền
       thoại đều giữ màu kim loại riêng. Kim cương phải là XANH BĂNG ở mọi theme.
       Số dưới đây = đúng giá trị ở theme mặc định → nhìn không đổi, chỉ khác ở chỗ
       nay nó đứng yên khi đổi theme. */
    border-color: #79ACDB;
    box-shadow:
        0 0 0 5px rgba(221, 235, 247, 0.95),
        0 0 22px rgba(111, 168, 220, 0.9),
        0 10px 26px rgba(27, 74, 115, 0.42);
}

.photo-frame-legend {
    border-color: var(--medal-legend-text);
    box-shadow:
        0 0 0 5px rgba(234, 220, 248, 1),
        0 0 22px rgba(112, 48, 160, 0.9),
        0 0 38px rgba(255, 215, 0, 0.7),
        0 12px 32px rgba(80, 30, 130, 0.45);
}

html,
body {
    overflow-x: hidden;
    overflow-y: scroll;
}

.content-area {
    overflow-x: hidden;
    overflow-y: auto;
}

.side-menu {
    overflow: hidden;
}

.side-menu {
    height: 670px;
    min-height: 620px;
    overflow: hidden;
}

/* .lucky-section: box-sizing/min-height do .main-panel đảm nhiệm */

body::before {
    content: "✏️  📘  ➕  🔢  ⭐  📐";
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: -1;

    font-size: 46px;
    letter-spacing: 42px;
    line-height: 120px;
    color: rgba(var(--shadow-rgb), 0.08);
    white-space: pre-wrap;
    padding: 40px;
    box-sizing: border-box;
}

.app {
    /* [ĐỢT 5 · M3.4 — gỡ bẫy 1+2 của M1.3] Đây là rule CUỐI CÙNG đặt nền cho .app
       (đã rà hết 9 khối .app trong file này; các khối sau chỉ đụng bo góc/bóng).
       Màu riêng của mỗi con do JS đặt qua biến --student-bg-active
       (script.js · applyStudentBackground). Trước đây JS ghi inline
       background-color nên THẮNG MỌI CSS → theme không với tới được.

       ⚠️ FALLBACK PHẢI GIỮ ĐÚNG rgba(255,255,255,0.94), tuyệt đối không đổi
          thành #ffffff hay var(--surface-app). Lý do: DataToan.html cũng nạp
          style.css nhưng KHÔNG nạp script.js → ở trang đó, fallback này CHÍNH LÀ
          màu cuối cùng người dùng nhìn thấy. Đổi fallback = đổi diện mạo trang đó.
       ⚠️ backdrop-filter dưới đây trông như vô dụng (nền đục che hết) nhưng
          KHÔNG được "nhân tiện dọn": nó tạo containing block, và app đang dựa
          vào đó — #mobileBottomNav bị cố ý đặt NGOÀI .app cũng vì lý do này. */
    background: var(--student-bg-active, rgba(255, 255, 255, 0.94));
    box-shadow: 0 8px 28px rgba(var(--shadow-rgb), 0.16);
    backdrop-filter: blur(4px);
}

h1 {
    background: linear-gradient(90deg, var(--blue-800), var(--accent-secondary), var(--progress-fill));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    background: #e2efda;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    font-weight: bold;
}

.reward-progress-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.reward-progress-title {
    color: var(--text-strong);
    white-space: nowrap;
    font-size: 14px;
}

.reward-progress-track {
    flex: 1;
    height: 14px;
    border-radius: var(--radius-pill);
    background: var(--blue-100);
    overflow: hidden;
    border: 1px solid var(--blue-300);
    min-width: 180px;
}

.reward-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--progress-fill), var(--yellow-300));
    transition: width 0.45s ease;
}

.reward-progress-text {
    color: var(--green-800);
    font-size: 13px;
    white-space: nowrap;
}

.reward-progress-percent {
    min-width: 44px;
    text-align: center;
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    background: var(--yellow-soft);
    color: var(--text-strong);
    font-size: 14px;
}

.reward-progress-hot .reward-progress-fill {
    animation: rewardProgressGlow 1.2s ease-in-out infinite;
}

@keyframes rewardProgressGlow {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.2);
    }
}


.hidden-student-menu {
    display: none !important;
}

.xoai-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    color: var(--text-strong);
    cursor: pointer;
}

.xoai-toggle-label input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===== MOBILE RESPONSIVE FIX - Samsung Android / Chrome / Samsung Internet ===== */
@media (max-width: 900px) {

    html,
    body {
        overflow-x: hidden;
        overflow-y: auto;
    }

    body {
        padding: 4px;
    }

    .app {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 8px;
        border-radius: var(--radius-sm);
    }

    h1 {
        font-size: 24px;
        line-height: 1.2;
        margin: 6px 0 8px;
        letter-spacing: 0;
    }

    .app-layout {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .side-menu {
        height: auto;
        min-height: auto;
        overflow: visible;
        padding: 10px;
    }

    .student-photo-box {
        margin-top: 8px;
        padding-top: 8px;
    }

    .student-photo-frame-box {
        width: 150px;
        height: 150px;
    }

    /* Kích thước .student-photo dùng chung tỉ lệ 70% từ rule gốc (line 1194). */

    .content-area {
        overflow-x: hidden;
        overflow-y: visible;
    }

    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .reward-progress-box {
        flex-wrap: wrap;
        gap: 6px;
    }

    .reward-progress-title,
    .reward-progress-text {
        white-space: normal;
    }

    .reward-progress-track {
        min-width: 120px;
    }

    .score-display {
        justify-content: center;
        flex-wrap: wrap;
    }

    .exam-header-table,
    .exam-header-table tbody,
    .exam-header-table tr,
    .exam-header-table td {
        display: block;
        width: 100%;
    }

    .exam-header-left,
    .exam-header-center,
    .exam-header-right {
        width: 100%;
        text-align: center;
        margin-bottom: 8px;
    }

    .hello-text {
        font-size: 20px;
        white-space: normal;
        text-align: center;
    }

    .exam-header-center {
        white-space: normal;
    }

    /* [ĐỢT 5 · M7.4] Đã gỡ `#finishAdminButton,` khỏi selector này — ở khổ ≤900px nút đó
       bị `.settings-title-row #finishAdminButton { display:none !important }` ẩn hẳn,
       và width/min-width/max-width của nó đều bị rule kia ghi đè bằng !important. */
    .exam-header-center .exam-btn,
    .exam-header-right .exam-btn,
    .exam-btn,
    #answerAdminButton {
        width: auto;
        min-width: 130px;
        max-width: 100%;
        margin: 3px;
    }

    .exam-header-right-inner {
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }

    #questions {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .choice-btn {
        font-size: 12px;
        padding: 5px 6px;
    }

    .answer-input {
        min-height: 34px;
        font-size: 16px;
    }

    .reward-section {
        align-items: stretch;
    }

    .history-panel {
        width: 100%;
    }

    .reward-section,
.history-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .settings-panel {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 12px;
    }

    .settings-row,
    .admin-buttons-row,
    .admin-bonus-spin-row:not(.hidden-admin-row) {
        flex-wrap: wrap;
    }

    .admin-buttons-row button,
    .admin-bonus-spin-row button {
        width: 100%;
        min-width: 0;
        white-space: normal;
    }

    .lucky-section {
        min-height: auto;
        overflow: visible;
        padding: 12px 8px;
    }

    .lucky-main-layout {
        grid-template-columns: 1fr;
        gap: 18px;
        margin-top: 16px;
    }
}

@media (max-width: 600px) {
    .menu-title {
        font-size: 20px;
        margin-bottom: 10px;
    }

    .menu-link {
        font-size: 14px;
        padding: 10px;
        white-space: normal;
    }

    .wheel-wrapper,
    .lucky-wheel {
        width: 280px;
        height: 280px;
    }

    .lucky-wheel::before {
        width: 72px;
        height: 72px;
        line-height: 72px;
        font-size: 18px;
        border-width: 6px;
    }

    .lucky-wheel::after {
        inset: 82px;
    }

    .wheel-label span {
        top: -104px;
        /* Kéo lùi chữ vào gần tâm trên điện thoại */
        left: -35px;
        /* Căn lại tâm cho hộp chữ nới rộng */
        width: 70px;
        /* Nới rộng hộp chữ */
        font-size: 11px;
        /* Thu nhỏ nhẹ chữ trên mobile */
    }

    .wheel-label span.lucky-spin-15x {
        font-size: 16px;
    }

    .lucky-info {
        padding: 10px;
        font-size: 14px;
    }

    .lucky-result {
        font-size: 20px;
    }

    .history-table {
        font-size: 12px;
    }

    .history-table-header {
        padding-right: 0;
    }
}

/* ===== FIX MOBILE SCROLL STUCK - Samsung Android ===== */
@media (max-width: 900px) {

    html,
    body {
        height: auto !important;
        min-height: 100% !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        touch-action: pan-y;
    }

    body {
        position: static !important;
        -webkit-overflow-scrolling: touch;
    }

    .app,
    .app-layout,
    .content-area,
    .side-menu,
    .content-section,
    .lucky-section {
        height: auto !important;
        max-height: none !important;
        overflow-y: visible !important;
    }

    .content-area {
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
    }

    .side-menu {
        overflow: visible !important;
    }

    #questions,
.reward-section,
.history-panel {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== MOBILE QUESTION CARD VIEW ONLY ===== */
@media (max-width: 600px) {
    #questions {
        overflow-x: visible !important;
    }

    .col-choice {
        min-height: 0;
    }

    .choice-btn {
        width: 100%;
        min-height: 38px;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        line-height: 1.3;
        font-size: 14px;
    }

    .answer-input {
        width: 100%;
        min-height: 40px;
        font-size: 16px;
    }
}

/* ===== HIDE EMPTY RESULT/CORRECT ANSWER ON MOBILE ===== */
@media (max-width: 600px) {
}

/* ===== HIDE MCQ AREA FOR INPUT QUESTIONS ON MOBILE ===== */
@media (max-width: 600px) {
}

/* =========================================================
   MOBILE ONLY: TINH GỌN VÙNG CÂU HỎI CHO ĐIỆN THOẠI
   (toàn bộ nằm trong media query -> KHÔNG ảnh hưởng giao diện PC)
   ========================================================= */
@media (max-width: 900px) {

    /* Vùng "Tính nhanh" đang bị inline style ép 2 cột rất chật trên điện thoại
       -> ép về 1 cột (cần !important để thắng inline style) */
    .fast-question-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Hai khối câu hỏi gọn lại, tiêu đề nhỏ vừa phải trên màn hình hẹp */
    .math-quiz-layout {
        gap: 12px;
    }

    .quiz-section {
        padding: 10px;
        border-radius: 16px;
    }

    .quiz-section-header h2 {
        font-size: 16px;
    }
}

@media (max-width: 600px) {

    /* 4 đáp án A/B/C/D xếp lưới 2x2 gọn gàng thay vì 4 dòng dài lê thê.
       Dùng float, được bao bởi overflow:hidden sẵn có trên .exam-table tr */
    .word-exam-table td.col-choice {
        float: left;
        width: 50% !important;
        box-sizing: border-box;
        padding: 4px;
        border-bottom: none;
    }

    /* Nút đã hiển thị nội dung đáp án nên bỏ nhãn "Đáp án A/B/C/D" thừa */
    .word-exam-table td.col-choice::before {
        display: none !important;
    }

    .word-exam-table .choice-btn {
        min-height: 46px;
        font-size: 14px;
    }
}

/* ===== MOBILE: ÉP Ô TRẢI HẾT CHIỀU NGANG & NHÃN + GIÁ TRỊ CÙNG HÀNG ===== */
@media (max-width: 600px) {

    /* Ghi đè width cố định của desktop bị "rò rỉ" xuống mobile.
       PHẢI có "td" để tăng specificity (0,2,1) thắng rule desktop ".x-exam-table .col-*" (0,2,0)
       vốn nằm sau trong file -> câu hỏi, ô trả lời, kết quả, đáp án đúng trải hết bề ngang thẻ */
    .fast-exam-table td.col-question,
    .fast-exam-table td.col-answer,
    .fast-exam-table td.col-result,
    .fast-exam-table td.col-correct,
    .word-exam-table td.col-question,
    .word-exam-table td.col-answer,
    .word-exam-table td.col-result,
    .word-exam-table td.col-correct {
        width: 100% !important;
    }

    /* Ô nhập (phần Tính nhanh) nằm ngay cạnh nhãn, chiếm phần còn lại của hàng */
    .exam-table td.col-answer .answer-input {
        width: auto;
        flex: 1 1 90px;
        min-height: 34px;
    }
}

.correct-streak-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    color: var(--text-strong);
    cursor: pointer;
}

.correct-streak-toggle-label input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Thời hạn "Thưởng chuỗi đúng": 2 ô ngày dưới checkbox (ưu tiên dễ nhập trên điện thoại) */
.correct-streak-schedule-row {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 6px;
    width: 100%;
}

.correct-streak-date-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.correct-streak-date-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 140px;
    min-width: 140px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-strong);
}

.correct-streak-date-field input[type="date"] {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--border-field);
    border-radius: var(--radius-sm);
    font-size: 16px;
    /* >=16px: tránh iOS tự zoom khi focus */
    color: #2d3748;
    background: var(--surface-white);
}

@media (max-width: 640px) {
    .correct-streak-date-field {
        flex: 1 1 100%;
    }
}

.correct-streak-message {
    min-height: 42px;
    margin-bottom: 4px;
    font-size: 15px;
    font-weight: bold;
    line-height: 1.35;
    text-align: left;
    animation: correctStreakBlink 1.4s ease-in-out infinite;
}

.correct-streak-message:empty {
    display: none;
}

.correct-streak-rainbow {
    /* [M5.1b] Khai trọn gói ở tokens.css (--rainbow-streak) — kèm ghi chú NỢ TƯƠNG PHẢN
       đã đo và bộ màu thay thế dò sẵn. Bản mặc định giữ y nguyên bộ màu cũ.
       ⚠️ ĐỪNG đụng @keyframes correctStreakRainbow và background-size: 300% 100% —
          chuyển động phụ thuộc cả hai. */
    background: var(--rainbow-streak);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation:
        correctStreakRainbow 2.4s linear infinite,
        correctStreakBlink 1.4s ease-in-out infinite;
}

@keyframes correctStreakRainbow {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 300% 50%;
    }
}

@keyframes correctStreakBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.65;
    }
}

@media (max-width: 900px) {
    .correct-streak-message {
        text-align: center;
        font-size: 14px;
        min-height: auto;
    }
}

/* ===== APP-LIKE MOBILE ONLY - PC KHÔNG BỊ ẢNH HƯỞNG ===== */
@media (max-width: 900px) {
    body {
        padding: 0;
        padding-bottom: 78px;
        background-attachment: scroll;
    }

    .app {
        min-height: 100vh;
        border-radius: 0;
        padding: 8px;
        box-shadow: none;
    }

    h1 {
        position: static;
        /* Để tiêu đề cuộn tự nhiên, nhường chỗ ghim cho Menu bar */
        background: linear-gradient(90deg, var(--blue-800), var(--blue-600), var(--green-400));
        /* Khôi phục màu sắc rực rỡ */
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
        padding: 10px 6px;
        box-shadow: none;
        /* Bỏ bóng đổ thừa trên mobile */
    }

    .top-bar {
        border-radius: 16px;
        box-shadow: 0 4px 14px rgba(var(--shadow-rgb), 0.12);
    }

    .menu-title,
    .student-photo-box {
        display: none;
    }

    .menu-link {
        margin: 0;
        padding: 8px 4px;
        border-radius: 14px;
        text-align: center;
        font-size: 11px;
        line-height: 1.2;
        white-space: normal;
    }

    .student-menu-link {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
    }

    .student-badge {
        font-size: 9px;
        padding: 2px 5px;
    }

    .content-area {
        overflow: visible;
    }

    .exam-header-table {
        margin-top: 8px;
    }

    .exam-header-center {
        display: flex !important;
        justify-content: center;
        gap: 8px;
    }

    .exam-header-center .exam-btn,
    .exam-btn {
        flex: 1;
        min-width: 0;
        height: 46px;
        border-radius: 16px;
        font-size: 14px;
    }

    /* [M4.4] Bo góc KHÔNG cần khác nhau giữa điện thoại và máy tính — đặc tả §4.3
       chỉ bảo co ĐỆM trên màn hẹp. Khối này trước đây ép mọi nút/ô nhập về 14px
       trên điện thoại, khiến CÙNG MỘT thành phần có 2 bo góc khác nhau ở 2 khổ
       (đo được: .choice-btn 14px trên ĐT vs 24px trên PC). Nay đều theo thang chung. */
    .history-panel,
    .settings-panel,
    .lucky-section,
    .reward-section,
    .summary-box,
    .lucky-info,
    .lucky-history-box {
        border-radius: var(--radius-lg);
    }

    .summary-box,
.lucky-info {
        box-shadow: var(--shadow-md);
    }

    button,
    .choice-btn {
        border-radius: var(--radius-md);
    }

    .answer-input,
    .password-input {
        border-radius: var(--radius-sm);
    }
}

/* ===== MOBILE TOP DROPDOWN MENU ONLY - PC KHÔNG ĐỔI ===== */
.mobile-menu-toggle {
    display: none;
}

@media (max-width: 900px) {
    body {
        padding-bottom: 0;
    }

    .side-menu {
        position: sticky;
        top: 0;
        z-index: 60;

        height: auto;
        min-height: auto;
        padding: 8px;

        display: block;
        border-radius: 0 0 18px 18px;
        background: rgba(248, 251, 255, 0.98);
        box-shadow: 0 6px 18px rgba(var(--shadow-rgb), 0.16);
        overflow: visible;
    }

    .mobile-menu-toggle {
        display: block;
        width: 100%;
        height: 46px;
        margin: 0;
        border-radius: 16px;
        font-size: 16px;
        text-align: center;

        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;
    }

    .side-menu .menu-title,
    .side-menu .menu-link,
    .side-menu .side-menu-caption,
    .side-menu .student-photo-box {
        display: none;
    }

    .side-menu.mobile-menu-open .menu-title,
    .side-menu.mobile-menu-open .menu-link,
    .side-menu.mobile-menu-open .side-menu-caption {
        display: block;
    }

    .side-menu.mobile-menu-open .student-menu-link {
        display: flex;
    }

    .side-menu.mobile-menu-open .student-photo-box {
        display: block;
    }

    .side-menu.mobile-menu-open .student-profile-card {
        display: flex;
    }

    .side-menu.mobile-menu-open {
        max-height: 85vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .menu-title {
        margin: 10px 0;
        font-size: 20px;
    }

    .menu-link {
        margin: 6px 0;
        padding: 12px;
        border-radius: 14px;
        text-align: left;
        font-size: 14px;
    }

    .student-photo-frame-box {
        width: 120px;
        height: 120px;
    }

    /* Kích thước .student-photo dùng chung tỉ lệ 70% từ rule gốc (line 1194). */
}

/* ===== FIX LUCKY SCREEN HISTORY SCROLL - PC + MOBILE ===== */
.lucky-main-layout {
    align-items: start;
}

.lucky-left {
    /* Xếp DỌC: vòng quay ở TRÊN, dòng "Đang quay…/Kết quả: Thưởng…" ngay BÊN DƯỚI
       (trước đây xếp ngang → dòng kết quả tràn sang phải gây vỡ hình). */
    flex-direction: column;
    align-items: center;
    padding-top: 0;
}

@media (max-width: 900px) {
    .lucky-left {
        padding-top: 0;
    }
}

/* .reward-shop-section: khung do .main-panel đảm nhiệm; chỉ giữ hành vi lấp đầy
   (height:100% + flex) ở rule riêng phía dưới. */

/* Hàng tiêu đề: tiêu đề căn giữa toàn bộ chiều rộng, nút Lưu căn phải tuyệt đối
   (không ảnh hưởng tới việc căn giữa của tiêu đề so với bảng bên dưới). */
.reward-shop-title-row {
    position: relative;
    /* Tiêu đề cố định cùng thanh tab, không cuộn theo danh sách */
    flex-shrink: 0;
    margin-bottom: 14px;
}

.reward-shop-title {
    font-size: 30px;
    font-weight: bold;
    color: var(--red-500);
    text-align: center;
}

/* Nút "Lưu phần thưởng" đặt căn phải trên cùng dòng với tiêu đề */
.reward-shop-save-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
}

.reward-shop-save-btn.hidden-section {
    display: none !important;
}

/* ===== REWARD SHOP: THANH TAB =====
   Dùng chung "Parent tab style" với khối admin tabs để thống nhất giao diện.
   (#nền nhạt, active = nền xanh đậm + chữ trắng + viền vàng dưới) */
.reward-shop-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 4px 4px;
    margin-bottom: 0;
    border-bottom: 2px solid var(--border-card);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.reward-shop-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--touch-min); /* ≥44px vùng chạm */
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--surface-subtle);
    color: var(--text-strong);
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.reward-shop-tab:hover {
    background: var(--blue-100);
    color: var(--text-strong);
}

.reward-shop-tab.active-section {
    background: var(--blue-800);
    color: var(--text-inverse);
    border-bottom-color: var(--yellow-500);
    font-weight: 800;
}

.reward-shop-tab-panel {
    width: 100%;
    /* Khoảng cách trên đặt bằng margin-top của CHÍNH vùng cuộn (nằm NGOÀI
       scrollport) nên header sticky luôn cách tiêu đề một khoảng cố định,
       không bị xê dịch khi cuộn. KHÔNG dùng padding-top vì padding của vùng
       cuộn sẽ làm hàng dữ liệu lọt lên phía trên header. */
    margin-top: 14px;
    /* Panel đang hiện là phần DUY NHẤT được cuộn (danh sách quà / lịch sử) */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Trên điện thoại: trả về cuộn trang tự nhiên (không khóa chiều cao vùng cửa hàng) */
@media (max-width: 900px) {
    .reward-shop-section {
        height: auto;
        display: block;
        overflow: visible;
    }

    .reward-shop-tab-panel {
        overflow-y: visible;
        min-height: 0;
    }

    /* [SHOPEE GĐ1] Điện thoại: 2 tab chia đôi bề rộng, gọn, không tràn ngang */
    .reward-shop-tabs {
        flex-wrap: nowrap;
    }

    .reward-shop-tab {
        flex: 1 1 0;
        min-width: 0;
        padding: 10px 8px;
        font-size: 14px;
    }
}

/* [SHOPEE GĐ1] Placeholder tab "Shopee & Shopping" (nội dung dựng ở GĐ2) */