body.tc { background: #070b12; color: #fff; overflow: hidden; height: 100vh; height: 100dvh; }

/* ── Lưới ô: 1, 2, 3 hoặc 4 khu phố một lúc ── */
.luoi { position: fixed; inset: 0; display: grid; grid-template: 1fr / 1fr; }
.luoi:not([data-bocuc="1"]) { top: 96px; gap: 6px; padding: 0 6px 10px; }
.luoi[data-bocuc="2"] { grid-template: 1fr / 1fr 1fr; }
.luoi[data-bocuc="3"] { grid-template: 1fr 1fr / 2fr 1fr; }
.luoi[data-bocuc="3"] .o-kp:first-child { grid-row: span 2; }
.luoi[data-bocuc="4"] { grid-template: 1fr 1fr / 1fr 1fr; }
@media (max-aspect-ratio: 1/1) {   /* màn hình dọc: xếp theo hàng */
  .luoi[data-bocuc="2"] { grid-template: 1fr 1fr / 1fr; }
  .luoi[data-bocuc="3"] { grid-template: 1.4fr 1fr / 1fr 1fr; }
  .luoi[data-bocuc="3"] .o-kp:first-child { grid-row: auto; grid-column: span 2; }
}

/* Mỗi ô là một container: chữ và khoảng cách co theo kích thước ô (cqw/cqh), không theo màn hình. */
.o-kp { position: relative; overflow: hidden; container-type: size; background: #0b111b; }
.luoi:not([data-bocuc="1"]) .o-kp { border-radius: 14px; }

/* 2 lớp thay phiên nhau để chuyển ảnh mờ dần */
/* Hiệu ứng chuyển ảnh chạy bằng Web Animations API (trinh-chieu.js → HIEU_UNG). */
.lop { position: absolute; inset: 0; opacity: 0; overflow: hidden; will-change: transform, opacity, clip-path; }
.lop.hien { opacity: 1; z-index: 1; }
.lop.tren { z-index: 2; }
.lop .nen {
  position: absolute; inset: -60px; background-size: cover; background-position: center;
  filter: blur(40px) saturate(1.3) brightness(.55); transform: scale(1.1);
}
.lop img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: center;
  padding: 2cqh 2cqw 3cqh;
}
.luoi[data-bocuc="1"] .lop img { padding: 104px 24px 90px; }
/* Chuyển động chậm trên ảnh (Ken Burns), mỗi ảnh một kiểu ngẫu nhiên; tên đặt qua style.animationName. */
.lop.hien img { animation: tien-gan 4.4s linear both; }
@keyframes tien-gan  { from { transform: scale(1); }    to { transform: scale(1.07); } }
@keyframes lui-xa    { from { transform: scale(1.08); } to { transform: scale(1); } }
@keyframes troi-trai { from { transform: scale(1.07) translateX(2%); }  to { transform: scale(1.07) translateX(-2%); } }
@keyframes troi-phai { from { transform: scale(1.07) translateX(-2%); } to { transform: scale(1.07) translateX(2%); } }
@keyframes troi-len  { from { transform: scale(1.07) translateY(2%); }  to { transform: scale(1.07) translateY(-2%); } }
.phu-toi {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: linear-gradient(to top, rgba(7, 11, 18, .85) 0, rgba(7, 11, 18, 0) 45cqh);
}
.luoi[data-bocuc="1"] .phu-toi {
  background:
    linear-gradient(to bottom, rgba(7, 11, 18, .78) 0, rgba(7, 11, 18, 0) 150px),
    linear-gradient(to top, rgba(7, 11, 18, .88) 0, rgba(7, 11, 18, 0) 300px);
}

/* ── Đầu trang ── */
.tc-dau {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center;
  justify-content: space-between; padding: 18px clamp(16px, 3vw, 40px); height: 96px;
}
.tc-dau .thuong-hieu { display: flex; align-items: center; gap: 14px; color: #fff; text-decoration: none; }
.tc-dau .thuong-hieu img {
  width: clamp(48px, 5vw, 64px); height: auto; border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .9), 0 8px 24px rgba(0, 0, 0, .4);
}
.tc-dau strong {
  display: block; font-size: clamp(1rem, 1.7vw, 1.45rem); font-weight: 800; letter-spacing: .02em;
  text-transform: uppercase; text-shadow: 0 2px 12px rgba(0, 0, 0, .5);
}
.tc-dau small { display: block; color: var(--vang); font-weight: 600; font-size: clamp(.75rem, 1vw, .9rem); letter-spacing: .04em; }
.dong-ho { text-align: right; text-shadow: 0 2px 12px rgba(0, 0, 0, .5); }
.dong-ho b { display: block; font-size: clamp(1.25rem, 2.2vw, 2rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.dong-ho small { color: rgba(255, 255, 255, .75); font-size: clamp(.7rem, .9vw, .85rem); }

/* ── Thẻ tên khu phố (trong từng ô) — thu còn 1/2 so với bản đầu (01/10/2026) ── */
.the-kp {
  position: absolute; z-index: 5; left: clamp(10px, 3cqw, 40px); bottom: clamp(10px, 4cqh, 48px);
  max-width: min(360px, calc(100cqw - 20px)); padding: clamp(6px, 1.2cqh, 9px) clamp(10px, 1.3cqw, 13px) clamp(6px, 1.2cqh, 9px) clamp(12px, 1.5cqw, 16px);
  border-radius: clamp(8px, .8cqw, 10px);
  background: rgba(12, 18, 28, .52); backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 20px 50px -12px rgba(0, 0, 0, .55); overflow: hidden;
}
.the-kp::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(to bottom, var(--do), var(--vang));
}
.the-kp__nhan { color: var(--vang); font-weight: 700; }
.the-kp__ten { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.the-kp__ten {
  margin: 2px 0 0; font-size: clamp(1rem, 2.6cqw, 2.2rem); font-weight: 800; line-height: 1.05; letter-spacing: -.02em;
}
.the-kp__ten.doi { animation: len-chu .7s var(--em) both; }
@keyframes len-chu { from { opacity: 0; transform: translateY(18px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.the-kp__ghi-chu { margin: 3px 0 0; color: rgba(255, 255, 255, .85); font-size: clamp(.7rem, .7cqw, .8rem); }
.the-kp__ghi-chu:empty { display: none; }
.the-kp__chan { display: flex; align-items: center; gap: 8px; margin-top: clamp(3px, .7cqh, 6px); }
.cham { display: flex; flex-wrap: wrap; gap: 4px; max-width: 200px; }
.cham i { width: 5px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .3); transition: width .35s var(--em), background-color .35s; }
.cham i.dang { width: 14px; background: var(--vang); }
.dem { color: rgba(255, 255, 255, .7); font-size: .7rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
@container (max-height: 220px) or (max-width: 220px) { .the-kp__ghi-chu, .cham { display: none; } .the-kp__chan { margin-top: 2px; } }
.cham.nhieu { display: none; }   /* quá 12 ảnh: chỉ hiện "Ảnh x/y" */

.tiep-theo {
  position: fixed; right: clamp(16px, 3vw, 40px); bottom: clamp(28px, 4vh, 48px); z-index: 5; text-align: right;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
}
.tiep-theo small { display: block; color: rgba(255, 255, 255, .6); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; }
.tiep-theo span { font-weight: 700; font-size: clamp(1rem, 1.5vw, 1.3rem); }

.thanh-tien-do { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; height: 4px; background: rgba(255, 255, 255, .12); }
.thanh-tien-do i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, var(--do), var(--vang)); }
.thanh-tien-do i.chay { animation: tien-do var(--tg, 3s) linear both; }
body.dung .thanh-tien-do i.chay { animation-play-state: paused; }
@keyframes tien-do { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ── Điều khiển: hiện khi rê chuột ── */
.dieu-khien {
  position: fixed; top: 50%; right: clamp(16px, 3vw, 40px); z-index: 7; display: flex; flex-direction: column; align-items: center; gap: 10px;
  transform: translate(12px, -50%); opacity: 0; transition: opacity .3s, transform .3s var(--em); pointer-events: none;
}
body.chuot .dieu-khien { opacity: 1; transform: translate(0, -50%); pointer-events: auto; }
.dieu-khien button, .nut-gui {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(12, 18, 28, .55); backdrop-filter: blur(10px); color: #fff; cursor: pointer;
  transition: background-color .15s, transform .1s var(--em);
}
.dieu-khien button:hover { background: rgba(255, 255, 255, .2); }
.dieu-khien button:active { transform: scale(.94); }
.dieu-khien svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.dieu-khien .i-chay { fill: currentColor; stroke: none; }
.dieu-khien .i-chay, body.dung .dieu-khien .i-dung { display: none; }
body.dung .dieu-khien .i-chay { display: block; }
.nut-gui {
  width: auto; height: auto; border-radius: 99px; padding: 10px 14px; font-size: .8rem; font-weight: 600;
  text-decoration: none; text-align: center; background: var(--do); border-color: var(--do); margin-top: 6px; max-width: 96px;
}
body.dung .tc-dau small::after { content: " · Đang tạm dừng"; color: #fff; }

/* ── Trạng thái chưa có ảnh ── */
.trong {
  position: fixed; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center;
  background: radial-gradient(ellipse at 50% 30%, #17375a 0, #070b12 70%);
}
.trong img { width: 148px; height: auto; border-radius: 50%; box-shadow: 0 0 0 4px #fff, 0 20px 60px rgba(47, 143, 214, .35); margin-bottom: 12px; }
.trong h1 { margin: 0; font-size: clamp(1.4rem, 3vw, 2.2rem); }
.trong p { margin: 0 0 12px; max-width: 520px; color: rgba(255, 255, 255, .72); }
body.trong-rong .luoi, body.trong-rong .tiep-theo, body.trong-rong .thanh-tien-do, body.trong-rong .dieu-khien { display: none; }

@media (max-width: 640px) {
  .luoi[data-bocuc="1"] .lop img { padding: 84px 8px 190px; }
  .luoi:not([data-bocuc="1"]) { top: 80px; }
  .tc-dau { height: 80px; }
  .tiep-theo { display: none; }
  .dong-ho small { display: none; }
  .dieu-khien { top: auto; bottom: 16px; flex-direction: row; flex-wrap: wrap; justify-content: center; left: 16px; right: 16px; transform: translateY(12px); }
  body.chuot .dieu-khien { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .lop.hien img { animation: none; }
}

/* Menu trên nền tối của trang trình chiếu */
.tc-dau { gap: 16px; }
.menu--toi { margin-left: auto; background: rgba(12, 18, 28, .5); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, .14); }
.menu--toi a { color: rgba(255, 255, 255, .82); }
.menu--toi a:hover { color: #fff; background: rgba(255, 255, 255, .14); }
.menu--toi a[aria-current="page"] { background: var(--vang); color: #14202f; box-shadow: none; }
@media (max-width: 860px) { .dong-ho { display: none; } }
@media (max-width: 640px) { .tc-dau strong { font-size: .9rem; } .tc-dau small { display: none; } }

/* Nhãn LIVE: chấm đỏ nhấp nháy; tạm dừng thì chuyển xám */
.live {
  display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; margin-left: 8px;
  padding: 3px 9px 3px 8px; border-radius: 6px; background: #e53935; color: #fff;
  font-size: .7rem; font-weight: 800; letter-spacing: .1em; line-height: 1.2; text-shadow: none;
  box-shadow: 0 0 0 0 rgba(229, 57, 53, .6); animation: live-vien 2s ease-out infinite;
}
.live i { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: live-cham 1s ease-in-out infinite alternate; }
@keyframes live-cham { from { opacity: 1; } to { opacity: .25; } }
@keyframes live-vien { 0% { box-shadow: 0 0 0 0 rgba(229, 57, 53, .55); } 100% { box-shadow: 0 0 0 10px rgba(229, 57, 53, 0); } }
body.dung .live { background: #6b7280; animation: none; }
body.dung .live i { animation: none; }
.tc-dau .thuong-hieu > span { min-width: 0; }
.tc-dau strong { white-space: nowrap; }
.tc-dau small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) {
  .tc-dau { gap: 8px; padding: 12px; }
  .tc-dau .thuong-hieu { gap: 8px; min-width: 0; }
  .tc-dau .thuong-hieu img { width: 40px; }
  #tenPhuong { display: none; }               /* điện thoại: chỉ còn nhãn LIVE cạnh logo */
  .live { margin-left: 0; }
}
@media (max-width: 640px) {
  .tc-dau small { display: -webkit-box !important; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    white-space: normal; font-size: .66rem; line-height: 1.25; margin-top: 3px; }
}

/* ── Thanh trái 31 khu phố ── */
:root { --rong-ds: 232px; }
.ds-kp-tc {
  position: fixed; z-index: 8; left: 6px; top: 96px; bottom: 10px; width: var(--rong-ds);
  display: flex; flex-direction: column; border-radius: 14px; overflow: hidden;
  background: rgba(12, 18, 28, .72); backdrop-filter: blur(16px) saturate(1.3); border: 1px solid rgba(255, 255, 255, .1);
  transition: transform .35s var(--em), opacity .25s;
}
body.an-ds-kp .ds-kp-tc { transform: translateX(calc(-100% - 12px)); opacity: 0; pointer-events: none; }
.ds-kp-tc__dau {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 12px 14px 8px;
  color: var(--vang); font-weight: 800; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
}
.ds-kp-tc__dau small { color: rgba(255, 255, 255, .5); font-weight: 600; letter-spacing: 0; text-transform: none; }
.ds-kp-tc ul { list-style: none; margin: 0; padding: 0 6px 8px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .2) transparent; }
.ds-kp-tc button {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 9px;
  background: transparent; color: rgba(255, 255, 255, .86); font-size: .875rem; font-weight: 600; text-align: left; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.ds-kp-tc li:first-child { margin-bottom: 4px; padding-bottom: 4px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.ds-kp-tc button:hover:not(:disabled) { background: rgba(255, 255, 255, .1); color: #fff; }
.ds-kp-tc button:disabled { color: rgba(255, 255, 255, .3); cursor: default; }
.ds-kp-tc button[aria-pressed="true"] { background: var(--vang); color: #14202f; }
.ds-kp-tc .ten { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-kp-tc .so { min-width: 26px; padding: 1px 7px; border-radius: 99px; background: rgba(255, 255, 255, .1); font-size: .72rem; text-align: center; font-variant-numeric: tabular-nums; }
.ds-kp-tc button[aria-pressed="true"] .so { background: rgba(20, 32, 47, .15); }
.ds-kp-tc button:disabled .so { background: transparent; }
/* chấm đỏ nhấp nháy = khu phố đang trên màn hình */
.dau-chieu { width: 7px; height: 7px; border-radius: 50%; flex: none; background: transparent; }
.ds-kp-tc button.dang-chieu .dau-chieu { background: #e53935; box-shadow: 0 0 0 3px rgba(229, 57, 53, .25); animation: live-cham 1s ease-in-out infinite alternate; }
.ds-kp-tc button[aria-pressed="true"].dang-chieu .dau-chieu { background: #b71c1c; }

.nut-ds-kp {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .16); background: rgba(12, 18, 28, .5); color: #fff;
}
.nut-ds-kp:hover { background: rgba(255, 255, 255, .14); }
.nut-ds-kp svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.nut-ds-kp[aria-expanded="true"] { background: var(--vang); color: #14202f; border-color: var(--vang); }

/* Thanh trái mở trên màn hình rộng: lưới ảnh lùi sang phải, mọi bố cục đều nằm dưới đầu trang. */
@media (min-width: 901px) {
  body:not(.an-ds-kp) .luoi { left: calc(var(--rong-ds) + 12px); top: 96px; padding: 0 6px 10px 0; gap: 6px; }
  body:not(.an-ds-kp) .luoi .o-kp { border-radius: 14px; }
  body:not(.an-ds-kp) .luoi[data-bocuc="1"] .lop img { padding: 2cqh 2cqw 3cqh; }
  body:not(.an-ds-kp) .luoi[data-bocuc="1"] .phu-toi { background: linear-gradient(to top, rgba(7, 11, 18, .85) 0, rgba(7, 11, 18, 0) 45cqh); }
}
/* Màn hình hẹp: thanh trái là ngăn kéo phủ lên trên */
@media (max-width: 900px) {
  .ds-kp-tc { top: 0; left: 0; bottom: 0; border-radius: 0 16px 16px 0; z-index: 20; width: min(280px, 82vw); background: rgba(12, 18, 28, .94); }
  .ds-kp-tc__dau { padding-top: 18px; }
}
.man-che { position: fixed; inset: 0; z-index: 19; background: rgba(0, 0, 0, .5); }
@media (max-width: 640px) { .nut-ds-kp { width: 40px; height: 40px; } }
body.trong-rong .ds-kp-tc, body.trong-rong .nut-ds-kp { display: none; }
