:root { --c: #7B68EE; --c2: #4FE3B5; --bg: #07060f; --ink: #1b1830; --mut: #635e80; --vang: #ffd66b; --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); font-family: "Be Vietnam Pro", system-ui, sans-serif; color: var(--ink); overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#menu { position: fixed; inset: 0; z-index: 20; display: none; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#menu.on { display: block; }
#menu.nen { background: rgba(6, 5, 16, .62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
button { font: inherit; cursor: pointer; color: inherit; }

/* ---------- màn chính: ngôi nhà 3D phía sau, bảng nút phía dưới (cuộn được) ---------- */
.home { min-height: 100%; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; padding: calc(var(--sat) + 62px) 14px calc(var(--sab) + 18px); }
.logo { display: flex; align-items: center; gap: 12px; color: #fff; text-shadow: 0 3px 14px rgba(0,0,0,.8); }
.logo img { width: 58px; height: 58px; border-radius: 16px; box-shadow: 0 8px 22px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.15); }
.logo h1 { margin: 0; font-size: 40px; font-weight: 900; letter-spacing: -1px; line-height: 1; }
.logo p { margin: 3px 0 0; font-weight: 800; font-size: 14px; opacity: .95; }
.home .mo { flex: 1; min-height: 34vh; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; }
.home .mo span { color: #c9ffe6; font-weight: 800; font-size: 13px; text-shadow: 0 2px 8px #000; }
.sheet { background: rgba(244, 241, 255, .96); border-radius: 26px; padding: 14px; box-shadow: 0 -6px 30px rgba(0,0,0,.55); display: flex; flex-direction: column; gap: 9px; }
.sheet h3 { margin: 6px 2px 0; font-size: 15px; display: flex; justify-content: space-between; align-items: baseline; }
.sheet h3 small { font-size: 13px; color: var(--mut); }
.btn { display: block; width: 100%; min-height: 52px; border: 0; border-radius: 18px; background: #fff; font-weight: 800; font-size: 17px; box-shadow: 0 5px 14px rgba(0,0,0,.14); margin: 6px 0; }
.btn:disabled { opacity: .5; }
.btn.main { background: linear-gradient(180deg, #9a8cff, #6a56e8 60%, #4c38c8); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.btn.big { min-height: 72px; font-size: 26px; font-weight: 900; margin: 0; }
.btn small { display: block; font-size: 13.5px; font-weight: 700; opacity: .92; }
.btn.ngay { background: linear-gradient(180deg, #1d2a3e, #10172a); color: #fff; text-align: left; padding: 10px 16px; margin: 0; box-shadow: 0 5px 14px rgba(0,0,0,.25), inset 0 0 0 1px rgba(120,255,200,.25); }
.btn.ngay b { font-size: 17px; }
.btn.ngay small { opacity: .85; line-height: 1.35; margin-top: 2px; }
.luoi { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.luoi .o { border: 2px solid transparent; background: #fff; border-radius: 16px; min-height: 78px; padding: 7px 8px; text-align: left; box-shadow: 0 3px 10px rgba(0,0,0,.08); display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center; }
.luoi .o i { font-style: normal; font-size: 26px; grid-row: span 2; text-align: center; }
.luoi .o b { font-size: 14px; font-weight: 900; line-height: 1.2; }
.luoi .o small { font-size: 11.5px; font-weight: 700; color: var(--mut); line-height: 1.3; }
.luoi .o .sao { color: #e0a400; letter-spacing: 1px; font-size: 12px; }
.luoi .o.chon { border-color: #7B68EE; background: #f1eeff; }
.luoi .o.khoa { opacity: .58; }
.viec { display: flex; flex-direction: column; gap: 6px; }
.viec div { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; background: #fff; border-radius: 12px; padding: 7px 10px; font-size: 13.5px; font-weight: 700; }
.viec div i { grid-column: 1; height: 6px; border-radius: 4px; background: #e6e2f4; overflow: hidden; }
.viec div i em { display: block; height: 100%; background: linear-gradient(90deg, #7B68EE, #4FE3B5); }
.viec div b { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: #b07c10; font-size: 13px; }
.viec div.xong { background: #e9fbf2; }
.hang { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.link { border: 0; background: #fff; border-radius: 14px; padding: 12px 8px; font-weight: 800; width: 100%; min-height: 46px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.foot { color: var(--mut); font-size: 12.5px; text-align: center; margin: 2px 0 0; }
.foot a { color: inherit; }

/* ---------- bảng phụ ---------- */
.panel { background: #f4f1ff; border-radius: 22px; padding: 18px 16px; max-width: 520px; margin: calc(var(--sat) + 64px) auto 24px; width: calc(100% - 24px); box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.panel h2 { margin: 0 0 6px; font-size: 22px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel h2 small { font-size: 14px; color: #b07c10; }
.panel h3 { margin: 16px 0 6px; font-size: 16px; }
.panel h3 small { font-size: 12.5px; font-weight: 700; color: var(--mut); }
.panel p, .panel li { color: var(--mut); font-weight: 600; line-height: 1.5; font-size: 14.5px; }
.panel ul { padding-left: 18px; margin: 4px 0; }
.panel li { margin: 5px 0; }
.panel li b { color: var(--ink); }
.panel li.chua { opacity: .6; }
.panel li em { font-style: normal; color: #4a4566; }
.panel .giai { color: #1f5a4a; }
.panel .nho { font-size: 12.5px; opacity: .85; }
.panel.khoa .giai { background: #e6fbf2; border-radius: 14px; padding: 10px 12px; color: #17483b; }
.dauds { display: flex; flex-wrap: wrap; gap: 6px; }
.dauds span { background: #fff; border-radius: 10px; padding: 5px 9px; font-weight: 800; font-size: 13px; color: var(--ink); }
.nc { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; background: #fff; border-radius: 14px; padding: 9px 10px; margin: 6px 0; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.nc i { font-style: normal; font-size: 24px; text-align: center; }
.nc b { font-size: 15px; } .nc b small { color: #7B68EE; letter-spacing: 1px; font-size: 12px; }
.nc em { display: block; font-style: normal; font-size: 12.5px; color: var(--mut); font-weight: 600; }
.nc button { border: 0; border-radius: 12px; min-height: 44px; min-width: 84px; padding: 0 10px; font-weight: 900; background: linear-gradient(180deg, #ffcf4a, #f0a820); color: #3a2a08; }
.nc button.thieu { filter: grayscale(.7); opacity: .7; }
.chondo { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.chondo button { border: 2px solid transparent; background: #fff; border-radius: 16px; min-height: 64px; padding: 8px; text-align: left; display: grid; grid-template-columns: 30px 1fr; column-gap: 6px; align-items: center; }
.chondo button i { font-style: normal; font-size: 24px; grid-row: span 2; }
.chondo button b { font-size: 14px; }
.chondo button small { font-size: 11.5px; color: var(--mut); font-weight: 700; }
.chondo button.chon { border-color: #7B68EE; background: #efeaff; }

/* ---------- HUD trong nhà ---------- */
#snHud { position: fixed; z-index: 12; left: 8px; right: 8px; top: calc(var(--sat) + 8px); display: none; flex-direction: column; gap: 6px; pointer-events: none; color: #fff; }
#snHud.on { display: flex; }
#snHud .r1 { display: flex; gap: 8px; align-items: center; }
#snHud .dung { pointer-events: auto; border: 0; border-radius: 14px; min-width: 52px; min-height: 48px; background: rgba(22,20,38,.85); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; box-shadow: 0 3px 10px rgba(0,0,0,.4); }
#snHud .dung b { font-size: 15px; } #snHud .dung small { font-size: 10px; font-weight: 800; margin-top: 3px; }
#snHud .noi { flex: 1; background: rgba(22,20,38,.78); border-radius: 14px; padding: 6px 10px; min-height: 48px; display: flex; flex-direction: column; justify-content: center; }
#snHud .noi b { font-size: 14px; font-weight: 900; } #snHud .noi small { font-size: 12px; font-weight: 700; color: #c9c2ff; }
#snHud .gio { background: rgba(22,20,38,.78); border-radius: 14px; min-height: 48px; padding: 0 10px; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
#snHud .thanh { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#snHud .thanh > span { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 5px; background: rgba(22,20,38,.78); border-radius: 12px; padding: 5px 8px; }
#snHud .thanh i { font-style: normal; font-size: 15px; }
#snHud .thanh em { height: 9px; border-radius: 6px; background: rgba(255,255,255,.14); overflow: hidden; }
#snHud .thanh u { display: block; height: 100%; border-radius: 6px; text-decoration: none; transition: width .15s; }
#snHud .pin u { background: linear-gradient(90deg, #ffd66b, #fff2b8); box-shadow: 0 0 10px #ffd66b; }
#snHud.pinthap .pin u { background: #ff6a5a; box-shadow: 0 0 10px #ff6a5a; }
#snHud .cang u { background: linear-gradient(90deg, #6fd0ff, #b38cff 60%, #ff6aa8); }
#snHud .thanh b { font-size: 11.5px; font-weight: 800; min-width: 52px; text-align: right; }
#snHud.cangcao .cang { animation: snNhip .8s infinite; }
#snHud .so { display: flex; gap: 4px; justify-content: center; }
#snHud .so span { background: rgba(22,20,38,.7); border-radius: 10px; padding: 2px 6px; display: flex; gap: 2px; align-items: center; font-size: 12px; }
#snHud .so span i { font-style: normal; font-size: 13px; }
#snHud .so span b { font-size: 12px; color: #9a94c0; }
#snHud .so span.co { background: rgba(40,160,110,.85); } #snHud .so span.co b { color: #fff; }
#snHud .so span.ko { background: rgba(90,40,50,.85); } #snHud .so span.ko b { color: #ff9a9a; }
#snHud .so span.thieu { opacity: .4; }
@keyframes snNhip { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.04); } 30% { transform: scale(1); } 45% { transform: scale(1.03); } }

/* viền tối theo độ căng + chớp đèn máy ảnh */
#snVien { position: fixed; inset: 0; z-index: 10; pointer-events: none; opacity: 0; display: none; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 48%, rgba(30,0,40,.75) 100%); transition: opacity .3s; }
#snVien.on { display: block; }
#snVien.dap { animation: snVien 0.85s infinite; }
@keyframes snVien { 0%, 100% { filter: none; } 20% { filter: brightness(1.6); } }
#snChop { position: fixed; inset: 0; z-index: 11; pointer-events: none; background: #fff; opacity: 0; }
#snChop.on { animation: snChop .45s ease-out; }
@keyframes snChop { 0% { opacity: .9; } 100% { opacity: 0; } }

/* thẻ đọc máy */
#snDoc { position: fixed; z-index: 13; left: 50%; top: calc(var(--sat) + 150px); transform: translate(-50%, -8px); width: min(360px, calc(100% - 24px)); pointer-events: none; opacity: 0; transition: opacity .2s, transform .2s; }
#snDoc.on { opacity: 1; transform: translate(-50%, 0); }
#snDoc .the { background: rgba(16,14,30,.92); color: #fff; border-radius: 18px; padding: 10px 12px; display: grid; grid-template-columns: 40px 1fr; gap: 4px 10px; box-shadow: 0 8px 26px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.08); }
#snDoc .the > i { font-style: normal; font-size: 30px; align-self: start; }
#snDoc .the small { display: block; font-size: 11.5px; font-weight: 700; color: #b9b2e6; }
#snDoc .the b { display: block; font-size: 26px; font-weight: 900; line-height: 1.15; font-variant-numeric: tabular-nums; }
#snDoc .the span { display: block; font-size: 14px; font-weight: 700; }
#snDoc .the small.nhieu { color: #ffc27a; margin-top: 3px; font-size: 12.5px; line-height: 1.35; }
#snDoc .the em { display: inline-block; margin-top: 5px; font-style: normal; font-size: 12px; font-weight: 900; background: rgba(255,255,255,.12); border-radius: 8px; padding: 2px 8px; }
#snDoc .the em.moi { background: #2fbf86; color: #04241a; }
#snDoc .the em.ko { background: #5a2a36; color: #ffb2b2; }
#snDoc .the.duong { box-shadow: 0 0 0 2px #4FE3B5, 0 0 30px rgba(79,227,181,.45); }
#snDoc .the.duong b { color: #9dffd6; }
#snDoc .the.k-uv.duong b { color: #d2b8ff; }
#snDoc .the.k-anh { grid-template-columns: 34px 1fr 132px; }
#snDoc canvas { grid-column: 3; grid-row: 1; align-self: center; width: 132px; height: 102px; background: #111; border: 5px solid #f4efe4; border-bottom-width: 15px; border-radius: 3px; transform: rotate(-3deg); box-shadow: 0 8px 18px rgba(0,0,0,.5); }
#snDoc .kim { grid-column: 1 / -1; height: 50px; position: relative; overflow: hidden; }
#snDoc .kim::before { content: ''; position: absolute; left: 50%; bottom: -40px; width: 160px; height: 80px; transform: translateX(-50%); border-radius: 80px 80px 0 0; background: conic-gradient(from -90deg at 50% 100%, #2fbf86 0 30deg, #ffd66b 30deg 60deg, #ff8a5a 60deg 120deg, #ff4a6a 120deg 180deg); opacity: .6; }
#snDoc .kim u { position: absolute; left: calc(50% - 2px); bottom: 0; width: 4px; height: 46px; background: #fff; transform-origin: 50% 100%; border-radius: 3px; transition: transform .6s cubic-bezier(.3,1.6,.5,1); }
#snDoc .kim u.loan { animation: snLoan .18s infinite; }
@keyframes snLoan { 0% { transform: rotate(-40deg); } 50% { transform: rotate(50deg); } 100% { transform: rotate(-20deg); } }
#snDoc .song { display: flex !important; gap: 3px; height: 22px; align-items: center; margin-top: 4px; }
#snDoc .song i { width: 5px; background: #c9b6ff; border-radius: 3px; animation: snSong .5s infinite alternate; }
#snDoc .song i:nth-child(2n) { animation-delay: .15s; } #snDoc .song i:nth-child(3n) { animation-delay: .3s; }
@keyframes snSong { from { height: 4px; } to { height: 22px; } }

/* băng thông báo giữa màn */
#snBan { position: fixed; z-index: 14; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(.9); width: min(340px, calc(100% - 32px)); text-align: center; color: #fff; pointer-events: none; opacity: 0; transition: opacity .25s, transform .25s; }
#snBan.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#snBan.thap { top: 57%; }
#snBan b { display: block; font-size: 26px; font-weight: 900; text-shadow: 0 3px 16px #000, 0 0 30px rgba(123,104,238,.8); }
#snBan span { display: block; margin-top: 4px; font-weight: 800; font-size: 14px; text-shadow: 0 2px 10px #000; background: rgba(10,8,20,.6); border-radius: 12px; padding: 5px 10px; }
#snBan.tim b { text-shadow: 0 3px 16px #000, 0 0 30px rgba(180,140,255,.95); }
#snBan.do b { color: #ffd0c8; text-shadow: 0 3px 16px #000, 0 0 26px rgba(255,90,90,.9); }
#snBan.xanh b { color: #c8ffe6; }

/* lời bạn đồng hành */
#snNoi { position: fixed; z-index: 12; left: 0; top: 0; max-width: 220px; background: #fffbe8; color: #2a2418; font-weight: 800; font-size: 13.5px; line-height: 1.35; border-radius: 14px; padding: 7px 11px; pointer-events: none; display: none; box-shadow: 0 6px 16px rgba(0,0,0,.4); }
#snNoi.on { display: block; }
#snNoi::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #fffbe8; }

/* tay chỉ (lượt tập) */
#snTay { position: fixed; z-index: 16; left: 0; top: 0; pointer-events: none; display: none; }
#snTay.on { display: block; }
#snTay i { position: absolute; left: -16px; top: -6px; font-style: normal; font-size: 36px; animation: snTay 0.9s infinite; filter: drop-shadow(0 3px 6px rgba(0,0,0,.6)); }
#snTay span { position: absolute; top: -64px; width: 220px; text-align: center; background: #ffd66b; color: #2a2008; font-weight: 900; font-size: 14px; border-radius: 12px; padding: 7px 10px; box-shadow: 0 6px 16px rgba(0,0,0,.4); }
#snTay.duoi span { top: 46px; }
@keyframes snTay { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }

/* sổ tay */
#snSo { position: fixed; inset: 0; z-index: 18; display: none; background: rgba(6,5,16,.45); overflow-y: auto; -webkit-overflow-scrolling: touch; }
#snSo.on { display: block; }
#snSo .hop { margin: calc(var(--sat) + 120px) auto calc(var(--sab) + 16px); width: min(500px, calc(100% - 16px)); background: #fbf6e6; color: #2a2418; border-radius: 22px; padding: 14px; box-shadow: 0 -6px 30px rgba(0,0,0,.6); background-image: repeating-linear-gradient(180deg, transparent 0 27px, rgba(80,120,200,.12) 27px 28px); }
#snSo .dau { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#snSo h2 { margin: 0; font-size: 21px; font-weight: 900; }
#snSo h3 { margin: 12px 2px 6px; font-size: 15px; display: flex; justify-content: space-between; }
#snSo h3 small { color: #7a6a4a; }
#snSo .phu { margin: 4px 0 8px; font-size: 12.5px; font-weight: 700; color: #7a6a4a; }
#snSo .dong-so { border: 0; border-radius: 12px; min-height: 44px; padding: 0 14px; font-weight: 900; background: #2a2418; color: #fff; }
#snSo .dau-ds { display: flex; flex-direction: column; gap: 6px; }
#snSo .dong { border: 0; background: #fff; border-radius: 14px; min-height: 52px; padding: 6px 8px; display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; text-align: left; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
#snSo .dong i { font-style: normal; font-size: 22px; text-align: center; }
#snSo .dong b { display: block; font-size: 14.5px; }
#snSo .dong small { display: block; font-size: 11.5px; font-weight: 700; color: #7a6a4a; line-height: 1.3; }
#snSo .dong em { font-style: normal; font-weight: 900; font-size: 13px; min-width: 68px; text-align: center; border-radius: 10px; padding: 7px 6px; background: #eee7d4; color: #7a6a4a; }
#snSo .dong.co em { background: #2fbf86; color: #fff; } #snSo .dong.co { box-shadow: inset 0 0 0 2px #2fbf86; }
#snSo .dong.ko em { background: #b8475a; color: #fff; } #snSo .dong.ko b { text-decoration: line-through; opacity: .7; }
#snSo .ht-ds { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
#snSo .ht { border: 2px solid transparent; background: #fff; border-radius: 14px; min-height: 60px; padding: 6px 8px; text-align: left; display: grid; grid-template-columns: 28px 1fr; column-gap: 6px; align-items: center; }
#snSo .ht i { font-style: normal; font-size: 22px; grid-row: span 2; }
#snSo .ht b { font-size: 13.5px; line-height: 1.2; }
#snSo .ht small { font-size: 13px; letter-spacing: 2px; }
#snSo .ht.loai { opacity: .32; }
#snSo .ht.chon { border-color: #7B68EE; background: #efeaff; box-shadow: 0 0 0 3px rgba(123,104,238,.25); }
#snSo .chot { margin: 10px 2px 2px; font-size: 13.5px; font-weight: 700; color: #4a3e28; }

/* khay nút (nut.js) — tô thêm trạng thái */
#t3Khay > button { position: relative; overflow: hidden; }
#t3Khay > button .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(123,104,238,.45); pointer-events: none; }
#t3Khay > button.tat { opacity: .5; }
#t3Khay > button.co::after { content: '✓'; position: absolute; top: 2px; right: 5px; font-size: 11px; font-weight: 900; color: #4FE3B5; }
#t3Khay > button.goiy { box-shadow: 0 0 0 3px #ffd66b, 0 0 18px rgba(255,214,107,.7); animation: snGoiY 1s infinite; }
@keyframes snGoiY { 50% { transform: translateY(-3px); } }
@media (min-width: 700px) { #snDoc { top: calc(var(--sat) + 150px); } }
