/* Mật thư, trò chơi lớn (/cong-cu/mat-thu). Tệp nạp ở mọi trang → mọi lớp có tiền tố mth-. Dùng token của app.css. */
.chinh:has(> .mth), .chinh:has(> .mth-the-ds), .chinh:has(.mth-bang--kq), .chinh:has(#mth-tien-do) { max-width: 1200px; }
.mth-an { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mth-mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.mth-lien { white-space: nowrap; }   /* một chữ Morse không ngắt giữa dòng */
.mth-dau { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.mth-dau h1 { margin: 0; }
.mth-dau .phu { margin: 2px 0 0; }
.mth-tab { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.mth-tab [role="tab"] { min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--vien); background: var(--the); color: var(--chu);
  font: inherit; font-weight: 700; cursor: pointer; }
.mth-tab [role="tab"][aria-selected="true"] { background: var(--c-dam); border-color: var(--c-dam); color: #fff; }
.mth-chon__hang { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.mth [hidden] { display: none !important; }   /* .field, .mth-chon__hang có display riêng nên phải ép */
.mth-chon__hang > .field { flex: 1 1 200px; }
.mth-chon__hang + .mth-chon__hang { margin-top: 10px; }
.mth-chon .field__hint { margin-top: 10px; font-size: .875rem; }
.mth-o-chon { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; min-height: 44px; }
.mth-o-chon input { width: 20px; height: 20px; accent-color: var(--c); }
.mth-hai { display: grid; gap: 14px; }
@media (min-width: 900px) { .mth-hai { grid-template-columns: 1fr 1fr; } }
.mth-hai .the { margin: 0; }
.mth-hai + .the, .mth-hai + section { margin-top: 14px; }
#mth-mat { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.0625rem; letter-spacing: .04em; }
.mth-bao { min-height: 1.5em; margin: 8px 0 0; }
.mth-phat { align-self: flex-end; }

/* Hình người cầm cờ */
.mth-sv { display: block; }
.mth-sv-dau { fill: #f3d3b3; stroke: var(--chu); stroke-width: 2; }
.mth-sv-than, .mth-sv-tay { stroke: var(--chu); stroke-width: 4; stroke-linecap: round; }
.mth-sv-can { stroke: #6b4a2b; stroke-width: 2; }
.mth-sv-do { fill: #c62828; }
.mth-sv-vang { fill: #f5c400; }
.mth-sem-ds, .mth-bang-sem { display: flex; flex-wrap: wrap; gap: 8px 6px; align-items: flex-end; }
.mth-sem-o { margin: 0; text-align: center; background: #fff; border: 1px solid var(--vien); border-radius: var(--r-nho); padding: 4px; }
.mth-sem-o figcaption { font-weight: 800; font-size: .9375rem; }
.mth-sem-o small { font-weight: 400; color: var(--phu); }
.mth-sem-cach { display: inline-block; width: 22px; }
.mth-sem-giai { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.mth-sem-chon { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 64px); gap: 6px; }
.mth-sem-huong { border: 2px solid var(--c-vien); border-radius: 12px; background: var(--the); cursor: pointer; position: relative; }
.mth-sem-huong::after { content: ""; position: absolute; inset: 22px; border-radius: 50%; background: var(--c-vien); }
.mth-sem-huong[aria-pressed="true"] { border-color: #c62828; background: #fdecea; }
.mth-sem-huong[aria-pressed="true"]::after { background: #c62828; }
.mth-sem-giua { grid-column: 2; grid-row: 2; display: grid; place-items: center; overflow: hidden; }
.mth-sem-giua .mth-sv { width: 64px; height: 72px; }
.mth-sem-kq { font-size: 2rem; color: var(--c-dam); }

/* Bảng tra */
.mth-bang-morse { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.mth-mo { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border: 1px solid var(--vien); border-radius: var(--r-nho); background: #fff; }
.mth-mo b { flex: none; width: 1.6em; font-size: 1.125rem; }
.mth-mo code { font-size: 1.125rem; letter-spacing: .1em; white-space: nowrap; }
.mth-bang { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.mth-bang th, .mth-bang td { padding: 8px 10px; border-bottom: 1px solid var(--vien); text-align: left; vertical-align: top; }
.mth-bang thead th { background: var(--c-nhat); color: var(--c-dam); font-weight: 700; }
.mth-cuon { overflow-x: auto; }
.mth-mo-ra { opacity: .6; }

/* Tập nghe */
.mth-tap-hien { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.75rem; letter-spacing: .15em; min-height: 1.6em; margin: 10px 0; color: var(--c-dam); }
.mth-tap-kq { font-weight: 700; min-height: 1.5em; }
.mth-tap-kq--dung { color: var(--xanh-la); }
.mth-tap-kq--sai { color: var(--do); }

/* Nháy đèn toàn màn hình */
.mth-den { position: fixed; inset: 0; z-index: 90; background: #000; display: flex; align-items: flex-end; justify-content: center; padding: 24px; }
.mth-den--sang { background: #fffbe0; }
.mth-den__tat { background: rgba(255,255,255,.9); }

/* Tờ in */
.mth-to-in { border: 1px dashed var(--vien); border-radius: var(--r-nho); padding: 16px; margin-top: 12px; background: #fff; min-height: 80px; }
.mth-to-in__h { font-size: 1.375rem; font-weight: 800; text-align: center; margin: 0 0 6px; }
.mth-to-in__h:empty, .mth-to-in__k:empty { display: none; }
.mth-to-in__k { text-align: center; font-style: italic; }
.mth-to-in__nd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.375rem; line-height: 1.9; word-break: break-word; white-space: pre-wrap; letter-spacing: .06em; }
.mth-to-in__nd--sem { display: flex; flex-wrap: wrap; gap: 6px; white-space: normal; }
@media print {
  body.mth-dang-in * { visibility: hidden; }
  body.mth-dang-in .mth-to-in, body.mth-dang-in .mth-to-in * { visibility: visible; }
  body.mth-dang-in .mth-to-in { position: absolute; left: 0; top: 0; width: 100%; border: 0; }
  .mth-sv-do, .mth-sv-vang { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Soạn trò chơi */
.mth-tram__so { font-weight: 800; color: var(--c-dam); padding: 0 6px; }
.mth-tram { display: flex; flex-direction: column; gap: 12px; }
.mth-tram--loi { border-color: var(--do); }
.mth-tram__hang { display: grid; gap: 12px; }
@media (min-width: 720px) { .mth-tram__hang { grid-template-columns: 1fr 1fr; } .mth-tram__hang:has(.mth-tram__diem) { grid-template-columns: 1fr 140px; } }

/* Trang điều khiển */
.mth-dk { margin-bottom: 14px; }
.mth-moi { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.mth-moi__chu { flex: 1 1 280px; min-width: 0; }
.mth-moi__ma { font-size: clamp(2rem, 7vw, 3rem); font-weight: 900; letter-spacing: .14em; color: var(--c-dam); font-variant-numeric: tabular-nums; }
.mth-qr { width: 160px; flex: none; background: #fff; }
.mth-qr svg, .mth-the__qr svg { display: block; width: 100%; height: auto; }
.mth-bang--td th, .mth-bang--td td { vertical-align: middle; }
.mth-o-tram { text-align: center !important; width: 42px; }
.mth-diem { font-weight: 800; font-variant-numeric: tabular-nums; }
.mth-cham { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-weight: 800; font-size: .875rem; }
.mth-cham--0 { border: 2px solid var(--vien); }
.mth-cham--1 { background: var(--nhan-nhat); color: var(--nhan-dam); border: 2px solid var(--nhan); }
.mth-cham--2 { background: var(--xanh-la); color: #fff; }
.mth-chu-giai { margin: 8px 0 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mth-chu-giai .mth-cham { width: 20px; height: 20px; font-size: .75rem; }

/* Màn chiếu */
.mth-chieu__dau { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.mth-chieu__dau h1 { font-size: clamp(1.6rem, 3.5vw, 2.8rem); margin: 0; }
.mth-chieu__vao { display: flex; gap: 20px; align-items: center; }
.mth-chieu__vao p { margin: 0; font-size: 1.125rem; }
.mth-qr--chieu { width: 170px; border-radius: 10px; }
.che-do-chieu .mth-bang { font-size: clamp(1rem, 1.6vw, 1.5rem); color: var(--chu); background: #fff; border-radius: 12px; overflow: hidden; }
.che-do-chieu .mth-cuon { border-radius: 12px; }
.che-do-chieu .rong { color: var(--chu); }
.che-do-chieu .mth-chu-giai { color: #dfe7f3; }
.che-do-chieu .mth-cham--0 { border-color: #c7cfdb; }
.mth-chieu__chan { position: fixed; right: 16px; bottom: 12px; display: flex; gap: 8px; opacity: .55; }
.mth-chieu__chan:hover, .mth-chieu__chan:focus-within { opacity: 1; }
.che-do-chieu .mth-chieu__chan .nut--vien { color: #fff; border-color: rgba(255,255,255,.5); }

/* In mã trạm */
.mth-the-ds { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.mth-the { background: #fff; border: 2px solid var(--c-dam); border-radius: var(--r); padding: 18px; text-align: center; break-inside: avoid; }
.mth-the__tc { margin: 0; color: var(--phu); font-size: .875rem; }
.mth-the__ten { font-size: 1.5rem; margin: 4px 0 10px; }
.mth-the__qr { width: 220px; max-width: 100%; margin: 0 auto; }
.mth-the__ma { font-size: 1.125rem; margin: 8px 0 4px; }
.mth-the__ma strong { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; font-size: 1.375rem; }
.mth-the__nv { text-align: left; border-top: 1px dashed var(--vien); margin-top: 10px; padding-top: 8px; }
.mth-the__nv pre { white-space: pre-wrap; word-break: break-word; font-size: 1.125rem; }
@media print {
  .mth-in-dau, .dau, .demo-bar, .chan { display: none !important; }
  .mth-the-ds { grid-template-columns: 1fr 1fr; gap: 10mm; }
  .mth-the { page-break-inside: avoid; }
}

/* Đội chơi */
.mth-vao h1, .mth-doi h1, .mth-tram-trang h1 { margin-top: 2px; }
.mth-doi__so { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 14px; }
.mth-doi__so > div { background: var(--the); border: 1px solid var(--vien); border-radius: var(--r); padding: 10px 14px; display: flex; flex-direction: column; }
.mth-doi__lon { font-size: 2rem; font-weight: 900; color: var(--c-dam); line-height: 1.1; font-variant-numeric: tabular-nums; }
.mth-quet { margin: 10px 0; }
.mth-quet video { width: 100%; max-height: 60vh; border-radius: var(--r-nho); background: #000; display: block; margin-bottom: 8px; }
.mth-lo { padding-left: 1.4em; margin: 0; }
.mth-lo li { padding: 8px 0; border-bottom: 1px solid var(--vien); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.mth-lo li:last-child { border-bottom: 0; }
.mth-lo li > span:first-child { flex: 1 1 auto; font-weight: 600; }
.mth-lo--xong > span:first-child { color: var(--xanh-la); }
.mth-lo--ke { background: var(--nhan-nhat); border-radius: 8px; padding-left: 8px !important; }
.mth-mat-thu { font-size: 1.25rem; line-height: 1.8; white-space: pre-wrap; word-break: break-word; background: var(--c-nhat); border-radius: var(--r-nho); padding: 10px 12px; margin: 0; letter-spacing: .06em; }
.mth-loi-dan p:last-child { margin-bottom: 0; }

@media (max-width: 640px) {
  .mth-tab [role="tab"] { flex: 1 1 auto; padding: 8px 12px; }
  .mth-sem-chon { grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); }
  .mth-bang { font-size: .875rem; }
  .mth-bang th, .mth-bang td { padding: 6px 6px; }
  .mth-qr { width: 130px; }
}
