/* Bảng tuần hoàn (/cong-cu/bang-tuan-hoan). Tệp nạp ở mọi trang → mọi lớp có tiền tố bth-. Ưu tiên màn chiếu 1280–1920px. */
.chinh:has(> .bth) { max-width: 1600px; }
.bth:fullscreen { background: var(--bg); padding: 14px clamp(12px, 2vw, 28px); overflow: auto; }
.bth-dau { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 10px; }
.bth-dau h1 { margin: 0; }
.bth-dau .phu { margin: 2px 0 0; }
.bth-thanh { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin-bottom: 10px; }
.bth-tim { flex: 1 1 280px; max-width: 420px; }
.bth-to { width: 230px; }
.bth-dem { margin: 0 0 12px; }

/* Lưới: cột 1 = số chu kì, 18 cột nhóm; hàng 1 = tiêu đề nhóm; hàng 9 trống; 10–11 = họ lanthanide, actinide */
.bth-cuon { overflow-x: auto; padding: 6px 4px 4px; }
.bth-bang { display: grid; grid-template-columns: 1.4rem repeat(18, minmax(0, 1fr)); grid-template-rows: auto repeat(7, auto) 10px auto auto;
  gap: 3px; min-width: 900px; }
.bth-nhom-h { text-align: center; font-size: .75rem; line-height: 1.15; color: var(--phu); padding-bottom: 2px; }
.bth-nhom-h b { display: block; color: var(--chu); font-size: .8125rem; }
.bth-ck-h { display: grid; place-items: center; font-weight: 700; color: var(--phu); font-size: .875rem; }
.bth-o { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: 1 / 1.08; min-width: 0;
  padding: 2px; border: 1px solid rgba(20, 40, 40, .16); border-radius: 6px; font: inherit; cursor: pointer; line-height: 1.05; overflow: hidden;
  transition: transform .12s ease, opacity .15s ease; }
.bth-o:hover, .bth-o:focus-visible { transform: scale(1.12); z-index: 2; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.bth-o__z { position: absolute; top: 3px; left: 4px; font-size: clamp(.55rem, .75vw, .8rem); font-weight: 600; }
.bth-o__kh { font-size: clamp(.95rem, 1.6vw, 1.75rem); font-weight: 800; margin-top: 6px; }
.bth-o__ten { font-size: clamp(.45rem, .62vw, .72rem); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bth-o__m { font-size: clamp(.45rem, .6vw, .7rem); opacity: .85; font-variant-numeric: tabular-nums; }
.bth-o--mo { opacity: .16; }
.bth-cho { display: grid; place-items: center; border: 1px dashed rgba(20, 40, 40, .3); border-radius: 6px; font-size: .75rem; font-weight: 700; color: var(--chu); }
.bth-ho { display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; font-size: .8125rem; font-weight: 700; color: var(--phu); text-align: right; }
.bth:fullscreen .bth-o__kh { font-size: clamp(1rem, 1.9vw, 2.2rem); }

/* Chú giải */
.bth-chu-giai { list-style: none; margin: 12px 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .875rem; }
.bth-chu-giai li { display: inline-flex; align-items: center; gap: 6px; }
.bth-chu-giai__o { width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(20, 40, 40, .18); }
.bth-thang { display: inline-block; width: 180px; height: 14px; border-radius: 4px; margin: 0 8px; background: linear-gradient(90deg, #ecf3fb, #093166); }
.bth-nguon { max-width: 70rem; }

/* Hộp chi tiết, trò chơi */
.bth-ct, .bth-choi { border: 0; border-radius: var(--r); padding: 18px 20px; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 18px 50px rgba(0, 0, 0, .25); }
.bth-ct::backdrop, .bth-choi::backdrop { background: rgba(10, 25, 40, .45); }
.bth-ct__dau { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.bth-ct__dau h2 { margin: 0; font-size: 1.3rem; }
.bth-ct__dau .phu { margin: 2px 0 0; }
.bth-ct__dong { margin-left: auto; align-self: flex-start; }
.bth-ct__o { position: relative; flex: none; width: 76px; height: 82px; border-radius: 8px; border: 1px solid rgba(20, 40, 40, .16); display: grid; place-items: center; }
.bth-ct__o .bth-o__z { font-size: .8rem; }
.bth-ct__o .bth-o__kh { font-size: 2rem; margin: 8px 0 0; }
.bth-ct__ds { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; }
.bth-ct__ds dt { color: var(--phu); font-size: .9375rem; }
.bth-ct__ds dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bth-choi__hoi { font-size: 1.15rem; margin: 14px 0 10px; }
.bth-choi__kh { font-size: 2.2rem; color: var(--c-dam); margin: 0 4px; vertical-align: -4px; }
.bth-choi__4 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bth-choi__lc { min-height: 54px; padding: 8px 10px; border-radius: var(--r-nho); border: 1px solid var(--vien); background: var(--bg); font: inherit; font-weight: 700; cursor: pointer; color: var(--chu); }
.bth-choi__lc:hover { border-color: var(--c-vien); background: var(--c-nhat); }
.bth-choi__lc--dung { background: var(--xanh-la-nhat) !important; border-color: var(--xanh-la) !important; color: #184d27; }
.bth-choi__lc--sai { background: var(--do-nhat) !important; border-color: var(--do) !important; color: #7a1a12; }
.bth-choi__kq { min-height: 1.6em; margin: 10px 0; font-weight: 600; }

@media (max-width: 640px) {
  .bth-to { width: 100%; }
  .bth-tim { max-width: none; }
  .bth-choi__4 { grid-template-columns: 1fr; }
}

/* In A4 ngang: chỉ bảng và chú giải */
@page bth-ngang { size: A4 landscape; margin: 8mm; }
@media print {
  body:has(.bth) .demo-bar, body:has(.bth) .dau, body:has(.bth) .chan, body:has(.bth) .bth-dau__nut, body:has(.bth) .bth-thanh { display: none !important; }
  body:has(.bth) { background: #fff; }
  body:has(.bth) .chinh { max-width: none; padding: 0; }
  .bth { page: bth-ngang; }
  .bth-dau h1 { font-size: 16pt; }
  .bth-dau .phu { display: none; }
  .bth-cuon { overflow: visible; padding: 0; }
  .bth-bang { min-width: 0; gap: 2px; }
  .bth-o { transform: none !important; box-shadow: none !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; border-color: #999; }
  .bth-o--mo { opacity: 1; }
  .bth-o__kh { font-size: 13pt; }
  .bth-o__z { font-size: 6pt; }
  .bth-o__ten, .bth-o__m { font-size: 5pt; }
  .bth-chu-giai__o, .bth-thang, .bth-cho { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bth-chu-giai { font-size: 8pt; margin: 6px 0 2px; }
  .bth-nguon { font-size: 7pt; margin: 0; }
}
