/* =========================================================
   CHẾ ĐỘ TV – màn hình lớn, không cuộn, kiểu bảng điện tử giải quốc tế
   ========================================================= */
body.tv-body { overflow: hidden; height: 100vh; }
.tv { height: 100vh; display: grid; grid-template-rows: auto 1fr auto; position: relative;
    background: radial-gradient(1400px 700px at 15% -10%, rgba(20,80,57,.7), transparent 60%),
                radial-gradient(1000px 600px at 110% 110%, rgba(212,175,55,.12), transparent 55%), #051a13; }
.tv-top { display: flex; align-items: center; gap: 1.4vw; padding: 1vh 1.6vw; border-bottom: 2px solid rgba(212,175,55,.45);
    background: linear-gradient(90deg, rgba(0,0,0,.55), rgba(0,0,0,.25)); }
.tv-brand img { width: clamp(40px, 4.2vh, 64px); height: auto; border-radius: 50%; display: block; }
.tv-title { flex: 1; min-width: 0; }
.tv-title h1 { margin: 0; font-size: clamp(18px, 3vh, 40px); font-weight: 900; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-sub { display: flex; gap: 1.2vw; flex-wrap: wrap; color: var(--muted); font-size: clamp(11px, 1.45vh, 18px); font-weight: 600; }
.tv-status { display: flex; flex-direction: column; align-items: flex-end; gap: .4vh; }
.tv-live { display: inline-flex; align-items: center; gap: 8px; font-weight: 900; letter-spacing: 1.5px; font-size: clamp(11px, 1.5vh, 18px);
    padding: .45vh 1vw; border-radius: 6px; background: #b91c1c; color: #fff; }
.tv-live.ready { background: #1d4ed8; }
.tv-live.done { background: var(--gold); color: #1a1405; }
.tv-live i { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: tvblink 1s steps(1) infinite; }
@keyframes tvblink { 50% { opacity: .2; } }
.tv-prog { color: var(--muted); font-size: clamp(11px, 1.4vh, 17px); }
.tv-prog b { color: var(--gold-2); font-size: 1.2em; }
.tv-clock { font: 800 clamp(20px, 3.4vh, 46px) var(--font); color: var(--gold-2); font-variant-numeric: tabular-nums;
    padding-left: 1.4vw; border-left: 1px solid var(--border-2); }

.tv-main { display: grid; grid-template-columns: 1fr minmax(300px, 24vw); gap: 1vw; padding: 1.2vh 1.2vw; min-height: 0; }
.tv.has-left .tv-main { grid-template-columns: minmax(280px, 22vw) 1fr minmax(300px, 24vw); }
.tv[data-layout="full"] .tv-main { grid-template-columns: 1fr; }
.tv[data-layout="full"] .tv-right, .tv[data-layout="full"] .tv-left { display: none; }
.tv[data-layout="list"] .tv-main { grid-template-columns: 1fr minmax(340px, 34vw); }
.tv-left:empty { display: none; }
.tv-left, .tv-right { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 1vh; }
.tv-left h2, .tv-card h2 { margin: 0 0 .8vh; font-size: clamp(12px, 1.6vh, 20px); font-weight: 900; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
.tv-left .grp-card { padding: .8vh .7vw; }
.tv-left .grp-games { display: none; }
.tv-left .grp-table { font-size: clamp(11px, 1.35vh, 16px); }
.tv-stage { position: relative; overflow: hidden; min-height: 0; border-radius: 14px; background: rgba(0,0,0,.18); border: 1px solid var(--border); }
.tv-fit { transform-origin: 0 0; position: absolute; left: 4px; top: 4px; }
.tv-fit .bracket { margin: 0; padding: 10px 14px 14px 20px; }
.tv.side-on .tv-stage .standings:not(.static) { display: none; }
.tv-stage .bracket-tools { display: none; }
.tv-stage .scroll { overflow: visible; padding: 0; }
.tv-list { width: min(1100px, 60vw); padding: 12px; font-size: 1.15em; }
.tv-card { background: linear-gradient(180deg, rgba(20,80,57,.5), rgba(11,42,32,.85)); border: 1px solid var(--border-2); border-radius: 14px; padding: 1.2vh .9vw; }
.tv-card .standings.static { position: static; margin: 0; padding: 0; border: 0; background: none; box-shadow: none; width: auto; }
.tv-card .st-row { font-size: clamp(11px, 1.35vh, 16px); }
.tv-card .st-row .who { font-size: clamp(12px, 1.6vh, 19px); }
#tvNow { flex: 1; min-height: 0; overflow: hidden; }
.tv-m { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: .6vw; align-items: center; padding: .7vh .4vw; border-radius: 8px;
    font-size: clamp(11px, 1.45vh, 18px); }
.tv-m:nth-child(odd) { background: rgba(0,0,0,.2); }
.tv-m .tb { background: var(--gold); color: #1a1405; font-weight: 900; border-radius: 6px; padding: 2px 8px; white-space: nowrap; font-size: .9em; }
.tv-m .a { text-align: right; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-m .b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-m .vs { color: var(--muted); font-size: .8em; white-space: nowrap; }
.tv-empty { color: var(--muted); padding: 1vh 0; text-align: center; }
.tv-qr { display: flex; gap: .8vw; align-items: center; }
.tv-qr #tvQr { width: clamp(70px, 11vh, 140px); flex: none; background: #fff; border-radius: 8px; padding: 4px; }
.tv-qr #tvQr svg { display: block; width: 100%; height: auto; }
.tv-qr b { display: block; font-size: clamp(12px, 1.6vh, 19px); }
.tv-qr span { display: block; color: var(--muted); font-size: clamp(11px, 1.3vh, 15px); }
.tv-qr em { font-style: normal; font-weight: 900; color: var(--gold-2); font-size: clamp(16px, 2.4vh, 30px); }
.tv-ticker { overflow: hidden; white-space: nowrap; background: linear-gradient(90deg, #0b2a20, #145039, #0b2a20);
    border-top: 2px solid rgba(212,175,55,.45); padding: .9vh 0; font-size: clamp(12px, 1.7vh, 21px); }
.tv-ticker-in { display: inline-block; padding-left: 100%; animation: tvticker 60s linear infinite; }
.tv-ticker-in span { margin: 0 1.2vw; }
.tv-ticker-in i { color: var(--gold); font-style: normal; }
.tv-ticker .gold { color: var(--gold-2); }
/* Tỉ số trên dòng chữ chạy: ô vàng chữ đậm tối – nổi bật, dễ nhận diện */
.tv-ticker .tk-sc { display: inline-block; font-style: normal; font-weight: 900; color: #1a1300; background: linear-gradient(180deg, #f6d77a, #d4af37);
    padding: .05em .55em; margin: 0 .35em; border-radius: .4em; letter-spacing: .04em; box-shadow: 0 0 0 1px rgba(0,0,0,.25) inset; }
.tv-ticker .tk-tag { display: inline-block; font-style: normal; font-weight: 800; font-size: .82em; color: #fff; background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.35); padding: 0 .45em; border-radius: .35em; margin-left: .2em; }
@keyframes tvticker { to { transform: translateX(-100%); } }
.tv-mark { position: absolute; right: 1.4vw; bottom: 5.4vh; font: 900 clamp(16px, 2.6vh, 34px) var(--font); color: rgba(240,215,122,.4);
    letter-spacing: 1px; pointer-events: none; text-shadow: 0 2px 10px rgba(0,0,0,.5); }
/* Chữ mờ mrk.vn luôn nằm bên trái cột phải (cột phải tối thiểu 300 / 340px) – không đè lên ô QR ở màn hẹp */
.tv[data-layout="side"] .tv-mark { right: calc(max(300px, 24vw) + 2.4vw); }
.tv[data-layout="list"] .tv-mark { right: calc(max(340px, 34vw) + 2.4vw); }
.tv-ctrl { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); max-width: calc(100% - 24px); justify-content: center; display: flex; gap: 6px; align-items: center; z-index: 30; flex-wrap: wrap;
    background: rgba(0,0,0,.85); border: 1px solid var(--border-2); border-radius: 12px; padding: 8px 10px; opacity: 0; pointer-events: none; transition: opacity .25s; }
.tv.ctrl-on .tv-ctrl { opacity: 1; pointer-events: auto; }
.tv-ctrl span { color: var(--muted); font-size: 13px; margin-right: 4px; }
.tv-ctrl button, .tv-ctrl a { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--border-2); border-radius: 8px;
    padding: 7px 12px; font: 600 13px var(--font); cursor: pointer; }
.tv-ctrl button.on { background: var(--gold); color: #1a1405; border-color: var(--gold); }
.tv-ctrl a { text-decoration: none; }
@media (max-width: 900px) {
    body.tv-body { overflow: auto; height: auto; }
    .tv { height: auto; min-height: 100vh; }
    .tv-main, .tv.has-left .tv-main, .tv[data-layout="list"] .tv-main { grid-template-columns: 1fr; }
    .tv-stage { height: 60vh; }
    .tv-mark, .tv[data-layout="side"] .tv-mark, .tv[data-layout="list"] .tv-mark { right: 12px; }
}

/* Bố trí 3: danh sách tự cuộn */
.tv[data-layout="list"] .tv-stage { overflow-y: auto; scrollbar-width: none; }
.tv[data-layout="list"] .tv-stage::-webkit-scrollbar { display: none; }
.tv[data-layout="list"] .tv-fit { position: relative; height: var(--list-h, auto) !important; }
.tv-ticker-in { padding-left: 30%; }

@media (max-width: 900px) {
    .tv-top { flex-wrap: wrap; }
    .tv-main, .tv.has-left .tv-main, .tv[data-layout="list"] .tv-main { grid-template-columns: minmax(0, 1fr); }
    .tv-ctrl { top: auto; bottom: 60px; width: calc(100% - 24px); justify-content: center; }
}

/* Xếp hạng thành tích: bố trí có cột phải thì không lặp bảng giải thưởng ở giữa */
.tv.side-on .tv-stage .rank-wrap .standings { display: none; }
.tv-stage .rank-wrap { min-width: 760px; }
.tv-stage .rank-table { font-size: 17px; }
/* Bố trí có cột phải: mọi thể thức đều không lặp bảng giải thưởng ở giữa → sơ đồ to hơn */
.tv.side-on .tv-stage .standings { display: none !important; }

/* Mất kết nối */
.tv-conn { position: fixed; left: 50%; top: 1.2vh; transform: translateX(-50%); z-index: 50; padding: .6vh 1.4vw; border-radius: 999px;
    background: #b42318; color: #fff; font: 800 clamp(13px, 1.9vh, 24px) var(--font); box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.tv-conn.hidden { display: none; }

/* Khung xếp hạng khi chưa ai đạt hạng: chữ "Đang tranh…", mục Dẫn đầu, số người còn trong cuộc */
.tv-card .tv-wait { font-style: normal; color: var(--gold-2); opacity: .75; animation: tvwait 2.4s ease-in-out infinite; }
@keyframes tvwait { 50% { opacity: .35; } }
.tv-lead { margin-top: 1vh; border-top: 1px dashed var(--border-2); padding-top: .8vh; }
.tv-lead h4 { margin: 0 0 .5vh; font-size: clamp(12px, 1.5vh, 18px); color: var(--gold-2); }
.tv-lead .ld { display: grid; grid-template-columns: auto 1fr auto; gap: .6vw; align-items: center; padding: .45vh .3vw; border-radius: 6px; font-size: clamp(11px, 1.45vh, 18px); }
.tv-lead .ld:nth-child(even) { background: rgba(0,0,0,.2); }
.tv-lead .k { min-width: 2.2em; text-align: center; background: rgba(255,255,255,.1); border-radius: 5px; padding: 1px 6px; font-weight: 800; }
.tv-lead .n { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-lead .n i { font-style: normal; color: var(--muted); font-size: .8em; margin-right: .3em; }
.tv-lead b { color: var(--gold-2); }
.tv-alive { margin-top: 1vh; text-align: center; color: var(--muted); font-size: clamp(12px, 1.5vh, 18px); }
.tv-alive b { color: var(--gold-2); font-size: 1.4em; }
.tv-m.done .sc { display: inline-block; color: #1a1300; background: linear-gradient(180deg, #f6d77a, #d4af37); border-radius: 6px; padding: 1px 8px; font-weight: 900; }
.tv-m.done .a, .tv-m.done .b { opacity: .7; }
.tv-m.done .w { opacity: 1; color: #fff; }
/* TV mở trên điện thoại / máy tính bảng (note120 N120-004): bảng điểm, bảng thành tích vừa chiều ngang – không cắt cột Tr / T-B / HS / Đ,
   tên dài xuống dòng; TV thật (≥ 900px) giữ nguyên bố cục */
@media (max-width: 900px) {
    .tv-main > * { min-width: 0; }
    .tv-left, .tv-right { overflow: visible; }
    .tv-left .grp-card { overflow-x: auto; }
    .tv-left .grp-table { width: 100%; }
    .tv-left .grp-table td.nm { white-space: normal; max-width: none; overflow-wrap: anywhere; line-height: 1.25; }
    .tv-left .grp-table td:not(.nm), .tv-left .grp-table th { white-space: nowrap; padding-left: 3px; padding-right: 3px; }
    .tv-stage { overflow: auto; }
    .tv-stage .rank-wrap { min-width: 0; }
    .tv-stage .rank-table { font-size: 13px; }
    .tv-top { min-width: 0; }
    .tv-title { min-width: 0; }
    .tv-title h1 { white-space: normal; }
}
/* Ô QR: link dài (VD tên miền thử) xuống dòng, không đẩy TV điện thoại tràn ngang */
.tv-qr > div { min-width: 0; }
.tv-qr em { overflow-wrap: anywhere; }
/* TV trên điện thoại: tên giải chiếm trọn 1 hàng cạnh logo; trạng thái + đồng hồ xuống hàng dưới (không ép tên thành cột 1 chữ / dòng) */
@media (max-width: 900px) {
    .tv-title { flex: 1 1 calc(100% - 80px); }
    .tv-title h1 { font-size: clamp(18px, 5.2vw, 28px); line-height: 1.2; }
    .tv-status, .tv-clock { margin-left: auto; }
}

/* TV: giải chưa đấu → khung giữa là thẻ KHAI MẠC SAU, chữ to đọc từ xa (tv-fit tự co giãn vừa khung) */
.tv-ko { width: 1000px; max-width: none; margin: 0 auto; padding: 36px; }
.tv-ko .next-info h3 { font-size: 40px; }
.tv-ko .cd-box { width: 150px; }
.tv-ko .cd-box b { font-size: 84px; }
.tv-ko .next-stats b { font-size: 22px; }
.tv-ko .next-loc { font-size: 20px; }
.tv-ko .ko-note { font-size: 18px; }
@media (max-width: 900px) { .tv-ko { width: auto; padding: 20px; } .tv-ko .cd-box { width: 70px; } .tv-ko .cd-box b { font-size: 40px; } .tv-ko .next-info h3 { font-size: 24px; } }
/* Loa đang bật nhưng trình duyệt chờ lần chạm đầu tiên */
#tvVoice.wait { animation: tvwait 1.6s ease-in-out infinite; }
/* Trước giờ khai mạc: thẻ đếm ngược NỔI trên nền sơ đồ mờ (sơ đồ vẫn vẽ bình thường phía dưới) */
.tv-ko-layer { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 18px;
    background: radial-gradient(ellipse at center, rgba(6,24,17,.55), rgba(6,24,17,.82)); backdrop-filter: blur(2px); }   /* kiểu ban đầu – anh chọn 22/10/2026 */
.tv-ko-layer.hidden { display: none; }
.tv-ko-layer .tv-ko { width: min(1000px, 100%); max-height: 100%; overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.55); }
/* Đồng hồ đếm ngược nhỏ ở góc sân khấu (lúc đang hiện sơ đồ, trước giờ khai mạc) */
.tv-ko-mini { position: absolute; top: 14px; right: 14px; z-index: 6; display: flex; flex-direction: column; align-items: center;
    padding: 10px 20px 12px; border-radius: 16px; background: rgba(5,18,13,.88); border: 1px solid rgba(212,175,55,.55);
    box-shadow: 0 10px 30px rgba(0,0,0,.45); animation: koMiniIn .5s ease; }
.tv-ko-mini.hidden { display: none; }
.tv-ko-mini small { font-size: 13px; font-weight: 800; letter-spacing: 2px; color: var(--gold-2); }
.tv-ko-mini b { font-size: 46px; font-weight: 900; line-height: 1.05; color: #f3d77a; font-variant-numeric: tabular-nums; text-shadow: 0 0 18px rgba(212,175,55,.35); }
.tv-ko-layer:not(.hidden) { animation: koMiniIn .5s ease; }
@keyframes koMiniIn { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 900px) { .tv-ko-mini b { font-size: 28px; } .tv-ko-mini { padding: 6px 12px 8px; } }
/* Thanh điều khiển sát mép trên: gọn hơn để nằm trong dải tiêu đề */
.tv-ctrl { padding: 6px 10px; border-radius: 12px; }
.tv-ctrl button, .tv-ctrl a { padding: 6px 10px; font-size: 13px; }
.tv-ctrl .tv-ko-pick { display: none; }
.tv.ko-active .tv-ctrl .tv-ko-pick { display: inline-flex; }
.tv.ko-active .tv-ctrl span.tv-ko-pick { margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--border-2); }
/* Màn TV / laptop nhỏ hơn 1800: thu gọn thanh để vẫn nằm trong dải tiêu đề (≤ 2 dòng), không lấn sân khấu */
@media (min-width: 901px) and (max-width: 1800px) {
    .tv-ctrl { top: 4px; gap: 4px; row-gap: 4px; padding: 4px 8px; }
    .tv-ctrl > span:first-child { display: none; }
    .tv-ctrl button, .tv-ctrl a { padding: 4px 8px; font-size: 12px; border-radius: 7px; }
    .tv.ko-active .tv-ctrl span.tv-ko-pick { font-size: 12px; margin-left: 4px; padding-left: 6px; }
}
/* Nhãn ngắn trên thanh điều khiển (màn < 1800px) – rê chuột vẫn có tên đầy đủ ở title */
.tv-ctrl .s { display: none; }
@media (min-width: 901px) and (max-width: 1800px) {
    .tv-ctrl .l { display: none; }
    .tv-ctrl .s { display: inline; }
    .tv.ko-active .tv-ctrl span.tv-ko-pick { display: none; }
}
