:root {
  --vang: #f3d27a;
  --vang-dam: #c8963e;
  --nau: #2a140a;
  --kem: #fbf1dc;
  --do: #b3261e;
  --co-chu: 18px;
  font-size: var(--co-chu);
}
body.chuLon { --co-chu: 22px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--nau); }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--kem);
  font-family: "Be Vietnam Pro", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
#nen { position: fixed; inset: 0; background: #1c0d06 url(img/nen.jpg) center / cover no-repeat; z-index: 0; }
#nen::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 40%, rgba(10,4,2,.55) 100%); }
button { font: inherit; color: inherit; cursor: pointer; }

.man { position: fixed; inset: 0; z-index: 1; display: none; flex-direction: column; align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom)); overflow-y: auto; }
.man.hien { display: flex; animation: hienRa .25s ease; }
@keyframes hienRa { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Màn chính */
.tieuDe { text-align: center; margin-top: 6vh; }
.logoQuan { width: 96px; height: 96px; filter: drop-shadow(0 8px 14px rgba(0,0,0,.6)); animation: lacNhe 4s ease-in-out infinite; }
@keyframes lacNhe { 50% { transform: rotate(-6deg) translateY(-3px); } }
h1 { font-family: "Noto Serif", Georgia, "Times New Roman", serif; font-size: 2.6rem; line-height: 1.05; margin: 10px 0 6px;
  background: linear-gradient(180deg, #fff4c9, #f0c860 55%, #b9832d); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.7)); letter-spacing: .5px; }
h1 span { font-size: 1.5rem; font-style: italic; letter-spacing: 3px; }
.khauHieu { color: #e9d6b0; opacity: .9; max-width: 22em; margin: 6px auto 0; font-size: .95rem; }
.dsNut { display: flex; flex-direction: column; gap: 12px; width: min(420px, 100%); margin-top: 5vh; }
.nutLon { padding: 16px 18px; border-radius: 16px; border: 1px solid rgba(255,220,150,.45); font-size: 1.15rem; font-weight: 600; text-align: left;
  background: linear-gradient(180deg, rgba(120,52,20,.92), rgba(72,28,10,.92)); box-shadow: 0 6px 16px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,230,170,.35);
  color: #fff3d6; transition: transform .1s; }
.nutLon:active { transform: scale(.97); }
.nutLon.phu { background: rgba(40,18,8,.75); }
#nutTiepTuc { background: linear-gradient(180deg, #e2b14e, #a8701f); color: #2a1404; border-color: #ffe39a; }
.caiDatNhanh { margin-top: auto; padding-top: 18px; display: flex; gap: 18px; font-size: .9rem; color: #e9d6b0; }
.caiDatNhanh input { transform: scale(1.3); margin-right: 6px; accent-color: var(--vang-dam); }

/* Thanh trên các màn phụ */
.thanhTren { width: min(560px, 100%); display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.thanhTren h2 { margin: 0; font-family: "Noto Serif", Georgia, serif; color: var(--vang); font-size: 1.35rem; }
.nutVe { background: rgba(0,0,0,.35); border: 1px solid rgba(255,220,150,.35); border-radius: 12px; padding: 8px 14px; }

/* Đối thủ */
.dsDoiThu { width: min(560px, 100%); display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.theDoiThu { background: linear-gradient(180deg, rgba(90,40,14,.9), rgba(50,20,8,.92)); border: 1px solid rgba(255,220,150,.35); border-radius: 18px;
  padding: 12px 10px; text-align: center; box-shadow: 0 6px 14px rgba(0,0,0,.4); transition: transform .1s; }
.theDoiThu:active { transform: scale(.97); }
.theDoiThu img { width: 84px; height: 84px; border-radius: 50%; border: 3px solid var(--vang-dam); background: #6b4422; object-fit: cover; }
.theDoiThu b { display: block; color: var(--vang); margin-top: 6px; font-size: 1.02rem; }
.theDoiThu small { display: block; opacity: .85; font-size: .8rem; margin-top: 2px; }
.sao { color: #ffd257; letter-spacing: 1px; font-size: .9rem; }
.thanhTich { font-size: .75rem; opacity: .75; margin-top: 3px; }
.chonBen { display: flex; align-items: center; gap: 10px; margin: 16px 0; flex-wrap: wrap; justify-content: center; }
.nutBen { padding: 10px 16px; border-radius: 12px; border: 1px solid rgba(255,220,150,.4); background: rgba(0,0,0,.35); }
.nutBen.chon { background: var(--vang-dam); color: #2a1404; font-weight: 700; }

.the { width: min(560px, 100%); background: rgba(30,12,5,.78); border: 1px solid rgba(255,220,150,.3); border-radius: 18px; padding: 14px 16px; }
.the p { margin-top: 0; line-height: 1.45; color: #f0e2c4; }
.o { display: block; margin: 8px 0; }
.o input { display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; border-radius: 12px; border: 1px solid #8a6a3a; background: #fff8e8; color: #2a1404; }
.loi { color: #ffb4a8; min-height: 1em; }
.tieuNho { color: var(--vang); width: min(560px, 100%); margin: 18px 0 8px; font-family: "Noto Serif", Georgia, serif; }
.dsVan { width: min(560px, 100%); display: flex; flex-direction: column; gap: 10px; }
.dongVan { display: flex; align-items: center; gap: 12px; background: rgba(30,12,5,.8); border: 1px solid rgba(255,220,150,.28); border-radius: 14px; padding: 10px 12px; text-align: left; width: 100%; }
.dongVan .noi { flex: 1; min-width: 0; }
.dongVan b { color: var(--vang); }
.dongVan small { display: block; opacity: .8; }
.dongVan .nhan { padding: 4px 10px; border-radius: 999px; font-size: .78rem; background: #4a2a12; white-space: nowrap; }
.dongVan .nhan.toi { background: #c8963e; color: #2a1404; font-weight: 700; animation: nhapNhay 1.4s ease-in-out infinite; }
@keyframes nhapNhay { 50% { opacity: .55; } }
.dongVan .xoa { background: none; border: none; font-size: 1.2rem; opacity: .6; padding: 4px 8px; }
.trong { opacity: .7; text-align: center; padding: 18px; }

/* Bàn cờ */
#manBan { padding-left: 6px; padding-right: 6px; justify-content: center; }
.nguoiChoi { width: min(560px, 100%); display: flex; align-items: center; gap: 10px; padding: 6px 8px; position: relative; border-radius: 14px; transition: background .3s; }
.nguoiChoi.denLuot { background: rgba(243,210,122,.16); box-shadow: inset 0 0 0 1px rgba(243,210,122,.45); }
.anhDai { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--vang-dam); background: #6b4422; object-fit: cover; flex: none; }
.tenVaTrangThai b { display: block; color: var(--vang); font-size: 1.05rem; }
.tenVaTrangThai small { opacity: .85; font-size: .82rem; }
.loiNoi { position: absolute; left: 70px; top: 54px; z-index: 5; max-width: 74%; background: #fff7e2; color: #3a1c08; padding: 8px 12px;
  border-radius: 4px 14px 14px 14px; font-size: .95rem; box-shadow: 0 6px 16px rgba(0,0,0,.45); animation: hienRa .2s ease; }
#khungBan { position: relative; width: 100%; flex: 0 0 auto; min-height: 0; margin: 4px 0; display: flex; align-items: center; justify-content: center; }
#ban { display: block; touch-action: none; }
#bangChieu { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 10px 26px; border-radius: 14px; font-weight: 800; font-size: 1.7rem;
  background: rgba(150,20,14,.92); color: #fff3d6; border: 2px solid #ffd79a; letter-spacing: 2px; box-shadow: 0 10px 30px rgba(0,0,0,.6); pointer-events: none;
  animation: chieu 1.3s ease forwards; font-family: "Noto Serif", Georgia, serif; }
@keyframes chieu { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.6); } 15% { opacity: 1; transform: translate(-50%,-50%) scale(1.08); }
  25% { transform: translate(-50%,-50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
.thanhNut { width: min(560px, 100%); display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 6px; }
.thanhNut button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: .78rem; border-radius: 12px;
  background: rgba(40,16,6,.82); border: 1px solid rgba(255,220,150,.3); color: #f5e6c8; }
.thanhNut button span { font-size: 1.35rem; line-height: 1.1; }
.thanhNut button:disabled { opacity: .35; }

/* Hộp thoại */
.hop { position: fixed; inset: 0; background: rgba(8,3,1,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px; animation: hienRa .15s ease; }
.hop[hidden] { display: none; }
.hopNoi { width: min(420px, 100%); background: linear-gradient(180deg, #fff6e0, #f1dfb6); color: #3a1c08; border-radius: 20px; padding: 18px 18px 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.6); border: 2px solid #c8963e; max-height: 86vh; overflow: auto; }
.hopNoi h3 { margin: 0 0 8px; font-family: "Noto Serif", Georgia, serif; color: #7a2a10; font-size: 1.35rem; text-align: center; }
.hopNoi p { line-height: 1.45; }
.hopNut { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.hopNut button { padding: 13px; border-radius: 12px; border: 1px solid #b07a32; background: #fffaf0; font-weight: 600; font-size: 1.02rem; color: #3a1c08; }
.hopNut button.chinh { background: linear-gradient(180deg, #8c3a14, #5a200a); color: #fff3d6; border-color: #5a200a; }
.oLink { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid #b07a32; font: inherit; font-size: .85rem; background: #fff; color: #333; }
#thongBao { position: fixed; left: 50%; bottom: max(90px, calc(env(safe-area-inset-bottom) + 90px)); transform: translateX(-50%); background: rgba(20,8,3,.92);
  color: #fff3d6; padding: 10px 18px; border-radius: 999px; border: 1px solid rgba(255,220,150,.4); z-index: 60; font-size: .95rem; max-width: 90vw; text-align: center; }

.man { scrollbar-width: thin; scrollbar-color: rgba(200,150,62,.5) transparent; }
.man::-webkit-scrollbar { width: 6px; } .man::-webkit-scrollbar-thumb { background: rgba(200,150,62,.5); border-radius: 3px; }
.taiApp { margin-top: 18px; font-size: .9rem; text-align: center; color: #f0dcae; max-width: 24em; }
.taiApp a { display: inline-block; padding: 10px 16px; border-radius: 12px; background: #3a6b2a; color: #fff; text-decoration: none; font-weight: 700; border: 1px solid #8fd06f; }
.caiDatNhanh { flex-wrap: wrap; justify-content: center; }

/* Trang tải app */
#manTai { justify-content: flex-start; }
.taiHero { position: relative; width: min(560px, 100%); border-radius: 22px; overflow: hidden; border: 1px solid rgba(255,220,150,.35); box-shadow: 0 12px 30px rgba(0,0,0,.55); }
.taiAnh { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.taiChu { position: absolute; inset: 0; padding: 16px 18px; display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(90deg, rgba(20,8,3,.82) 0%, rgba(20,8,3,.45) 55%, transparent 80%), linear-gradient(0deg, rgba(20,8,3,.7), transparent 60%); }
.taiChu h1 { font-size: 2.1rem; margin: 6px 0 4px; }
.taiChu h1 span { font-size: 1.25rem; }
.taiChu .khauHieu { margin: 0; max-width: 20em; font-size: .9rem; }
.taiLogo { width: 56px; height: 56px; border-radius: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.6); }
.taiNut { width: min(560px, 100%); display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.nutTai { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 18px; text-decoration: none; color: #fff3d6; text-align: left;
  border: 1px solid rgba(255,220,150,.5); box-shadow: 0 6px 16px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,230,170,.35); transition: transform .1s; font: inherit; }
.nutTai:active { transform: scale(.97); }
.nutTai img, .nutTai .bieuTuong { width: 64px; height: 64px; border-radius: 16px; flex: none; object-fit: cover; }
.nutTai .bieuTuong { display: flex; align-items: center; justify-content: center; font-size: 2.2rem; background: rgba(0,0,0,.3); }
.nutTai b { display: block; font-size: 1.2rem; }
.nutTai small { display: block; opacity: .85; font-size: .85rem; margin-top: 2px; }
.nutTai.ios { background: linear-gradient(180deg, rgba(140,40,20,.95), rgba(80,20,8,.95)); }
.nutTai.android { background: linear-gradient(180deg, rgba(50,100,40,.95), rgba(25,60,20,.95)); }
.nutTai.web { background: rgba(40,18,8,.8); }
.huongDan { width: min(560px, 100%); margin-top: 12px; background: rgba(30,12,5,.78); border: 1px solid rgba(255,220,150,.3); border-radius: 14px; padding: 10px 14px; color: #f0e2c4; }
.huongDan summary { cursor: pointer; color: var(--vang); font-weight: 600; }
.huongDan ol { margin: 8px 0 2px; padding-left: 1.3em; line-height: 1.5; }
.chanTrang { margin-top: auto; padding-top: 18px; font-size: .85rem; opacity: .8; }
.chanTrang a { color: #f0dcae; }
.taiApp a { background: #8c3a14; border-color: #ffd79a; }

/* Xem lại ván, sổ cờ, danh hiệu */
#khungBan { position: relative; }
#nutThoatXem { position: absolute; top: calc(50% - 24px); left: 50%; transform: translateX(-50%); z-index: 5; font-size: 1.15em; padding: 10px 18px; border-radius: 24px; border: 0; background: #2a140a; color: #ffe9b0; box-shadow: 0 3px 10px rgba(0,0,0,.5); }
.bangSo { width: 100%; border-collapse: collapse; font-size: 1.05em; margin: 6px 0 10px; }
.bangSo th, .bangSo td { padding: 6px 4px; border-bottom: 1px solid rgba(0,0,0,.12); text-align: center; }
.bangSo td:first-child, .bangSo th:first-child { text-align: left; }
.tieuDH { margin: 10px 0 6px; }
.dsDH { display: grid; gap: 6px; }
.dh { padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.05); opacity: .6; }
.dh.co { opacity: 1; background: #fff3cf; border: 1px solid #d9a441; }
.dh b { display: block; } .dh small { color: #6b4a2a; }
#hopNoiDung { max-height: 62vh; overflow: auto; }
@media (prefers-reduced-motion: reduce) { #bangChieu { animation: none !important; } }
body.itHU #bangChieu { animation: none !important; }
