/* ===== Màu & kích thước ===== */
:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #eef3fa;
  --text: #1d2129;
  --muted: #6b7280;
  --border: #e0e7f0;
  --primary: #1a73e8;
  --primary-hover: #1561c9;
  --primary-soft: #e6f0fe;
  --chat-theirs: #e9eef5;
  --ok: #15803d;
  --chat-mine: var(--primary);
  --danger: #c0392b;
  --danger-soft: #fbeaea;
  --warning-soft: #fff6e0;
  --hl: rgba(255, 213, 0, 0.5);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141b;
    --surface: #182029;
    --surface-2: #222c38;
    --text: #e7e9ec;
    --muted: #9aa3ad;
    --border: #2b3644;
    --primary: #4c9aff;
    --primary-hover: #6daeff;
    --primary-soft: #17304f;
    --chat-theirs: #2c3746;
    --ok: #4ade80;
    --chat-mine: #2b6fd8;
    --danger: #e05d4f;
    --danger-soft: #3a2222;
    --warning-soft: #3a3020;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.25);
  }
}

/* ===== Nền tảng ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; background: var(--bg); color: var(--text);
  min-height: 100vh; display: flex; flex-direction: column; } /* chân trang luôn ở đáy, kể cả trang ít nội dung */
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.container { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }

/* ===== Header ===== */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; height: 60px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); white-space: nowrap; }
/* Chữ logo: font Outfit đậm, "CoVua" xanh chuyển màu như ô logo, ".info" xám */
.brand-text { font-family: "Outfit", var(--font); font-weight: 800; font-size: 1.45rem; letter-spacing: -0.01em; line-height: 1; }
.brand-name { background: linear-gradient(90deg, #0b57d0, #1a73e8 55%, #4fa8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-tld { color: #8a94a3; }
.footer-brand .brand-text { font-size: 1rem; }
/* Nút ở thẻ hồ sơ: sửa hồ sơ (xanh đặc), xem lịch sử (xanh nhạt), đăng xuất (đỏ nhạt); cách phần thống kê bên trên 20px */
.btn.soft, button.soft { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.btn.soft:hover, button.soft:hover { background: var(--primary); color: #fff; }
button.soft-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
button.soft-danger:hover { background: var(--danger); color: #fff; }
.profile-public { margin-top: 20px; }
/* Link mời: chơi ngay với tư cách khách */
.guest-play { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.guest-play p { margin: 0; text-align: center; }
/* Trang quản trị: sao lưu tự động */
.tool-backups { align-items: flex-start; }
.backup-warn { color: var(--danger); margin: 4px 0; }
.cron-cmd { display: block; padding: 8px 10px; margin-top: 4px; border-radius: 8px; background: var(--surface-2);
  font-family: var(--mono); font-size: 0.8rem; overflow-wrap: anywhere; user-select: all; }
.backup-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
/* Khách: tên trên menu và thanh nhắc đăng nhập */
.guest-chip { cursor: default; }
.guest-chip:hover { background: none; }
.guest-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 18px; border-radius: var(--radius); background: var(--warning-soft); }
.guest-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.or-line { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; color: var(--muted); font-size: 0.85rem; }
.or-line::before, .or-line::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.profile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.profile-actions form, .profile-actions .btn, .profile-actions button { width: 100%; margin: 0; }
img.brand-logo { display: block; object-fit: cover; background: none; } /* logo là ảnh icon (quân Hậu), giống hệt icon app */
.auth-head img.brand-logo { margin: 0 auto 12px; }
img.brand-logo.sm { display: inline-block; vertical-align: -5px; }
@media (prefers-color-scheme: dark) { /* nền tối: xanh sáng hơn cho rõ */
  .brand-name { background-image: linear-gradient(90deg, #4c9aff, #8cc4ff); }
  .brand-tld { color: #9aa3ad; }
}
.brand:hover { text-decoration: none; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #0b57d0, #1a73e8 55%, #4fa8ff); color: #fff; display: grid; place-items: center; font-size: 1.3rem; }
.nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav > a, .nav-menu > summary { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav > a:hover, .nav-menu > summary:hover, .nav-menu[open] > summary { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav > a.active, .nav-menu > summary.active { background: var(--primary-soft); color: var(--primary); }
/* Menu thả xuống (Chơi cờ, Học cờ) */
.nav-menu { position: relative; }
.nav-menu > summary { list-style: none; cursor: pointer; user-select: none; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 2px 3px 7px;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform .15s; }
.nav-menu[open] > summary::after { transform: translateY(3px) rotate(-135deg); }
.nav-drop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; width: 300px; padding: 6px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
/* Cầu nối vô hình giữa tên menu và khung thả xuống để rê chuột qua khe hở không làm menu đóng */
.nav-drop::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; }
.nav-drop a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.nav-drop a:hover { background: var(--surface-2); text-decoration: none; }
.nav-drop a.active { background: var(--primary-soft); }
.nav-drop .ic { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--surface-2); font-size: 1.1rem; }
.nav-drop b { display: block; font-weight: 600; }
.nav-drop small { display: block; color: var(--muted); font-size: 0.82rem; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-menu button, .user-menu .btn { white-space: nowrap; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; color: var(--text); font-weight: 600; }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
/* Chuỗi điểm danh 🔥: màu theo độ dài chuỗi; chưa điểm danh hôm nay thì ngọn lửa mờ */
.streak-chip { display: inline-flex; align-items: center; gap: 3px; padding: 5px 9px; border-radius: 999px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.streak-chip:hover { text-decoration: none; filter: brightness(0.96); }
.streak-chip.s-orange { background: #fff1e0; color: #c25e00; }
.streak-chip.s-red { background: #ffe4e1; color: #c62828; }
.streak-chip.off { filter: grayscale(1); opacity: .75; }
@media (prefers-color-scheme: dark) {
  .streak-chip.s-orange { background: #3d2610; color: #ffb066; }
  .streak-chip.s-red { background: #3d1515; color: #ff8a80; }
}
.user-chip .rating { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
@media (max-width: 720px) {
  .topbar-inner { gap: 8px; }
  .topbar .brand-text, .user-chip .uname, .user-chip .rating { display: none; }
  .nav { gap: 0; min-width: 0; }
  .nav > a, .nav-menu > summary { padding: 7px 6px; font-size: 0.85rem; }
  .nav-menu > summary::after { margin-left: 5px; }
  .nav .nav-tx { display: none; } /* Quản trị: chỉ còn biểu tượng */
  /* Màn hình hẹp: khung thả xuống trải rộng theo màn hình, ngay dưới thanh trên cùng */
  .nav-menu { position: static; }
  .nav-drop { position: fixed; top: 60px; left: 8px; right: 8px; width: auto; }
  .user-menu { gap: 2px; }
  .user-chip { padding: 2px; }
  .user-menu button.ghost { padding: 6px; font-size: 0.9rem; }
}
@media (max-width: 520px) {
  .user-menu form { display: none; } /* màn hình hẹp: Đăng xuất nằm trong trang hồ sơ của mình */
  .user-menu .btn { padding: 7px 10px; font-size: 0.85rem; }
  .user-menu a[href="register.php"] { display: none; } /* khách: chỉ giữ Đăng nhập; trang đăng nhập có link Đăng ký */
  .guest-chip .badge { display: none; } /* khách: dải vàng dưới thanh trên cùng đã ghi rõ, bỏ nhãn để menu không bị đè */
}
/* Điện thoại rất hẹp (≤ 400px, vd. 360px): thu gọn menu + ngọn lửa để không đè lên nhau */
@media (max-width: 400px) {
  .topbar-inner { gap: 6px; padding: 0 10px; }
  .nav > a, .nav-menu > summary { padding: 7px 4px; font-size: 0.8rem; }
  .nav-menu > summary::after { margin-left: 3px; }
  .streak-chip { padding: 4px 7px; font-size: 0.85rem; }
}
/* "Xếp hạng" chỉ hiện 🏆 dưới 375px; chữ vẫn còn cho trình đọc màn hình (ẩn bằng clip, không dùng display: none) */
.nav .nav-ic-lb { display: none; }
@media (max-width: 374px) {
  .nav .nav-ic-lb { display: inline; }
  .nav .nav-lb { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ===== Avatar ===== */
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; object-fit: cover; color: #fff; font-weight: 700; background: var(--surface-2); }

/* ===== Thẻ ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h1 { margin: 0; }
h1.card-title { font-size: 1.1rem; } /* h1 của trang nhưng trông như tiêu đề thẻ */
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ===== Nút ===== */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px;
  background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background 0.15s, border-color 0.15s; }
button:hover, .btn:hover { background: var(--primary-hover); text-decoration: none; }
button:disabled { opacity: 0.55; cursor: default; }
button.secondary, .btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); }
button.danger, .btn.danger { background: var(--surface); color: var(--danger); border-color: var(--border); }
button.danger:hover, .btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button.ghost { background: none; color: var(--muted); padding: 6px 10px; }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.link { background: none; color: var(--primary); padding: 0; border: 0; font-weight: 500; }
.btn-lg { padding: 12px 20px; font-size: 1rem; }
.btn-block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }

/* ===== Form ===== */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label, .field > span { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="password"], input:not([type]), select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--surface); color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
select { width: auto; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--primary-soft); color: var(--primary); }
.error { color: var(--danger); }

/* ===== Trang đăng nhập / đăng ký / lời mời ===== */
.auth { max-width: 420px; margin: 40px auto; }
.auth .card { padding: 28px; }
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head .brand-logo { margin: 0 auto 12px; width: 48px; height: 48px; font-size: 1.8rem; border-radius: 12px; }
.auth-foot { text-align: center; margin-top: 16px; color: var(--muted); }
/* Nút đăng nhập Google: kiểu nút trắng viền xám theo hướng dẫn thương hiệu của Google */
.btn-google { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; padding: 12px 16px;
  border-radius: 10px; border: 1px solid #dadce0; background: #fff; color: #1f1f1f; font-weight: 600; font-size: 1rem;
  box-shadow: var(--shadow); transition: background 0.15s, box-shadow 0.15s; }
.btn-google:hover { background: #f8faff; text-decoration: none; box-shadow: 0 2px 10px rgba(16, 24, 40, 0.12); }
.btn-google.dim { opacity: 0.7; }
.auth-note { margin: 14px 0 0; text-align: center; }
.google-account { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; overflow-wrap: anywhere; }
.g-dot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: #fff; border: 1px solid #dadce0; color: #4285f4; font-weight: 700; font-size: 0.8rem; }
/* Hướng dẫn mở bằng trình duyệt khi đang ở trong Zalo / Messenger */
.inapp-warning { padding: 14px; border-radius: 10px; background: var(--warning-soft); margin-bottom: 16px; }
.inapp-warning p { margin: 6px 0; }
.inapp-warning ol { margin: 6px 0 10px; padding-left: 20px; }

/* ===== Sảnh ===== */
.lobby { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .lobby { grid-template-columns: 1fr; } }
.tc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
@media (max-width: 520px) { .tc-grid { grid-template-columns: repeat(2, 1fr); } }
.color-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 12px 8px; min-height: 64px;
  border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; user-select: none; transition: border-color 0.15s, background 0.15s; }
.tile:hover { border-color: var(--muted); }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.tile:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.tile-main { font-weight: 700; font-size: 1.15rem; }
.tile-sub { font-size: 0.78rem; color: var(--muted); }
.tile img { width: 34px; height: 34px; }
.tile .kings { display: flex; align-items: center; height: 34px; } /* cao bằng ảnh một quân vua để chữ bên dưới thẳng hàng */
.tile .kings img { width: 26px; height: 26px; }

.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--border); }
.list-row:first-child { border-top: 0; }
.list-row .who { flex: 1; min-width: 0; }
.list-row .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.list-row { color: var(--text); border-radius: 8px; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.warn { background: var(--warning-soft); color: #b7791f; }
.empty { padding: 20px 8px; text-align: center; color: var(--muted); }
#create-form .actions button { flex: 1 1 220px; }
@media (max-width: 520px) {
  /* Màn hình hẹp: nút hành động xuống dòng riêng để tên người chơi không bị cắt */
  .list-row { flex-wrap: wrap; }
  .list-row > .actions { width: 100%; justify-content: flex-end; }
}
.online-list { display: flex; flex-wrap: wrap; gap: 8px; }
.online-list .person { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; background: var(--surface-2); border-radius: 999px; font-size: 0.88rem; font-weight: 500; }

/* ===== Hộp thoại ===== */
dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 480px; width: calc(100% - 32px); background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.copy-row { display: flex; gap: 8px; margin: 12px 0; }
.copy-row input { flex: 1; font-family: var(--mono); font-size: 0.85rem; }

/* ===== Trang ván cờ ===== */
.game { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; justify-content: center; }
/* Trừ header + 2 thẻ người chơi + khoảng cách để cả cụm bàn cờ vừa một màn hình */
.board-wrap { position: relative; flex: 1 1 480px; min-width: 280px; max-width: min(720px, calc(100vh - 250px)); display: flex; flex-direction: column; gap: 8px; }
/* touch-action: kéo quân trên điện thoại không làm cuộn trang */
#board { width: 100%; touch-action: none; }
.player { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.player .who { flex: 1; min-width: 0; line-height: 1.2; }
.player .name { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .rating { font-size: 0.8rem; color: var(--muted); }
.elo-up { color: var(--primary); }
.elo-down { color: var(--danger); }
.player.to-move { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.clock { font-family: var(--mono); font-size: 1.35rem; font-weight: 600; padding: 4px 12px; border-radius: 8px; background: var(--surface-2); min-width: 96px; text-align: right; }
.clock.running { background: var(--primary); color: #fff; }
.clock.low { background: var(--danger); color: #fff; }

.side { flex: 1 1 280px; max-width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.side-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.side-tools { display: flex; gap: 2px; }
.side-tools button { white-space: nowrap; padding: 6px 8px; font-size: 0.88rem; }
.status { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); font-weight: 600; transition: background 0.2s, color 0.2s; }
/* Tới lượt mình: nổi bật hẳn, nhấp nháy nhẹ; đang bị chiếu thì chuyển đỏ */
.status.my-turn { background: var(--primary); color: #fff; font-size: 1.05rem; animation: turn-pulse 1.8s ease-out infinite; }
.status.my-turn::before { content: "➤ "; }
.status.my-turn.in-check { background: var(--danger); animation-name: check-pulse; }
@keyframes turn-pulse { 0% { box-shadow: 0 0 0 0 rgba(26, 115, 232, 0.5); } 70%, 100% { box-shadow: 0 0 0 10px rgba(26, 115, 232, 0); } }
@keyframes check-pulse { 0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.5); } 70%, 100% { box-shadow: 0 0 0 10px rgba(192, 57, 43, 0); } }
.notice { padding: 12px; border-radius: 10px; background: var(--warning-soft); display: flex; flex-direction: column; gap: 10px; font-weight: 500; }
.moves { list-style: none; margin: 0; padding: 0; counter-reset: mv; max-height: 320px; min-height: 120px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 10px; font-family: var(--mono); font-size: 0.92rem; }
.moves li { display: grid; grid-template-columns: 3em 1fr 1fr; padding: 3px 8px; }
.moves li:nth-child(even) { background: var(--surface-2); }
.moves li::before { counter-increment: mv; content: counter(mv) "."; color: var(--muted); }
.moves:empty::after { content: "Chưa có nước đi"; display: block; padding: 12px; color: var(--muted); font-family: var(--font); }
details.settings { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
details.settings summary { cursor: pointer; font-weight: 600; color: var(--muted); }
details.settings .row { margin-top: 10px; }
.back-link { font-weight: 500; }

/* Trang quản trị: báo cáo */
.admin-stats a.card { color: inherit; text-decoration: none; }
.admin-stats .stat-alert { border-color: var(--danger); }
.admin-stats .stat-alert b { color: var(--danger); }
/* Quản trị: số liệu chuỗi điểm danh */
.admin-streak { margin-bottom: 20px; }
.admin-streak-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.admin-streak-grid > div { display: flex; flex-direction: column; padding: 12px; border-radius: 10px; background: var(--surface-2); }
.admin-streak-grid b { font-size: 1.5rem; }
.admin-streak-grid small { color: var(--muted); }
.admin-streak-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-bottom: 10px; }
.admin-bars { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.admin-bars li { display: grid; grid-template-columns: 150px 1fr 36px; align-items: center; gap: 8px; font-size: 0.88rem; }
.admin-bars i { display: block; height: 10px; min-width: 2px; border-radius: 99px; background: linear-gradient(90deg, #f9ab00, #e8710a); }
.admin-bars b { text-align: right; }
.admin-reports { margin-bottom: 20px; }
.report { padding: 14px 0; border-top: 1px solid var(--border); }
.report-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-reason { margin: 8px 0 4px; }
.report-chat-box summary { cursor: pointer; font-weight: 600; color: var(--muted); margin: 6px 0; }
.report-chat { list-style: none; margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); max-height: 220px;
  overflow-y: auto; font-size: 0.9rem; }
.report-chat li { padding: 2px 0; }
.report-chat li.by-reported { color: var(--danger); }
.report .actions { margin-top: 10px; }

/* Báo cáo / chặn */
.radio-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; }
.radio-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
#report-dialog textarea { width: 100%; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); resize: vertical; }
#report-dialog .actions { margin-top: 12px; }
.chat-tools { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; }
button.link.danger-link { color: var(--danger); }
.site-notice { margin-bottom: 16px; }

/* Kết thúc ván: thông báo đè lên bàn cờ (board.js → showResult) */
.result-overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; overflow: hidden; cursor: pointer;
  border-radius: 10px; background: rgba(12, 18, 28, 0.5); backdrop-filter: blur(2px); animation: result-fade 0.25s ease-out; }
.result-card { position: relative; z-index: 1; min-width: 240px; max-width: 86%; padding: 26px 30px; border-radius: 18px; text-align: center;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35); animation: result-pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1); }
.result-icon { font-size: 3.2rem; line-height: 1; }
.result-title { margin: 10px 0 4px; font-family: "Outfit", var(--font); font-size: 2rem; font-weight: 800; letter-spacing: 0.02em; line-height: 1.15; }
.result-win .result-title { background: linear-gradient(90deg, #0b57d0, #1a73e8 55%, #4fa8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-loss .result-title { color: var(--danger); }
.result-draw .result-title { color: #b45309; }
.result-detail { color: var(--muted); font-weight: 500; }
.result-close { margin-top: 16px; }
@media (max-width: 520px) { .result-card { padding: 22px 18px; } .result-title { font-size: 1.45rem; } .result-icon { font-size: 2.6rem; } }
.confetti { position: absolute; inset: 0; pointer-events: none; } /* phủ cả khung, không chiếm chỗ trong lưới (thẻ kết quả vẫn ở giữa) */
.confetti i { position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translate(var(--drift), 115vh) rotate(var(--spin)); } }
@keyframes result-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes result-fade { from { opacity: 0; } }
@media (prefers-color-scheme: dark) {
  .result-win .result-title { background-image: linear-gradient(90deg, #4c9aff, #8cc4ff); }
  .result-draw .result-title { color: #fbbf24; }
}
/* Máy bật "giảm chuyển động" (vd. Windows tắt Animation effects): không nhấp nháy, không rơi/xoay;
   pháo giấy vẫn có nhưng đứng yên rải rác rồi mờ dần */
@media (prefers-reduced-motion: reduce) {
  .status.my-turn, .result-card, .result-overlay { animation: none; }
  .confetti i { top: var(--y); transform: rotate(var(--r)); animation: confetti-fade 3s ease-in forwards !important; animation-delay: 0s !important; }
}
@keyframes confetti-fade { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }

/* Đấu lại */
.rematch { display: flex; flex-direction: column; gap: 8px; }
.rematch p { margin: 0; }
#rematch-offer { padding: 12px 16px; font-size: 1rem; }

/* Chat trong ván */
.chat { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-head label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.chat-log { display: flex; flex-direction: column; gap: 6px; max-height: 260px; min-height: 64px; overflow-y: auto; padding: 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.chat-log.muted .theirs { display: none; }
.chat-empty { margin: auto; }
/* Tin đối thủ: trái, ảnh đại diện + tên, bong bóng xám. Tin của mình: phải, bong bóng xanh. */
.msg { display: flex; align-items: flex-end; gap: 6px; max-width: 85%; }
.msg + .msg:not(.cont) { margin-top: 6px; }
.msg.cont { margin-top: -3px; }
.msg-avatar { width: 28px; flex-shrink: 0; display: flex; }
.msg-body { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.msg-head { font-size: 0.74rem; color: var(--muted); padding: 0 4px; }
.msg-head b { color: var(--text); font-weight: 600; }
.msg .bubble { padding: 7px 12px; border-radius: 16px; overflow-wrap: anywhere; line-height: 1.4; }
.msg.theirs { align-self: flex-start; }
.msg.theirs .bubble { background: var(--chat-theirs); color: var(--text); border-bottom-left-radius: 4px; }
.msg.mine { align-self: flex-end; }
.msg.mine .msg-body { align-items: flex-end; }
.msg.mine .bubble { background: var(--chat-mine); color: #fff; border-bottom-right-radius: 4px; }
.chat-sys { margin: 0; text-align: center; font-size: 0.8rem; color: var(--danger); }
.quick-chat { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.quick-chat-box > summary { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; padding: 4px 10px; border-radius: 999px;
  cursor: pointer; list-style: none; font-size: 0.84rem; font-weight: 600; color: var(--primary); background: var(--primary-soft); }
.quick-chat-box > summary::-webkit-details-marker { display: none; }
.quick-chat-box > summary::after { content: "▾"; transition: transform 0.15s; }
.quick-chat-box[open] > summary::after { transform: rotate(180deg); }
.chip { padding: 5px 10px; border-radius: 999px; font-size: 0.84rem; font-weight: 500;
  background: var(--primary-soft); color: var(--primary); border: 1px solid transparent; }
.chip:hover { background: var(--primary); color: #fff; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; }

/* Ô vừa đi; ô gợi ý (đấu với máy) */
#board .hl { box-shadow: inset 0 0 0 100px var(--hl); }
#board .hint { box-shadow: inset 0 0 0 4px var(--primary), inset 0 0 0 100px rgba(26, 115, 232, 0.25); }

/* Đấu với máy */
/* Sảnh: khối "Luôn sẵn sàng" (6 đối thủ máy, bấm là vào ván) */
.bots-ready { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bot-ready { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); transition: border-color .15s, transform .15s; }
.bot-ready:hover { text-decoration: none; border-color: var(--primary); transform: translateY(-1px); }
.bots-note { margin: 10px 0 0; }
.bot-suggest { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; }
.bot-suggest[hidden] { display: none; }
@media (max-width: 760px) {
  .bots-ready { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bot-ready .bot-style { display: none; } /* điện thoại: chỉ giữ Elo ước lượng cho thẻ gọn */
}
/* Đấu với AI: thẻ chọn đối thủ máy, bong bóng lời thoại */
.bot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0 8px; }
.bot-card { position: relative; display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; background: var(--surface); }
.bot-card:hover { border-color: var(--muted); }
.bot-card input { position: absolute; opacity: 0; pointer-events: none; }
.bot-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.bot-card:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.bot-emoji { flex: none; font-size: 1.6rem; line-height: 1; }
.bot-info { min-width: 0; line-height: 1.25; }
.bot-info small { display: block; color: var(--muted); font-size: 0.72rem; }
.bot-beaten { color: #188038; font-weight: 700; }
.bot-intro { margin: 0 0 12px; min-height: 2.6em; }
/* Bong bóng nằm trong thanh tên của máy (không chen giữa thanh tên và bàn cờ) */
#top-player .who { flex: 0 1 auto; min-width: 72px; }
#top-player .rating { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-say { flex: 1 1 0; min-width: 0; margin-left: auto; padding: 0 9px; border: 3px solid var(--surface-2); border-radius: 10px;
  background: var(--surface-2); font-size: 0.8rem; line-height: 1.25; max-height: calc(3.75em + 6px); /* viền thay padding: cắt gọn sau dòng 3 */
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* Giữ sẵn chỗ cho 3 dòng thoại: bong bóng hiện / ẩn không làm bàn cờ dịch chuyển */
#top-player:has(.bot-say) { min-height: calc(3.75 * 0.8rem + 6px + 18px); }
.bot-say[hidden] { display: none; }
/* Màn hình hẹp: lúc máy đang nói thì tạm ẩn tên + Elo (ảnh đại diện vẫn còn) để câu thoại đủ chỗ, không bị cắt */
@media (max-width: 640px) {
  #top-player:has(.bot-say:not([hidden])) .who { display: none; }
}
.bot-say.pop { animation: bot-pop .25s ease-out; }
@keyframes bot-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .bot-say.pop { animation: none; } }
.result-note { margin-top: 10px; font-size: 0.92rem; }
.result-note:empty { display: none; }
.btn.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
#new-game-form .color-grid { margin-bottom: 12px; }
#new-game-form .tile { min-height: 56px; }
.avatar.bot { background: var(--surface-2); }
/* ===== Bàn cờ minh họa (trang chủ) ===== */
.board-art { display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; width: 100%;
  border-radius: 10px; overflow: hidden; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28); }
.board-art span { position: relative; display: grid; place-items: center; }
.board-art .l { background: #f0d9b5; }
.board-art .d { background: #b58863; }
.board-art .hl::before { content: ""; position: absolute; inset: 0; background: rgba(255, 213, 0, 0.45); }
.board-art img { position: relative; width: 92%; height: 92%; }

/* ===== Khối "Giữ chuỗi" đầu sảnh chờ (thành viên) ===== */
.streak-hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px 28px; margin-bottom: 24px; padding: 22px 24px; }
.streak-hero.is-todo { border: 2px solid #f9ab00; background: linear-gradient(135deg, #fff8e6 0%, var(--surface) 60%); }
.streak-hero .streak-num { font-size: 2.4rem; }
.streak-hero .streak-flame { font-size: 3rem; }
.streak-hero-title { font-size: 0.85rem; text-transform: uppercase; letter-spacing: .06em; color: #c25e00; margin: 0 0 10px; }
.streak-hero-msg { margin: 10px 0 14px; font-size: 1.02rem; }
/* "Vì sao nên giữ chuỗi?": một dòng, bấm để mở 3 ý ngắn */
.streak-why { font-size: 0.84rem; color: var(--muted); }
.streak-why summary { cursor: pointer; width: fit-content; color: var(--primary); font-weight: 600; }
.streak-why ul { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; line-height: 1.45; }
.streak-hero-actions { display: flex; flex-direction: column; gap: 8px; }
.streak-action { --c: var(--primary); --c-soft: var(--surface-2);
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--c);
  border-radius: 12px; background: var(--surface); color: var(--text); transition: border-color .15s, transform .15s, background .15s; }
.streak-action:hover { text-decoration: none; border-color: var(--c); background: var(--c-soft); transform: translateY(-1px); }
/* Mỗi cách giữ chuỗi một màu, dùng nhất quán: câu đố cam (màu ngọn lửa), máy xanh dương, luyện tập xanh lá */
.a-daily { --c: #e8710a; --c-soft: #fff1e0; }
.a-bot { --c: #1a73e8; --c-soft: #e8f0fe; }
.a-puzzle { --c: #188038; --c-soft: #e6f4ea; }
.streak-action .ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--c-soft); font-size: 1.25rem; }
.act-text { flex: 1; min-width: 0; }
.streak-action b, .streak-action small { display: block; }
.streak-action small { color: var(--muted); font-size: 0.82rem; }
.act-state { flex: none; padding: 3px 9px; border-radius: 999px; background: var(--c-soft); color: var(--c); font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.act-state.done { background: #e6f4ea; color: #188038; }
.act-bar { display: block; height: 5px; margin-top: 5px; max-width: 160px; border-radius: 99px; background: var(--c-soft); overflow: hidden; }
.act-bar span { display: block; height: 100%; border-radius: 99px; background: var(--c); }
.is-todo .streak-action.is-main { border-color: transparent; background: linear-gradient(120deg, #e8710a, #f9ab00); color: #fff;
  box-shadow: 0 6px 18px rgba(232, 113, 10, .28); }
.is-todo .streak-action.is-main small { color: rgba(255, 255, 255, .9); }
.is-todo .streak-action.is-main .ic { background: rgba(255, 255, 255, .22); }
@media (prefers-color-scheme: dark) {
  .streak-hero.is-todo { background: linear-gradient(135deg, #3a2a0e 0%, var(--surface) 60%); }
  .a-daily { --c: #ffa24d; --c-soft: #3d2610; }
  .a-bot { --c: #6ea8ff; --c-soft: #1c2b45; }
  .a-puzzle { --c: #5bc27a; --c-soft: #16301f; }
  .act-state.done { background: #16301f; color: #5bc27a; }
}
@media (max-width: 760px) {
  .streak-hero { grid-template-columns: 1fr; padding: 18px 16px; }
  /* Đã giữ chuỗi hôm nay: điện thoại không cần lối tắt nữa, để phần Chơi online hiện gần hơn */
  .streak-hero.is-done .streak-hero-actions { display: none; }
}

/* ===== Trang giới thiệu (khách) ===== */
.landing-hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 56px; align-items: center; padding: 32px 0 48px; }
.eyebrow { display: inline-block; padding: 5px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary);
  font-size: 0.85rem; font-weight: 600; margin-bottom: 18px; }
.landing-text h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); line-height: 1.12; letter-spacing: -0.02em; margin-bottom: 18px; }
.landing-text .accent { background: linear-gradient(90deg, var(--primary), #38b6ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 540px; margin-bottom: 26px; }
.landing-text .actions { margin-bottom: 14px; }
.landing-art { max-width: 420px; width: 100%; justify-self: center; transform: perspective(900px) rotateY(-8deg) rotate(-2deg); }
@media (max-width: 860px) {
  .landing-hero { grid-template-columns: 1fr; gap: 28px; padding: 8px 0 32px; text-align: center; }
  .lead { margin-left: auto; margin-right: auto; }
  .landing-text .actions { flex-direction: column; align-items: stretch; max-width: 320px; margin: 0 auto 14px; }
  .landing-art { max-width: 300px; transform: none; }
}
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 12px; margin-bottom: 32px; padding: 20px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); text-align: center; }
.stat-strip b { display: block; font-size: 1.8rem; color: var(--primary); }
.stat-strip span { color: var(--muted); font-size: 0.9rem; }
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 32px; }
@media (max-width: 1100px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .feature-grid { grid-template-columns: 1fr; } }
/* Icon đứng trước tiêu đề trên cùng một hàng; đoạn mô tả bên dưới, trải hết chiều rộng thẻ */
.feature { position: relative; display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 12px; align-content: start;
  padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--text); transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s; }
.feature:hover { text-decoration: none; transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 10px 28px rgba(16, 24, 40, 0.1); }
/* Cả thẻ là một link: mũi tên ở góc, đậm lên khi rê chuột */
.feature::after { content: "→"; position: absolute; top: 20px; right: 20px; color: var(--muted); font-weight: 700;
  transition: transform 0.15s, color 0.15s; }
.feature:hover::after { color: var(--accent); transform: translateX(3px); }
.feature-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft);
  font-size: 1.25rem; }
.feature h3 { font-size: 1rem; font-weight: 700; letter-spacing: 0.04em; margin: 0; line-height: 1.3; padding-right: 18px; color: var(--accent); }
.feature p { grid-column: 1 / -1; color: var(--muted); margin: 12px 0 0; text-wrap: pretty; } /* không để một chữ rớt xuống dòng cuối */
/* Mỗi thẻ một màu nhấn (tiêu đề, nền icon, viền và mũi tên khi rê chuột); chữ đủ tương phản trên nền trắng */
.feature { --accent: var(--primary); --accent-soft: var(--primary-soft); --tint: 14%; }
/* Lớp màu nhạt chuyển dần từ góc trên về trắng; rê chuột thì đậm lên */
.feature::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) var(--tint), transparent), transparent 65%);
  opacity: 0.55; transition: opacity 0.15s; }
.feature:hover::before { opacity: 1; }
.feature > * { position: relative; } /* chữ và icon nằm trên lớp màu */
.feature .feature-icon { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent); } /* không chìm vào lớp màu */
.feature.f-ai { --accent: #7c3aed; --accent-soft: #f1eafe; }
.feature.f-puzzle { --accent: #15803d; --accent-soft: #e5f5ea; }
.feature.f-rank { --accent: #b45309; --accent-soft: #fdf0e1; }
@media (prefers-color-scheme: dark) {
  .feature { --tint: 24%; }
  .feature.f-ai { --accent: #a78bfa; --accent-soft: #2a2342; }
  .feature.f-puzzle { --accent: #4ade80; --accent-soft: #16301f; }
  .feature.f-rank { --accent: #fbbf24; --accent-soft: #382c14; }
}
.landing-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.landing-bottom.single { grid-template-columns: minmax(0, 1fr); } /* chưa đủ người cho "Top kỳ thủ": chỉ còn thẻ mời chơi */
/* Bảng xếp hạng khi còn ít người: lời mời "Mùa đầu tiên" + các suất còn trống */
.season-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 14px; padding: 12px 16px;
  border-radius: var(--radius); background: #fff8e6; border: 1px solid #f9ab00; }
.season-banner span { color: var(--muted); flex: 1 1 260px; }
.rank-table tr.rank-free td { padding-top: 10px; padding-bottom: 10px; font-size: 0.9rem; }
.rank-table tr.rank-free { opacity: .6; }
@media (prefers-color-scheme: dark) { .season-banner { background: #3a2a0e; border-color: #8a5a00; } }
@media (max-width: 760px) { .landing-bottom { grid-template-columns: 1fr; } }
.cta-card { display: flex; flex-direction: column; justify-content: center; gap: 10px;
  background: linear-gradient(160deg, var(--primary-soft), var(--surface) 70%); }
.cta-card h2 { font-size: 1.4rem; margin: 0; }

/* ===== Top kỳ thủ, thẻ của tôi (trang chủ) ===== */
.top-list { list-style: none; margin: 0; padding: 0; }
.top-list li { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-top: 1px solid var(--border); }
.top-list li:first-child { border-top: 0; }
.top-list .pos { width: 26px; text-align: center; font-weight: 700; }
.top-list .person-link { flex: 1; min-width: 0; }
.top-list .person-link b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.top-list .elo { font-weight: 700; }
.me-card .person-link { margin-bottom: 14px; }
.me-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.me-stats div { background: var(--surface-2); border-radius: 10px; padding: 10px 4px; }
.me-stats b { display: block; font-size: 1.25rem; }
.me-stats span { font-size: 0.75rem; color: var(--muted); }
.wdl-text { text-align: center; margin: 4px 0 0; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #3fa46a; margin-right: 4px;
  box-shadow: 0 0 0 0 rgba(63, 164, 106, 0.6); animation: pulse 2s infinite; vertical-align: 1px; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(63, 164, 106, 0); } 100% { box-shadow: 0 0 0 0 rgba(63, 164, 106, 0); } }

/* ===== Bài tập cờ ===== */
.puzzle-status { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center;
  padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid transparent; transition: background 0.2s; }
.puzzle-status b { font-size: 1.02rem; }
.puzzle-status .muted { grid-column: 2; }
.puzzle-turn { grid-row: span 2; width: 34px; height: 34px; border-radius: 8px; border: 2px solid var(--border); }
.puzzle-turn.white { background: #fff; }
.puzzle-turn.black { background: #222; }
.puzzle-status.ok { background: var(--primary-soft); border-color: var(--primary); }
.puzzle-status.bad { background: var(--danger-soft); border-color: var(--danger); }
.puzzle-status.done { border-color: var(--border); }
.puzzle-done { display: flex; flex-direction: column; gap: 8px; }
.puzzle-done .row { justify-content: space-between; }
.themes { display: flex; flex-wrap: wrap; gap: 6px; }
.puzzle-me { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.puzzle-me div { background: var(--surface-2); border-radius: 10px; padding: 10px 4px; }
.puzzle-me b { display: block; font-size: 1.3rem; }
.puzzle-me span { font-size: 0.75rem; color: var(--muted); }
.puzzle-me em { display: block; font-style: normal; font-weight: 700; font-size: 0.8rem; min-height: 1.1em; }
.puzzle-card .puzzle-me { margin-bottom: 12px; }

/* ===== Gợi ý cài app (PWA) ===== */
.install-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 10px 12px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.install-banner img { border-radius: 10px; flex: none; }
.install-banner > div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.install-banner button { flex: none; }
.install-banner .ghost { padding: 6px 8px; }

/* ===== Chân trang ===== */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 24px; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 28px 16px; display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 24px; color: var(--muted); font-size: 0.88rem; }
.footer-about { display: flex; flex-direction: column; gap: 8px; }
.footer-about p { margin: 0; max-width: 280px; }
.footer-inner nav { display: flex; flex-direction: column; gap: 8px; }
.footer-inner nav b { color: var(--text); font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.footer-inner a { color: var(--muted); }
@media (max-width: 760px) {
  .footer-inner { grid-template-columns: 1fr 1fr; gap: 22px 16px; }
  .footer-about { grid-column: 1 / -1; }
}
.footer-inner a:hover { color: var(--text); }
.brand-logo.sm { display: inline-grid; width: 22px; height: 22px; border-radius: 6px; font-size: 0.85rem; vertical-align: -5px; }

/* Màu bàn cờ (ghi đè màu mặc định của chessboard.js; "brown" dùng màu mặc định) */
body[data-board-theme="green"] #board .white-1e1d7 { background-color: #eeeed2; color: #769656; }
body[data-board-theme="green"] #board .black-3c85d { background-color: #769656; color: #eeeed2; }
body[data-board-theme="blue"] #board .white-1e1d7 { background-color: #dee3e6; color: #8ca2ad; }
body[data-board-theme="blue"] #board .black-3c85d { background-color: #8ca2ad; color: #dee3e6; }
body[data-board-theme="grey"] #board .white-1e1d7 { background-color: #dcdcdc; color: #9a9a9a; }
body[data-board-theme="grey"] #board .black-3c85d { background-color: #9a9a9a; color: #dcdcdc; }
/* Bàn cờ độc quyền "Ngọc bích" (mở khóa ở mốc chuỗi 30 ngày) */
body[data-board-theme="jade"] #board .white-1e1d7 { background-color: #e3f1e8; color: #3d8a6a; }
body[data-board-theme="jade"] #board .black-3c85d { background-color: #3d8a6a; color: #e3f1e8; }
#board .board-b72b1 { border: 0; border-radius: 4px; overflow: hidden; box-shadow: var(--shadow); }

/* Chế độ toàn màn hình: bàn cờ lớn nhất có thể, bảng thông tin bên cạnh (hoặc bên dưới trên màn hình dọc) */
body.no-scroll { overflow: hidden; }
.game.fullscreen { position: fixed; inset: 0; z-index: 1000; margin: 0; padding: 12px; background: var(--bg); align-items: flex-start; overflow: auto; }
.game.fullscreen .board-wrap { flex: 0 0 auto; max-width: none;
  width: min(calc(100vw - 24px), calc(100vh - 150px));
  width: min(calc(100vw - 24px), calc(100dvh - 150px)); }

/* Khung bên cạnh bàn cờ: trên màn hình rộng luôn cao đúng bằng bàn cờ, nội dung cuộn bên trong
   (contain: size → khung không tự kéo dài theo nội dung, chỉ giãn theo bàn cờ) */
@media (min-width: 900px) {
  .game, .game.fullscreen { flex-wrap: nowrap; align-items: stretch; }
  .game > .side { contain: size; overflow-y: auto; scrollbar-width: thin; gap: 10px; padding: 14px; }
  .game > .side .status { padding: 9px 12px; }
  .game > .side .status.my-turn { font-size: 1rem; }
  /* lịch sử nước đi và khung chat cùng chia phần chỗ còn lại; mỗi phần còn tối thiểu ~3 dòng */
  .game > .side .moves { flex: 1 1 0; min-height: 86px; max-height: none; }
  .game > .side .chat { flex: 1 1 0; } /* co tới mức tối thiểu của nội dung (không đè lên phần bên dưới), thiếu chỗ thì khung cuộn */
  .game > .side .chat-log { flex: 1 1 0; min-height: 84px; max-height: none; }
  .game > .side .quick-chat { max-height: 96px; overflow-y: auto; }
}
@media (max-width: 899px) {
  .game > .side .moves { max-height: 210px; }
}

/* ===== Hồ sơ ===== */
.profile { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .profile { grid-template-columns: 1fr; } }
.profile-card { text-align: center; }
.profile-card .avatar { margin: 0 auto 12px; }
.profile-card h1 { font-size: 1.3rem; margin-bottom: 2px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 18px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 4px; }
.stat b { display: block; font-size: 1.25rem; }
.stat span { font-size: 0.75rem; color: var(--muted); }
.avatar-edit { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* ===== Hồ sơ công khai, lịch sử ván ===== */
.elo-big { margin: 6px 0 4px; }
.elo-num { display: block; font-size: 2rem; font-weight: 700; line-height: 1.1; }
.wdl-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; margin: 14px 0 4px; background: var(--surface-2); }
.wdl-bar .w { background: var(--primary); }
.wdl-bar .d { background: #9aa3ad; }
.wdl-bar .l { background: var(--danger); }
.h2h { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.h2h div { background: var(--surface-2); border-radius: 10px; padding: 10px 4px; }
.h2h b { display: block; font-size: 1.4rem; }
.h2h span { font-size: 0.78rem; color: var(--muted); }
.game-row { gap: 10px; }
.game-row .row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.outcome { flex: none; width: 52px; text-align: center; padding: 3px 0; border-radius: 6px; font-size: 0.8rem; font-weight: 700; }
.outcome.win { background: var(--primary-soft); color: var(--primary); }
.outcome.loss { background: var(--danger-soft); color: var(--danger); }
.outcome.draw { background: var(--surface-2); color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 14px; }
a.plain-link { color: inherit; }
.online-list a.person { color: var(--text); }
.online-list a.person:hover { text-decoration: none; background: var(--border); }
.player .name a { color: inherit; }

/* ===== Bảng xếp hạng ===== */
.my-rank { padding: 10px 14px; border-radius: 10px; background: var(--primary-soft); }
.rank-table { width: 100%; border-collapse: collapse; }
.rank-table th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.rank-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.rank-table tr.me td { background: var(--primary-soft); }
.rank-table .pos { width: 44px; font-weight: 700; font-size: 1.05rem; }
.person-link { display: flex; align-items: center; gap: 10px; color: var(--text); }
.person-link:hover { text-decoration: none; }
.person-link:hover b { text-decoration: underline; }
.person-link > span { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
@media (max-width: 600px) { .hide-sm { display: none; } .rank-table .muted.small { display: none; } }

/* ===== Xem lại ván ===== */
.replay { display: flex; flex-direction: column; gap: 10px; }
.replay-nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.replay-nav button { font-size: 1.1rem; padding: 8px 0; }
.moves span[data-ply] { cursor: pointer; border-radius: 4px; padding: 0 4px; margin-left: -4px; }
.moves span[data-ply]:hover { background: var(--border); }
.moves span.cur { background: var(--primary); color: #fff; }

/* ===== Phân tích ván ===== */
.analysis { display: flex; flex-direction: column; gap: 10px; }
.progress { position: relative; height: 26px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.progress span { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--primary-soft); transition: width 0.2s; }
.progress small { position: relative; display: block; line-height: 26px; text-align: center; font-weight: 600; }
.eval-row { display: flex; align-items: center; gap: 10px; }
.eval-bar { flex: 1; height: 14px; border-radius: 7px; overflow: hidden; background: #3a3a3a; }
.eval-bar span { display: block; height: 100%; width: 50%; background: #f5f5f5; transition: width 0.25s; }
.eval-row b { min-width: 52px; text-align: right; font-family: var(--mono); }
.eval-graph { width: 100%; height: 64px; display: block; border-radius: 8px; background: #3a3a3a; cursor: pointer; }
.eval-graph .area { fill: #f5f5f5; }
.eval-graph .mid { stroke: rgba(128, 128, 128, 0.6); stroke-width: 0.6; }
.eval-graph .cursor { stroke: var(--primary); stroke-width: 2; vector-effect: non-scaling-stroke; }
.eval-graph circle.j-blunder { fill: var(--danger); }
.eval-graph circle.j-mistake { fill: #e8890c; }
.verdict { margin: 0; font-size: 0.9rem; min-height: 1.4em; }
.judgments { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.judgments div { display: flex; align-items: center; gap: 10px; }
.judgments .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.judgments span:not(.who) { font-weight: 700; min-width: 34px; text-align: right; }
.j-inaccuracy { color: #b8860b; }
.j-mistake { color: #e8890c; }
.j-blunder { color: var(--danger); }
.moves span.j-inaccuracy, .moves span.j-mistake, .moves span.j-blunder { font-weight: 700; }
.moves span.cur.j-inaccuracy, .moves span.cur.j-mistake, .moves span.cur.j-blunder { color: #fff; }

/* ===== Ghép nhanh: lời mời vừa tạo được tô sáng một lúc ===== */
.list-row.flash { animation: flash 3s ease-out; border-radius: 8px; }
@keyframes flash { 0%, 40% { background: var(--primary-soft); } 100% { background: transparent; } }

/* ===== Sảnh: ô thời gian bấm là tìm đối thủ ===== */
.tile.qp { color: var(--text); font: inherit; min-height: 84px; gap: 1px; }
.tile.qp:hover { background: var(--surface); border-color: var(--primary); }
.tile.qp:disabled { opacity: 1; cursor: progress; }
.qp-status { min-height: 1.2em; font-size: 0.74rem; font-weight: 600; line-height: 1.2; text-align: center; }
.qp.has-waiting { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.qp.has-waiting .qp-status { color: var(--ok); }
.qp.searching, .qp.searching:hover { border-color: var(--primary); background: var(--primary-soft); }
.qp.searching .qp-status { color: var(--primary); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.qp.locked { opacity: 0.55; }
.qp.locked:hover { opacity: 0.8; }
.qp.locked .qp-status { color: var(--muted); }
.busy-note { margin-bottom: 12px; }
.qp.last::after { content: "★"; position: absolute; top: 5px; right: 8px; font-size: 0.75rem; color: #f59e0b; }

/* ===== Sảnh: hai tab "Tìm đối thủ" / "Chơi với bạn bè" ===== */
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; margin-bottom: 16px;
  background: var(--surface-2); border-radius: 12px; }
.mode-tab { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 8px; border-radius: 9px;
  background: transparent; color: var(--muted); font: inherit; text-align: center; border: 1px solid transparent; }
.mode-tab:hover { background: var(--surface); color: var(--text); }
.mode-tab.active { background: var(--surface); color: var(--text); border-color: var(--primary); box-shadow: var(--shadow); }
.mode-title { font-weight: 700; font-size: 1rem; }
.mode-tab.active .mode-title { color: var(--primary); }
.mode-sub { font-size: 0.78rem; font-weight: 400; }
@media (max-width: 520px) { /* điện thoại: tên tab trên một dòng, mô tả nhỏ lại */
  .mode-tab { padding: 8px 4px; }
  .mode-title { font-size: 0.86rem; white-space: nowrap; }
  .mode-sub { font-size: 0.7rem; line-height: 1.3; }
}
.pane-hint { margin: 12px 0 0; }
.quick-grid { margin-bottom: 0; }
#pane-friend .tc-grid { margin-bottom: 14px; }
#pane-friend .tile { min-height: 56px; padding: 8px 6px; }
#pane-friend .color-grid { margin-bottom: 16px; }
#invite-result .copy-row { margin: 8px 0 10px; }
#invite-result .field-label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#invite-new { margin-top: 8px; }

/* ===== Quản trị ===== */
.admin-title h1 { margin: 0 0 4px; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.admin-stats .card { padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.admin-stats b { font-size: 1.7rem; line-height: 1.1; }
.admin-stats span { font-weight: 600; }
.admin-stats small { color: var(--muted); }
.admin-tools { margin-bottom: 18px; }
.admin-tools .tool { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.admin-tools .tool:first-of-type { border-top: 0; }
.admin-tools .tool p { margin: 2px 0 0; }
.admin-search input { width: 200px; }
.table-wrap { overflow-x: auto; }
.admin-table tr.banned td { opacity: 0.6; }
.admin-actions { white-space: nowrap; }
.admin-actions form { margin-right: 4px; }
.admin-actions button { padding: 6px 10px; font-size: 0.85rem; }

/* ===== Lời mời ===== */
.invite { max-width: 460px; margin: 40px auto; text-align: center; }
.invite .avatar { margin: 0 auto 14px; }
.invite .meta { display: flex; justify-content: center; gap: 8px; margin: 12px 0 20px; flex-wrap: wrap; }
.invite-share { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; text-align: left; }
.invite-share .copy-row { margin: 0; }
.invite-share p { margin: 0; }
.invite-message { padding: 12px 14px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--bg);
  font-size: 0.92rem; line-height: 1.5; overflow-wrap: anywhere; }
/* Trang tạo link mời: rộng hơn để chứa lưới thời gian, nội dung căn trái */
.invite-create { max-width: 560px; text-align: left; }
.invite-create h1 { font-size: 1.5rem; margin: 0 0 6px; }
.invite-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.invite-form p { margin: 0; text-align: center; }
.invite-steps { margin: 24px 4px 0; }
.invite-steps h2 { font-size: 1.15rem; }
.invite-steps li { margin-bottom: 6px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Hướng dẫn chơi cờ vua (guide.php) ===== */
.guide-wrap { max-width: 780px; margin: 0 auto; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.guide-hero { margin-bottom: 24px; }
.guide-hero h1, .guide h1 { font-size: 2rem; letter-spacing: -0.01em; }
.guide-hero .lead { max-width: none; margin-bottom: 0; }
.guide-hero .actions { margin-top: 16px; }
.guide-group { margin-bottom: 26px; scroll-margin-top: 80px; }
/* Lộ trình học trên trang /huong-dan */
.guide-path { margin: 0 0 18px; }
.guide-path ol { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.guide-path a { display: flex; align-items: center; gap: 10px; height: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: inherit; }
.guide-path a:hover { text-decoration: none; border-color: var(--g, var(--primary)); }
.guide-path a > span:last-child { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.guide-path .step { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--g, var(--primary)); color: #fff; font-weight: 700; }
.guide-path li { border-radius: var(--radius); }
.guide-path li a { border-top: 3px solid var(--g, var(--border)); }

/* ===== Màu nhấn của từng nhóm bài (dùng chung cho mục lục và trang bài) ===== */
.g-co-ban { --g: #1a73e8; --g-soft: #e8f0fe; }
.g-luat-choi { --g: #8e24aa; --g-soft: #f3e8fd; }
.g-chieu-het { --g: #d93025; --g-soft: #fce8e6; }
.g-chien-thuat { --g: #e8710a; --g-soft: #feefe3; }
.g-khai-cuoc { --g: #188038; --g-soft: #e6f4ea; }
.g-tan-cuoc { --g: #00838f; --g-soft: #e0f7fa; }
.g-choi-gioi { --g: #c2185b; --g-soft: #fce4ec; }
.g-day-co { --g: #3949ab; --g-soft: #e8eaf6; }
.g-kien-thuc { --g: #5f6368; --g-soft: #f1f3f4; }
@media (prefers-color-scheme: dark) {
  .g-co-ban { --g: #6ea8ff; --g-soft: #1c2b45; }
  .g-luat-choi { --g: #ce93d8; --g-soft: #2e1f36; }
  .g-chieu-het { --g: #f28b82; --g-soft: #3d1b19; }
  .g-chien-thuat { --g: #fcad70; --g-soft: #3d2610; }
  .g-khai-cuoc { --g: #81c995; --g-soft: #16301f; }
  .g-tan-cuoc { --g: #78d9e3; --g-soft: #10303a; }
  .g-choi-gioi { --g: #f48fb1; --g-soft: #3a1a28; }
  .g-day-co { --g: #9fa8da; --g-soft: #1f2340; }
  .g-kien-thuc { --g: #bdc1c6; --g-soft: #2d333b; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Mục lục: đầu mỗi bước (biểu tượng, nhãn "Bước N", tên, câu giới thiệu) và các bài dạng thẻ gọn */
.guide-hub .guide-hero .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.guide-group { margin-bottom: 36px; }
.guide-group-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.guide-group-icon { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--g-soft); font-size: 1.6rem; }
.guide-group-head > div { flex: 1; min-width: 0; }
.guide-all .guide-group-head h3 { margin: 0; font-size: 1.45rem; line-height: 1.3; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.guide-group-step { padding: 3px 10px; border-radius: 999px; background: var(--g); color: #fff; font-size: 0.78rem; font-weight: 700; letter-spacing: .03em; }
.guide-group-head p { margin: 4px 0 0; }
.guide-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.guide-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s, transform .15s; }
.guide-row:hover { text-decoration: none; border-color: var(--g); box-shadow: 0 4px 14px rgba(0, 0, 0, .06); transform: translateY(-1px); }
.guide-row-num { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--g-soft); color: var(--g); font-weight: 700; font-size: 0.9rem; }
.guide-row.is-read .guide-row-num { background: var(--g); color: #fff; font-size: 0; } /* đã đọc: số thay bằng dấu ✓ */
.guide-row.is-read .guide-row-num::after { content: "✓"; font-size: 0.95rem; }
.guide-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.guide-row-title { font-weight: 600; line-height: 1.35; }
.guide-row-lead { color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
@media (max-width: 760px) {
  .guide-rows { grid-template-columns: minmax(0, 1fr); }
  .guide-all .guide-group-head h3 { font-size: 1.25rem; }
}

/* Trang bài: dải các bài trong bước (ô đậm = đã đọc, ô viền đậm = bài đang xem) */
.guide-steps { list-style: none; margin: -8px 0 18px; padding: 0; display: flex; gap: 4px; }
.guide-steps li { flex: 1; }
.guide-steps a { display: block; height: 6px; border-radius: 99px; background: var(--g-soft, var(--surface-2)); }
.guide-steps a.is-read { background: var(--g, var(--primary)); opacity: .55; }
.guide-steps a[aria-current="page"] { background: var(--g, var(--primary)); opacity: 1; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--g, var(--primary)); }
.guide-steps a:hover { opacity: .85; }
.guide-all { margin-top: 34px; }
/* Máy tính Elo (g_elo_calc) */
.elo-calc { margin: 6px 0 22px; padding: 16px; border: 2px solid var(--primary-soft); border-radius: var(--radius); background: var(--surface); }
.elo-calc-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.elo-calc .field span { font-size: 0.85rem; }
.elo-calc input { width: 100%; }
.elo-calc-out { margin: 12px 0 0; }
.elo-calc-out b { font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .elo-calc-row { grid-template-columns: 1fr; } }
/* Bảng thuật ngữ */
.glossary dt { margin-top: 14px; font-weight: 700; }
.glossary dt small { font-weight: 400; color: var(--muted); }
.glossary dd { margin: 4px 0 0 0; }
/* Câu đố hôm nay */
.daily { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 24px; align-items: start; margin-bottom: 26px; }
.daily .dg-fig { margin: 0; max-width: none; }
.daily-info .badge { margin-bottom: 8px; }
.daily-info[hidden] { display: none; }
.daily-done { padding: 18px 20px; border-radius: var(--radius); background: #e6f4ea; }
.daily-done-title { margin: 0 0 6px; font-size: 1.25rem; font-weight: 700; color: #188038; }
@media (prefers-color-scheme: dark) {
  .daily-done { background: #16301f; }
  .daily-done-title { color: #81c995; }
}
.guide-body tr.today td { background: var(--primary-soft); font-weight: 600; }
/* Dải nhắc "chuỗi sắp mất" (buổi tối, chưa điểm danh) + thông báo nhỏ "Đã giữ chuỗi" */
.streak-remind { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 16px;
  padding: 10px 14px; border-radius: 12px; border: 1px solid #f9ab00; background: #fff8e6; color: #7a4100; }
.streak-remind[hidden] { display: none; }
.streak-remind-actions { display: flex; align-items: center; gap: 6px; }
.streak-remind .ghost { padding: 4px 8px; color: inherit; }
/* Căn giữa bằng left/right + margin auto (không dùng left: 50% để chữ không bị xuống dòng sớm trên điện thoại) */
.streak-toast { position: fixed; left: 16px; right: 16px; bottom: 24px; z-index: 200; width: fit-content; margin: 0 auto;
  transform: translateY(20px); opacity: 0; pointer-events: none;
  padding: 11px 18px; border-radius: 999px; background: #202124; color: #fff; font-size: 0.95rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  transition: opacity .3s, transform .3s; text-align: center; }
.streak-toast.show { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .streak-toast { transition: none; } }
@media (prefers-color-scheme: dark) {
  .streak-remind { background: #3a2a0e; color: #ffcf8a; border-color: #8a5a00; }
  .streak-toast { background: #e8eaed; color: #202124; }
}
/* ===== Phần thưởng chuỗi (Rewards) ===== */
/* Khung ảnh đại diện: viền vẽ bằng box-shadow nên không đổi kích thước ảnh ở bất cứ đâu */
.avatar.frame-bronze { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #c47b3c, 0 0 8px rgba(196, 123, 60, .55); }
.avatar.frame-silver { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #a9b6c4, 0 0 10px rgba(169, 182, 196, .85); }
/* Độ hiếm: màu nhãn */
.badge-rarity { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.rarity-common .badge-rarity { background: #eceff1; color: #5f6368; }
.rarity-rare .badge-rarity { background: #e8f0fe; color: #1a73e8; }
/* Lưới huy hiệu (hồ sơ) */
.badge-grid { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.badge-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 8px; border: 1px solid var(--border);
  border-radius: 12px; text-align: center; background: var(--surface); }
.badge-item.rarity-rare:not(.is-locked) { border-color: #a8c7fa; background: linear-gradient(180deg, #f3f7ff, var(--surface)); }
.badge-item-icon { font-size: 2rem; line-height: 1.1; }
.badge-item small { color: var(--muted); font-size: 0.75rem; }
.badge-item.is-locked { opacity: .55; }
.badge-item.is-locked .badge-item-icon { filter: grayscale(1); }
.profile-card .badge-grid { margin-top: 10px; }
.frame-form .frame-options { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 12px; }
.frame-form .tile { min-width: 96px; padding: 10px 12px; }
.frame-form .tile .avatar { margin: 4px 0; }
/* Hộp chúc mừng khi nhận huy hiệu */
.badge-modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .45);
  animation: badge-fade .2s ease-out; }
.badge-card { width: min(360px, 100%); padding: 26px 22px 20px; border-radius: 18px; background: var(--surface); text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.badge-card.rarity-rare { box-shadow: 0 0 0 3px #a8c7fa, 0 20px 50px rgba(26, 115, 232, .35); }
.badge-icon { font-size: 4rem; line-height: 1; animation: badge-pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.badge-kicker { margin-top: 10px; color: #c25e00; font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.badge-title { margin: 4px 0 8px; font-size: 1.3rem; font-weight: 700; }
.badge-gives { margin: 12px 0 16px; color: var(--muted); }
.badge-card .actions { justify-content: center; }
@keyframes badge-fade { from { opacity: 0; } }
@keyframes badge-pop { from { transform: scale(.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .badge-modal, .badge-icon { animation: none; } }
/* Ngọn lửa cạnh tên (bảng xếp hạng) */
.name-fire { margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.name-fire.s-orange { background: #fff1e0; color: #c25e00; }
.name-fire.s-red { background: #ffe4e1; color: #c62828; }
@media (prefers-color-scheme: dark) {
  .rarity-common .badge-rarity { background: #2d333b; color: #adbac7; }
  .rarity-rare .badge-rarity { background: #1c2b45; color: #8ab4f8; }
  .badge-item.rarity-rare:not(.is-locked) { border-color: #2f4d7a; background: linear-gradient(180deg, #1a2333, var(--surface)); }
  .name-fire.s-orange { background: #3d2610; color: #ffb066; }
  .name-fire.s-red { background: #3d1515; color: #ff8a80; }
}

/* Khối "Chuỗi của bạn" (trang câu đố hôm nay) */
.streak-box { margin-bottom: 26px; scroll-margin-top: 80px; }
.streak-head { display: flex; align-items: center; gap: 14px; }
.streak-head small { display: block; font-size: 0.85rem; font-weight: 400; }
.streak-flame { font-size: 2.6rem; line-height: 1; }
.streak-head.off .streak-flame { filter: grayscale(1); opacity: .6; } /* xám = hôm nay chưa giữ chuỗi */
.streak-num { font-size: 2rem; line-height: 1; }
.streak-head.s-orange .streak-num { color: #e8710a; }
.streak-head.s-red .streak-num { color: #d93025; }
.streak-state { margin: 12px 0; }
.streak-week { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; text-align: center; }
.streak-week li { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; border-radius: 8px; background: var(--surface-2); font-size: 0.8rem; color: var(--muted); }
.streak-week b { height: 1.2em; font-size: 1rem; }
.streak-week .done { background: #fff1e0; color: #c25e00; }
.streak-week .frozen { background: #e8f0fe; color: var(--primary); }
.streak-week .is-today { box-shadow: inset 0 0 0 2px var(--primary); }
.streak-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; font-size: 0.9rem; }
.streak-bar { height: 8px; margin-top: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.streak-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #f9ab00, #e8710a); }
.streak-how { margin: 12px 0 0; }
@media (prefers-color-scheme: dark) {
  .streak-week .done { background: #3d2610; color: #ffb066; }
  .streak-week .frozen { background: #1c2b45; }
}
.daily-archive { list-style: none; padding: 0; margin: 0; }
.daily-archive li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 760px) { .daily { grid-template-columns: 1fr; } }
/* Trang bài tập theo chủ đề: lưới bài mẫu */
.puzzle-samples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 6px 0 20px; }
.puzzle-sample { color: var(--text); border-radius: var(--radius); }
.puzzle-sample:hover { text-decoration: none; }
.puzzle-sample:hover .dg { outline: 3px solid var(--primary); outline-offset: 2px; }
.puzzle-sample .dg-fig { margin: 0; }
.puzzle-sample figcaption { font-size: 0.85rem; }
.theme-links { columns: 2; column-gap: 24px; }
@media (max-width: 640px) { .puzzle-samples { grid-template-columns: repeat(2, minmax(0, 1fr)); } .theme-links { columns: 1; } }
.guide-all > h2 { font-size: 1.4rem; scroll-margin-top: 80px; }
.guide-all h3 { font-size: 1.05rem; margin: 18px 0 10px; }
.guide-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.guide-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); color: var(--text); transition: border-color 0.15s, transform 0.15s; }
.guide-card:hover { text-decoration: none; border-color: var(--primary); transform: translateY(-2px); }
.guide-card span { color: var(--muted); font-size: 0.9rem; }
.guide-meta { margin: -4px 0 18px; }
.guide-toc { margin: 0 0 22px; padding: 14px 18px; border-radius: var(--radius); background: var(--surface-2); }
.guide-toc ol { margin: 8px 0 0; padding-left: 22px; }
.guide-toc li { margin: 3px 0; }
.guide-body, .guide-faq { font-size: 1.05rem; line-height: 1.7; }
.guide-body h2, .guide-faq h2, .guide-related h2 { font-size: 1.4rem; margin: 34px 0 10px; scroll-margin-top: 80px; }
.guide-body h3, .guide-faq h3 { font-size: 1.1rem; margin: 22px 0 6px; }
.guide-body p, .guide-body ul, .guide-body ol { margin: 0 0 14px; }
.guide-body li { margin: 4px 0; }
.guide-body .answer { padding: 14px 18px; border-left: 4px solid var(--primary); border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--primary-soft); font-size: 1.08rem; }
.guide-body table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 0.97rem; }
.guide-body th, .guide-body td { padding: 8px 10px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.guide-body th { background: var(--surface-2); }
.guide-body code { font-family: var(--mono); font-size: 0.92em; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); }
.guide-body td code { white-space: nowrap; }
.g-note { display: flex; gap: 10px; margin: 0 0 16px; padding: 12px 16px; border-radius: var(--radius); background: var(--surface-2); }
.g-note > div > :last-child { margin-bottom: 0; }
.g-warn { background: var(--warning-soft); }
.g-info { background: var(--primary-soft); }
.guide-cta { margin: 30px 0 22px; }
.guide-cta h2 { margin-top: 0; }
.guide-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.guide-pager a { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); }
.guide-pager a:hover { text-decoration: none; border-color: var(--primary); }
.guide-pager .next { grid-column: 2; text-align: right; }
.guide-related ul, .guide-sources ul { padding-left: 20px; }
.guide-sources { font-size: 0.95rem; }
.guide-sources h2 { font-size: 1.15rem; margin: 26px 0 8px; }
.guide-related h2 { font-size: 1.15rem; margin-top: 20px; }

/* Bàn cờ minh họa tĩnh (g_board) */
.dg-fig { margin: 6px auto 20px; max-width: 400px; }
.dg { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); aspect-ratio: 1; border-radius: 6px; overflow: hidden;
  box-shadow: var(--shadow); }
.dg span { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; }
.dg .l { background: #f0d9b5; }
.dg .d { background: #b58863; }
.dg img { position: relative; width: 92%; height: 92%; object-fit: contain; z-index: 2; }
.dg i { position: absolute; font: 600 clamp(8px, 1.6vw, 11px)/1 var(--font); font-style: normal; z-index: 3; }
.dg .l i { color: #b58863; }
.dg .d i { color: #f0d9b5; }
.dg .rk { top: 3px; left: 3px; }
.dg .fl { right: 3px; bottom: 2px; }
.dg .m-hl::before, .dg .m-good::before, .dg .m-bad::before { content: ""; position: absolute; inset: 0; }
.dg .m-hl::before { background: rgba(255, 213, 0, 0.5); }
.dg .m-good::before { background: rgba(34, 160, 80, 0.5); }
.dg .m-bad::before { background: rgba(214, 48, 49, 0.45); }
.dg .m-dot::after { content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(20, 85, 30, 0.45); z-index: 3; }
.dg .m-cap::after { content: ""; position: absolute; inset: 3%; border-radius: 50%; border: 0.35em solid rgba(20, 85, 30, 0.5); z-index: 3; }
.dg .m-x::after { content: "✕"; position: absolute; color: #c0392b; font: 700 clamp(14px, 4vw, 26px)/1 var(--font); z-index: 3; }
.dg-arrows { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; }
/* Logo bản quyền: giữa bàn cờ, mờ, dưới quân cờ (bàn tĩnh) / trên quân nhưng không bắt chuột (bàn "Thử ngay") */
.dg-wm { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 2.5%;
  pointer-events: none; opacity: 0.32; }
.dg-wm img { width: 11%; height: auto; border-radius: 22%; }
.dg-wm span { font: 800 clamp(16px, 5.4vw, 34px)/1 "Outfit", var(--font); color: #3b2a1a; letter-spacing: -0.01em; }
.try-board { position: relative; }
.try-board > .dg-wm { opacity: 0.2; z-index: 5; }
.dg-arrows line { stroke-width: 0.16; stroke-linecap: round; }
.dg-arrows g { opacity: 0.82; }
.dg-arrows .ar-green line { stroke: #15781b; } .dg-arrows .ar-green polygon { fill: #15781b; }
.dg-arrows .ar-red line { stroke: #c62828; } .dg-arrows .ar-red polygon { fill: #c62828; }
.dg-arrows .ar-blue line { stroke: #1a5fd0; } .dg-arrows .ar-blue polygon { fill: #1a5fd0; }
.dg-arrows .ar-grey line { stroke: #555; } .dg-arrows .ar-grey polygon { fill: #555; }
.dg-fig figcaption { margin-top: 8px; color: var(--muted); font-size: 0.9rem; line-height: 1.5; text-align: center; }

/* Bài "Thử ngay" (g_try + guide.js) */
.try { margin: 8px 0 24px; padding: 16px; border: 2px solid var(--primary-soft); border-radius: var(--radius); background: var(--surface); }
.try.solved { border-color: var(--ok); }
.try-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 12px; }
.try-badge { flex: none; padding: 3px 10px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 0.82rem; font-weight: 700; }
.try-task { margin: 0; font-weight: 600; }
.try-body { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.try-board .dg-fig { margin: 0; }
.try-status { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 0.97rem; }
.try-status.good { background: rgba(34, 160, 80, 0.14); color: var(--ok); font-weight: 600; }
.try-status.bad { background: var(--danger-soft); color: var(--danger); }
.try .try-hl { box-shadow: inset 0 0 0 999px var(--hl); }
.try-promo { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: -4px 0 12px; }
.try-promo button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; font-size: 0.8rem; }
.try-promo img { width: 38px; height: 38px; }
@media (max-width: 640px) {
  .try-body { grid-template-columns: 1fr; }
  .guide-hero h1, .guide h1 { font-size: 1.6rem; }
  .guide-pager { grid-template-columns: 1fr; }
  .guide-pager .next { grid-column: 1; }
  .guide-path ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Trang chủ: dải "Mới học cờ vua?"; trang công cụ: đoạn giới thiệu dưới bàn cờ */
.learn-strip { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto; gap: 18px; align-items: center; margin-bottom: 32px; }
.learn-strip h2 { margin-bottom: 4px; }
.learn-strip p { margin: 0; }
.learn-strip ul { margin: 0; padding-left: 18px; }
@media (max-width: 860px) { .learn-strip { grid-template-columns: 1fr; } }
.tool-intro { max-width: 820px; margin: 36px auto 0; color: var(--muted); }
.tool-intro h1 { font-size: 1.3rem; color: var(--text); }

/* ===== Bàn cờ giảng dạy (teach.php): bàn cờ để chia sẻ màn hình khi dạy qua Zoom / Zalo ===== */
.teach { display: flex; gap: 16px; align-items: flex-start; }
.teach-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.teach-board-wrap { position: relative; }
.teach-svg { position: absolute; pointer-events: none; touch-action: none; z-index: 5; }
.teach-board-wrap.drawing .teach-svg { pointer-events: auto; cursor: crosshair; }
.teach-note { margin: 0; max-width: 100%; padding: 8px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  font-size: 1.15rem; font-weight: 600; text-align: center; }
.teach-panel { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.teach-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.teach-row > button { flex: 1 1 auto; padding: 7px 10px; font-size: 0.9rem; }
.teach-tools { display: grid; grid-template-columns: repeat(2, 1fr); }
.teach-tools .tool { padding: 7px 2px; font-size: 0.85rem; white-space: nowrap; background: var(--surface); color: var(--text); border-color: var(--border); }
.teach-tools .tool.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.teach-colors .color { flex: 0 0 34px; height: 34px; padding: 0; border-radius: 50%; border: 3px solid transparent; }
.teach-colors .color.active { border-color: var(--text); }
.teach-colors [data-color="green"] { background: #15781b; }
.teach-colors [data-color="red"] { background: #c33; }
.teach-colors [data-color="blue"] { background: #1f5fbf; }
.teach-colors [data-color="yellow"] { background: #e68f00; }
.teach-colors .ghost { flex: 0 1 auto; padding: 6px 8px; }
.teach-colors #undo-shape { margin-left: auto; font-size: 1.1rem; }
.teach-mode { gap: 16px; font-size: 0.95rem; }
.teach-mode label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.teach-nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.teach-nav button { padding: 6px 0; font-size: 1rem; }
.moves.teach-moves { display: flex; flex-wrap: wrap; gap: 2px 4px; align-content: flex-start; min-height: 48px; max-height: 150px; padding: 6px; }
.moves.teach-moves li { display: block; padding: 0; background: none; }
.moves.teach-moves li::before { content: none; }
.teach-moves button { background: none; border: 0; color: var(--text); padding: 2px 6px; font-weight: 500; font-size: 0.92rem; border-radius: 4px; }
.teach-moves button:hover { background: var(--surface-2); }
.teach-moves button.cur { background: var(--primary); color: #fff; }
.teach-status { margin: 0; min-height: 1.2em; }
.teach-edit, .teach-load { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px dashed var(--border); border-radius: var(--radius); }
.teach-edit p { margin: 0; }
.teach-load textarea { width: 100%; font-family: var(--mono); font-size: 0.8rem; }
.teach-lesson summary { cursor: pointer; font-weight: 600; }
.teach-lesson[open] { display: flex; flex-direction: column; gap: 8px; }
.lesson-list { list-style: none; margin: 0; padding: 0; max-height: 200px; overflow-y: auto; }
.lesson-list li { display: flex; align-items: center; border-radius: 6px; }
.lesson-list li.cur { background: var(--g-soft, #e8f0fe); }
.lesson-open { flex: 1; min-width: 0; display: block; text-align: left; background: none; border: 0; color: var(--text); padding: 6px 8px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-list li.cur .lesson-open { color: var(--primary); font-weight: 700; }
.lesson-del { padding: 4px 8px; }
.teach-keys { margin: 0; }
/* Tọa độ a–h, 1–8 to hơn để học viên đọc được qua màn hình chia sẻ (ảnh Zoom / Zalo thường bị nén) */
.teach #board .notation-322f9 { font-size: 0.95rem; font-weight: 600; }
/* Khay quân khi bày thế cờ */
.teach #board .spare-pieces-7492f { background: var(--surface-2); border-radius: 6px; }
@media (max-width: 900px) {
  .teach { flex-direction: column; align-items: stretch; }
  .teach-panel { width: auto; }
}
/* Chế độ trình chiếu: chỉ còn bàn cờ và bảng điều khiển gọn, để chia sẻ cửa sổ qua Zoom / Zalo */
body.teach-present .topbar, body.teach-present .site-footer, body.teach-present .tool-intro, body.teach-present .streak-remind,
body.teach-present .guest-bar, body.teach-present .install-banner, body.teach-present .teach-keys, body.teach-present .settings { display: none !important; }
body.teach-present .container { max-width: none; padding: 12px 16px; }
/* Trang giới thiệu cho giáo viên dưới công cụ: chữ đậm hơn phần giới thiệu ngắn của các công cụ khác */
.teach-intro { color: var(--text); line-height: 1.65; }
.teach-intro h2 { font-size: 1.25rem; margin: 28px 0 8px; }
.teach-intro li { margin-bottom: 6px; }
.faq-item { border-bottom: 1px solid var(--border); padding: 10px 0; }
.faq-item summary { cursor: pointer; font-weight: 600; }
.faq-item p { margin: 8px 0 0; color: var(--muted); }
body.teach-present .teach-panel { width: 300px; gap: 8px; padding: 12px; max-height: calc(100vh - 24px); overflow-y: auto; position: sticky; top: 12px; }
body.teach-present .teach #board .notation-322f9 { font-size: 1.1rem; }
body.teach-present .teach-note { font-size: 1.35rem; }

/* ===== Giáo án cờ vua (lesson.php) ===== */
.lesson-meta { list-style: none; margin: 10px 0 14px; padding: 12px 16px; border-radius: var(--radius); background: var(--surface-2);
  display: grid; gap: 4px; font-size: 0.97rem; }
.lesson-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.lesson-time { margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  font-size: 0.8rem; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.lesson-boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 8px 20px; }
.lesson-boards .dg-fig { margin: 6px 0 14px; max-width: none; }
.table-scroll { overflow-x: auto; }
.lesson-plan td:first-child { text-align: center; font-weight: 700; width: 3.5em; }
/* In giáo án: chỉ giữ nội dung và bàn cờ */
@media print {
  .topbar, .site-footer, .crumbs, .lesson-actions, .guide-pager, .streak-remind, .guest-bar, .install-banner { display: none !important; }
  body { background: #fff; color: #000; }
  .container { max-width: none; padding: 0; }
  .lesson-wrap .guide { box-shadow: none; border: 0; }
  .lesson-boards { grid-template-columns: repeat(3, 1fr); }
  .lesson-boards .dg-fig, .lesson h3 { break-inside: avoid; }
  .lesson a { color: inherit; text-decoration: none; }
}
/* Bàn cờ giảng dạy: lưu vào tài khoản, chia sẻ link, danh sách bài đã lưu */
.teach-cloud > button { flex: 1 1 45%; }
.teach-cloud > #cloud-save { flex-basis: 100%; }
.teach-share-box, .teach-saved { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px dashed var(--border); border-radius: var(--radius); }
.teach-share-box p { margin: 0; }
.teach-share-box .copy-row { margin: 0; }
.teach-saved p { margin: 0; }
.saved-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.saved-list li { display: flex; align-items: center; border-radius: 6px; }
.saved-list li.cur { background: var(--surface-2); }
.saved-open { flex: 1; min-width: 0; display: block; text-align: left; background: none; border: 0; color: var(--text); padding: 6px 8px; font-weight: 600; }
.saved-open span { display: block; font-weight: 400; }
.teach-shared { margin: 0; padding: 8px 10px; border-radius: 6px; background: var(--surface-2); }
.teach-login { margin: 0; }
/* Khối FEN / PGN trong bài hướng dẫn: cuộn ngang thay vì tràn khung trên điện thoại */
.guide-body pre { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius); background: var(--surface-2); font-family: var(--mono);
  font-size: 0.85rem; line-height: 1.5; overflow-x: auto; white-space: pre; }
.guide-body pre.code-block { white-space: pre-wrap; overflow-wrap: anywhere; }
