:root { --c: #3FA9F5; --c2: #FFC857; --bg: #03040b; --ink: #e9f2ff; --mut: #9fb2d4; --xanh: #4fe3a0; --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(3, 5, 16, .62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
button { font: inherit; cursor: pointer; color: inherit; }

/* ---------- màn chính: hành tinh 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) + 60px) 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: 56px; height: 56px; 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.05; background: linear-gradient(180deg, #ffffff, #9fd8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo p { margin: 3px 0 0; font-weight: 800; font-size: 13.5px; opacity: .95; }
.home .mo { flex: 1; min-height: 40vh; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; }
.home .mo span { color: #cfe6ff; font-weight: 800; font-size: 12.5px; opacity: .75; text-shadow: 0 2px 8px #000; }
.sheet { background: rgba(10, 16, 36, .9); border: 1px solid rgba(140, 190, 255, .18); border-radius: 26px; padding: 14px; box-shadow: 0 -6px 30px rgba(0,0,0,.55); display: flex; flex-direction: column; gap: 9px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet h3 { margin: 6px 2px 0; font-size: 15px; display: flex; justify-content: space-between; align-items: baseline; color: #fff; }
.sheet h3 small { font-size: 13px; color: var(--mut); }
.btn { display: block; width: 100%; min-height: 52px; border: 0; border-radius: 18px; background: rgba(255,255,255,.1); color: #fff; font-weight: 800; font-size: 17px; box-shadow: 0 5px 14px rgba(0,0,0,.25); margin: 6px 0; }
.btn:disabled { opacity: .5; }
.btn.main { background: linear-gradient(160deg, #6fd3ff, #3fa9f5 45%, #2563c9); 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, .btn.vuon { text-align: left; padding: 10px 16px; margin: 0; }
.btn.ngay { background: linear-gradient(180deg, #1d2346, #11152c); box-shadow: 0 5px 14px rgba(0,0,0,.3), inset 0 0 0 1px rgba(255, 200, 87, .3); }
.btn.vuon { background: linear-gradient(180deg, #123a2c, #0b2219); box-shadow: 0 5px 14px rgba(0,0,0,.3), inset 0 0 0 1px rgba(79, 227, 160, .3); }
.btn.ngay b, .btn.vuon b { font-size: 17px; }
.btn.ngay small, .btn.vuon small { opacity: .85; line-height: 1.35; margin-top: 2px; }
.luoi { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.luoi .o { display: flex; align-items: center; gap: 8px; text-align: left; border: 0; border-radius: 15px; padding: 8px 9px; min-height: 56px; background: rgba(255,255,255,.07); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.luoi .o > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.luoi .o b { font-size: 13.5px; line-height: 1.2; }
.luoi .o small { font-size: 11.5px; color: var(--mut); font-weight: 700; line-height: 1.3; }
.luoi .o .sao { color: var(--c2); letter-spacing: 1px; }
.luoi .o.chon { box-shadow: inset 0 0 0 2px var(--c2); background: rgba(255, 200, 87, .1); }
.luoi .o.khoa { opacity: .5; }
.bi { flex: 0 0 auto; border-radius: 50%; display: inline-block; background: radial-gradient(circle at 34% 30%, rgba(255,255,255,.55), transparent 32%), radial-gradient(circle at 40% 38%, var(--a), var(--b) 70%, #05070f 100%); box-shadow: 0 0 0 2px rgba(120, 190, 255, .25), 0 0 12px rgba(120, 190, 255, .35); }
.viec { display: flex; flex-direction: column; gap: 5px; }
.viec > div { display: grid; grid-template-columns: 1fr 56px 58px; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; background: rgba(255,255,255,.06); border-radius: 12px; padding: 7px 10px; }
.viec i { height: 7px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.viec i em { display: block; height: 100%; background: linear-gradient(90deg, #6fd3ff, #4fe3a0); }
.viec b { text-align: right; color: var(--c2); font-size: 12px; }
.viec .xong span { opacity: .7; text-decoration: line-through; }
.hang { display: flex; gap: 8px; }
.link { flex: 1; border: 0; background: rgba(255,255,255,.1); color: #fff; border-radius: 14px; padding: 12px 10px; font-weight: 800; font-size: 14px; min-height: 46px; width: 100%; }
.foot { color: #b9c8e6; font-size: 13px; text-align: center; opacity: .85; margin: 6px 0 0; }
.foot a { color: #fff; }
.panel { background: rgba(10, 16, 36, .96); border: 1px solid rgba(140, 190, 255, .2); color: #fff; border-radius: 22px; padding: 20px; max-width: 480px; margin: calc(var(--sat) + 64px) auto 24px; width: calc(100% - 28px); box-shadow: 0 12px 40px rgba(0,0,0,.6); }
.panel h2 { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel h2 small { font-size: 14px; color: var(--c2); }
.panel h3 { margin: 16px 0 6px; }
.panel p, .panel li { color: #c3d2ee; font-weight: 600; line-height: 1.5; }
.panel li { margin: 6px 0; }
.panel b { color: #fff; }
.panel .luoi { margin: 10px 0; }
.panel.sach ul { padding-left: 0; list-style: none; }
.panel.sach li { background: rgba(255,255,255,.06); border-radius: 12px; padding: 9px 12px; }
.panel.sach li.chua { opacity: .5; }
.panel.sach li span { font-size: 14px; }
.nc { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.nc > i { font-style: normal; font-size: 26px; }
.nc b { display: block; font-size: 15px; }
.nc b small { color: var(--c2); letter-spacing: 1px; }
.nc em { font-style: normal; font-size: 12.5px; color: var(--mut); font-weight: 700; }
.nc button { border: 0; border-radius: 12px; padding: 10px 12px; min-height: 44px; font-weight: 900; background: linear-gradient(180deg, #6fd3ff, #2a7fd6); color: #fff; }
.nc button.thieu, .nc button:disabled { background: rgba(255,255,255,.12); color: #9fb2d4; }

/* ---------- HUD khi đang dùng ---------- */
#kqHud { position: fixed; z-index: 12; left: 8px; right: 8px; top: calc(var(--sat) + 8px); display: none; flex-direction: column; gap: 6px; pointer-events: none; }
#kqHud.on { display: flex; }
#kqHud .r1 { display: flex; align-items: center; gap: 8px; }
#kqHud .dung { pointer-events: auto; width: 52px; height: 52px; border: 0; border-radius: 15px; background: rgba(16, 24, 48, .85); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
#kqHud .dung b { font-size: 15px; line-height: 1; }
#kqHud .dung small { font-size: 10.5px; font-weight: 800; }
#kqHud .ten { flex: 1; min-width: 0; background: rgba(16, 24, 48, .7); border-radius: 15px; padding: 6px 12px; text-shadow: 0 1px 4px #000; }
#kqHud .ten b { display: block; font-size: 16px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#kqHud .ten small { font-size: 12px; font-weight: 800; color: var(--c2); }
#kqHud .nl { width: 92px; background: rgba(16, 24, 48, .7); border-radius: 15px; padding: 6px 10px; text-align: center; }
#kqHud .nl b { font-size: 16px; font-weight: 900; color: #ffe08a; }
#kqHud .nl i { display: block; height: 5px; margin: 3px 0 2px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
#kqHud .nl u { display: block; height: 100%; background: linear-gradient(90deg, #ffcf3a, #ffe08a); transition: width .2s; }
#kqHud .nl small { font-size: 11px; font-weight: 800; color: var(--mut); }
#kqHud .chuoi { display: flex; justify-content: center; gap: 5px; }
#kqHud .chuoi span { position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(16, 24, 48, .72); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.14); filter: grayscale(1); opacity: .55; }
#kqHud .chuoi span i { font-style: normal; font-size: 19px; }
#kqHud .chuoi span.xong { filter: none; opacity: 1; background: rgba(79, 227, 160, .25); box-shadow: inset 0 0 0 2px #4fe3a0; }
#kqHud .chuoi span.ke { filter: none; opacity: 1; box-shadow: inset 0 0 0 2px rgba(255, 200, 87, .6); }
#kqHud .chuoi span.dich::after { content: '🚩'; position: absolute; right: -5px; top: -7px; font-size: 13px; }
#kqHud .chuoi span.xa { opacity: .28; }
#kqHud .chuoi span u { position: absolute; inset: -3px; border-radius: 50%; background: conic-gradient(#ffc857 calc(var(--p) * 360deg), transparent 0); -webkit-mask: radial-gradient(circle, transparent 57%, #000 59%); mask: radial-gradient(circle, transparent 57%, #000 59%); }
#kqHud .giu { align-self: center; font-size: 13px; font-weight: 800; background: rgba(16, 24, 48, .72); border-radius: 12px; padding: 5px 12px; text-shadow: 0 1px 3px #000; }
#kqHud .giu b { color: #ffe08a; }
#kqHud.du .giu { background: rgba(30, 110, 70, .8); }

#kqVach { position: fixed; z-index: 12; left: 8px; right: 8px; bottom: 120px; display: none; flex-direction: column; gap: 4px; background: rgba(8, 13, 30, .74); border-radius: 16px; padding: 8px 10px; pointer-events: none; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); max-width: 560px; margin: 0 auto; }
#kqVach.on { display: flex; }
#kqVach .hang { display: grid; grid-template-columns: 92px 1fr 92px; align-items: center; gap: 8px; min-height: 26px; opacity: .72; }
#kqVach .hang.xet { opacity: 1; }
#kqVach .nhan { font-size: 12.5px; font-weight: 800; white-space: nowrap; }
#kqVach .nhan i { font-style: normal; margin-right: 4px; }
#kqVach .thanh { position: relative; height: 12px; border-radius: 6px; background: linear-gradient(90deg, rgba(120,170,255,.16), rgba(255,140,90,.16)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
#kqVach .thanh em { position: absolute; top: -2px; bottom: -2px; border-radius: 6px; background: rgba(79, 227, 160, .38); box-shadow: inset 0 0 0 1.5px rgba(79, 227, 160, .9); }
#kqVach .thanh b { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.4), 0 0 8px rgba(255,255,255,.7); transition: left .25s; }
#kqVach .thanh s { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; border: 2px dashed #ffe08a; transition: left .35s, opacity .3s; }
#kqVach .hang.sai .thanh b { background: #ffb04a; }
#kqVach .hang.ok .thanh b { background: #4fe3a0; }
#kqVach .so { text-align: right; line-height: 1.1; }
#kqVach .so b { display: block; font-size: 13.5px; font-weight: 900; }
#kqVach .so small { font-size: 10.5px; font-weight: 800; color: var(--mut); white-space: nowrap; }
#kqVach .hang.ok .so small { color: var(--xanh); }
#kqVach .hang.sai .so small { color: #ffc27a; }

#kqBan { position: fixed; z-index: 15; left: 50%; bottom: 300px; transform: translate(-50%, 8px); width: min(92vw, 420px); display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 18px; background: rgba(12, 22, 50, .9); box-shadow: 0 10px 30px rgba(0,0,0,.5), inset 0 0 0 1.5px rgba(255, 200, 87, .45); opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; }
#kqBan.on { opacity: 1; transform: translate(-50%, 0); }
#kqBan > i { font-style: normal; font-size: 36px; }
#kqBan b { display: block; font-size: 18px; font-weight: 900; color: #ffe08a; }
#kqBan span { display: block; font-size: 13px; font-weight: 700; color: #d6e4ff; line-height: 1.4; margin-top: 2px; }
#kqBan.mua { background: linear-gradient(135deg, rgba(20, 60, 120, .95), rgba(10, 30, 70, .95)); box-shadow: 0 10px 30px rgba(0,0,0,.5), inset 0 0 0 2px #6fd3ff; }
#kqBan.mua b { color: #bfeaff; font-size: 20px; }
#kqBan.do { background: rgba(80, 14, 20, .94); box-shadow: 0 10px 30px rgba(0,0,0,.5), inset 0 0 0 2px #ff6a5a; }
#kqBan.do b { color: #ffb4a8; }
#kqCanh { position: fixed; z-index: 13; left: 50%; top: calc(var(--hudDay, 130px) + 6px); transform: translateX(-50%); max-width: 92vw; padding: 6px 12px; border-radius: 12px; background: rgba(90, 30, 10, .88); color: #ffd6b0; font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: none; pointer-events: none; }
#kqCanh.on { display: block; animation: kqRung .4s; }
#kqGoi { position: fixed; z-index: 13; left: 50%; top: calc(var(--hudDay, 130px) + 40px); transform: translateX(-50%); padding: 8px 14px; border-radius: 14px; background: rgba(255, 200, 87, .95); color: #2a1e04; font-size: 14px; font-weight: 800; white-space: nowrap; display: none; pointer-events: none; box-shadow: 0 6px 16px rgba(0,0,0,.4); }
#kqGoi.on { display: block; animation: kqNhip 1.2s infinite; }
#kqNoi { position: fixed; inset: 0; z-index: 14; pointer-events: none; overflow: hidden; }
#kqNoi .noi { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 16px; color: #fff; text-shadow: 0 2px 6px #000, 0 0 12px rgba(0,0,0,.6); white-space: nowrap; animation: kqNoi 1.6s ease-out forwards; }
#kqNoi .noi.lam { color: #9fe3ff; }
#kqNoi .noi.xanh { color: #8dffbf; }
@keyframes kqNoi { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -230%) scale(1); } }
@keyframes kqNhip { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.04); } }
@keyframes kqRung { 0%, 100% { transform: translateX(-50%); } 25% { transform: translateX(-52%); } 75% { transform: translateX(-48%); } }

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

/* khay công cụ (nut.js) */
#t3Khay > button { position: relative; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.4), inset 0 0 0 1px rgba(140, 190, 255, .2); }
#t3Khay > button em { font-style: normal; font-size: 10.5px; font-weight: 900; color: #ffe08a; line-height: 1; }
#t3Khay > button.on em { color: #5a3a00; }
#t3Khay > button.on { color: #2a1e04; }
#t3Khay > button .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(63, 169, 245, .35); pointer-events: none; }
#t3Khay > button.thieu { opacity: .5; }
#t3Khay > button.khoa { opacity: .32; }
#t3Khay > button.goiy { opacity: 1; animation: kqGoiY 1s infinite; }
@keyframes kqGoiY { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 200, 87, .9), 0 4px 14px rgba(0,0,0,.4); } 50% { box-shadow: 0 0 0 6px rgba(255, 200, 87, 0), 0 4px 14px rgba(0,0,0,.4); } }
@media (min-width: 700px) { #kqHud { left: 50%; right: auto; width: 560px; transform: translateX(-50%); } }
@media (max-height: 700px) { #kqHud .chuoi span { width: 32px; height: 32px; } #kqHud .chuoi span i { font-size: 16px; } #kqVach .hang { min-height: 22px; } }
