* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #04192f; overflow: hidden; font-family: Tahoma, 'Segoe UI', Arial, sans-serif; color: #fff; }
button, input { font-family: inherit; }
#app { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
#stage { position: absolute; left: 0; top: 0; width: 800px; height: 600px; transform-origin: 0 0; overflow: hidden; background: #0a5fb4; user-select: none; -webkit-user-select: none; }
.scr { position: absolute; inset: 0; background-size: 800px 600px; }
.hide { display: none !important; }

/* ---------- nut ---------- */
.btn { border: 2px solid #0b3d7a; border-radius: 7px; background: linear-gradient(#5ec8ff, #1f86e0); color: #fff; font-weight: bold;
  font-size: 13px; cursor: pointer; text-shadow: 0 1px 1px #0a3a70; box-shadow: inset 0 1px 0 #b9ecff, 0 2px 0 #062f5c; padding: 4px 8px; }
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); box-shadow: inset 0 1px 0 #b9ecff; }
.btn.y { background: linear-gradient(#ffe259, #ff9f1a); border-color: #8a4b00; text-shadow: 0 1px 1px #8a4b00; box-shadow: inset 0 1px 0 #fff3b0, 0 2px 0 #6b3a00; }
.btn.g { background: linear-gradient(#8cf07a, #2fb52a); border-color: #145c10; text-shadow: 0 1px 1px #145c10; }
.btn.r { background: linear-gradient(#ff8a80, #e0362c); border-color: #6d0f0a; text-shadow: 0 1px 1px #6d0f0a; }
.btn.sm { font-size: 11px; padding: 2px 6px; border-radius: 5px; }
.btn:disabled { filter: grayscale(0.8) brightness(0.8); cursor: default; }
input { border: 1px solid #0b3d7a; border-radius: 4px; background: #062a55; color: #fff; padding: 4px 6px; font-size: 13px; outline: none; }
input:focus { border-color: #ffd54f; }
input::placeholder { color: #7fa9d6; }

/* ---------- dang nhap ---------- */
#scr-login { background-image: url(../res/img/LoginStage/CAStage.jpg); }
.login-box { position: absolute; left: 255px; top: 385px; width: 290px; padding: 8px 12px 8px; background: rgba(6, 40, 90, 0.82);
  border: 2px solid #ffd54f; border-radius: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.5); }
.login-title { text-align: center; font-weight: bold; color: #ffeb3b; font-size: 13px; margin-bottom: 4px; text-shadow: 0 1px 2px #000; }
.login-tabs { display: flex; gap: 3px; margin-bottom: 5px; }
.login-tabs button { flex: 1; font-size: 11px; padding: 3px 0; border-radius: 6px 6px 0 0; border: 1px solid #0b3d7a; background: #0d4a8c; color: #b5d8ff; cursor: pointer; }
.login-tabs button.on { background: #ffb300; color: #3a2000; font-weight: bold; }
.ltab { display: flex; flex-direction: column; gap: 4px; }
.ltab input { height: 26px; }
.ltab .btn { height: 28px; font-size: 14px; }
.login-msg { min-height: 16px; font-size: 11px; color: #ffcdd2; text-align: center; margin-top: 3px; }
.login-btns { position: absolute; left: 184px; top: 556px; width: 432px; height: 34px; display: flex; gap: 3px; }
.login-btns .lb { flex: 1; border: 0; background: transparent; color: #fff; font-weight: bold; font-size: 12px; cursor: pointer; text-shadow: 0 1px 2px #000; border-radius: 4px; }
.login-btns .lb:hover { background: rgba(255,255,255,.18); color: #ffeb3b; }
.login-online { position: absolute; left: 10px; top: 578px; font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000; }

/* ---------- sanh ---------- */
#scr-lobby { background-image: url(../res/img/Lobby/CAStage.jpg); }
.ticker { position: absolute; left: 218px; top: 5px; width: 550px; height: 20px; overflow: hidden; white-space: nowrap; font-size: 12px; line-height: 20px; color: #ffeb3b; }
.ticker span { display: inline-block; padding-left: 100%; animation: tick 22s linear infinite; }
@keyframes tick { to { transform: translateX(-100%); } }
.lb-nick { position: absolute; left: 32px; top: 148px; width: 138px; height: 16px; font-size: 12px; font-weight: bold; text-align: center; color: #ffeb3b; line-height: 16px; overflow: hidden; }
.lb-avatar { position: absolute; left: 100px; top: 186px; width: 0; height: 0; }
.lb-me1 { position: absolute; left: 34px; top: 201px; width: 126px; height: 20px; font-size: 11px; line-height: 20px; padding-left: 20px; overflow: hidden; }
.lb-me2 { position: absolute; left: 34px; top: 228px; width: 136px; height: 16px; font-size: 10px; line-height: 16px; color: #bfe3ff; overflow: hidden; }
.lb-users { position: absolute; left: 40px; top: 288px; width: 124px; height: 230px; overflow-y: auto; scrollbar-width: none; }
.lb-users::-webkit-scrollbar { display: none; }
.lb-users div { height: 23px; line-height: 21px; font-size: 11px; padding-left: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.lb-users div b { position: absolute; left: 5px; top: 3px; width: 14px; height: 14px; font-size: 9px; line-height: 14px; text-align: center; background: #ffb300; color: #3a2000; border-radius: 3px; }
.lb-users div.gm { color: #ffeb3b; }
.lb-tab { position: absolute; top: 66px; width: 184px; height: 44px; display: flex; gap: 6px; padding: 4px; }
.lb-tab.t1 { left: 215px; } .lb-tab.t2 { left: 405px; }
.lb-tab .btn { flex: 1; font-size: 12px; }
.lb-right { position: absolute; left: 598px; top: 42px; width: 188px; height: 72px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; }
#lbServer { width: 100%; font-size: 11px; color: #e3f2ff; height: 16px; overflow: hidden; white-space: nowrap; }
.lb-right .btn { height: 23px; }
.rooms { position: absolute; left: 218px; top: 125px; width: 549px; height: 249px; display: grid; grid-template-columns: 272px 272px; grid-auto-rows: 80px; gap: 4px 5px; }
.room { border-radius: 6px; padding: 6px 8px; cursor: pointer; position: relative; font-size: 12px; overflow: hidden; }
.room:hover { background: rgba(255,255,255,.12); }
.room .rno { position: absolute; left: 8px; top: 6px; background: #ffb300; color: #3a2000; font-weight: bold; font-size: 11px; padding: 0 5px; border-radius: 4px; }
.room .rt { position: absolute; left: 52px; top: 5px; right: 30px; font-weight: bold; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room .rl { position: absolute; right: 8px; top: 4px; font-size: 13px; }
.room .rm { position: absolute; left: 8px; top: 30px; color: #9fd4ff; font-size: 11px; }
.room .rs { position: absolute; left: 8px; bottom: 6px; font-size: 11px; font-weight: bold; }
.room .rs.wait { color: #b9f6ca; } .room .rs.play { color: #ff8a80; }
.room .rn { position: absolute; right: 10px; bottom: 6px; font-size: 18px; font-weight: bold; color: #ffeb3b; }
.room.empty { cursor: default; } .room.empty:hover { background: none; }
.pager { position: absolute; left: 372px; top: 382px; width: 240px; height: 19px; display: flex; justify-content: center; align-items: center; gap: 14px; font-size: 12px; }
.pager button { background: none; border: 0; color: #fff; cursor: pointer; font-size: 12px; }
.chatlog { position: absolute; overflow-y: auto; font-size: 12px; line-height: 16px; padding: 4px 6px; word-break: break-word; scrollbar-width: thin; }
.chatlog .sys { color: #ffeb3b; } .chatlog .ntc { color: #ff8a80; font-weight: bold; } .chatlog .me b { color: #b9f6ca; }
.chatlog b { color: #9fe0ff; }
.lb-chat { left: 214px; top: 425px; width: 530px; height: 92px; }
.chatin { position: absolute; height: 24px; background: #08376d; border-color: #0a2a52; font-size: 12px; }
.lb-in { left: 360px; top: 526px; width: 355px; }
.lb-send { position: absolute; left: 250px; top: 527px; width: 102px; height: 22px; }

/* ---------- phong cho ---------- */
#scr-room { background-image: url(../res/img/Prepare/CAStage.jpg); }
.rm-title { position: absolute; left: 130px; top: 5px; width: 540px; height: 18px; font-size: 13px; font-weight: bold; text-align: center; color: #ffeb3b; line-height: 18px; overflow: hidden; }
.rm-head { position: absolute; left: 24px; top: 60px; width: 424px; height: 24px; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.rm-no { display: inline-block; width: 46px; height: 17px; text-align: center; font-weight: bold; font-size: 11px; line-height: 17px; color: #fff; }
.rm-mode { flex: 1; font-weight: bold; color: #ffeb3b; }
.slots { position: absolute; left: 28px; top: 95px; width: 416px; height: 285px; }
.slot { position: absolute; width: 96px; height: 137px; cursor: pointer; }
.slot .card { position: absolute; left: 0; top: 0; width: 96px; height: 95px; border-radius: 6px; overflow: hidden; }
.slot canvas { position: absolute; left: 8px; top: 4px; width: 80px; height: 88px; }
.slot .sn { position: absolute; left: 0; top: 100px; width: 96px; height: 19px; font-size: 11px; font-weight: bold; text-align: center; line-height: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .sl { position: absolute; left: 0; top: 121px; width: 96px; height: 16px; font-size: 10px; text-align: center; line-height: 16px; color: #bfe3ff; }
.slot .host { position: absolute; left: 4px; top: 4px; background: #ffb300; color: #3a2000; font-size: 9px; font-weight: bold; padding: 0 4px; border-radius: 3px; z-index: 2; }
.slot .rdy { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; z-index: 2; }
.slot .rdy span { background: #ff6f00; color: #fff; font-weight: bold; font-size: 12px; padding: 1px 8px; border-radius: 9px; border: 2px solid #fff3; }
.slot .team { position: absolute; right: 4px; top: 4px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; z-index: 2; }
.slot .closed { position: absolute; inset: 0; background: rgba(0, 20, 60, .75) url() center no-repeat; display: flex; align-items: center; justify-content: center; font-weight: bold; color: #6f93c0; font-size: 26px; }
.slot .open { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #ffffffb0; font-size: 12px; font-weight: bold; text-shadow: 0 1px 2px #036; }
.slot.me .card { box-shadow: 0 0 0 3px #ffeb3b inset; }
.rm-chat { left: 22px; top: 408px; width: 400px; height: 106px; }
.rm-in { left: 139px; top: 521px; width: 254px; }
.rm-send { position: absolute; left: 30px; top: 522px; width: 100px; height: 22px; }
.chars { position: absolute; left: 484px; top: 62px; width: 292px; height: 194px; display: grid; grid-template-columns: repeat(7, 40px); grid-auto-rows: 47px; gap: 1px 2px; overflow-y: auto; scrollbar-width: none; }
.chars::-webkit-scrollbar { display: none; }
.ch { position: relative; border-radius: 5px; cursor: pointer; overflow: hidden; background: rgba(255,255,255,.05); }
.ch canvas { width: 40px; height: 47px; }
.ch:hover { background: rgba(255,255,255,.18); }
.ch.on { background: rgba(255, 213, 79, .45); box-shadow: 0 0 0 2px #ffd54f inset; }
.ch .nm { position: absolute; bottom: 0; left: 0; right: 0; font-size: 8px; text-align: center; background: rgba(0,0,0,.45); white-space: nowrap; overflow: hidden; }
.teams { position: absolute; left: 486px; top: 276px; width: 288px; height: 46px; display: flex; gap: 6px; align-items: center; justify-content: center; font-size: 12px; }
.teams button { width: 60px; height: 34px; border-radius: 8px; border: 2px solid #fff6; color: #fff; font-weight: bold; cursor: pointer; font-size: 11px; }
.teams button.on { border-color: #fff; box-shadow: 0 0 0 2px #ffeb3b; }
.rm-map { position: absolute; left: 487px; top: 348px; width: 152px; height: 132px; border-radius: 4px; }
.rm-mapinfo { position: absolute; left: 645px; top: 348px; width: 126px; font-size: 11px; }
.rm-mapinfo div { height: 19px; line-height: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rmMapName { font-weight: bold; color: #ffeb3b; }
.rm-mapbtn { position: absolute; left: 645px; top: 427px; width: 125px; height: 50px; font-size: 12px; line-height: 15px; }
.rm-start { position: absolute; left: 510px; top: 497px; width: 198px; height: 50px; font-size: 20px; letter-spacing: 1px; }
.rm-start.ready { background: linear-gradient(#ff8a80, #e0362c); border-color: #6d0f0a; }

/* ---------- man choi ---------- */
#scr-game { background: #0a5fb4; }
#cv { position: absolute; left: 0; top: 0; width: 800px; height: 600px; image-rendering: pixelated; }
.gchat { position: absolute; left: 24px; top: 44px; width: 420px; font-size: 12px; pointer-events: none; text-shadow: 0 1px 2px #000, 0 0 2px #000; }
.gchat div { animation: fadechat 7s forwards; }
@keyframes fadechat { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
.g-in { left: 24px; top: 532px; width: 360px; }
.g-exit { position: absolute; left: 676px; top: 563px; width: 84px; height: 28px; }
.compact .g-exit { left: 558px; top: 44px; width: 60px; height: 24px; opacity: .85; }
.compact .result { left: 120px; top: 90px; }
.result { position: absolute; left: 120px; top: 120px; width: 400px; background: rgba(4, 30, 70, .92); border: 3px solid #ffd54f; border-radius: 14px; padding: 10px 14px; box-shadow: 0 6px 30px #000a; }
.result h2 { margin: 0 0 8px; text-align: center; font-size: 24px; color: #ffeb3b; text-shadow: 0 2px 0 #b35900; }
.result table { width: 100%; border-collapse: collapse; font-size: 12px; }
.result td { padding: 4px; border-bottom: 1px solid #ffffff22; }
.result tr.win td { color: #ffeb3b; font-weight: bold; }
.result .lvup { color: #69f0ae; font-weight: bold; }

/* ---------- hop thoai ---------- */
.modal { position: absolute; inset: 0; background: rgba(0, 10, 30, .55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.mbox { min-width: 300px; max-width: 700px; max-height: 540px; background: linear-gradient(#1b7fd6, #0b4c96); border: 3px solid #8fd3ff; border-radius: 12px; box-shadow: 0 8px 30px #000a; display: flex; flex-direction: column; }
.mtitle { padding: 6px 12px; font-weight: bold; font-size: 14px; color: #ffeb3b; border-bottom: 2px solid #ffffff30; }
.mbody { padding: 10px 12px; overflow: auto; font-size: 13px; }
.mbody .row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.mbody .row label { width: 110px; }
.mbody .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.mbody table { border-collapse: collapse; width: 100%; font-size: 12px; }
.mbody th { text-align: left; color: #ffeb3b; padding: 3px; border-bottom: 1px solid #ffffff40; }
.mbody td { padding: 3px; border-bottom: 1px solid #ffffff18; }
.maplist { display: grid; grid-template-columns: repeat(5, 116px); gap: 6px; }
.mapit { cursor: pointer; border-radius: 6px; padding: 3px; background: rgba(0,0,0,.2); text-align: center; font-size: 10px; }
.mapit:hover, .mapit.on { background: rgba(255, 213, 79, .4); }
.mapit img { width: 110px; height: 95px; display: block; border-radius: 4px; image-rendering: pixelated; }
.themes { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.themes button { font-size: 11px; }
.themes button.on { background: linear-gradient(#ffe259, #ff9f1a); color: #3a2000; }
#toast { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 4px; align-items: center; pointer-events: none; }
#toast div { background: rgba(0, 0, 0, .78); border: 1px solid #ffd54f; color: #fff; padding: 6px 14px; border-radius: 16px; font-size: 13px; animation: fadechat 4s forwards; }
#toast div.notice { background: #b71c1c; border-color: #fff; font-weight: bold; }

/* ---------- cua hang ---------- */
.shop { display: flex; gap: 10px; width: 660px; height: 420px; }
.sh-left { width: 170px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.sh-prev { width: 150px; height: 150px; background: radial-gradient(#3a9df0, #0b4c96); border-radius: 12px; border: 2px solid #8fd3ff; image-rendering: pixelated; }
.sh-money { font-size: 13px; background: rgba(0,0,0,.3); padding: 3px 10px; border-radius: 10px; }
.sh-money b { color: #ffd740; }
.sh-info { width: 100%; font-size: 12px; display: flex; flex-direction: column; gap: 5px; align-items: center; text-align: center; }
.sh-name { font-weight: bold; font-size: 14px; }
.sh-rar, .sh-exp, .sh-hint { color: #bfe3ff; font-size: 11px; }
.sh-buy { display: flex; gap: 3px; }
.sh-buy .btn { font-size: 10px; padding: 2px 4px; line-height: 13px; }
.sh-right { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sh-tabs { display: flex; gap: 3px; }
.sh-tabs button { flex: 1; font-size: 11px; padding: 4px 0; border-radius: 6px 6px 0 0; border: 1px solid #0b3d7a; background: #0d4a8c; color: #b5d8ff; cursor: pointer; font-weight: bold; }
.sh-tabs button.on { background: #ffb300; color: #3a2000; }
.sh-grid { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); grid-auto-rows: 86px; gap: 5px; overflow: hidden; }
.sh-it { background: rgba(0,0,0,.25); border: 2px solid #555; border-radius: 8px; display: flex; flex-direction: column; align-items: center; cursor: pointer; padding: 2px; position: relative; }
.sh-it:hover { background: rgba(255,255,255,.12); }
.sh-it.on { background: rgba(255, 213, 79, .3); }
.sh-it.worn::after { content: '✔'; position: absolute; right: 4px; top: 2px; color: #69f0ae; font-weight: bold; }
.sh-it canvas { width: 50px; height: 50px; image-rendering: pixelated; }
.sh-it .nm { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sh-it .pr { font-size: 11px; font-weight: bold; }
.sh-empty { grid-column: 1 / -1; color: #bfe3ff; text-align: center; padding-top: 40px; }
.sh-pager { display: flex; justify-content: center; gap: 14px; align-items: center; font-size: 12px; }
.sh-pager button { background: none; border: 0; color: #fff; cursor: pointer; font-size: 14px; }
.modelist { display: grid; grid-template-columns: repeat(5, 120px); gap: 8px; }
.modelist button { height: 76px; font-size: 13px; line-height: 17px; }
.modelist button small { font-weight: normal; font-size: 10px; display: block; opacity: .85; }

/* ---------- cam ung ---------- */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.tpad { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: 18px; width: 150px; height: 150px; pointer-events: auto; }
.tpad-ring { position: absolute; inset: 0; border-radius: 50%; background: rgba(255,255,255,.12); border: 3px solid rgba(255,255,255,.35); }
.tpad-knob { position: absolute; left: 47px; top: 47px; width: 56px; height: 56px; border-radius: 50%; background: radial-gradient(#ffffffd0, #8fd3ffa0); box-shadow: 0 2px 8px #0008; }
.tbtns { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: 18px; width: 190px; height: 150px; pointer-events: auto; }
.tbtns button { position: absolute; border-radius: 50%; border: 3px solid #fff8; color: #fff; font-weight: bold; text-shadow: 0 1px 2px #000; }
.tb-bomb { right: 0; bottom: 0; width: 110px; height: 110px; font-size: 22px; background: radial-gradient(#7fd8ff, #1167c9); }
.tb-item { left: 0; top: 0; width: 66px; height: 66px; font-size: 14px; background: radial-gradient(#ffe082, #f57c00); }
.tbtns button.on { filter: brightness(1.4); transform: scale(.94); }
/* may tinh: chi hien nut BOM/KIM noi ben phai, co the chinh kich thuoc / do trong suot */
#touch.pc .tpad { display: none; }
#touch.pc .tbtns { transform: scale(var(--tbs, 1)); transform-origin: right bottom; opacity: var(--tbo, .85); bottom: 24px; right: 20px; width: 110px; height: 190px; }
#touch.pc .tb-item { left: auto; right: 22px; top: 0; }
#touch.pc .tbtns button { cursor: pointer; user-select: none; }
#touch.pc .tbtns button:hover { filter: brightness(1.15); }
.g-set { position: absolute; left: 640px; top: 563px; width: 30px; height: 28px; }
.compact .g-set { left: 524px; top: 44px; width: 30px; height: 24px; opacity: .85; }
#rotate { position: fixed; inset: 0; z-index: 90; background: #04192f; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 18px; gap: 12px; text-align: center; padding: 20px; }
#rotate div { font-size: 54px; }
#loading { position: fixed; inset: 0; z-index: 99; background: radial-gradient(#1b7fd6, #04192f); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.ld-logo { font-size: 64px; font-weight: 900; color: #ffeb3b; text-shadow: 0 4px 0 #e65100, 0 8px 20px #000; letter-spacing: 4px; }
.ld-bar { width: 260px; height: 14px; border: 2px solid #fff; border-radius: 8px; overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffeb3b, #ff9800); transition: width .2s; }
#ldText { font-size: 13px; color: #bfe3ff; }
