* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #07080d; color: #eee;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; user-select: none; -webkit-user-select: none;
  touch-action: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; }
.hidden { display: none !important; }
:root { --gold: #e6c16a; --gold2: #b8862f; --glass: rgba(12, 14, 22, 0.78); --line: rgba(230, 193, 106, 0.35); }

#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }

/* ---------- Đăng nhập ---------- */
#login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20;
  background: radial-gradient(ellipse at 50% 30%, #26314f 0%, #121626 45%, #06070b 100%); overflow: auto; }
.embers { position: absolute; inset: 0; pointer-events: none; background-image:
  radial-gradient(2px 2px at 20% 80%, #ffb347aa, transparent), radial-gradient(2px 2px at 70% 60%, #ffd27aaa, transparent),
  radial-gradient(1.5px 1.5px at 40% 30%, #ffcf8faa, transparent), radial-gradient(2px 2px at 85% 20%, #ff9a5aaa, transparent),
  radial-gradient(1.5px 1.5px at 10% 40%, #fff0c0aa, transparent), radial-gradient(2px 2px at 55% 90%, #ffb347aa, transparent);
  animation: rise 9s linear infinite; }
@keyframes rise { from { background-position: 0 0; } to { background-position: 0 -600px; } }
.login-box { position: relative; width: min(420px, 92vw); padding: 22px 22px 18px; border-radius: 18px;
  background: rgba(10, 12, 20, 0.72); border: 1px solid var(--line); box-shadow: 0 20px 60px #000a, inset 0 0 40px #e6c16a10;
  backdrop-filter: blur(6px); display: flex; flex-direction: column; gap: 10px; margin: 16px; }
.logo { margin: 0; text-align: center; font-family: Georgia, "Times New Roman", serif; font-size: 34px; letter-spacing: 6px;
  background: linear-gradient(180deg, #fff3c4, #e6c16a 45%, #9a6a20); -webkit-background-clip: text; background-clip: text;
  color: transparent; filter: drop-shadow(0 2px 6px #000); line-height: 1.1; }
.logo span { display: block; font-size: 46px; letter-spacing: 10px; }
.tag { margin: -4px 0 4px; text-align: center; color: #b9b09a; font-style: italic; font-size: 14px; }
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; padding: 9px; border-radius: 10px; background: #ffffff0d; color: #bbb; }
.tabs button.on { background: linear-gradient(180deg, #3a3220, #241f14); color: var(--gold); box-shadow: inset 0 0 0 1px var(--line); }
.login-box input { padding: 12px 14px; border-radius: 10px; border: 1px solid #ffffff22; background: #0008; color: #fff; outline: none; user-select: text; -webkit-user-select: text; }
.login-box input:focus { border-color: var(--gold); }
#cls-pick { display: flex; gap: 6px; }
.cls { flex: 1; padding: 10px 4px; border-radius: 12px; background: #ffffff0a; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: inset 0 0 0 1px #ffffff14; }
.cls b { font-size: 26px; }
.cls span { font-weight: 600; font-size: 14px; }
.cls small { font-size: 11px; color: #999; text-align: center; }
.cls.on { background: linear-gradient(180deg, #3a3220, #1e1a10); box-shadow: inset 0 0 0 1.5px var(--gold); }
.btn-gold { padding: 13px; border-radius: 12px; font-weight: 700; font-size: 17px; letter-spacing: 1px; color: #2a1c05;
  background: linear-gradient(180deg, #ffe7a0, #e6b850 50%, #b8862f); box-shadow: 0 4px 16px #e6c16a40, inset 0 1px 0 #fff8; }
.btn-gold:disabled { filter: grayscale(0.7); opacity: 0.7; }
#l-msg { min-height: 20px; text-align: center; color: #ff9a8a; font-size: 14px; }
.btn-install { padding: 10px; border-radius: 12px; font-weight: 600; font-size: 15px; color: #cfe8ff; background: linear-gradient(180deg, #1e3a5a, #0e1c2c); box-shadow: inset 0 0 0 1px #6ab8ff66; }
.install-help { font-size: 13px; line-height: 1.5; color: #bcd; text-align: center; padding: 8px; border-radius: 10px; background: #ffffff0a; }
#l-load { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #888; font-size: 13px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#hud > * { pointer-events: auto; }
#topleft { position: absolute; top: calc(8px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); width: 210px;
  padding: 8px; border-radius: 12px; background: var(--glass); border: 1px solid #ffffff14; }
.who { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  background: radial-gradient(circle at 35% 30%, #4a4030, #15120c); box-shadow: inset 0 0 0 1.5px var(--gold); }
#p-name { font-weight: 700; color: var(--gold); font-size: 14px; }
#p-lv { font-size: 12px; color: #bbb; }
.bar { position: relative; height: 15px; border-radius: 8px; background: #000a; overflow: hidden; margin-top: 4px; box-shadow: inset 0 0 0 1px #ffffff1a; }
.bar i { position: absolute; inset: 0; width: 100%; transform-origin: left; transition: transform .15s; border-radius: 8px; }
.bar.hp i { background: linear-gradient(180deg, #ff7a6a, #c3221a); }
.bar.mp i { background: linear-gradient(180deg, #7ab8ff, #2457c9); }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 15px; font-weight: 600; text-shadow: 0 1px 2px #000; }

#topright { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); text-align: center; }
#minimap { width: 120px; height: 120px; border-radius: 50%; border: 2px solid var(--line); background: #0008; display: block; box-shadow: 0 4px 14px #0008; }
#gold { margin-top: 4px; font-size: 13px; color: #ffd84a; font-weight: 600; text-shadow: 0 1px 2px #000; }

#menu { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: calc(138px + env(safe-area-inset-right)); display: flex; gap: 6px; }
#menu button { position: relative; width: 40px; height: 40px; border-radius: 12px; background: var(--glass); border: 1px solid #ffffff1a; font-size: 18px; }
#menu button:active { transform: scale(.94); }
#pts-dot { position: absolute; top: -3px; right: -3px; width: 12px; height: 12px; border-radius: 50%; background: #ff4a3a; box-shadow: 0 0 6px #ff4a3a; }

#chat { position: absolute; left: calc(8px + env(safe-area-inset-left)); bottom: calc(14px + env(safe-area-inset-bottom)); width: min(330px, 40vw); }
#chat-log { max-height: 128px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 12.5px; gap: 1px; pointer-events: none; }
#chat-log div { padding: 2px 7px; border-radius: 6px; background: #0007; width: fit-content; max-width: 100%; text-shadow: 0 1px 2px #000; animation: fadeOld 30s forwards; word-break: break-word; }
#chat-log b { color: #9fd3ff; }
#chat-log .sys { color: #ffd98a; }
@keyframes fadeOld { 0%, 80% { opacity: 1; } 100% { opacity: .35; } }
#chat-form { display: flex; gap: 4px; margin-top: 4px; }
#chat-in { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 9px; border: 1px solid #ffffff22; background: #000a; color: #fff; outline: none; user-select: text; -webkit-user-select: text; }
#chat-form button { padding: 0 12px; border-radius: 9px; background: #ffffff1a; font-size: 13px; }

#actions { position: absolute; right: calc(10px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); width: 300px; height: 210px; pointer-events: none; }
#skillbar { position: absolute; inset: 0; pointer-events: none; }
.sk { position: absolute; width: 58px; height: 58px; border-radius: 50%; pointer-events: auto; overflow: hidden; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #4a3a2a, #140c06); box-shadow: 0 4px 12px #0009, inset 0 0 0 2px #ffb35a; }
.sk.gA { box-shadow: 0 4px 12px #0009, inset 0 0 0 2px #ffe27a; }
.sk.gB { box-shadow: 0 4px 12px #0009, inset 0 0 0 2px #ff7a4a; }
.sk.gbuff { width: 46px; height: 46px; background: radial-gradient(circle at 35% 30%, #1e4a2e, #08160c); box-shadow: 0 4px 12px #0009, inset 0 0 0 2px #7dff9a; }
.sk:active { transform: scale(.92); }
.sk .ic { font-size: 25px; line-height: 1; position: relative; z-index: 2; filter: drop-shadow(0 1px 2px #000); }
.sk.gbuff .ic { font-size: 20px; }
.sk .mp { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 9.5px; color: #9fd0ff; z-index: 2; text-shadow: 0 1px 2px #000; }
.sk .cd { position: absolute; inset: 0; z-index: 3; background: conic-gradient(#000c var(--p, 0%), transparent 0); display: grid; place-items: center; font-size: 15px; font-weight: 800; color: #fff; text-shadow: 0 1px 3px #000; }
.sk.lock { filter: grayscale(1) brightness(.55); }
.sk.lock .cd { background: #0008; font-size: 10px; }
.sk.nomp .ic { opacity: .45; }
.sk.next { animation: nextGlow .5s ease-in-out infinite alternate; }
@keyframes nextGlow { to { box-shadow: 0 0 16px #9fd0ff, inset 0 0 0 3px #bfe4ff; } }
#sk0 { right: 127px; bottom: 23px; } #sk1 { right: 109px; bottom: 80px; } #sk2 { right: 61px; bottom: 117px; } #sk3 { right: 1px; bottom: 120px; }
#sk4 { right: 242px; bottom: 62px; } #sk5 { right: 190px; bottom: 116px; }

#b-auto { position: absolute; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: 112px; height: 42px; border-radius: 21px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
  background: linear-gradient(180deg, #2a2d3a, #12141c); box-shadow: 0 4px 14px #000a, inset 0 0 0 1.5px #ffffff33; }
#b-auto b { font-size: 15px; letter-spacing: 2px; }
#b-auto small { font-size: 10px; color: #aaa; }
#b-auto:active { transform: translateX(-50%) scale(.95); }
#b-auto.on { background: linear-gradient(180deg, #3fcf63, #136b26); box-shadow: 0 0 18px #4fd16a99, inset 0 0 0 1.5px #b4ffc0; animation: pulse 1.6s infinite; }
#b-auto.on small { color: #e0ffe6; }
#combo { position: absolute; top: calc(56px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 14px; background: #0a1430cc; box-shadow: inset 0 0 0 1px #6ab8ff88; pointer-events: none; }
#combo span { font-size: 12px; font-weight: 800; letter-spacing: 2px; color: #bfe4ff; }
#combo i { width: 12px; height: 12px; border-radius: 50%; background: #ffffff22; box-shadow: inset 0 0 0 1px #9fd0ff88; }
#combo i.on { background: #9fd0ff; box-shadow: 0 0 8px #9fd0ff; }
#buffs { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
#buffs span { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: #ffffff14; }
#ppts-dot { position: absolute; top: -3px; right: -3px; width: 12px; height: 12px; border-radius: 50%; background: #5ad1ff; box-shadow: 0 0 6px #5ad1ff; }
.pskill { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; background: #ffffff08; margin-bottom: 6px; }
.pskill .ic { font-size: 22px; width: 32px; text-align: center; }
.pskill .tx { flex: 1; font-size: 13px; } .pskill .tx b { font-size: 14px; } .pskill .tx small { display: block; color: #999; }
.pskill.locked { opacity: .55; }
.pskill button.plus { width: 38px; height: 32px; border-radius: 8px; background: linear-gradient(180deg, #1e3a5a, #0e1c2c); color: #9fd0ff; font-weight: 700; box-shadow: inset 0 0 0 1px #6ab8ff66; }
.pskill button.plus:disabled { opacity: .3; }
.combo-note { padding: 10px; border-radius: 10px; background: #0a1430; box-shadow: inset 0 0 0 1px #6ab8ff55; font-size: 13px; line-height: 1.5; margin-bottom: 10px; color: #cfe4ff; }
.act { position: absolute; pointer-events: auto; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: radial-gradient(circle at 35% 30%, #3a3a46, #12121a); box-shadow: 0 4px 12px #0009, inset 0 0 0 1.5px #ffffff26; overflow: hidden; }
.act:active { transform: scale(.92); }
.act.big { right: 14px; bottom: 10px; width: 84px; height: 84px; font-size: 34px; box-shadow: 0 4px 16px #000a, inset 0 0 0 2px var(--gold); }
#b-pick { right: 190px; bottom: 62px; width: 46px; height: 46px; font-size: 21px; }
@keyframes pulse { 50% { box-shadow: 0 0 6px #4fd16a55, inset 0 0 0 2px #b4ffc0; } }
.act.pot { width: 46px; height: 46px; bottom: 8px; font-size: 18px; }
.act.pot em { position: absolute; bottom: 3px; right: 0; left: 0; font-style: normal; font-size: 11px; text-shadow: 0 1px 2px #000; }
.act.pot span { margin-top: -8px; }
#b-hp { right: 190px; } #b-hp span { color: #ff5a4a; }
#b-mp { right: 242px; } #b-mp span { color: #5aa8ff; }

#xpbar { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; background: #000c; }
#xpbar i { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, #8a5cff, #d27aff); box-shadow: 0 0 8px #b77aff; }
#xpbar span { position: absolute; right: 8px; bottom: 8px; font-size: 11px; color: #d8c4ff; text-shadow: 0 1px 2px #000; pointer-events: none; }

#toasts { position: absolute; top: calc(90px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; width: min(520px, 70vw); }
.toast { padding: 6px 14px; border-radius: 10px; background: #000b; font-size: 13.5px; text-align: center; animation: toast 3s forwards; border: 1px solid #ffffff14; }
.toast.good { color: #9dff9a; } .toast.bad { color: #ff9a8a; } .toast.item { color: #ffe08a; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-6px); } 8%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

#dead { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); font-size: 26px; font-family: Georgia, serif; color: #ff8a7a; text-align: center; text-shadow: 0 2px 10px #000; pointer-events: none; }
#dead small { display: block; font-size: 14px; color: #ccc; font-family: inherit; margin-top: 4px; }

/* ---------- Nhãn trên đầu ---------- */
.lbl { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 12px; text-shadow: 0 1px 2px #000, 0 0 4px #000; will-change: transform; }
.lbl.pl { color: #cfe8ff; font-weight: 600; }
.lbl.pl.me { color: var(--gold); }
.lbl.npc { color: #ffe08a; font-weight: 600; pointer-events: auto; }
.lbl.mon { color: #ffb0a0; text-align: center; }
.lbl .hpb { width: 54px; height: 5px; margin: 2px auto 0; background: #000b; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px #0008; }
.lbl .hpb i { display: block; height: 100%; background: linear-gradient(90deg, #ff5a3a, #ffa24a); transform-origin: left; }
.lbl.drop { pointer-events: auto; font-size: 12px; padding: 1px 6px; border-radius: 6px; background: #0009; border: 1px solid #ffffff14; cursor: pointer; }
.ftext { position: absolute; left: 0; top: 0; font-weight: 800; font-size: 17px; white-space: nowrap; color: #fff; text-shadow: 0 2px 3px #000, 0 0 6px #000; will-change: transform, opacity; }
.ftext.crit { color: #ffb03a; font-size: 23px; }
.ftext.hurt { color: #ff4a3a; }
.ftext.xp { color: #c69bff; font-size: 14px; }
.ftext.lv { color: #ffe27a; font-size: 26px; font-family: Georgia, serif; letter-spacing: 2px; }
.ftext.heal { color: #7dff8a; font-size: 14px; }
.ftext.combo { font-size: 30px; font-family: Georgia, serif; letter-spacing: 3px; color: #dff2ff;
  text-shadow: 0 0 12px #3a8aff, 0 0 24px #3a8aff, 0 2px 3px #000; }

/* ---------- Bảng ---------- */
#panel, #popup { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: #0006; }
#popup { z-index: 40; background: #0004; }
.panel-box { width: min(680px, 94vw); max-height: 90vh; display: flex; flex-direction: column; border-radius: 16px;
  background: linear-gradient(180deg, rgba(24, 26, 38, .97), rgba(12, 13, 20, .97)); border: 1px solid var(--line); box-shadow: 0 20px 60px #000c; }
.panel-head { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid #ffffff14; }
.panel-head h2 { flex: 1; margin: 0; font-size: 18px; color: var(--gold); font-family: Georgia, serif; letter-spacing: 1px; }
.panel-head .x { width: 34px; height: 34px; border-radius: 10px; background: #ffffff12; font-size: 16px; }
.panel-body { padding: 12px 14px 16px; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .cols { grid-template-columns: 1fr; } }
.sec h3 { margin: 0 0 6px; font-size: 13px; color: #aaa; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 9px; background: #ffffff08; margin-bottom: 4px; font-size: 14px; }
.row .k { flex: 1; color: #ccc; } .row .v { font-weight: 700; min-width: 38px; text-align: right; }
.row button.plus { width: 30px; height: 28px; border-radius: 8px; background: linear-gradient(180deg, #4a3d1e, #2a2210); color: var(--gold); font-weight: 700; box-shadow: inset 0 0 0 1px var(--line); }
.row button.plus:disabled { opacity: .3; }
.pts { padding: 8px; border-radius: 9px; background: #3a2a10; color: #ffd98a; text-align: center; margin-bottom: 8px; font-weight: 600; }
.eqgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.eqs { padding: 8px; border-radius: 10px; background: #ffffff08; min-height: 52px; font-size: 13px; box-shadow: inset 0 0 0 1px #ffffff10; text-align: left; }
.eqs small { display: block; color: #888; font-size: 11px; }
.invgrid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
@media (max-width: 480px) { .invgrid { grid-template-columns: repeat(6, 1fr); } }
.cell { position: relative; aspect-ratio: 1; border-radius: 9px; background: #ffffff08; box-shadow: inset 0 0 0 1px #ffffff12; display: grid; place-items: center; font-size: 22px; }
.cell.has { background: radial-gradient(circle at 50% 40%, #ffffff14, #ffffff05); }
.cell .pl { position: absolute; top: 1px; right: 4px; font-size: 11px; font-weight: 800; }
.cell .n { position: absolute; bottom: 1px; right: 4px; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.cell .rare { position: absolute; top: 1px; left: 4px; font-size: 10px; color: #5fd4ff; }
.glyph { font-size: 22px; font-weight: 900; }
.btn { padding: 9px 14px; border-radius: 10px; background: #ffffff14; font-size: 14px; font-weight: 600; }
.btn.gold { background: linear-gradient(180deg, #ffe7a0, #d9a840 55%, #a8782a); color: #2a1c05; }
.btn.red { background: #5a1e1a; color: #ffb0a0; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pop-box { width: min(360px, 90vw); padding: 14px; border-radius: 14px; background: #161824f5; border: 1px solid var(--line); box-shadow: 0 16px 50px #000c; }
.pop-box h3 { margin: 0 0 6px; font-size: 17px; }
.pop-box p { margin: 3px 0; font-size: 14px; color: #ccc; }
.note { font-size: 12.5px; color: #999; margin-top: 8px; line-height: 1.45; }
.shoprow { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; background: #ffffff08; margin-bottom: 6px; }
.shoprow .nm { flex: 1; font-weight: 600; }
.shoprow .pr { color: #ffd84a; font-size: 13px; min-width: 60px; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: #ffffff08; margin-bottom: 6px; font-size: 14px; }
.toggle input { width: 20px; height: 20px; accent-color: #e6c16a; }
.enh-box { text-align: center; padding: 10px; }
.enh-item { font-size: 20px; font-weight: 700; margin: 6px 0; }
.enh-arrow { font-size: 28px; color: var(--gold); }
.enh-res { min-height: 30px; font-size: 20px; font-weight: 800; margin-top: 8px; }
.enh-res.ok { color: #9dff9a; text-shadow: 0 0 12px #4fd16a; } .enh-res.fail { color: #ff8a7a; }
select { padding: 8px; border-radius: 9px; background: #000a; color: #fff; border: 1px solid #ffffff22; font: inherit; }

#rotate { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 50; padding: 8px; text-align: center; background: #3a2a10ee; color: #ffd98a; font-size: 13px; pointer-events: none; }
@media (orientation: portrait) and (max-width: 700px) { body.ingame #rotate { display: block; } }
#disc { position: fixed; inset: 0; z-index: 60; background: #000b; display: flex; align-items: center; justify-content: center; }
#disc > div { padding: 22px; border-radius: 14px; background: #161824; border: 1px solid var(--line); text-align: center; display: flex; flex-direction: column; gap: 12px; }
#disc button { padding: 10px 18px; border-radius: 10px; background: linear-gradient(180deg, #ffe7a0, #d9a840); color: #2a1c05; font-weight: 700; }

/* Điện thoại cầm dọc: menu xếp dọc dưới bản đồ nhỏ */
@media (max-width: 560px) {
  #menu { top: calc(160px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); flex-direction: column; }
  #topleft { width: min(210px, 52vw); }
  #chat { width: 56vw; }
  #actions { transform: scale(.8); transform-origin: right bottom; }
  #b-auto { top: calc(118px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); transform: none; }
  #b-auto:active { transform: scale(.95); }
  #combo { top: calc(166px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); transform: none; }
}

/* Màn hình nhỏ (điện thoại nằm ngang) */
@media (max-height: 430px) {
  #topleft { width: 180px; padding: 6px; }
  .avatar { width: 30px; height: 30px; font-size: 16px; }
  #minimap { width: 96px; height: 96px; }
  #menu { right: calc(112px + env(safe-area-inset-right)); }
  #menu button { width: 36px; height: 36px; font-size: 16px; }
  #chat-log { max-height: 84px; font-size: 11.5px; }
  #actions { transform: scale(.88); transform-origin: right bottom; }
}
