/* Man hinh dang nhap + chon / tao nhan vat (client/src/login.ts; markup #login, #chars trong index.html).
 *
 * Bo cuc theo HUONG man hinh, khong theo chieu rong:
 *   - PC / may tinh bang ngang   : dang nhap = the ben phai, anh nen ben trai; chon NV = danh sach trai + san khau phai
 *   - dien thoai doc (portrait)  : dang nhap = the dat day man hinh; chon NV = san khau nho tren, danh sach duoi,
 *                                  nut "Vao game" co dinh o day man hinh
 *   - dien thoai ngang (thap)    : hai cot, thu nho khoang cach / chu; noi dung dai thi cuon BEN TRONG the,
 *                                  cac nut (Tao nhan vat, Quay lai, Vao game) luon nam o duoi
 * html[data-ui] (desktop | tablet | phone-port | phone-land) do login.ts gan: thiet bi cam ung -> o nhap / nut cao hon. */

:root {
  --lg-sl: max(12px, env(safe-area-inset-left));
  --lg-sr: max(12px, env(safe-area-inset-right));
  --lg-st: max(10px, env(safe-area-inset-top));
  --lg-sb: max(10px, env(safe-area-inset-bottom));
  --lg-ctl: 44px; /* chieu cao toi thieu o nhap / nut */
  --lg-gold: #f0c96a;
  --lg-gold-2: #d9b866;
  --lg-line: #8a6a2e;
  --lg-dim: #a8987a;
  --lg-tx: #efe6d2;
  --lg-field: rgba(6, 6, 8, .62);
  --lg-field-line: #4d3f25;
  --lg-sans: "Segoe UI", Tahoma, "Noto Sans", Arial, sans-serif;
  --lg-serif: "Palatino Linotype", "Book Antiqua", "Times New Roman", Georgia, serif;
}
html[data-ui="tablet"], html[data-ui="phone-port"], html[data-ui="phone-land"] { --lg-ctl: 50px; }

/* ---- khung toan man hinh dung chung ---- */
#login, #chars {
  display: none; position: fixed; inset: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: radial-gradient(ellipse at 50% 35%, #1d2433, #07080c 72%);
  font: 15px/1.5 var(--lg-sans); color: var(--lg-tx);
}
#login { z-index: 30; padding: var(--lg-st) var(--lg-sr) var(--lg-sb) var(--lg-sl); }
#chars { z-index: 31; }
#login.show, #chars.show { display: flex; }
/* luc mo trang (body.boot, truoc khi login.ts / main.ts quyet dinh vao man nao - bootDone): chi hien nen man dang nhap,
   an giao dien game (minimap, menu, HUD) de khong nhay qua lai khi JS / kiem tra may chu con dang tai */
body.boot > :not(#login) { visibility: hidden !important; }
body.boot #login { display: flex; }
body.boot #login:not(.show) .lg-wrap { visibility: hidden; }
#login [hidden], #chars [hidden] { display: none !important; }
#login::before, #chars::before { content: ""; position: fixed; inset: 0; background: var(--lg-bg, none) 50% 40% / cover no-repeat; opacity: 0; transform: scale(1.04); transition: opacity .9s ease; }
#login.bg-ok::before, #chars.bg-ok::before { opacity: 1; animation: lg-drift 40s ease-in-out infinite alternate; }
#login::after, #chars::after { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse 70% 75% at 50% 50%, rgba(6, 7, 10, .2), rgba(6, 7, 10, .72)), linear-gradient(rgba(6, 7, 10, .3), rgba(6, 7, 10, 0) 30%, rgba(6, 7, 10, .6)); }
@keyframes lg-drift { from { transform: scale(1.04) translate(0, 0); } to { transform: scale(1.1) translate(-1.2%, -.8%); } }
@media (prefers-reduced-motion: reduce) { #login.bg-ok::before, #chars.bg-ok::before { animation: none; } }

/* ---- dung chung: o nhap, nut, lien ket ---- */
#login .lnk, #chars .lnk { background: none; border: 0; color: #e5c47c; cursor: pointer; font: inherit; padding: 0; touch-action: manipulation; }
#login .lnk:hover, #chars .lnk:hover { color: #fff0c4; text-decoration: underline; }
html:not([data-ui="desktop"]) #login .lnk, html:not([data-ui="desktop"]) #chars .lnk { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; }
#login input[type=text], #login input[type=password], #chars input[type=text], #chars input[type=password] {
  width: 100%; box-sizing: border-box; min-height: var(--lg-ctl); background: var(--lg-field); border: 1px solid var(--lg-field-line); color: #f3ead6;
  border-radius: 6px; padding: 8px 12px; font: inherit; font-size: 16px; /* >=16px: iOS khong tu phong to khi focus */ outline: none; transition: border-color .15s, box-shadow .15s;
}
#login input::placeholder, #chars input::placeholder { color: #7d735f; }
#login input[type=text]:focus, #login input[type=password]:focus, #chars input[type=text]:focus, #chars input[type=password]:focus { border-color: var(--lg-gold-2); box-shadow: 0 0 0 3px rgba(217, 184, 102, .18); }
#login label, #chars label { display: block; color: #cdbf9c; margin: 10px 0 4px; font-size: 13px; }
#login .go, #chars .go {
  display: block; width: 100%; min-height: calc(var(--lg-ctl) + 4px); margin-top: 6px; padding: 8px; border: 1px solid #f1cf78; border-radius: 6px;
  background: linear-gradient(180deg, #f7dc8f, #d7a748 52%, #b07f2a); color: #2b1705; font: inherit; font-size: 16px; font-weight: 700; letter-spacing: 2px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(201, 150, 50, .32), inset 0 1px 0 rgba(255, 255, 255, .55); transition: filter .15s, transform .05s; touch-action: manipulation;
}
#login .go:active, #chars .go:active { transform: translateY(1px); filter: brightness(.96); }
#login .go:disabled, #chars .go:disabled { opacity: .6; filter: none; }
#chars .ghost { min-height: calc(var(--lg-ctl) + 4px); margin-top: 6px; padding: 8px 14px; border: 1px solid #6a5530; border-radius: 6px; background: rgba(6, 6, 8, .55); color: #e5c47c; font: inherit; cursor: pointer; touch-action: manipulation; }
@media (hover: hover) {
  #login .go:hover, #chars .go:hover { filter: brightness(1.08); }
  #chars .ghost:hover { border-color: var(--lg-gold-2); }
}
#login .lg-mark, #chars .lg-mark { flex: none; display: block; width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .6)); user-select: none; -webkit-user-drag: none; }
#lg-err, #ch-err { min-height: 18px; margin-top: 10px; font-size: 13px; word-break: break-word; }
#lg-err { color: #ff8f7a; }
#ch-err { color: #ff9e9e; margin-top: 8px; }
#lg-err[data-kind=ok] { color: #8fd18f; }
#lg-err[data-kind=info] { color: #e5c07b; }
/* thong bao bao tri (login.ts + maint.ts): dang bao tri = do, sap bao tri = vang */
#lg-maint { margin: 0 0 10px; padding: 9px 12px; border: 1px solid #a2463a; border-radius: 6px; background: rgba(70, 16, 12, .72); color: #ffb2a4; font-size: 14px; font-weight: 600; line-height: 1.45; word-break: break-word; }
#lg-maint[data-kind=soon] { border-color: #8a6a2a; background: rgba(60, 44, 10, .7); color: #f0d48a; font-weight: 500; }

/* nut bat / tat nhac nen */
#lg-music { display: none; position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 32; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--lg-line); background: rgba(16, 13, 9, .78); color: var(--lg-gold); font-size: 17px; line-height: 1; cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, .5); touch-action: manipulation; }
#lg-music.show { display: block; }
#lg-music.off { color: #8f8672; border-color: var(--lg-field-line); }
@media (hover: hover) { #lg-music:hover { border-color: var(--lg-gold-2); } }
body:not(:has(#login.show, #chars.show)) #lg-music { display: none; } /* chi hien o man hinh dang nhap / chon nhan vat */

/* ======================= DANG NHAP ======================= */
/* mac dinh (PC, may tinh bang ngang, dien thoai ngang): the nam ben phai, anh nen lo ra ben trai */
#login .lg-wrap { position: relative; z-index: 1; margin: auto 0 auto auto; margin-right: clamp(0px, 6vw, 120px); width: 100%; max-width: 420px; padding: 16px 0; box-sizing: border-box; }
#login .box { position: relative; padding: 24px 28px 16px; background: linear-gradient(180deg, rgba(32, 25, 16, .86), rgba(12, 10, 8, .92)); border: 1px solid var(--lg-line); border-radius: 10px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .85), 0 20px 60px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 226, 150, .12); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
#login .box::before { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(217, 184, 102, .2); border-radius: 7px; pointer-events: none; }
#login .box::after { content: ""; position: absolute; left: 50%; top: -1px; width: 46%; height: 2px; transform: translateX(-50%); background: linear-gradient(90deg, transparent, #f3d27a, transparent); }
/* logo + ten game: man ngang = dat co dinh ben TRAI (ngoai the dang nhap); man doc = nam tren the (xem @media portrait) */
#login .lg-logo { position: fixed; left: max(var(--lg-sl), clamp(20px, 6vw, 120px)); top: 50%; transform: translateY(-50%); z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: calc(100vw - 420px - clamp(0px, 6vw, 120px) - clamp(20px, 6vw, 120px) - 16px); text-align: center; pointer-events: none; user-select: none; }
#login .lg-logo .lg-mark { width: clamp(96px, 17vw, 240px); height: clamp(96px, 17vw, 240px); max-width: 100%; }
#login .lg-name b { display: block; font: 700 clamp(24px, 3vw, 38px)/1.1 var(--lg-serif); color: var(--lg-gold); background: linear-gradient(180deg, #fff4c9, #eac26a 50%, #a9752a); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .85)); }
#login .lg-sub { margin-top: 4px; color: #b9a67c; font-size: 11px; letter-spacing: 3px; text-transform: uppercase; }
#login h1 { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: #e5c07b; letter-spacing: 1px; }
#login .lg-opt { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0 12px; margin-top: 6px; font-size: 13px; }
#login .lg-chk { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; margin: 0; color: #cdbf9c; cursor: pointer; }
#login .lg-chk input { width: 18px; height: 18px; margin: 0; accent-color: #c99a3e; }
#login .lg-alt { margin-top: 8px; text-align: center; color: var(--lg-dim); font-size: 13px; }
#login::after { background: radial-gradient(ellipse 70% 75% at 35% 50%, rgba(6, 7, 10, .05), rgba(6, 7, 10, .55)), linear-gradient(90deg, rgba(6, 7, 10, .1) 0%, rgba(6, 7, 10, .1) 45%, rgba(6, 7, 10, .62) 100%), linear-gradient(rgba(6, 7, 10, .3), rgba(6, 7, 10, 0) 30%, rgba(6, 7, 10, .55)); }

/* dien thoai / may tinh bang doc: the nam day man hinh (ngon cai voi toi), anh nen o tren */
@media (orientation: portrait) {
  #login .lg-wrap { margin: auto auto 0; max-width: 460px; padding-top: 12px; }
  #login .lg-logo { position: static; transform: none; max-width: none; margin: 0 0 10px; gap: 4px; }
  #login .lg-logo .lg-mark { width: 84px; height: 84px; }
  #login .lg-name b { font-size: 30px; }
  #login::after { background: linear-gradient(rgba(6, 7, 10, .35) 0%, rgba(6, 7, 10, .05) 28%, rgba(6, 7, 10, .55) 55%, rgba(6, 7, 10, .92) 100%); }
}
@media (orientation: portrait) and (max-height: 700px) {
  #login .lg-logo .lg-mark { width: 56px; height: 56px; }
  #login .lg-sub { display: none; }
}
/* ngang thap (dien thoai nam ngang): gon lai, the van o ben phai, noi dung dai thi cuon */
@media (max-height: 520px) {
  #login .box { padding: 14px 20px 8px; }
  #login .lg-wrap { padding: 4px 0; max-width: 380px; }
  #login .lg-logo .lg-mark { width: clamp(72px, 22vh, 140px); height: clamp(72px, 22vh, 140px); }
  #login .lg-sub { display: none; }
  #login h1 { display: none; }
  #login label { margin: 4px 0 2px; }
  #login .lg-opt { margin-top: 2px; }
  #lg-err { min-height: 0; margin-top: 4px; }
  #login .lg-alt { margin-top: 2px; }
}
/* ======================= CHON / TAO NHAN VAT ======================= */
/* mac dinh (PC): trai = the danh sach / form tao, phai = san khau hoat anh he phai */
#chars .cs-wrap { position: relative; z-index: 1; margin: 0 auto; display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 28px; align-items: center; width: 100%; max-width: 1120px; padding: max(var(--lg-st), 20px) max(var(--lg-sr), 24px) max(var(--lg-sb), 20px) max(var(--lg-sl), 24px); box-sizing: border-box; }
#chars .cs-side { position: relative; display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); padding: 18px 18px 12px; box-sizing: border-box; background: linear-gradient(180deg, rgba(32, 25, 16, .86), rgba(12, 10, 8, .92)); border: 1px solid var(--lg-line); border-radius: 10px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .85), 0 20px 60px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 226, 150, .12); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
#chars .cs-side::before { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(217, 184, 102, .2); border-radius: 7px; pointer-events: none; }
#chars .cs-side::after { content: ""; position: absolute; left: 50%; top: -1px; width: 46%; height: 2px; transform: translateX(-50%); background: linear-gradient(90deg, transparent, #f3d27a, transparent); }
#chars .cs-head { flex: none; display: flex; align-items: center; gap: 12px; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid rgba(217, 184, 102, .25); }
#chars .cs-head .lg-mark { width: 44px; height: 44px; }
#chars .cs-head small { display: block; color: #b9a67c; font-size: 11px; letter-spacing: 3px; text-transform: uppercase; }
#chars h1 { margin: 0; font: 700 22px/1.2 var(--lg-serif); color: var(--lg-gold); }

/* danh sach nhan vat: cuon ben trong the */
#ch-list { flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
#chars .slot { flex: none; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 10px; border: 1px solid var(--lg-field-line); border-radius: 8px; background: rgba(6, 6, 8, .55); cursor: pointer; outline: none; transition: border-color .15s, background .15s, box-shadow .15s; touch-action: manipulation; }
#chars .slot:focus-visible { border-color: #a8873f; background: rgba(40, 32, 18, .6); }
#chars .slot.sel { border-color: #f1cf78; background: linear-gradient(90deg, rgba(120, 86, 30, .45), rgba(30, 24, 14, .6)); box-shadow: 0 0 0 1px rgba(241, 207, 120, .35), 0 0 18px rgba(217, 170, 80, .25); }
#chars .slot .th { position: relative; flex: none; display: grid; place-items: center; width: 54px; height: 54px; overflow: hidden; border: 2px solid #7a5f2c; border-radius: 50%; background: #14110b; color: #a8873f; font-size: 26px; box-shadow: 0 0 0 1px #000, 0 2px 6px rgba(0, 0, 0, .6); } /* anh dai dien = icon HUD mau / pana (/ui/char/) */
#chars .slot .th img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(.55) brightness(.8); transition: filter .15s; }
#chars .slot.sel .th { border-color: #f1cf78; box-shadow: 0 0 0 1px #000, 0 0 12px rgba(241, 207, 120, .55); }
#chars .slot.sel .th img { filter: none; }
#chars .slot .nm { flex: 1; min-width: 0; }
#chars .slot .nm b { display: block; overflow: hidden; color: var(--lg-gold); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
#chars .slot .nm span { display: block; color: var(--lg-dim); font-size: 12px; }
#chars .slot.empty { border-style: dashed; background: rgba(6, 6, 8, .35); }
#chars .slot.empty .nm b { color: #cdbf9c; }
@media (hover: hover) {
  #chars .slot:hover { border-color: #a8873f; background: rgba(40, 32, 18, .6); }
  #chars .slot:hover .th img { filter: none; }
  #chars .slot.empty:hover .nm b { color: var(--lg-gold); }
  #chars .opts span:hover { border-color: #a8873f; }
}

/* form tao nhan vat: phan nhap cuon ben trong, hang nut (.row) luon co dinh o day the */
#ch-new { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
#ch-new .ch-fields { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 2px 6px; }
#ch-new .ch-fields > label:first-child { margin-top: 0; }
#ch-hint { margin-top: 4px; color: #8f8672; font-size: 12px; }
#chars .opts { display: flex; gap: 6px; }
#chars .opts label { position: relative; flex: 1; margin: 0; }
#chars .opts input { position: absolute; opacity: 0; pointer-events: none; }
#chars .opts span { display: flex; align-items: center; justify-content: center; min-height: var(--lg-ctl); padding: 6px 4px; border: 1px solid var(--lg-field-line); border-radius: 6px; background: rgba(6, 6, 8, .55); color: #cdbf9c; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; touch-action: manipulation; }
#chars .opts input:checked + span { border-color: #f1cf78; background: linear-gradient(180deg, #f7dc8f, #d7a748 52%, #b07f2a); color: #2b1705; font-weight: 700; }
#chars .opts input:focus-visible + span { outline: 2px solid var(--lg-gold-2); outline-offset: 1px; }
#chars .row { flex: none; display: flex; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid rgba(217, 184, 102, .18); }
#chars .row .go { flex: 1; margin-top: 0; }
#chars .row .ghost { flex: none; margin-top: 0; }
#chars .cs-foot { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; padding-top: 6px; border-top: 1px solid rgba(217, 184, 102, .18); color: #8f8672; font-size: 12px; }
#chars .cs-side > #ch-err { flex: none; }

/* san khau */
#chars .cs-stage { --fac: #f0b85a; --glow: rgba(232, 150, 60, .32); position: relative; display: flex; flex-direction: column; align-items: center; min-width: 0; }
#chars .cs-stage[data-prof="1"] { --fac: #8fd3f0; --glow: rgba(90, 170, 230, .3); }
#chars .cs-stage[data-prof="2"] { --fac: #d4a2f5; --glow: rgba(170, 100, 230, .3); }
#chars .cs-fac { position: relative; z-index: 2; height: 58px; width: auto; filter: drop-shadow(0 0 14px var(--glow)) drop-shadow(0 2px 3px rgba(0, 0, 0, .8)); user-select: none; } /* bien he phai (/loginres/hephai/<phai>_active.webp) */
#chars .cs-figure { position: relative; width: min(540px, 100%, calc((100vh - 250px) / .84)); width: min(540px, 100%, calc((100dvh - 250px) / .84)); aspect-ratio: 1 / .84; } /* canvas vuong, phan duoi chan (trong) tran ra ngoai */
#chars .cs-figure::before { content: ""; position: absolute; inset: 8% 14% 6%; border-radius: 50%; background: radial-gradient(closest-side, var(--glow), transparent); pointer-events: none; }
#chars .cs-figure::after { content: ""; position: absolute; left: 28%; right: 28%; top: 86%; height: 14%; border-radius: 50%; border: 1px solid rgba(241, 207, 120, .45); background: radial-gradient(closest-side, rgba(241, 207, 120, .28), rgba(241, 207, 120, .05) 70%, transparent); box-shadow: 0 0 30px var(--glow); pointer-events: none; }
#ch-anim { position: absolute; width: 100%; pointer-events: none; inset: 0 0 auto; height: auto; aspect-ratio: 1; z-index: 1; transform: scale(1.18); transform-origin: 50% 62%; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .6)); transition: opacity .3s; }
#ch-anim.loading { opacity: .35; }
#chars .cs-info { margin-top: -4px; text-align: center; max-width: 100%; }
#chars .cs-info b { display: block; overflow: hidden; text-overflow: ellipsis; font: 700 30px/1.2 var(--lg-serif); color: var(--lg-gold); text-shadow: 0 2px 4px rgba(0, 0, 0, .9); }
#chars .cs-info span { color: #d8cba8; text-shadow: 0 1px 3px rgba(0, 0, 0, .9); }
#chars .cs-act { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 12px; width: min(280px, 100%); }
#chars .cs-act .del { color: #e89a86; font-size: 13px; }
#chars .cs-stage.empty .cs-fac, #chars .cs-stage.empty .cs-figure, #chars .cs-stage.empty .cs-info { visibility: hidden; }

/* ---- dien thoai / may tinh bang DOC: san khau nho o tren, the chiem phan con lai, nut "Vao game" co dinh o day ---- */
@media (orientation: portrait) {
  #chars .cs-wrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 8px; align-items: stretch; height: 100vh; height: 100dvh; min-height: 460px; max-width: 560px; padding-top: var(--lg-st); padding-left: var(--lg-sl); padding-right: var(--lg-sr); padding-bottom: var(--lg-sb); }
  #chars .cs-stage { order: -1; }
  #chars .cs-side { max-height: none; min-height: 0; padding: 14px 14px 10px; -webkit-backdrop-filter: none; backdrop-filter: none; }
  #chars .cs-fac { height: 34px; }
  #chars .cs-figure { width: min(280px, 100%, calc(26vh / .84)); width: min(280px, 100%, calc(26dvh / .84)); }
  #chars .cs-info b { font-size: 21px; }
  #chars .cs-info span { font-size: 13px; }
  /* nut Vao game / Xoa co dinh sat day man hinh */
  #chars .cs-act { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; flex-direction: row; justify-content: center; gap: 10px; width: auto; margin: 0; padding: 22px max(var(--lg-sr), 16px) var(--lg-sb) max(var(--lg-sl), 16px); background: linear-gradient(rgba(6, 7, 10, 0), rgba(6, 7, 10, .88) 38%); }
  #chars .cs-act .go { flex: 1; max-width: 360px; margin-top: 0; }
  #chars .cs-act .lnk { flex: none; }
  #chars:has(#ch-act:not([hidden])) .cs-wrap { padding-bottom: calc(var(--lg-ctl) + 40px + var(--lg-sb)); }
  #chars .cs-foot span { display: none; } /* "Nhap dup de vao game" khong hop voi cam ung */
}
@media (orientation: portrait) and (max-height: 700px) {
  #chars .cs-figure { width: min(280px, 100%, calc(20vh / .84)); width: min(280px, 100%, calc(20dvh / .84)); }
  #chars .cs-fac { height: 26px; }
  #chars .cs-info b { font-size: 18px; }
}

/* ---- ngang thap (dien thoai nam ngang, cua so PC thap): the nho + san khau nho, cuon ben trong the ---- */
@media (max-height: 520px) {
  #chars .cs-wrap { grid-template-columns: minmax(250px, 330px) minmax(0, 1fr); gap: 14px; padding-top: max(var(--lg-st), 8px); padding-bottom: max(var(--lg-sb), 8px); }
  #chars .cs-side { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); padding: 10px 12px 8px; }
  #chars .cs-head { padding-bottom: 6px; margin-bottom: 6px; gap: 10px; }
  #chars .cs-head .lg-mark { width: 34px; height: 34px; }
  #chars h1 { font-size: 18px; }
  #chars .cs-head small { display: none; }
  #chars .slot { min-height: 52px; padding: 5px 8px; }
  #chars .slot .th { width: 42px; height: 42px; }
  #chars label { margin: 6px 0 3px; }
  #chars .cs-foot { padding-top: 2px; }
  #chars .cs-fac { height: 30px; }
  #chars .cs-figure { width: min(100%, calc((100vh - 150px) / .84)); width: min(100%, calc((100dvh - 150px) / .84)); }
  #chars .cs-info b { font-size: 20px; }
  #chars .cs-info span { font-size: 13px; }
  #chars .cs-act { margin-top: 4px; flex-direction: row; gap: 10px; width: min(360px, 100%); }
  #chars .cs-act .go { flex: 1; }
  #ch-err { min-height: 0; margin-top: 2px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #chars .cs-wrap { padding-left: max(var(--lg-sl), 14px); padding-right: max(var(--lg-sr), 14px); }
}

/* ---- hop xac nhan xoa nhan vat (login.ts askDelete) ---- */
#chars .lg-modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: var(--lg-st) var(--lg-sr) var(--lg-sb) var(--lg-sl); background: rgba(4, 5, 8, .72); }
#chars .lg-dlg { width: min(380px, 100%); box-sizing: border-box; padding: 18px 18px 14px; background: linear-gradient(180deg, rgba(40, 30, 18, .98), rgba(14, 11, 8, .98)); border: 1px solid var(--lg-line); border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .7); }
#chars .lg-dlg h2 { margin: 0 0 8px; font: 700 18px/1.2 var(--lg-serif); color: #ffb09e; }
#chars .lg-dlg p { margin: 0 0 8px; color: #d8cba8; font-size: 14px; word-break: break-word; }
#chars .lg-dlg .row { margin-top: 12px; border-top: 0; padding-top: 0; }
#chars .lg-dlg .go.danger { background: linear-gradient(180deg, #e0745c, #b8321f); border-color: #ffb09e; color: #fff; box-shadow: 0 4px 16px rgba(184, 50, 31, .35); }
#chars .lg-dlg-err { min-height: 18px; margin-top: 8px; color: #ff9e9e; font-size: 13px; word-break: break-word; }
