:root { --c: #2F9FD0; --c2: #FFC93C; --bg: #13324A; --ink: #14203d; --mut: #5d6a8a; --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(10, 22, 40, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
button { font: inherit; cursor: pointer; color: inherit; }

/* ---------- màn chính: cả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,.6); }
.logo img { width: 58px; height: 58px; border-radius: 16px; box-shadow: 0 8px 22px rgba(0,0,0,.4); }
.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; }
.sheet { background: rgba(246, 250, 255, .96); border-radius: 26px; padding: 14px; box-shadow: 0 -6px 30px rgba(0,0,0,.4); 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.main { background: linear-gradient(180deg, #5cc8f0, #2f9fd0 60%, #1d78b0); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.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, #1d4a6e, #13324a); color: #fff; text-align: left; padding: 10px 16px; margin: 0; }
.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: 74px; 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.chon { border-color: #2f9fd0; background: #e6f5fd; }
.luoi .o.khoa { opacity: .62; }
.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: #e2eaf2; overflow: hidden; }
.viec div i em { display: block; height: 100%; background: linear-gradient(90deg, #2f9fd0, #7fe0c0); }
.viec div b { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: #1d78b0; font-size: 13px; }
.viec div.xong { background: #e6f7ef; }
.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: #f6faff; 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,.4); }
.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: #1d78b0; }
.panel h2 small { font-size: 14px; color: #1d78b0; }
.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 b { color: var(--ink); }
.panel li.chua { opacity: .6; }
.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: #1d78b0; 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; }
.nc button[disabled] { background: #eadfd6; color: #8a7a70; }

/* ---------- HUD trong lượt ---------- */
#ttTren { position: fixed; left: 0; right: 0; top: 0; z-index: 8; display: none; padding: calc(var(--sat) + 8px) 10px 0; pointer-events: none; }
#ttTren.on { display: block; }
#ttTren .r1 { display: grid; grid-template-columns: 62px 1fr auto; gap: 8px; align-items: center; }
#ttTren .dung { pointer-events: auto; border: 0; border-radius: 14px; min-height: 48px; background: rgba(10,24,44,.62); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
#ttTren .dung b { font-size: 15px; } #ttTren .dung small { font-size: 11px; font-weight: 800; margin-top: 3px; }
#ttTren .ten { background: rgba(246,250,255,.93); border-radius: 14px; padding: 6px 10px; min-height: 48px; box-shadow: 0 3px 10px rgba(0,0,0,.25); min-width: 0; }
#ttTren .ten b { display: block; font-size: 15px; font-weight: 900; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ttTren .ten small { display: block; font-size: 12px; font-weight: 700; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ttTren .so { text-align: right; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.8); min-width: 64px; max-width: 96px; }
#ttTren .so b { display: block; font-size: 25px; font-weight: 900; line-height: 1; }
#ttTren .so small { display: block; font-size: 11px; font-weight: 800; line-height: 1.15; }
#ttTren .thanh { margin-top: 7px; position: relative; height: 24px; border-radius: 12px; background: rgba(10,24,44,.62); overflow: hidden; border: 1.5px solid rgba(255,255,255,.3); }
#ttTren .thanh i { position: absolute; inset: 0; }
#ttTren .thanh em { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2f9fd0, #7fe0c0); transition: width .25s; }
#ttTren .thanh.canh em { background: linear-gradient(90deg, #ffb020, #ffd36b); }
#ttTren .thanh span { position: absolute; inset: 0; text-align: center; font-size: 12.5px; line-height: 21px; color: #fff; font-weight: 800; text-shadow: 0 1px 3px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; }

/* bảng dưới: khay đồ + nút một ngón */
#ttDuoi { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; display: none; padding: 8px 10px calc(var(--sab) + 10px); background: linear-gradient(180deg, rgba(10,24,44,0), rgba(10,24,44,.72) 22%); }
#ttDuoi.on { display: block; }
#ttDuoi .khay { display: flex; gap: 7px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 4px 2px 8px; scroll-snap-type: x proximity; scrollbar-width: none; touch-action: pan-x; }
#ttDuoi .khay::-webkit-scrollbar { display: none; }
#ttDuoi.rot .khay { display: none; }
#ttDuoi .khay .the { flex: 0 0 auto; width: 92px; min-height: 76px; border: 0; border-radius: 16px; background: #fff; padding: 6px 6px 7px; text-align: center; box-shadow: 0 3px 10px rgba(0,0,0,.25); border-bottom: 5px solid var(--m); scroll-snap-align: center; transition: transform .12s; }
#ttDuoi .khay .the i { display: block; font-style: normal; font-size: 24px; line-height: 1.1; }
#ttDuoi .khay .the b { display: block; font-size: 12px; font-weight: 900; line-height: 1.2; margin-top: 2px; }
#ttDuoi .khay .the small { display: block; font-size: 10.5px; font-weight: 700; color: var(--mut); margin-top: 2px; }
#ttDuoi .khay .the.chon { transform: translateY(-5px); box-shadow: 0 0 0 3px #ffd34d, 0 8px 18px rgba(0,0,0,.35); }
#ttDuoi .khay .the.t-vo small { color: #c8341a; } #ttDuoi .khay .the.t-nang small { color: #3e4a5c; } #ttDuoi .khay .the.t-dung small { color: #1d78b0; }
#ttDuoi .khay .het { color: #fff; font-weight: 800; margin: 18px auto; text-shadow: 0 1px 3px #000; }
#ttDuoi .hang { display: flex; gap: 7px; margin-top: 6px; }
#ttDuoi .hang:empty { display: none; }
#ttDuoi .hang button { flex: 1; border: 0; border-radius: 16px; min-height: 52px; padding: 5px 4px; background: rgba(246,250,255,.95); color: var(--ink); font-weight: 900; box-shadow: 0 3px 10px rgba(0,0,0,.25); line-height: 1.1; touch-action: manipulation; }
#ttDuoi .hang button b { display: block; font-size: 15px; }
#ttDuoi .hang button small { display: block; font-size: 10.5px; font-weight: 700; color: var(--mut); margin-top: 2px; }
#ttDuoi .h1 button.chinh { flex: 1.5; background: linear-gradient(180deg, #ffd34d, #f0a820); color: #3a2a08; }
#ttDuoi .h1 button.chinh b { font-size: 19px; }
#ttDuoi .h2 button { min-height: 44px; background: rgba(20,40,66,.85); color: #fff; }
#ttDuoi .h2 button b { font-size: 12.5px; }
#ttDuoi .hang button.tat { opacity: .45; filter: grayscale(.6); }
#ttDuoi.rot .h1 button { min-height: 58px; }

/* nhãn bình */
#ttNhan { position: fixed; left: 0; top: 0; z-index: 7; }
#ttNhan .nb { position: absolute; left: 0; top: 0; margin-left: -31px; margin-top: -40px; width: 62px; text-align: center; background: rgba(246,250,255,.92); border-radius: 10px; padding: 3px 2px; box-shadow: 0 2px 8px rgba(0,0,0,.25); cursor: pointer; line-height: 1.1; }
#ttNhan .nb b { display: block; font-size: 12.5px; font-weight: 900; white-space: nowrap; }
#ttNhan .nb small { font-size: 10.5px; font-weight: 800; color: var(--mut); }
#ttNhan .nb.dung { background: #b8f5cf; box-shadow: 0 0 0 2px #2fbf6a; }
#ttNhan .nb.chon { background: #ffe27a; }
#ttNhan .nb.phu { background: rgba(20,40,66,.85); color: #fff; margin-top: -78px; }
#ttNhan .nb.phu small { color: #cfe4ff; }

#ttBan { position: fixed; left: 50%; top: calc(var(--sat) + 104px); transform: translate(-50%, -10px); z-index: 9; text-align: center; pointer-events: none; opacity: 0; transition: opacity .25s, transform .25s; width: min(80vw, 440px); }
#ttBan.on { opacity: 1; transform: translate(-50%, 0); }
#ttBan b { display: block; color: #fff; font-size: 24px; font-weight: 900; text-shadow: 0 3px 10px rgba(0,0,0,.85), 0 0 2px #000; line-height: 1.15; }
#ttBan span { display: inline-block; margin-top: 6px; background: rgba(10,24,44,.75); color: #fff; padding: 6px 12px; border-radius: 12px; font-size: 13.5px; font-weight: 700; line-height: 1.35; }
#ttTay { position: fixed; left: 0; top: 0; z-index: 10; pointer-events: none; display: none; }
#ttTay.on { display: block; }
#ttTay i { position: absolute; left: -14px; top: -4px; font-style: normal; font-size: 40px; animation: ttTayA 1.1s infinite; filter: drop-shadow(0 3px 4px rgba(0,0,0,.5)); }
#ttTay span { position: absolute; top: -92px; width: 220px; text-align: center; background: rgba(255,250,235,.96); color: #14203d; padding: 7px 10px; border-radius: 12px; font-size: 14px; font-weight: 800; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
#ttTay.duoi span { top: 46px; }
@keyframes ttTayA { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }

/* thẻ xong chặng */
#ttThe { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; display: none; padding: 0 12px calc(var(--sab) + 12px); }
#ttThe.on { display: block; animation: ttLen .3s ease-out; }
@keyframes ttLen { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
#ttThe .hop { max-width: 460px; margin: 0 auto; background: rgba(246,250,255,.97); border-radius: 24px; padding: 14px 16px; box-shadow: 0 -6px 30px rgba(0,0,0,.45); }
#ttThe .sao { text-align: center; font-size: 38px; letter-spacing: 4px; color: #ffb21a; text-shadow: 0 2px 0 #b86a00; line-height: 1; }
#ttThe .sao.s0 { color: #b8c4d2; text-shadow: none; }
#ttThe h3 { margin: 6px 0 0; text-align: center; font-size: 20px; }
#ttThe p { margin: 2px 0 6px; text-align: center; color: var(--mut); font-weight: 700; font-size: 14px; }
#ttThe ul { list-style: none; padding: 0; margin: 0 0 6px; }
#ttThe li { font-weight: 800; font-size: 14px; padding: 3px 0; }
#ttThe li.tot { color: #1f8a4a; } #ttThe li.vua { color: #b5761a; }
#ttThe .dg { text-align: center; margin: 4px 0; } #ttThe .dg b { font-size: 28px; color: #1d78b0; } #ttThe .dg small { display: block; color: var(--mut); font-weight: 700; font-size: 12.5px; }
#ttThe .btn { min-height: 56px; margin: 6px 0 0; }

/* màn chính: thẻ chế độ + kho */
.tab { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #e2eaf2; border-radius: 16px; padding: 4px; margin-top: 4px; }
.tab button { border: 0; border-radius: 13px; min-height: 46px; background: transparent; font-weight: 900; font-size: 15px; }
.tab button small { display: block; font-size: 11.5px; font-weight: 700; color: var(--mut); }
.tab button.chon { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.nc i.mau { display: block; width: 32px; height: 32px; border-radius: 10px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: #fff; border-radius: 10px; padding: 4px 8px; font-size: 12.5px; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.08); display: inline-flex; align-items: center; gap: 5px; }
.chip.chua { opacity: .5; }
.chip i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
